Skip to content

Commit

Permalink
generic: 5.15: rework hack patch
Browse files Browse the repository at this point in the history
Rework hack patch in dir for kernel 5.15.
For the specific patch of packet mangeling introduce a new extra_priv_flags
as we don't have enough space to add additional flags in priv_flags.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel authored and dangowrt committed Mar 27, 2022
1 parent 7829ae4 commit 1f302af
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 91 deletions.
8 changes: 8 additions & 0 deletions target/linux/ath25/files/drivers/net/phy/mvswitch.c
Expand Up @@ -312,7 +312,11 @@ mvswitch_config_init(struct phy_device *pdev)
priv->orig_features = dev->features;

#ifdef HEADER_MODE
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
dev->extra_priv_flags |= IFF_NO_IP_ALIGN;
#else
dev->priv_flags |= IFF_NO_IP_ALIGN;
#endif
dev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX;
#else
dev->features |= NETIF_F_HW_VLAN_CTAG_RX;
Expand Down Expand Up @@ -372,7 +376,11 @@ mvswitch_detach(struct phy_device *pdev)
dev->eth_mangle_rx = NULL;
dev->eth_mangle_tx = NULL;
dev->features = priv->orig_features;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
dev->extra_priv_flags &= ~IFF_NO_IP_ALIGN;
#else
dev->priv_flags &= ~IFF_NO_IP_ALIGN;
#endif
}

static void
Expand Down
8 changes: 8 additions & 0 deletions target/linux/generic/files/drivers/net/phy/ar8216.c
Expand Up @@ -2465,7 +2465,11 @@ ar8xxx_phy_config_init(struct phy_device *phydev)
/* VID fixup only needed on ar8216 */
if (chip_is_ar8216(priv)) {
dev->phy_ptr = priv;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
dev->extra_priv_flags |= IFF_NO_IP_ALIGN;
#else
dev->priv_flags |= IFF_NO_IP_ALIGN;
#endif
dev->eth_mangle_rx = ar8216_mangle_rx;
dev->eth_mangle_tx = ar8216_mangle_tx;
}
Expand Down Expand Up @@ -2700,7 +2704,11 @@ ar8xxx_phy_detach(struct phy_device *phydev)

#ifdef CONFIG_ETHERNET_PACKET_MANGLE
dev->phy_ptr = NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
dev->extra_priv_flags &= ~IFF_NO_IP_ALIGN;
#else
dev->priv_flags &= ~IFF_NO_IP_ALIGN;
#endif
dev->eth_mangle_rx = NULL;
dev->eth_mangle_tx = NULL;
#endif
Expand Down
Expand Up @@ -529,7 +529,7 @@ static int b53_configure_ports_of(struct b53_device *dev)
po |= PORT_OVERRIDE_SPEED_2000M;
else
po |= GMII_PO_SPEED_2000M;
/* fall through */
fallthrough;
case 1000:
po |= GMII_PO_SPEED_1000M;
break;
Expand Down
4 changes: 2 additions & 2 deletions target/linux/generic/hack-5.15/212-tools_portability.patch
Expand Up @@ -69,9 +69,9 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/tools/include/linux/types.h
+++ b/tools/include/linux/types.h
@@ -7,8 +7,12 @@
#include <stdint.h>

#define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */
#endif

+#ifndef __linux__
+#include <tools/linux_types.h>
+#else
Expand Down
4 changes: 2 additions & 2 deletions target/linux/generic/hack-5.15/220-arm-gc_sections.patch
Expand Up @@ -12,7 +12,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -114,6 +114,7 @@ config ARM
@@ -113,6 +113,7 @@ config ARM
select HAVE_UID16
select HAVE_VIRT_CPU_ACCOUNTING_GEN
select IRQ_FORCED_THREADING
Expand All @@ -22,7 +22,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
select OF_EARLY_FLATTREE if OF
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -100,6 +100,7 @@ $(foreach o, $(libfdt_objs) atags_to_fdt
@@ -98,6 +98,7 @@ $(foreach o, $(libfdt_objs) atags_to_fdt
ifdef building_out_of_srctree
$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c))
endif
Expand Down
38 changes: 24 additions & 14 deletions target/linux/generic/hack-5.15/259-regmap_dynamic.patch
Expand Up @@ -14,77 +14,87 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>

--- a/drivers/base/regmap/Kconfig
+++ b/drivers/base/regmap/Kconfig
@@ -4,9 +4,8 @@
@@ -4,10 +4,9 @@
# subsystems should select the appropriate symbols.

config REGMAP
- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM)
- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO)
select IRQ_DOMAIN if REGMAP_IRQ
select MDIO_BUS if REGMAP_MDIO
- bool
+ tristate

config REGCACHE_COMPRESSED
select LZO_COMPRESS
@@ -14,46 +13,59 @@ config REGCACHE_COMPRESSED
@@ -15,53 +14,67 @@ config REGCACHE_COMPRESSED
bool

config REGMAP_AC97
+ select REGMAP
tristate

config REGMAP_I2C
tristate
+ select REGMAP
tristate
depends on I2C

config REGMAP_SLIMBUS
tristate
+ select REGMAP
tristate
depends on SLIMBUS

config REGMAP_SPI
tristate
+ select REGMAP
+ depends on SPI_MASTER
tristate
depends on SPI

config REGMAP_SPMI
tristate
+ select REGMAP
tristate
depends on SPMI

config REGMAP_W1
tristate
+ select REGMAP
tristate
depends on W1

config REGMAP_MMIO
config REGMAP_MDIO
+ select REGMAP
tristate

config REGMAP_MMIO
+ select REGMAP
tristate

config REGMAP_IRQ
bool
+ select REGMAP
bool

config REGMAP_SOUNDWIRE
+ select REGMAP
tristate
depends on SOUNDWIRE

config REGMAP_SOUNDWIRE_MBQ
+ select REGMAP
tristate
depends on SOUNDWIRE

config REGMAP_SCCB
tristate
+ select REGMAP
tristate
depends on I2C

config REGMAP_I3C
tristate
+ select REGMAP
tristate
depends on I3C

config REGMAP_SPI_AVMM
tristate
+ select REGMAP
tristate
depends on SPI

--- a/drivers/base/regmap/Makefile
+++ b/drivers/base/regmap/Makefile
@@ -2,10 +2,14 @@
Expand Down
Expand Up @@ -24,7 +24,7 @@ Signed-off-by: Alexandros C. Couloumbis <alex@ozo.com>
-ifdef CONFIG_PPC32
-KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
-else
-ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
-ifeq ($(call ld-ifversion, -ge, 22500, y),y)
-# Have the linker provide sfpr if possible.
-# There is a corresponding test in arch/powerpc/lib/Makefile
-KBUILD_LDFLAGS_MODULE += --save-restore-funcs
Expand Down
Expand Up @@ -28,43 +28,42 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
#include <linux/namei.h>
#include <linux/export.h>
#include <linux/ctype.h>
@@ -121,7 +122,8 @@ int get_tree_mtd(struct fs_context *fc,
@@ -120,8 +121,9 @@ int get_tree_mtd(struct fs_context *fc,
struct fs_context *fc))
{
#ifdef CONFIG_BLOCK
struct block_device *bdev;
- int ret, major;
- dev_t dev;
- int ret;
+ struct mtd_blktrans_dev *blktrans_dev;
+ int ret, major, part_bits;
+ struct block_device *bdev;
+ int ret, part_bits;
#endif
int mtdnr;

@@ -169,21 +171,38 @@ int get_tree_mtd(struct fs_context *fc,
@@ -169,16 +171,36 @@ int get_tree_mtd(struct fs_context *fc,
/* try the old way - the hack where we allowed users to mount
* /dev/mtdblock$(n) but didn't actually _use_ the blockdev
*/
- bdev = lookup_bdev(fc->source);
- ret = lookup_bdev(fc->source, &dev);
- if (ret) {
+ bdev = blkdev_get_by_path(fc->source, FMODE_READ, NULL);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
+ if (IS_ERR(bdev)) {
+ ret = PTR_ERR(bdev);
errorf(fc, "MTD: Couldn't look up '%s': %d", fc->source, ret);
return ret;
}
- pr_debug("MTDSB: lookup_bdev() returned 0\n");
+ pr_debug("MTDSB: blkdev_get_by_path() returned 0\n");

major = MAJOR(bdev->bd_dev);
- mtdnr = MINOR(bdev->bd_dev);
- bdput(bdev);

- if (major == MTD_BLOCK_MAJOR)
- return mtd_get_sb_by_nr(fc, mtdnr, fill_super);
+ if (major == MTD_BLOCK_MAJOR) {
- if (MAJOR(dev) == MTD_BLOCK_MAJOR)
- return mtd_get_sb_by_nr(fc, MINOR(dev), fill_super);
+ if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
+ if (!bdev->bd_disk) {
+ blkdev_put(bdev, FMODE_READ);
+ BUG();
+ return -EINVAL;
+ }
+
+ blktrans_dev = (struct mtd_blktrans_dev *)(bdev->bd_disk->private_data);
+ if (!blktrans_dev || !blktrans_dev->tr) {
+ blkdev_put(bdev, FMODE_READ);
Expand All @@ -76,7 +75,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+ blkdev_put(bdev, FMODE_READ);
+ if (MINOR(bdev->bd_dev) != (mtdnr << part_bits))
+ return -EINVAL;

+
+ return mtd_get_sb_by_nr(fc, mtdnr, fill_super);
+ }
+ blkdev_put(bdev, FMODE_READ);
Expand Down
Expand Up @@ -51,7 +51,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+
+ list_for_each_entry(tr, &blktrans_majors, list) {
+ list_for_each_entry_safe(dev, next, &tr->devs, list) {
+ if (dev->disk->flags & GENHD_FL_UP)
+ if (disk_live(dev->disk))
+ continue;
+
+ device_add_disk(&dev->mtd->dev, dev->disk, NULL);
Expand Down Expand Up @@ -88,11 +88,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
del_mtd_device(mtd);
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -76,6 +76,6 @@ extern int deregister_mtd_blktrans(struc
@@ -76,6 +76,7 @@ extern int deregister_mtd_blktrans(struc
extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev);
-
+extern void register_mtd_blktrans_devs(void);

#endif /* __MTD_TRANS_H__ */
/**
* module_mtd_blktrans() - Helper macro for registering a mtd blktrans driver
22 changes: 11 additions & 11 deletions target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch
Expand Up @@ -6,9 +6,9 @@
#define ADDPART_FLAG_WHOLEDISK 2
+#define ADDPART_FLAG_READONLY 4
+#define ADDPART_FLAG_ROOTDEV 8
void delete_partition(struct hd_struct *part);
int bdev_add_partition(struct block_device *bdev, int partno,
sector_t start, sector_t length);
int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
sector_t length);
int bdev_del_partition(struct gendisk *disk, int partno);
--- a/block/partitions/Kconfig
+++ b/block/partitions/Kconfig
@@ -101,6 +101,13 @@ config ATARI_PARTITION
Expand Down Expand Up @@ -92,17 +92,17 @@
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -396,7 +396,11 @@ int ubiblock_create(struct ubi_volume_in
dev->leb_size = vi->usable_leb_size;

/* Initialize the gendisk of this ubiblock device */
gd->fops = &ubiblock_ops;
gd->major = ubiblock_major;
+#ifdef CONFIG_FIT_PARTITION
+ gd = alloc_disk(0);
+ gd->minors = 0;
+#else
gd = alloc_disk(1);
gd->minors = 1;
+#endif
if (!gd) {
pr_err("UBI: block: alloc_disk failed\n");
ret = -ENODEV;
gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
if (gd->first_minor < 0) {
dev_err(disk_to_dev(gd),
@@ -413,6 +417,9 @@ int ubiblock_create(struct ubi_volume_in
goto out_put_disk;
}
Expand All @@ -118,7 +118,7 @@
@@ -706,6 +706,9 @@ int efi_partition(struct parsed_partitio
gpt_entry *ptes = NULL;
u32 i;
unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
+#ifdef CONFIG_FIT_PARTITION
+ u32 extra_slot = 64;
+#endif
Expand Down

0 comments on commit 1f302af

Please sign in to comment.