diff options
Diffstat (limited to 'target/linux/generic/patches-3.10')
202 files changed, 0 insertions, 37870 deletions
diff --git a/target/linux/generic/patches-3.10/003-11-001-MIPS-Declare-emulate_load_store_microMIPS-as-a-stati.patch b/target/linux/generic/patches-3.10/003-11-001-MIPS-Declare-emulate_load_store_microMIPS-as-a-stati.patch deleted file mode 100644 index 30dc0b469d..0000000000 --- a/target/linux/generic/patches-3.10/003-11-001-MIPS-Declare-emulate_load_store_microMIPS-as-a-stati.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2b76d9221a02fa69bbb8c1045616afb923fc6bad Mon Sep 17 00:00:00 2001 -From: David Daney <david.daney@cavium.com> -Date: Fri, 24 May 2013 20:54:08 +0000 -Subject: [PATCH] MIPS: Declare emulate_load_store_microMIPS as a static - function. - -commit 74338805ec6869594d583535f941cb478c94dd73 upstream. - -It is only used from within a single file, it should not be globally -visible. - -Signed-off-by: David Daney <david.daney@cavium.com> -Acked-by: Steven J. Hill <Steven.Hill@imgtec.com> -Cc: linux-mips@linux-mips.org -Patchwork: https://patchwork.linux-mips.org/patch/5325/ -Signed-off-by: Ralf Baechle <ralf@linux-mips.org> ---- - arch/mips/kernel/unaligned.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/arch/mips/kernel/unaligned.c -+++ b/arch/mips/kernel/unaligned.c -@@ -683,7 +683,8 @@ const int reg16to32[] = { 16, 17, 2, 3, - /* Recode table from 16-bit STORE register notation to 32-bit GPR. */ - const int reg16to32st[] = { 0, 17, 2, 3, 4, 5, 6, 7 }; - --void emulate_load_store_microMIPS(struct pt_regs *regs, void __user * addr) -+static void emulate_load_store_microMIPS(struct pt_regs *regs, -+ void __user *addr) - { - unsigned long value; - unsigned int res; diff --git a/target/linux/generic/patches-3.10/003-11-002-MIPS-Only-set-cpu_has_mmips-if-SYS_SUPPORTS_MICROMIP.patch b/target/linux/generic/patches-3.10/003-11-002-MIPS-Only-set-cpu_has_mmips-if-SYS_SUPPORTS_MICROMIP.patch deleted file mode 100644 index b1eddc6ee7..0000000000 --- a/target/linux/generic/patches-3.10/003-11-002-MIPS-Only-set-cpu_has_mmips-if-SYS_SUPPORTS_MICROMIP.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 15a051ad98309f71989f9bda4b020fff160f4022 Mon Sep 17 00:00:00 2001 -From: David Daney <david.daney@cavium.com> -Date: Fri, 24 May 2013 20:54:10 +0000 -Subject: [PATCH 2/2] MIPS: Only set cpu_has_mmips if SYS_SUPPORTS_MICROMIPS - -commit 3ddc14add5e6341cf8ef4058c34c67ba7fd15317 upstream. - -As Jonas Gorske said in his patch: - - Disable cpu_has_mmips for everything but SEAD3 and MALTA. Most of - these platforms are from before the micromips introduction, so they - are very unlikely to implement it. - - Reduces an -Os compiled, uncompressed kernel image by 8KiB for - BCM63XX. - -This patch taks a different approach than his, we gate the runtime -test for microMIPS by the config symbol SYS_SUPPORTS_MICROMIPS. - -Signed-off-by: David Daney <david.daney@cavium.com> -Cc: Jonas Gorski <jogo@openwrt.org> -Cc: Steven J. Hill <Steven.Hill@imgtec.com> -Acked-by: Steven J. Hill <Steven.Hill@imgtec.com> -Cc: linux-mips@linux-mips.org -Patchwork: https://patchwork.linux-mips.org/patch/5327/ -Signed-off-by: Ralf Baechle <ralf@linux-mips.org> ---- - arch/mips/include/asm/cpu-features.h | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - ---- a/arch/mips/include/asm/cpu-features.h -+++ b/arch/mips/include/asm/cpu-features.h -@@ -99,7 +99,11 @@ - #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI) - #endif - #ifndef cpu_has_mmips --#define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS) -+# ifdef CONFIG_SYS_SUPPORTS_MICROMIPS -+# define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS) -+# else -+# define cpu_has_mmips 0 -+# endif - #endif - #ifndef cpu_has_vtag_icache - #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG) diff --git a/target/linux/generic/patches-3.10/003-11-003-of-pci-Add-of_pci_get_devfn-function.patch b/target/linux/generic/patches-3.10/003-11-003-of-pci-Add-of_pci_get_devfn-function.patch deleted file mode 100644 index 4dd151688b..0000000000 --- a/target/linux/generic/patches-3.10/003-11-003-of-pci-Add-of_pci_get_devfn-function.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 45ab9702fb47d18dca116b3a0509efa19fbcb27a Mon Sep 17 00:00:00 2001 -From: Thierry Reding <thierry.reding@avionic-design.de> -Date: Thu, 16 May 2013 17:55:18 +0200 -Subject: [PATCH] of/pci: Add of_pci_get_devfn() function - -commit 45ab9702fb47d18dca116b3a0509efa19fbcb27a upstream. - -This function can be used to parse the device and function number from a -standard 5-cell PCI resource. PCI_SLOT() and PCI_FUNC() can be used on -the returned value obtain the device and function numbers respectively. - -Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> -Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> -Signed-off-by: Jason Cooper <jason@lakedaemon.net> ---- - drivers/of/of_pci.c | 34 +++++++++++++++++++++++++++++----- - include/linux/of_pci.h | 1 + - 2 files changed, 30 insertions(+), 5 deletions(-) - ---- a/drivers/of/of_pci.c -+++ b/drivers/of/of_pci.c -@@ -5,14 +5,15 @@ - #include <asm/prom.h> - - static inline int __of_pci_pci_compare(struct device_node *node, -- unsigned int devfn) -+ unsigned int data) - { -- unsigned int size; -- const __be32 *reg = of_get_property(node, "reg", &size); -+ int devfn; - -- if (!reg || size < 5 * sizeof(__be32)) -+ devfn = of_pci_get_devfn(node); -+ if (devfn < 0) - return 0; -- return ((be32_to_cpup(®[0]) >> 8) & 0xff) == devfn; -+ -+ return devfn == data; - } - - struct device_node *of_pci_find_child_device(struct device_node *parent, -@@ -40,3 +41,26 @@ struct device_node *of_pci_find_child_de - return NULL; - } - EXPORT_SYMBOL_GPL(of_pci_find_child_device); -+ -+/** -+ * of_pci_get_devfn() - Get device and function numbers for a device node -+ * @np: device node -+ * -+ * Parses a standard 5-cell PCI resource and returns an 8-bit value that can -+ * be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device -+ * and function numbers respectively. On error a negative error code is -+ * returned. -+ */ -+int of_pci_get_devfn(struct device_node *np) -+{ -+ unsigned int size; -+ const __be32 *reg; -+ -+ reg = of_get_property(np, "reg", &size); -+ -+ if (!reg || size < 5 * sizeof(__be32)) -+ return -EINVAL; -+ -+ return (be32_to_cpup(reg) >> 8) & 0xff; -+} -+EXPORT_SYMBOL_GPL(of_pci_get_devfn); ---- a/include/linux/of_pci.h -+++ b/include/linux/of_pci.h -@@ -10,5 +10,6 @@ int of_irq_map_pci(const struct pci_dev - struct device_node; - struct device_node *of_pci_find_child_device(struct device_node *parent, - unsigned int devfn); -+int of_pci_get_devfn(struct device_node *np); - - #endif diff --git a/target/linux/generic/patches-3.10/003-11-004-hso-Earlier-catch-of-error-condition.patch b/target/linux/generic/patches-3.10/003-11-004-hso-Earlier-catch-of-error-condition.patch deleted file mode 100644 index 04866edbcd..0000000000 --- a/target/linux/generic/patches-3.10/003-11-004-hso-Earlier-catch-of-error-condition.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 35e57e1b49a351aa804dab6010cd46ae6112a541 Mon Sep 17 00:00:00 2001 -From: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us> -Date: Wed, 21 Aug 2013 01:43:07 -0700 -Subject: [PATCH] hso: Earlier catch of error condition - -commit 35e57e1b49a351aa804dab6010cd46ae6112a541 upstream. - -There is no need to get an interface specification if we know it's the -wrong one. - -Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us> -Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -Signed-off-by: David S. Miller <davem@davemloft.net> ---- - drivers/net/usb/hso.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - ---- a/drivers/net/usb/hso.c -+++ b/drivers/net/usb/hso.c -@@ -2886,6 +2886,11 @@ static int hso_probe(struct usb_interfac - struct hso_shared_int *shared_int; - struct hso_device *tmp_dev = NULL; - -+ if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { -+ dev_err(&interface->dev, "Not our interface\n"); -+ return -ENODEV; -+ } -+ - if_num = interface->altsetting->desc.bInterfaceNumber; - - /* Get the interface/port specification from either driver_info or from -@@ -2895,10 +2900,6 @@ static int hso_probe(struct usb_interfac - else - port_spec = hso_get_config_data(interface); - -- if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { -- dev_err(&interface->dev, "Not our interface\n"); -- return -ENODEV; -- } - /* Check if we need to switch to alt interfaces prior to port - * configuration */ - if (interface->num_altsetting > 1) diff --git a/target/linux/generic/patches-3.10/003-11-008-hso-Fix-stack-corruption-on-some-architectures.patch b/target/linux/generic/patches-3.10/003-11-008-hso-Fix-stack-corruption-on-some-architectures.patch deleted file mode 100644 index e44f713d63..0000000000 --- a/target/linux/generic/patches-3.10/003-11-008-hso-Fix-stack-corruption-on-some-architectures.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e75dc677ff8d06ffa61bef6fee436227ae5440c6 Mon Sep 17 00:00:00 2001 -From: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us> -Date: Wed, 21 Aug 2013 01:43:19 -0700 -Subject: [PATCH] hso: Fix stack corruption on some architectures - -commit e75dc677ff8d06ffa61bef6fee436227ae5440c6 upstream. - -As Sergei Shtylyov explained in the #mipslinux IRC channel: -[Mon 2013-08-19 12:28:21 PM PDT] <headless> guys, are you sure it's not "DMA off stack" case? -[Mon 2013-08-19 12:28:35 PM PDT] <headless> it's a known stack corruptor on non-coherent arches -[Mon 2013-08-19 12:31:48 PM PDT] <DonkeyHotei> headless: for usb/ehci? -[Mon 2013-08-19 12:34:11 PM PDT] <DonkeyHotei> headless: explain -[Mon 2013-08-19 12:35:38 PM PDT] <headless> usb_control_msg() (or other such func) should not use buffer on stack. DMA from/to stack is prohibited -[Mon 2013-08-19 12:35:58 PM PDT] <headless> and EHCI uses DMA on control xfers (as well as all the others) - -Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us> -Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -Signed-off-by: David S. Miller <davem@davemloft.net> ---- - drivers/net/usb/hso.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - ---- a/drivers/net/usb/hso.c -+++ b/drivers/net/usb/hso.c -@@ -2816,13 +2816,16 @@ exit: - static int hso_get_config_data(struct usb_interface *interface) - { - struct usb_device *usbdev = interface_to_usbdev(interface); -- u8 config_data[17]; -+ u8 *config_data = kmalloc(17, GFP_KERNEL); - u32 if_num = interface->altsetting->desc.bInterfaceNumber; - s32 result; - -+ if (!config_data) -+ return -ENOMEM; - if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), - 0x86, 0xC0, 0, 0, config_data, 17, - USB_CTRL_SET_TIMEOUT) != 0x11) { -+ kfree(config_data); - return -EIO; - } - -@@ -2873,6 +2876,7 @@ static int hso_get_config_data(struct us - if (config_data[16] & 0x1) - result |= HSO_INFO_CRC_BUG; - -+ kfree(config_data); - return result; - } - diff --git a/target/linux/generic/patches-3.10/003-12-001-mtd-chips-Add-support-for-PMC-SPI-Flash-chips-in-m25.patch b/target/linux/generic/patches-3.10/003-12-001-mtd-chips-Add-support-for-PMC-SPI-Flash-chips-in-m25.patch deleted file mode 100644 index 8902acb687..0000000000 --- a/target/linux/generic/patches-3.10/003-12-001-mtd-chips-Add-support-for-PMC-SPI-Flash-chips-in-m25.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 6c3b88970175e18a67eb8e55c4eba10614d0d5dc Mon Sep 17 00:00:00 2001 -From: Michel Stempin <michel.stempin@wanadoo.fr> -Date: Mon, 15 Jul 2013 12:13:56 +0200 -Subject: [PATCH] mtd: chips: Add support for PMC SPI Flash chips in m25p80.c - -commit 6c3b88970175e18a67eb8e55c4eba10614d0d5dc upstream. - -Add support for PMC (now Chingis, part of ISSI) Pm25LV512 (512 Kib), -Pm25LV010 (1 Mib) and Pm25LQ032 (32 Mib) SPI Flash chips. - -This patch addresses two generations of PMC SPI Flash chips: - - - Pm25LV512 and Pm25LV010: these have 4KiB sectors and 32KiB - blocks. The 4KiB sector erase uses a non-standard opcode - (0xd7). They do not support JEDEC RDID (0x9f), and so they can only - be detected by matching their name string with pre-configured - platform data. Because of the cascaded acquisitions, the datasheet - is no longer available on the current manufacturer's website, - although it is still commonly used in some recent wireless routers - (<https://forum.openwrt.org/viewtopic.php?pid=186360#p186360>). The - only public datasheet available seems to be on GeoCities: - <http://www.geocities.jp/scottle556/pdf/Pm25LV512-010.pdf> - - - Pm25LQ032: a newer generation flash, with 4KiB sectors and 64KiB - blocks. It uses the standard erase and JEDEC read-ID - opcodes. Manufacturer's datasheet is here: - <http://www.chingistek.com/img/Product_Files/Pm25LQ032C%20datasheet%20v1.6.1.pdf> - -This patch is resent in order to take into account both Brian Norris -remarks and this upstream patch: - -commit e534ee4f9ca29fdb38eea4b0c53f2154fbd8c1ee -Author: Krzysztof Mazur <krzysiek@podlesie.net> -Date: Fri Feb 22 15:51:05 2013 +0100 - - mtd: m25p80: introduce SST_WRITE flag for SST byte programming - - Not all SST devices implement the SST byte programming command. - Some devices (like SST25VF064C) implement only standard m25p80 page - write command. - - Now SPI flash devices that need sst_write() are explicitly marked - with new SST_WRITE flag and the decision to use sst_write() is based - on this flag instead of manufacturer id. - -Signed-off-by: Gabor Juhos <juhosg@openwrt.org> -Signed-off-by: Michel Stempin <michel.stempin@wanadoo.fr> -[Brian: fixed conflict] -Signed-off-by: Brian Norris <computersforpeace@gmail.com> -Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> ---- - drivers/mtd/devices/m25p80.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - ---- a/drivers/mtd/devices/m25p80.c -+++ b/drivers/mtd/devices/m25p80.c -@@ -43,6 +43,7 @@ - #define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */ - #define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */ - #define OPCODE_BE_4K 0x20 /* Erase 4KiB block */ -+#define OPCODE_BE_4K_PMC 0xd7 /* Erase 4KiB block on PMC chips */ - #define OPCODE_BE_32K 0x52 /* Erase 32KiB block */ - #define OPCODE_CHIP_ERASE 0xc7 /* Erase whole flash chip */ - #define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */ -@@ -682,6 +683,7 @@ struct flash_info { - #define SECT_4K 0x01 /* OPCODE_BE_4K works uniformly */ - #define M25P_NO_ERASE 0x02 /* No erase command needed */ - #define SST_WRITE 0x04 /* use SST byte programming */ -+#define SECT_4K_PMC 0x10 /* OPCODE_BE_4K_PMC works uniformly */ - }; - - #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \ -@@ -762,6 +764,11 @@ static const struct spi_device_id m25p_i - { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, - { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) }, - -+ /* PMC */ -+ { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, -+ { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, -+ { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) }, -+ - /* Spansion -- single (large) sector size only, at least - * for the chips listed here (without boot sectors). - */ -@@ -1014,6 +1021,9 @@ static int m25p_probe(struct spi_device - if (info->flags & SECT_4K) { - flash->erase_opcode = OPCODE_BE_4K; - flash->mtd.erasesize = 4096; -+ } else if (info->flags & SECT_4K_PMC) { -+ flash->erase_opcode = OPCODE_BE_4K_PMC; -+ flash->mtd.erasesize = 4096; - } else { - flash->erase_opcode = OPCODE_SE; - flash->mtd.erasesize = info->sector_size; diff --git a/target/linux/generic/patches-3.10/009-mtd_m25p80_add_support_for_esmt_f25l32pa.patch b/target/linux/generic/patches-3.10/009-mtd_m25p80_add_support_for_esmt_f25l32pa.patch deleted file mode 100644 index 4aed409532..0000000000 --- a/target/linux/generic/patches-3.10/009-mtd_m25p80_add_support_for_esmt_f25l32pa.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 7d75ef5f56dbc2bedb9a893eb9ecfd03c456338d Mon Sep 17 00:00:00 2001 -From: Flavio Silveira <fggs@terra.com.br> -Date: Thu, 29 Aug 2013 08:51:48 -0300 -Subject: [PATCH v2] mtd: m25p80: Add support for ESMT F25L32PA - -This flashchip is used in D-Link DIR-610 A1 router board -and maybe several others, yet is not kernel upstream. - -So add support for it according to datasheet [0], making it easier -to support other boards using this flashchip in the future. - -Changelog v2: - - Better description - - Datasheet link at the bottom, similar to other patches. - -[0] http://www.esmt.com.tw/DB/manager/upload/F25L32PA.pdf - -Signed-off-by: Flavio Silveira <fggs@terra.com.br> ---- - drivers/mtd/devices/m25p80.c | 3 +++ - 1 file changed, 3 insertions(+) - - http://patchwork.ozlabs.org/patch/272438/ - http://lists.infradead.org/pipermail/linux-mtd/2013-September/048511.html - ---- a/drivers/mtd/devices/m25p80.c -+++ b/drivers/mtd/devices/m25p80.c -@@ -733,6 +733,9 @@ static const struct spi_device_id m25p_i - { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, - { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) }, - -+ /* ESMT */ -+ { "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) }, -+ - /* Everspin */ - { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2) }, - diff --git a/target/linux/generic/patches-3.10/020-ssb_update.patch b/target/linux/generic/patches-3.10/020-ssb_update.patch deleted file mode 100644 index a85ab10967..0000000000 --- a/target/linux/generic/patches-3.10/020-ssb_update.patch +++ /dev/null @@ -1,981 +0,0 @@ ---- a/drivers/ssb/Kconfig -+++ b/drivers/ssb/Kconfig -@@ -138,13 +138,13 @@ config SSB_DRIVER_MIPS - - config SSB_SFLASH - bool "SSB serial flash support" -- depends on SSB_DRIVER_MIPS && BROKEN -+ depends on SSB_DRIVER_MIPS - default y - - # Assumption: We are on embedded, if we compile the MIPS core. - config SSB_EMBEDDED - bool -- depends on SSB_DRIVER_MIPS -+ depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE - default y - - config SSB_DRIVER_EXTIF -@@ -168,6 +168,7 @@ config SSB_DRIVER_GIGE - config SSB_DRIVER_GPIO - bool "SSB GPIO driver" - depends on SSB && GPIOLIB -+ select IRQ_DOMAIN if SSB_EMBEDDED - help - Driver to provide access to the GPIO pins on the bus. - ---- a/drivers/ssb/b43_pci_bridge.c -+++ b/drivers/ssb/b43_pci_bridge.c -@@ -38,6 +38,7 @@ static const struct pci_device_id b43_pc - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x432b) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x432c) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4350) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4351) }, - { 0, }, - }; - MODULE_DEVICE_TABLE(pci, b43_pci_bridge_tbl); ---- a/drivers/ssb/driver_chipcommon_sflash.c -+++ b/drivers/ssb/driver_chipcommon_sflash.c -@@ -9,6 +9,19 @@ - - #include "ssb_private.h" - -+static struct resource ssb_sflash_resource = { -+ .name = "ssb_sflash", -+ .start = SSB_FLASH2, -+ .end = 0, -+ .flags = IORESOURCE_MEM | IORESOURCE_READONLY, -+}; -+ -+struct platform_device ssb_sflash_dev = { -+ .name = "ssb_sflash", -+ .resource = &ssb_sflash_resource, -+ .num_resources = 1, -+}; -+ - struct ssb_sflash_tbl_e { - char *name; - u32 id; -@@ -16,7 +29,7 @@ struct ssb_sflash_tbl_e { - u16 numblocks; - }; - --static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = { -+static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = { - { "M25P20", 0x11, 0x10000, 4, }, - { "M25P40", 0x12, 0x10000, 8, }, - -@@ -24,10 +37,10 @@ static struct ssb_sflash_tbl_e ssb_sflas - { "M25P32", 0x15, 0x10000, 64, }, - { "M25P64", 0x16, 0x10000, 128, }, - { "M25FL128", 0x17, 0x10000, 256, }, -- { 0 }, -+ { NULL }, - }; - --static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = { -+static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = { - { "SST25WF512", 1, 0x1000, 16, }, - { "SST25VF512", 0x48, 0x1000, 16, }, - { "SST25WF010", 2, 0x1000, 32, }, -@@ -42,10 +55,10 @@ static struct ssb_sflash_tbl_e ssb_sflas - { "SST25VF016", 0x41, 0x1000, 512, }, - { "SST25VF032", 0x4a, 0x1000, 1024, }, - { "SST25VF064", 0x4b, 0x1000, 2048, }, -- { 0 }, -+ { NULL }, - }; - --static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = { -+static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = { - { "AT45DB011", 0xc, 256, 512, }, - { "AT45DB021", 0x14, 256, 1024, }, - { "AT45DB041", 0x1c, 256, 2048, }, -@@ -53,7 +66,7 @@ static struct ssb_sflash_tbl_e ssb_sflas - { "AT45DB161", 0x2c, 512, 4096, }, - { "AT45DB321", 0x34, 512, 8192, }, - { "AT45DB642", 0x3c, 1024, 8192, }, -- { 0 }, -+ { NULL }, - }; - - static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode) -@@ -73,7 +86,8 @@ static void ssb_sflash_cmd(struct ssb_ch - /* Initialize serial flash access */ - int ssb_sflash_init(struct ssb_chipcommon *cc) - { -- struct ssb_sflash_tbl_e *e; -+ struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash; -+ const struct ssb_sflash_tbl_e *e; - u32 id, id2; - - switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) { -@@ -131,10 +145,20 @@ int ssb_sflash_init(struct ssb_chipcommo - return -ENOTSUPP; - } - -- pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n", -- e->name, e->blocksize, e->numblocks); -- -- pr_err("Serial flash support is not implemented yet!\n"); -+ sflash->window = SSB_FLASH2; -+ sflash->blocksize = e->blocksize; -+ sflash->numblocks = e->numblocks; -+ sflash->size = sflash->blocksize * sflash->numblocks; -+ sflash->present = true; -+ -+ pr_info("Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n", -+ e->name, sflash->size / 1024, e->blocksize, e->numblocks); -+ -+ /* Prepare platform device, but don't register it yet. It's too early, -+ * malloc (required by device_private_init) is not available yet. */ -+ ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start + -+ sflash->size; -+ ssb_sflash_dev.dev.platform_data = sflash; - -- return -ENOTSUPP; -+ return 0; - } ---- a/drivers/ssb/driver_gpio.c -+++ b/drivers/ssb/driver_gpio.c -@@ -9,16 +9,40 @@ - */ - - #include <linux/gpio.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/irqdomain.h> - #include <linux/export.h> - #include <linux/ssb/ssb.h> - - #include "ssb_private.h" - -+ -+/************************************************** -+ * Shared -+ **************************************************/ -+ - static struct ssb_bus *ssb_gpio_get_bus(struct gpio_chip *chip) - { - return container_of(chip, struct ssb_bus, gpio); - } - -+#if IS_ENABLED(CONFIG_SSB_EMBEDDED) -+static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) -+{ -+ struct ssb_bus *bus = ssb_gpio_get_bus(chip); -+ -+ if (bus->bustype == SSB_BUSTYPE_SSB) -+ return irq_find_mapping(bus->irq_domain, gpio); -+ else -+ return -EINVAL; -+} -+#endif -+ -+/************************************************** -+ * ChipCommon -+ **************************************************/ -+ - static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio) - { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); -@@ -74,19 +98,129 @@ static void ssb_gpio_chipco_free(struct - ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0); - } - --static int ssb_gpio_chipco_to_irq(struct gpio_chip *chip, unsigned gpio) -+#if IS_ENABLED(CONFIG_SSB_EMBEDDED) -+static void ssb_gpio_irq_chipco_mask(struct irq_data *d) - { -- struct ssb_bus *bus = ssb_gpio_get_bus(chip); -+ struct ssb_bus *bus = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); - -- if (bus->bustype == SSB_BUSTYPE_SSB) -- return ssb_mips_irq(bus->chipco.dev) + 2; -- else -- return -EINVAL; -+ ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), 0); -+} -+ -+static void ssb_gpio_irq_chipco_unmask(struct irq_data *d) -+{ -+ struct ssb_bus *bus = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); -+ u32 val = ssb_chipco_gpio_in(&bus->chipco, BIT(gpio)); -+ -+ ssb_chipco_gpio_polarity(&bus->chipco, BIT(gpio), val); -+ ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), BIT(gpio)); -+} -+ -+static struct irq_chip ssb_gpio_irq_chipco_chip = { -+ .name = "SSB-GPIO-CC", -+ .irq_mask = ssb_gpio_irq_chipco_mask, -+ .irq_unmask = ssb_gpio_irq_chipco_unmask, -+}; -+ -+static irqreturn_t ssb_gpio_irq_chipco_handler(int irq, void *dev_id) -+{ -+ struct ssb_bus *bus = dev_id; -+ struct ssb_chipcommon *chipco = &bus->chipco; -+ u32 val = chipco_read32(chipco, SSB_CHIPCO_GPIOIN); -+ u32 mask = chipco_read32(chipco, SSB_CHIPCO_GPIOIRQ); -+ u32 pol = chipco_read32(chipco, SSB_CHIPCO_GPIOPOL); -+ unsigned long irqs = (val ^ pol) & mask; -+ int gpio; -+ -+ if (!irqs) -+ return IRQ_NONE; -+ -+ for_each_set_bit(gpio, &irqs, bus->gpio.ngpio) -+ generic_handle_irq(ssb_gpio_to_irq(&bus->gpio, gpio)); -+ ssb_chipco_gpio_polarity(chipco, irqs, val & irqs); -+ -+ return IRQ_HANDLED; -+} -+ -+static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus) -+{ -+ struct ssb_chipcommon *chipco = &bus->chipco; -+ struct gpio_chip *chip = &bus->gpio; -+ int gpio, hwirq, err; -+ -+ if (bus->bustype != SSB_BUSTYPE_SSB) -+ return 0; -+ -+ bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio, -+ &irq_domain_simple_ops, chipco); -+ if (!bus->irq_domain) { -+ err = -ENODEV; -+ goto err_irq_domain; -+ } -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_create_mapping(bus->irq_domain, gpio); -+ -+ irq_set_chip_data(irq, bus); -+ irq_set_chip_and_handler(irq, &ssb_gpio_irq_chipco_chip, -+ handle_simple_irq); -+ } -+ -+ hwirq = ssb_mips_irq(bus->chipco.dev) + 2; -+ err = request_irq(hwirq, ssb_gpio_irq_chipco_handler, IRQF_SHARED, -+ "gpio", bus); -+ if (err) -+ goto err_req_irq; -+ -+ ssb_chipco_gpio_intmask(&bus->chipco, ~0, 0); -+ chipco_set32(chipco, SSB_CHIPCO_IRQMASK, SSB_CHIPCO_IRQ_GPIO); -+ -+ return 0; -+ -+err_req_irq: -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(bus->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(bus->irq_domain); -+err_irq_domain: -+ return err; -+} -+ -+static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus) -+{ -+ struct ssb_chipcommon *chipco = &bus->chipco; -+ struct gpio_chip *chip = &bus->gpio; -+ int gpio; -+ -+ if (bus->bustype != SSB_BUSTYPE_SSB) -+ return; -+ -+ chipco_mask32(chipco, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO); -+ free_irq(ssb_mips_irq(bus->chipco.dev) + 2, chipco); -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(bus->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(bus->irq_domain); -+} -+#else -+static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus) -+{ -+ return 0; -+} -+ -+static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus) -+{ - } -+#endif - - static int ssb_gpio_chipco_init(struct ssb_bus *bus) - { - struct gpio_chip *chip = &bus->gpio; -+ int err; - - chip->label = "ssb_chipco_gpio"; - chip->owner = THIS_MODULE; -@@ -96,7 +230,9 @@ static int ssb_gpio_chipco_init(struct s - chip->set = ssb_gpio_chipco_set_value; - chip->direction_input = ssb_gpio_chipco_direction_input; - chip->direction_output = ssb_gpio_chipco_direction_output; -- chip->to_irq = ssb_gpio_chipco_to_irq; -+#if IS_ENABLED(CONFIG_SSB_EMBEDDED) -+ chip->to_irq = ssb_gpio_to_irq; -+#endif - chip->ngpio = 16; - /* There is just one SoC in one device and its GPIO addresses should be - * deterministic to address them more easily. The other buses could get -@@ -106,9 +242,23 @@ static int ssb_gpio_chipco_init(struct s - else - chip->base = -1; - -- return gpiochip_add(chip); -+ err = ssb_gpio_irq_chipco_domain_init(bus); -+ if (err) -+ return err; -+ -+ err = gpiochip_add(chip); -+ if (err) { -+ ssb_gpio_irq_chipco_domain_exit(bus); -+ return err; -+ } -+ -+ return 0; - } - -+/************************************************** -+ * EXTIF -+ **************************************************/ -+ - #ifdef CONFIG_SSB_DRIVER_EXTIF - - static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio) -@@ -145,19 +295,127 @@ static int ssb_gpio_extif_direction_outp - return 0; - } - --static int ssb_gpio_extif_to_irq(struct gpio_chip *chip, unsigned gpio) -+#if IS_ENABLED(CONFIG_SSB_EMBEDDED) -+static void ssb_gpio_irq_extif_mask(struct irq_data *d) - { -- struct ssb_bus *bus = ssb_gpio_get_bus(chip); -+ struct ssb_bus *bus = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); - -- if (bus->bustype == SSB_BUSTYPE_SSB) -- return ssb_mips_irq(bus->extif.dev) + 2; -- else -- return -EINVAL; -+ ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), 0); -+} -+ -+static void ssb_gpio_irq_extif_unmask(struct irq_data *d) -+{ -+ struct ssb_bus *bus = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); -+ u32 val = ssb_extif_gpio_in(&bus->extif, BIT(gpio)); -+ -+ ssb_extif_gpio_polarity(&bus->extif, BIT(gpio), val); -+ ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), BIT(gpio)); -+} -+ -+static struct irq_chip ssb_gpio_irq_extif_chip = { -+ .name = "SSB-GPIO-EXTIF", -+ .irq_mask = ssb_gpio_irq_extif_mask, -+ .irq_unmask = ssb_gpio_irq_extif_unmask, -+}; -+ -+static irqreturn_t ssb_gpio_irq_extif_handler(int irq, void *dev_id) -+{ -+ struct ssb_bus *bus = dev_id; -+ struct ssb_extif *extif = &bus->extif; -+ u32 val = ssb_read32(extif->dev, SSB_EXTIF_GPIO_IN); -+ u32 mask = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTMASK); -+ u32 pol = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTPOL); -+ unsigned long irqs = (val ^ pol) & mask; -+ int gpio; -+ -+ if (!irqs) -+ return IRQ_NONE; -+ -+ for_each_set_bit(gpio, &irqs, bus->gpio.ngpio) -+ generic_handle_irq(ssb_gpio_to_irq(&bus->gpio, gpio)); -+ ssb_extif_gpio_polarity(extif, irqs, val & irqs); -+ -+ return IRQ_HANDLED; -+} -+ -+static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus) -+{ -+ struct ssb_extif *extif = &bus->extif; -+ struct gpio_chip *chip = &bus->gpio; -+ int gpio, hwirq, err; -+ -+ if (bus->bustype != SSB_BUSTYPE_SSB) -+ return 0; -+ -+ bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio, -+ &irq_domain_simple_ops, extif); -+ if (!bus->irq_domain) { -+ err = -ENODEV; -+ goto err_irq_domain; -+ } -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_create_mapping(bus->irq_domain, gpio); -+ -+ irq_set_chip_data(irq, bus); -+ irq_set_chip_and_handler(irq, &ssb_gpio_irq_extif_chip, -+ handle_simple_irq); -+ } -+ -+ hwirq = ssb_mips_irq(bus->extif.dev) + 2; -+ err = request_irq(hwirq, ssb_gpio_irq_extif_handler, IRQF_SHARED, -+ "gpio", bus); -+ if (err) -+ goto err_req_irq; -+ -+ ssb_extif_gpio_intmask(&bus->extif, ~0, 0); -+ -+ return 0; -+ -+err_req_irq: -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(bus->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(bus->irq_domain); -+err_irq_domain: -+ return err; - } - -+static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus) -+{ -+ struct ssb_extif *extif = &bus->extif; -+ struct gpio_chip *chip = &bus->gpio; -+ int gpio; -+ -+ if (bus->bustype != SSB_BUSTYPE_SSB) -+ return; -+ -+ free_irq(ssb_mips_irq(bus->extif.dev) + 2, extif); -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(bus->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(bus->irq_domain); -+} -+#else -+static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus) -+{ -+ return 0; -+} -+ -+static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus) -+{ -+} -+#endif -+ - static int ssb_gpio_extif_init(struct ssb_bus *bus) - { - struct gpio_chip *chip = &bus->gpio; -+ int err; - - chip->label = "ssb_extif_gpio"; - chip->owner = THIS_MODULE; -@@ -165,7 +423,9 @@ static int ssb_gpio_extif_init(struct ss - chip->set = ssb_gpio_extif_set_value; - chip->direction_input = ssb_gpio_extif_direction_input; - chip->direction_output = ssb_gpio_extif_direction_output; -- chip->to_irq = ssb_gpio_extif_to_irq; -+#if IS_ENABLED(CONFIG_SSB_EMBEDDED) -+ chip->to_irq = ssb_gpio_to_irq; -+#endif - chip->ngpio = 5; - /* There is just one SoC in one device and its GPIO addresses should be - * deterministic to address them more easily. The other buses could get -@@ -175,7 +435,17 @@ static int ssb_gpio_extif_init(struct ss - else - chip->base = -1; - -- return gpiochip_add(chip); -+ err = ssb_gpio_irq_extif_domain_init(bus); -+ if (err) -+ return err; -+ -+ err = gpiochip_add(chip); -+ if (err) { -+ ssb_gpio_irq_extif_domain_exit(bus); -+ return err; -+ } -+ -+ return 0; - } - - #else -@@ -185,6 +455,10 @@ static int ssb_gpio_extif_init(struct ss - } - #endif - -+/************************************************** -+ * Init -+ **************************************************/ -+ - int ssb_gpio_init(struct ssb_bus *bus) - { - if (ssb_chipco_available(&bus->chipco)) -@@ -201,7 +475,8 @@ int ssb_gpio_unregister(struct ssb_bus * - { - if (ssb_chipco_available(&bus->chipco) || - ssb_extif_available(&bus->extif)) { -- return gpiochip_remove(&bus->gpio); -+ gpiochip_remove(&bus->gpio); -+ return 0; - } else { - SSB_WARN_ON(1); - } ---- a/drivers/ssb/main.c -+++ b/drivers/ssb/main.c -@@ -553,6 +553,14 @@ static int ssb_devices_register(struct s - } - #endif - -+#ifdef CONFIG_SSB_SFLASH -+ if (bus->mipscore.sflash.present) { -+ err = platform_device_register(&ssb_sflash_dev); -+ if (err) -+ pr_err("Error registering serial flash\n"); -+ } -+#endif -+ - return 0; - error: - /* Unwind the already registered devices. */ -@@ -582,6 +590,13 @@ static int ssb_attach_queued_buses(void) - ssb_pcicore_init(&bus->pcicore); - if (bus->bustype == SSB_BUSTYPE_SSB) - ssb_watchdog_register(bus); -+ -+ err = ssb_gpio_init(bus); -+ if (err == -ENOTSUPP) -+ ssb_dbg("GPIO driver not activated\n"); -+ else if (err) -+ ssb_dbg("Error registering GPIO driver: %i\n", err); -+ - ssb_bus_may_powerdown(bus); - - err = ssb_devices_register(bus); -@@ -819,11 +834,6 @@ static int ssb_bus_register(struct ssb_b - ssb_chipcommon_init(&bus->chipco); - ssb_extif_init(&bus->extif); - ssb_mipscore_init(&bus->mipscore); -- err = ssb_gpio_init(bus); -- if (err == -ENOTSUPP) -- ssb_dbg("GPIO driver not activated\n"); -- else if (err) -- ssb_dbg("Error registering GPIO driver: %i\n", err); - err = ssb_fetch_invariants(bus, get_invariants); - if (err) { - ssb_bus_may_powerdown(bus); ---- a/drivers/ssb/pci.c -+++ b/drivers/ssb/pci.c -@@ -326,13 +326,13 @@ err_ctlreg: - return err; - } - --static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in, -- u16 mask, u16 shift) -+static s8 sprom_extract_antgain(u8 sprom_revision, const u16 *in, u16 offset, -+ u16 mask, u16 shift) - { - u16 v; - u8 gain; - -- v = in[SPOFF(SSB_SPROM1_AGAIN)]; -+ v = in[SPOFF(offset)]; - gain = (v & mask) >> shift; - if (gain == 0xFF) - gain = 2; /* If unset use 2dBm */ -@@ -416,12 +416,14 @@ static void sprom_extract_r123(struct ss - SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0); - - /* Extract the antenna gain values. */ -- out->antenna_gain.a0 = r123_extract_antgain(out->revision, in, -- SSB_SPROM1_AGAIN_BG, -- SSB_SPROM1_AGAIN_BG_SHIFT); -- out->antenna_gain.a1 = r123_extract_antgain(out->revision, in, -- SSB_SPROM1_AGAIN_A, -- SSB_SPROM1_AGAIN_A_SHIFT); -+ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM1_AGAIN, -+ SSB_SPROM1_AGAIN_BG, -+ SSB_SPROM1_AGAIN_BG_SHIFT); -+ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM1_AGAIN, -+ SSB_SPROM1_AGAIN_A, -+ SSB_SPROM1_AGAIN_A_SHIFT); - if (out->revision >= 2) - sprom_extract_r23(out, in); - } -@@ -468,7 +470,15 @@ static void sprom_extract_r458(struct ss - - static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) - { -+ static const u16 pwr_info_offset[] = { -+ SSB_SPROM4_PWR_INFO_CORE0, SSB_SPROM4_PWR_INFO_CORE1, -+ SSB_SPROM4_PWR_INFO_CORE2, SSB_SPROM4_PWR_INFO_CORE3 -+ }; - u16 il0mac_offset; -+ int i; -+ -+ BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) != -+ ARRAY_SIZE(out->core_pwr_info)); - - if (out->revision == 4) - il0mac_offset = SSB_SPROM4_IL0MAC; -@@ -524,14 +534,59 @@ static void sprom_extract_r45(struct ssb - } - - /* Extract the antenna gain values. */ -- SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01, -- SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT); -- SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01, -- SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT); -- SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23, -- SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT); -- SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23, -- SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT); -+ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM4_AGAIN01, -+ SSB_SPROM4_AGAIN0, -+ SSB_SPROM4_AGAIN0_SHIFT); -+ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM4_AGAIN01, -+ SSB_SPROM4_AGAIN1, -+ SSB_SPROM4_AGAIN1_SHIFT); -+ out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM4_AGAIN23, -+ SSB_SPROM4_AGAIN2, -+ SSB_SPROM4_AGAIN2_SHIFT); -+ out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM4_AGAIN23, -+ SSB_SPROM4_AGAIN3, -+ SSB_SPROM4_AGAIN3_SHIFT); -+ -+ /* Extract cores power info info */ -+ for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { -+ u16 o = pwr_info_offset[i]; -+ -+ SPEX(core_pwr_info[i].itssi_2g, o + SSB_SPROM4_2G_MAXP_ITSSI, -+ SSB_SPROM4_2G_ITSSI, SSB_SPROM4_2G_ITSSI_SHIFT); -+ SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SPROM4_2G_MAXP_ITSSI, -+ SSB_SPROM4_2G_MAXP, 0); -+ -+ SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SPROM4_2G_PA_0, ~0, 0); -+ SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SPROM4_2G_PA_1, ~0, 0); -+ SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SPROM4_2G_PA_2, ~0, 0); -+ SPEX(core_pwr_info[i].pa_2g[3], o + SSB_SPROM4_2G_PA_3, ~0, 0); -+ -+ SPEX(core_pwr_info[i].itssi_5g, o + SSB_SPROM4_5G_MAXP_ITSSI, -+ SSB_SPROM4_5G_ITSSI, SSB_SPROM4_5G_ITSSI_SHIFT); -+ SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SPROM4_5G_MAXP_ITSSI, -+ SSB_SPROM4_5G_MAXP, 0); -+ SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM4_5GHL_MAXP, -+ SSB_SPROM4_5GH_MAXP, 0); -+ SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM4_5GHL_MAXP, -+ SSB_SPROM4_5GL_MAXP, SSB_SPROM4_5GL_MAXP_SHIFT); -+ -+ SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SPROM4_5GL_PA_0, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SPROM4_5GL_PA_1, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SPROM4_5GL_PA_2, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gl[3], o + SSB_SPROM4_5GL_PA_3, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SPROM4_5G_PA_0, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SPROM4_5G_PA_1, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SPROM4_5G_PA_2, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5g[3], o + SSB_SPROM4_5G_PA_3, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SPROM4_5GH_PA_0, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SPROM4_5GH_PA_1, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SPROM4_5GH_PA_2, ~0, 0); -+ SPEX(core_pwr_info[i].pa_5gh[3], o + SSB_SPROM4_5GH_PA_3, ~0, 0); -+ } - - sprom_extract_r458(out, in); - -@@ -621,14 +676,22 @@ static void sprom_extract_r8(struct ssb_ - SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0); - - /* Extract the antenna gain values. */ -- SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01, -- SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT); -- SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01, -- SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT); -- SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23, -- SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT); -- SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23, -- SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT); -+ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM8_AGAIN01, -+ SSB_SPROM8_AGAIN0, -+ SSB_SPROM8_AGAIN0_SHIFT); -+ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM8_AGAIN01, -+ SSB_SPROM8_AGAIN1, -+ SSB_SPROM8_AGAIN1_SHIFT); -+ out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM8_AGAIN23, -+ SSB_SPROM8_AGAIN2, -+ SSB_SPROM8_AGAIN2_SHIFT); -+ out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in, -+ SSB_SPROM8_AGAIN23, -+ SSB_SPROM8_AGAIN3, -+ SSB_SPROM8_AGAIN3_SHIFT); - - /* Extract cores power info info */ - for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { ---- a/drivers/ssb/pcihost_wrapper.c -+++ b/drivers/ssb/pcihost_wrapper.c -@@ -11,15 +11,17 @@ - * Licensed under the GNU/GPL. See COPYING for details. - */ - -+#include <linux/pm.h> - #include <linux/pci.h> - #include <linux/export.h> - #include <linux/slab.h> - #include <linux/ssb/ssb.h> - - --#ifdef CONFIG_PM --static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state) -+#ifdef CONFIG_PM_SLEEP -+static int ssb_pcihost_suspend(struct device *d) - { -+ struct pci_dev *dev = to_pci_dev(d); - struct ssb_bus *ssb = pci_get_drvdata(dev); - int err; - -@@ -28,17 +30,23 @@ static int ssb_pcihost_suspend(struct pc - return err; - pci_save_state(dev); - pci_disable_device(dev); -- pci_set_power_state(dev, pci_choose_state(dev, state)); -+ -+ /* if there is a wakeup enabled child device on ssb bus, -+ enable pci wakeup posibility. */ -+ device_set_wakeup_enable(d, d->power.wakeup_path); -+ -+ pci_prepare_to_sleep(dev); - - return 0; - } - --static int ssb_pcihost_resume(struct pci_dev *dev) -+static int ssb_pcihost_resume(struct device *d) - { -+ struct pci_dev *dev = to_pci_dev(d); - struct ssb_bus *ssb = pci_get_drvdata(dev); - int err; - -- pci_set_power_state(dev, 0); -+ pci_back_from_sleep(dev); - err = pci_enable_device(dev); - if (err) - return err; -@@ -49,10 +57,12 @@ static int ssb_pcihost_resume(struct pci - - return 0; - } --#else /* CONFIG_PM */ --# define ssb_pcihost_suspend NULL --# define ssb_pcihost_resume NULL --#endif /* CONFIG_PM */ -+ -+static const struct dev_pm_ops ssb_pcihost_pm_ops = { -+ SET_SYSTEM_SLEEP_PM_OPS(ssb_pcihost_suspend, ssb_pcihost_resume) -+}; -+ -+#endif /* CONFIG_PM_SLEEP */ - - static int ssb_pcihost_probe(struct pci_dev *dev, - const struct pci_device_id *id) -@@ -115,8 +125,9 @@ int ssb_pcihost_register(struct pci_driv - { - driver->probe = ssb_pcihost_probe; - driver->remove = ssb_pcihost_remove; -- driver->suspend = ssb_pcihost_suspend; -- driver->resume = ssb_pcihost_resume; -+#ifdef CONFIG_PM_SLEEP -+ driver->driver.pm = &ssb_pcihost_pm_ops; -+#endif - - return pci_register_driver(driver); - } ---- a/drivers/ssb/sprom.c -+++ b/drivers/ssb/sprom.c -@@ -54,7 +54,7 @@ static int hex2sprom(u16 *sprom, const c - while (cnt < sprom_size_words) { - memcpy(tmp, dump, 4); - dump += 4; -- err = strict_strtoul(tmp, 16, &parsed); -+ err = kstrtoul(tmp, 16, &parsed); - if (err) - return err; - sprom[cnt++] = swab16((u16)parsed); ---- a/drivers/ssb/ssb_private.h -+++ b/drivers/ssb/ssb_private.h -@@ -243,6 +243,10 @@ static inline int ssb_sflash_init(struct - extern struct platform_device ssb_pflash_dev; - #endif - -+#ifdef CONFIG_SSB_SFLASH -+extern struct platform_device ssb_sflash_dev; -+#endif -+ - #ifdef CONFIG_SSB_DRIVER_EXTIF - extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks); - extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); ---- a/include/linux/ssb/ssb.h -+++ b/include/linux/ssb/ssb.h -@@ -33,6 +33,7 @@ struct ssb_sprom { - u8 et1phyaddr; /* MII address for enet1 */ - u8 et0mdcport; /* MDIO for enet0 */ - u8 et1mdcport; /* MDIO for enet1 */ -+ u16 dev_id; /* Device ID overriding e.g. PCI ID */ - u16 board_rev; /* Board revision number from SPROM. */ - u16 board_num; /* Board number from SPROM. */ - u16 board_type; /* Board type from SPROM. */ -@@ -486,6 +487,7 @@ struct ssb_bus { - #endif /* EMBEDDED */ - #ifdef CONFIG_SSB_DRIVER_GPIO - struct gpio_chip gpio; -+ struct irq_domain *irq_domain; - #endif /* DRIVER_GPIO */ - - /* Internal-only stuff follows. Do not touch. */ ---- a/include/linux/ssb/ssb_driver_gige.h -+++ b/include/linux/ssb/ssb_driver_gige.h -@@ -108,6 +108,16 @@ static inline int ssb_gige_get_macaddr(s - return 0; - } - -+/* Get the device phy address */ -+static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev) -+{ -+ struct ssb_gige *dev = pdev_to_ssb_gige(pdev); -+ if (!dev) -+ return -ENODEV; -+ -+ return dev->dev->bus->sprom.et0phyaddr; -+} -+ - extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev, - struct pci_dev *pdev); - extern int ssb_gige_map_irq(struct ssb_device *sdev, -@@ -174,6 +184,10 @@ static inline int ssb_gige_get_macaddr(s - { - return -ENODEV; - } -+static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev) -+{ -+ return -ENODEV; -+} - - #endif /* CONFIG_SSB_DRIVER_GIGE */ - #endif /* LINUX_SSB_DRIVER_GIGE_H_ */ ---- a/include/linux/ssb/ssb_driver_mips.h -+++ b/include/linux/ssb/ssb_driver_mips.h -@@ -20,6 +20,18 @@ struct ssb_pflash { - u32 window_size; - }; - -+#ifdef CONFIG_SSB_SFLASH -+struct ssb_sflash { -+ bool present; -+ u32 window; -+ u32 blocksize; -+ u16 numblocks; -+ u32 size; -+ -+ void *priv; -+}; -+#endif -+ - struct ssb_mipscore { - struct ssb_device *dev; - -@@ -27,6 +39,9 @@ struct ssb_mipscore { - struct ssb_serial_port serial_ports[4]; - - struct ssb_pflash pflash; -+#ifdef CONFIG_SSB_SFLASH -+ struct ssb_sflash sflash; -+#endif - }; - - extern void ssb_mipscore_init(struct ssb_mipscore *mcore); ---- a/include/linux/ssb/ssb_regs.h -+++ b/include/linux/ssb/ssb_regs.h -@@ -172,6 +172,7 @@ - #define SSB_SPROMSIZE_WORDS_R4 220 - #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16)) - #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16)) -+#define SSB_SPROMSIZE_WORDS_R10 230 - #define SSB_SPROM_BASE1 0x1000 - #define SSB_SPROM_BASE31 0x0800 - #define SSB_SPROM_REVISION 0x007E -@@ -344,6 +345,43 @@ - #define SSB_SPROM4_TXPID5GH2_SHIFT 0 - #define SSB_SPROM4_TXPID5GH3 0xFF00 - #define SSB_SPROM4_TXPID5GH3_SHIFT 8 -+ -+/* There are 4 blocks with power info sharing the same layout */ -+#define SSB_SPROM4_PWR_INFO_CORE0 0x0080 -+#define SSB_SPROM4_PWR_INFO_CORE1 0x00AE -+#define SSB_SPROM4_PWR_INFO_CORE2 0x00DC -+#define SSB_SPROM4_PWR_INFO_CORE3 0x010A -+ -+#define SSB_SPROM4_2G_MAXP_ITSSI 0x00 /* 2 GHz ITSSI and 2 GHz Max Power */ -+#define SSB_SPROM4_2G_MAXP 0x00FF -+#define SSB_SPROM4_2G_ITSSI 0xFF00 -+#define SSB_SPROM4_2G_ITSSI_SHIFT 8 -+#define SSB_SPROM4_2G_PA_0 0x02 /* 2 GHz power amp */ -+#define SSB_SPROM4_2G_PA_1 0x04 -+#define SSB_SPROM4_2G_PA_2 0x06 -+#define SSB_SPROM4_2G_PA_3 0x08 -+#define SSB_SPROM4_5G_MAXP_ITSSI 0x0A /* 5 GHz ITSSI and 5.3 GHz Max Power */ -+#define SSB_SPROM4_5G_MAXP 0x00FF -+#define SSB_SPROM4_5G_ITSSI 0xFF00 -+#define SSB_SPROM4_5G_ITSSI_SHIFT 8 -+#define SSB_SPROM4_5GHL_MAXP 0x0C /* 5.2 GHz and 5.8 GHz Max Power */ -+#define SSB_SPROM4_5GH_MAXP 0x00FF -+#define SSB_SPROM4_5GL_MAXP 0xFF00 -+#define SSB_SPROM4_5GL_MAXP_SHIFT 8 -+#define SSB_SPROM4_5G_PA_0 0x0E /* 5.3 GHz power amp */ -+#define SSB_SPROM4_5G_PA_1 0x10 -+#define SSB_SPROM4_5G_PA_2 0x12 -+#define SSB_SPROM4_5G_PA_3 0x14 -+#define SSB_SPROM4_5GL_PA_0 0x16 /* 5.2 GHz power amp */ -+#define SSB_SPROM4_5GL_PA_1 0x18 -+#define SSB_SPROM4_5GL_PA_2 0x1A -+#define SSB_SPROM4_5GL_PA_3 0x1C -+#define SSB_SPROM4_5GH_PA_0 0x1E /* 5.8 GHz power amp */ -+#define SSB_SPROM4_5GH_PA_1 0x20 -+#define SSB_SPROM4_5GH_PA_2 0x22 -+#define SSB_SPROM4_5GH_PA_3 0x24 -+ -+/* TODO: Make it deprecated */ - #define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */ - #define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */ - #define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */ ---- a/arch/mips/bcm47xx/sprom.c -+++ b/arch/mips/bcm47xx/sprom.c -@@ -168,6 +168,7 @@ static void nvram_read_alpha2(const char - static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, - const char *prefix, bool fallback) - { -+ nvram_read_u16(prefix, NULL, "devid", &sprom->dev_id, 0, fallback); - nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff, fallback); - nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff, fallback); - nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff, fallback); diff --git a/target/linux/generic/patches-3.10/025-bcma_backport.patch b/target/linux/generic/patches-3.10/025-bcma_backport.patch deleted file mode 100644 index 3ae8fd54a2..0000000000 --- a/target/linux/generic/patches-3.10/025-bcma_backport.patch +++ /dev/null @@ -1,2716 +0,0 @@ ---- a/drivers/bcma/Kconfig -+++ b/drivers/bcma/Kconfig -@@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE - config BCMA_HOST_PCI - bool "Support for BCMA on PCI-host bus" - depends on BCMA_HOST_PCI_POSSIBLE -+ default y - - config BCMA_DRIVER_PCI_HOSTMODE - bool "Driver for PCI core working in hostmode" -@@ -34,8 +35,14 @@ config BCMA_DRIVER_PCI_HOSTMODE - PCI core hostmode operation (external PCI bus). - - config BCMA_HOST_SOC -- bool -- depends on BCMA_DRIVER_MIPS -+ bool "Support for BCMA in a SoC" -+ depends on BCMA -+ help -+ Host interface for a Broadcom AIX bus directly mapped into -+ the memory. This only works with the Broadcom SoCs from the -+ BCM47XX line. -+ -+ If unsure, say N - - config BCMA_DRIVER_MIPS - bool "BCMA Broadcom MIPS core driver" -@@ -68,6 +75,7 @@ config BCMA_DRIVER_GMAC_CMN - config BCMA_DRIVER_GPIO - bool "BCMA GPIO driver" - depends on BCMA && GPIOLIB -+ select IRQ_DOMAIN if BCMA_HOST_SOC - help - Driver to provide access to the GPIO pins of the bcma bus. - ---- a/drivers/bcma/Makefile -+++ b/drivers/bcma/Makefile -@@ -1,8 +1,10 @@ - bcma-y += main.o scan.o core.o sprom.o - bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o -+bcma-y += driver_chipcommon_b.o - bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o - bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o - bcma-y += driver_pci.o -+bcma-y += driver_pcie2.o - bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o - bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o - bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o ---- a/drivers/bcma/bcma_private.h -+++ b/drivers/bcma/bcma_private.h -@@ -22,6 +22,9 @@ - struct bcma_bus; - - /* main.c */ -+bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value, -+ int timeout); -+void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core); - int bcma_bus_register(struct bcma_bus *bus); - void bcma_bus_unregister(struct bcma_bus *bus); - int __init bcma_bus_early_register(struct bcma_bus *bus, -@@ -31,8 +34,6 @@ int __init bcma_bus_early_register(struc - int bcma_bus_suspend(struct bcma_bus *bus); - int bcma_bus_resume(struct bcma_bus *bus); - #endif --struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid, -- u8 unit); - - /* scan.c */ - int bcma_bus_scan(struct bcma_bus *bus); -@@ -50,6 +51,10 @@ void bcma_chipco_serial_init(struct bcma - extern struct platform_device bcma_pflash_dev; - #endif /* CONFIG_BCMA_DRIVER_MIPS */ - -+/* driver_chipcommon_b.c */ -+int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb); -+void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb); -+ - /* driver_chipcommon_pmu.c */ - u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); - u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc); -@@ -84,6 +89,20 @@ extern int __init bcma_host_pci_init(voi - extern void __exit bcma_host_pci_exit(void); - #endif /* CONFIG_BCMA_HOST_PCI */ - -+/* host_soc.c */ -+#if defined(CONFIG_BCMA_HOST_SOC) && defined(CONFIG_OF) -+extern int __init bcma_host_soc_register_driver(void); -+extern void __exit bcma_host_soc_unregister_driver(void); -+#else -+static inline int __init bcma_host_soc_register_driver(void) -+{ -+ return 0; -+} -+static inline void __exit bcma_host_soc_unregister_driver(void) -+{ -+} -+#endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */ -+ - /* driver_pci.c */ - u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address); - ---- a/drivers/bcma/core.c -+++ b/drivers/bcma/core.c -@@ -9,6 +9,25 @@ - #include <linux/export.h> - #include <linux/bcma/bcma.h> - -+static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask, -+ u32 value, int timeout) -+{ -+ unsigned long deadline = jiffies + timeout; -+ u32 val; -+ -+ do { -+ val = bcma_aread32(core, reg); -+ if ((val & mask) == value) -+ return true; -+ cpu_relax(); -+ udelay(10); -+ } while (!time_after_eq(jiffies, deadline)); -+ -+ bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg); -+ -+ return false; -+} -+ - bool bcma_core_is_enabled(struct bcma_device *core) - { - if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC)) -@@ -25,13 +44,15 @@ void bcma_core_disable(struct bcma_devic - if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET) - return; - -- bcma_awrite32(core, BCMA_IOCTL, flags); -- bcma_aread32(core, BCMA_IOCTL); -- udelay(10); -+ bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300); - - bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET); - bcma_aread32(core, BCMA_RESET_CTL); - udelay(1); -+ -+ bcma_awrite32(core, BCMA_IOCTL, flags); -+ bcma_aread32(core, BCMA_IOCTL); -+ udelay(10); - } - EXPORT_SYMBOL_GPL(bcma_core_disable); - -@@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device - bcma_aread32(core, BCMA_IOCTL); - - bcma_awrite32(core, BCMA_RESET_CTL, 0); -+ bcma_aread32(core, BCMA_RESET_CTL); - udelay(1); - - bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags)); ---- a/drivers/bcma/driver_chipcommon.c -+++ b/drivers/bcma/driver_chipcommon.c -@@ -140,8 +140,15 @@ void bcma_core_chipcommon_init(struct bc - bcma_core_chipcommon_early_init(cc); - - if (cc->core->id.rev >= 20) { -- bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0); -- bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0); -+ u32 pullup = 0, pulldown = 0; -+ -+ if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) { -+ pullup = 0x402e0; -+ pulldown = 0x20500; -+ } -+ -+ bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup); -+ bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown); - } - - if (cc->capabilities & BCMA_CC_CAP_PMU) -@@ -332,7 +339,7 @@ void bcma_chipco_serial_init(struct bcma - return; - } - -- irq = bcma_core_irq(cc->core); -+ irq = bcma_core_irq(cc->core, 0); - - /* Determine the registers of the UARTs */ - cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART); ---- a/drivers/bcma/driver_chipcommon_pmu.c -+++ b/drivers/bcma/driver_chipcommon_pmu.c -@@ -56,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b - } - EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset); - -+static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc) -+{ -+ u32 ilp_ctl, alp_hz; -+ -+ if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) & -+ BCMA_CC_PMU_STAT_EXT_LPO_AVAIL)) -+ return 0; -+ -+ bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, -+ BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT)); -+ usleep_range(1000, 2000); -+ -+ ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ); -+ ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK; -+ -+ bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0); -+ -+ alp_hz = ilp_ctl * 32768 / 4; -+ return (alp_hz + 50000) / 100000 * 100; -+} -+ -+static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq) -+{ -+ struct bcma_bus *bus = cc->core->bus; -+ u32 freq_tgt_target = 0, freq_tgt_current; -+ u32 pll0, mask; -+ -+ switch (bus->chipinfo.id) { -+ case BCMA_CHIP_ID_BCM43142: -+ /* pmu2_xtaltab0_adfll_485 */ -+ switch (xtalfreq) { -+ case 12000: -+ freq_tgt_target = 0x50D52; -+ break; -+ case 20000: -+ freq_tgt_target = 0x307FE; -+ break; -+ case 26000: -+ freq_tgt_target = 0x254EA; -+ break; -+ case 37400: -+ freq_tgt_target = 0x19EF8; -+ break; -+ case 52000: -+ freq_tgt_target = 0x12A75; -+ break; -+ } -+ break; -+ } -+ -+ if (!freq_tgt_target) { -+ bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n", -+ xtalfreq); -+ return; -+ } -+ -+ pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0); -+ freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >> -+ BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT; -+ -+ if (freq_tgt_current == freq_tgt_target) { -+ bcma_debug(bus, "Target TGT frequency already set\n"); -+ return; -+ } -+ -+ /* Turn off PLL */ -+ switch (bus->chipinfo.id) { -+ case BCMA_CHIP_ID_BCM43142: -+ mask = (u32)~(BCMA_RES_4314_HT_AVAIL | -+ BCMA_RES_4314_MACPHY_CLK_AVAIL); -+ -+ bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask); -+ bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask); -+ bcma_wait_value(cc->core, BCMA_CLKCTLST, -+ BCMA_CLKCTLST_HAVEHT, 0, 20000); -+ break; -+ } -+ -+ pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK; -+ pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT; -+ bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0); -+ -+ /* Flush */ -+ if (cc->pmu.rev >= 2) -+ bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD); -+ -+ /* TODO: Do we need to update OTP? */ -+} -+ -+static void bcma_pmu_pll_init(struct bcma_drv_cc *cc) -+{ -+ struct bcma_bus *bus = cc->core->bus; -+ u32 xtalfreq = bcma_pmu_xtalfreq(cc); -+ -+ switch (bus->chipinfo.id) { -+ case BCMA_CHIP_ID_BCM43142: -+ if (xtalfreq == 0) -+ xtalfreq = 20000; -+ bcma_pmu2_pll_init0(cc, xtalfreq); -+ break; -+ } -+} -+ - static void bcma_pmu_resources_init(struct bcma_drv_cc *cc) - { - struct bcma_bus *bus = cc->core->bus; -@@ -66,6 +169,25 @@ static void bcma_pmu_resources_init(stru - min_msk = 0x200D; - max_msk = 0xFFFF; - break; -+ case BCMA_CHIP_ID_BCM43142: -+ min_msk = BCMA_RES_4314_LPLDO_PU | -+ BCMA_RES_4314_PMU_SLEEP_DIS | -+ BCMA_RES_4314_PMU_BG_PU | -+ BCMA_RES_4314_CBUCK_LPOM_PU | -+ BCMA_RES_4314_CBUCK_PFM_PU | -+ BCMA_RES_4314_CLDO_PU | -+ BCMA_RES_4314_LPLDO2_LVM | -+ BCMA_RES_4314_WL_PMU_PU | -+ BCMA_RES_4314_LDO3P3_PU | -+ BCMA_RES_4314_OTP_PU | -+ BCMA_RES_4314_WL_PWRSW_PU | -+ BCMA_RES_4314_LQ_AVAIL | -+ BCMA_RES_4314_LOGIC_RET | -+ BCMA_RES_4314_MEM_SLEEP | -+ BCMA_RES_4314_MACPHY_RET | -+ BCMA_RES_4314_WL_CORE_READY; -+ max_msk = 0x3FFFFFFF; -+ break; - default: - bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n", - bus->chipinfo.id); -@@ -165,6 +287,7 @@ void bcma_pmu_init(struct bcma_drv_cc *c - bcma_cc_set32(cc, BCMA_CC_PMU_CTL, - BCMA_CC_PMU_CTL_NOILPONW); - -+ bcma_pmu_pll_init(cc); - bcma_pmu_resources_init(cc); - bcma_pmu_workarounds(cc); - } -@@ -480,6 +603,8 @@ void bcma_pmu_spuravoid_pllupdate(struct - tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW; - break; - -+ case BCMA_CHIP_ID_BCM43131: -+ case BCMA_CHIP_ID_BCM43217: - case BCMA_CHIP_ID_BCM43227: - case BCMA_CHIP_ID_BCM43228: - case BCMA_CHIP_ID_BCM43428: ---- a/drivers/bcma/driver_chipcommon_sflash.c -+++ b/drivers/bcma/driver_chipcommon_sflash.c -@@ -30,7 +30,7 @@ struct bcma_sflash_tbl_e { - u16 numblocks; - }; - --static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = { -+static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = { - { "M25P20", 0x11, 0x10000, 4, }, - { "M25P40", 0x12, 0x10000, 8, }, - -@@ -38,10 +38,10 @@ static struct bcma_sflash_tbl_e bcma_sfl - { "M25P32", 0x15, 0x10000, 64, }, - { "M25P64", 0x16, 0x10000, 128, }, - { "M25FL128", 0x17, 0x10000, 256, }, -- { 0 }, -+ { NULL }, - }; - --static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = { -+static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = { - { "SST25WF512", 1, 0x1000, 16, }, - { "SST25VF512", 0x48, 0x1000, 16, }, - { "SST25WF010", 2, 0x1000, 32, }, -@@ -56,10 +56,10 @@ static struct bcma_sflash_tbl_e bcma_sfl - { "SST25VF016", 0x41, 0x1000, 512, }, - { "SST25VF032", 0x4a, 0x1000, 1024, }, - { "SST25VF064", 0x4b, 0x1000, 2048, }, -- { 0 }, -+ { NULL }, - }; - --static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = { -+static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = { - { "AT45DB011", 0xc, 256, 512, }, - { "AT45DB021", 0x14, 256, 1024, }, - { "AT45DB041", 0x1c, 256, 2048, }, -@@ -67,7 +67,7 @@ static struct bcma_sflash_tbl_e bcma_sfl - { "AT45DB161", 0x2c, 512, 4096, }, - { "AT45DB321", 0x34, 512, 8192, }, - { "AT45DB642", 0x3c, 1024, 8192, }, -- { 0 }, -+ { NULL }, - }; - - static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode) -@@ -89,7 +89,7 @@ int bcma_sflash_init(struct bcma_drv_cc - { - struct bcma_bus *bus = cc->core->bus; - struct bcma_sflash *sflash = &cc->sflash; -- struct bcma_sflash_tbl_e *e; -+ const struct bcma_sflash_tbl_e *e; - u32 id, id2; - - switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { ---- a/drivers/bcma/driver_gpio.c -+++ b/drivers/bcma/driver_gpio.c -@@ -9,6 +9,9 @@ - */ - - #include <linux/gpio.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/irqdomain.h> - #include <linux/export.h> - #include <linux/bcma/bcma.h> - -@@ -73,19 +76,136 @@ static void bcma_gpio_free(struct gpio_c - bcma_chipco_gpio_pullup(cc, 1 << gpio, 0); - } - -+#if IS_BUILTIN(CONFIG_BCM47XX) - static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) - { - struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip); - - if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC) -- return bcma_core_irq(cc->core); -+ return irq_find_mapping(cc->irq_domain, gpio); - else - return -EINVAL; - } - -+static void bcma_gpio_irq_unmask(struct irq_data *d) -+{ -+ struct bcma_drv_cc *cc = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); -+ u32 val = bcma_chipco_gpio_in(cc, BIT(gpio)); -+ -+ bcma_chipco_gpio_polarity(cc, BIT(gpio), val); -+ bcma_chipco_gpio_intmask(cc, BIT(gpio), BIT(gpio)); -+} -+ -+static void bcma_gpio_irq_mask(struct irq_data *d) -+{ -+ struct bcma_drv_cc *cc = irq_data_get_irq_chip_data(d); -+ int gpio = irqd_to_hwirq(d); -+ -+ bcma_chipco_gpio_intmask(cc, BIT(gpio), 0); -+} -+ -+static struct irq_chip bcma_gpio_irq_chip = { -+ .name = "BCMA-GPIO", -+ .irq_mask = bcma_gpio_irq_mask, -+ .irq_unmask = bcma_gpio_irq_unmask, -+}; -+ -+static irqreturn_t bcma_gpio_irq_handler(int irq, void *dev_id) -+{ -+ struct bcma_drv_cc *cc = dev_id; -+ u32 val = bcma_cc_read32(cc, BCMA_CC_GPIOIN); -+ u32 mask = bcma_cc_read32(cc, BCMA_CC_GPIOIRQ); -+ u32 pol = bcma_cc_read32(cc, BCMA_CC_GPIOPOL); -+ unsigned long irqs = (val ^ pol) & mask; -+ int gpio; -+ -+ if (!irqs) -+ return IRQ_NONE; -+ -+ for_each_set_bit(gpio, &irqs, cc->gpio.ngpio) -+ generic_handle_irq(bcma_gpio_to_irq(&cc->gpio, gpio)); -+ bcma_chipco_gpio_polarity(cc, irqs, val & irqs); -+ -+ return IRQ_HANDLED; -+} -+ -+static int bcma_gpio_irq_domain_init(struct bcma_drv_cc *cc) -+{ -+ struct gpio_chip *chip = &cc->gpio; -+ int gpio, hwirq, err; -+ -+ if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC) -+ return 0; -+ -+ cc->irq_domain = irq_domain_add_linear(NULL, chip->ngpio, -+ &irq_domain_simple_ops, cc); -+ if (!cc->irq_domain) { -+ err = -ENODEV; -+ goto err_irq_domain; -+ } -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_create_mapping(cc->irq_domain, gpio); -+ -+ irq_set_chip_data(irq, cc); -+ irq_set_chip_and_handler(irq, &bcma_gpio_irq_chip, -+ handle_simple_irq); -+ } -+ -+ hwirq = bcma_core_irq(cc->core, 0); -+ err = request_irq(hwirq, bcma_gpio_irq_handler, IRQF_SHARED, "gpio", -+ cc); -+ if (err) -+ goto err_req_irq; -+ -+ bcma_chipco_gpio_intmask(cc, ~0, 0); -+ bcma_cc_set32(cc, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO); -+ -+ return 0; -+ -+err_req_irq: -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(cc->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(cc->irq_domain); -+err_irq_domain: -+ return err; -+} -+ -+static void bcma_gpio_irq_domain_exit(struct bcma_drv_cc *cc) -+{ -+ struct gpio_chip *chip = &cc->gpio; -+ int gpio; -+ -+ if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC) -+ return; -+ -+ bcma_cc_mask32(cc, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO); -+ free_irq(bcma_core_irq(cc->core, 0), cc); -+ for (gpio = 0; gpio < chip->ngpio; gpio++) { -+ int irq = irq_find_mapping(cc->irq_domain, gpio); -+ -+ irq_dispose_mapping(irq); -+ } -+ irq_domain_remove(cc->irq_domain); -+} -+#else -+static int bcma_gpio_irq_domain_init(struct bcma_drv_cc *cc) -+{ -+ return 0; -+} -+ -+static void bcma_gpio_irq_domain_exit(struct bcma_drv_cc *cc) -+{ -+} -+#endif -+ - int bcma_gpio_init(struct bcma_drv_cc *cc) - { - struct gpio_chip *chip = &cc->gpio; -+ int err; - - chip->label = "bcma_gpio"; - chip->owner = THIS_MODULE; -@@ -95,8 +215,22 @@ int bcma_gpio_init(struct bcma_drv_cc *c - chip->set = bcma_gpio_set_value; - chip->direction_input = bcma_gpio_direction_input; - chip->direction_output = bcma_gpio_direction_output; -+#if IS_BUILTIN(CONFIG_BCM47XX) - chip->to_irq = bcma_gpio_to_irq; -- chip->ngpio = 16; -+#endif -+#if IS_BUILTIN(CONFIG_OF) -+ if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC) -+ chip->of_node = cc->core->dev.of_node; -+#endif -+ switch (cc->core->bus->chipinfo.id) { -+ case BCMA_CHIP_ID_BCM5357: -+ case BCMA_CHIP_ID_BCM53572: -+ chip->ngpio = 32; -+ break; -+ default: -+ chip->ngpio = 16; -+ } -+ - /* There is just one SoC in one device and its GPIO addresses should be - * deterministic to address them more easily. The other buses could get - * a random base number. */ -@@ -105,10 +239,22 @@ int bcma_gpio_init(struct bcma_drv_cc *c - else - chip->base = -1; - -- return gpiochip_add(chip); -+ err = bcma_gpio_irq_domain_init(cc); -+ if (err) -+ return err; -+ -+ err = gpiochip_add(chip); -+ if (err) { -+ bcma_gpio_irq_domain_exit(cc); -+ return err; -+ } -+ -+ return 0; - } - - int bcma_gpio_unregister(struct bcma_drv_cc *cc) - { -- return gpiochip_remove(&cc->gpio); -+ bcma_gpio_irq_domain_exit(cc); -+ gpiochip_remove(&cc->gpio); -+ return 0; - } ---- a/drivers/bcma/driver_pci.c -+++ b/drivers/bcma/driver_pci.c -@@ -31,7 +31,7 @@ static void bcma_pcie_write(struct bcma_ - pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data); - } - --static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy) -+static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy) - { - u32 v; - int i; -@@ -55,7 +55,7 @@ static void bcma_pcie_mdio_set_phy(struc - } - } - --static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address) -+static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address) - { - int max_retries = 10; - u16 ret = 0; -@@ -98,7 +98,7 @@ static u16 bcma_pcie_mdio_read(struct bc - return ret; - } - --static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, -+static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device, - u8 address, u16 data) - { - int max_retries = 10; -@@ -137,6 +137,13 @@ static void bcma_pcie_mdio_write(struct - pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0); - } - -+static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device, -+ u8 address, u16 data) -+{ -+ bcma_pcie_mdio_write(pc, device, address, data); -+ return bcma_pcie_mdio_read(pc, device, address); -+} -+ - /************************************************** - * Workarounds. - **************************************************/ -@@ -229,6 +236,32 @@ void bcma_core_pci_init(struct bcma_drv_ - bcma_core_pci_clientmode_init(pc); - } - -+void bcma_core_pci_power_save(struct bcma_bus *bus, bool up) -+{ -+ struct bcma_drv_pci *pc; -+ u16 data; -+ -+ if (bus->hosttype != BCMA_HOSTTYPE_PCI) -+ return; -+ -+ pc = &bus->drv_pci[0]; -+ -+ if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) { -+ data = up ? 0x74 : 0x7C; -+ bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, -+ BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64); -+ bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, -+ BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data); -+ } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) { -+ data = up ? 0x75 : 0x7D; -+ bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, -+ BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65); -+ bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1, -+ BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data); -+ } -+} -+EXPORT_SYMBOL_GPL(bcma_core_pci_power_save); -+ - int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, - bool enable) - { -@@ -262,7 +295,7 @@ out: - } - EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl); - --void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend) -+static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend) - { - u32 w; - -@@ -274,4 +307,29 @@ void bcma_core_pci_extend_L1timer(struct - bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w); - bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG); - } --EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer); -+ -+void bcma_core_pci_up(struct bcma_bus *bus) -+{ -+ struct bcma_drv_pci *pc; -+ -+ if (bus->hosttype != BCMA_HOSTTYPE_PCI) -+ return; -+ -+ pc = &bus->drv_pci[0]; -+ -+ bcma_core_pci_extend_L1timer(pc, true); -+} -+EXPORT_SYMBOL_GPL(bcma_core_pci_up); -+ -+void bcma_core_pci_down(struct bcma_bus *bus) -+{ -+ struct bcma_drv_pci *pc; -+ -+ if (bus->hosttype != BCMA_HOSTTYPE_PCI) -+ return; -+ -+ pc = &bus->drv_pci[0]; -+ -+ bcma_core_pci_extend_L1timer(pc, false); -+} -+EXPORT_SYMBOL_GPL(bcma_core_pci_down); ---- a/drivers/bcma/driver_pci_host.c -+++ b/drivers/bcma/driver_pci_host.c -@@ -581,6 +581,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI - int bcma_core_pci_plat_dev_init(struct pci_dev *dev) - { - struct bcma_drv_pci_host *pc_host; -+ int readrq; - - if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { - /* This is not a device on the PCI-core bridge. */ -@@ -592,9 +593,14 @@ int bcma_core_pci_plat_dev_init(struct p - pr_info("PCI: Fixing up device %s\n", pci_name(dev)); - - /* Fix up interrupt lines */ -- dev->irq = bcma_core_irq(pc_host->pdev->core); -+ dev->irq = bcma_core_irq(pc_host->pdev->core, 0); - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - -+ readrq = pcie_get_readrq(dev); -+ if (readrq > 128) { -+ pr_info("change PCIe max read request size from %i to 128\n", readrq); -+ pcie_set_readrq(dev, 128); -+ } - return 0; - } - EXPORT_SYMBOL(bcma_core_pci_plat_dev_init); -@@ -611,6 +617,6 @@ int bcma_core_pci_pcibios_map_irq(const - - pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, - pci_ops); -- return bcma_core_irq(pc_host->pdev->core); -+ return bcma_core_irq(pc_host->pdev->core, 0); - } - EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq); ---- /dev/null -+++ b/drivers/bcma/driver_pcie2.c -@@ -0,0 +1,175 @@ -+/* -+ * Broadcom specific AMBA -+ * PCIe Gen 2 Core -+ * -+ * Copyright 2014, Broadcom Corporation -+ * Copyright 2014, RafaÅ‚ MiÅ‚ecki <zajec5@gmail.com> -+ * -+ * Licensed under the GNU/GPL. See COPYING for details. -+ */ -+ -+#include "bcma_private.h" -+#include <linux/bcma/bcma.h> -+ -+/************************************************** -+ * R/W ops. -+ **************************************************/ -+ -+#if 0 -+static u32 bcma_core_pcie2_cfg_read(struct bcma_drv_pcie2 *pcie2, u32 addr) -+{ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr); -+ pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR); -+ return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA); -+} -+#endif -+ -+static void bcma_core_pcie2_cfg_write(struct bcma_drv_pcie2 *pcie2, u32 addr, -+ u32 val) -+{ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, val); -+} -+ -+/************************************************** -+ * Init. -+ **************************************************/ -+ -+static u32 bcma_core_pcie2_war_delay_perst_enab(struct bcma_drv_pcie2 *pcie2, -+ bool enable) -+{ -+ u32 val; -+ -+ /* restore back to default */ -+ val = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL); -+ val |= PCIE2_CLKC_DLYPERST; -+ val &= ~PCIE2_CLKC_DISSPROMLD; -+ if (enable) { -+ val &= ~PCIE2_CLKC_DLYPERST; -+ val |= PCIE2_CLKC_DISSPROMLD; -+ } -+ pcie2_write32(pcie2, (BCMA_CORE_PCIE2_CLK_CONTROL), val); -+ /* flush */ -+ return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL); -+} -+ -+static void bcma_core_pcie2_set_ltr_vals(struct bcma_drv_pcie2 *pcie2) -+{ -+ /* LTR0 */ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x844); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x883c883c); -+ /* LTR1 */ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x848); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x88648864); -+ /* LTR2 */ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x84C); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x90039003); -+} -+ -+static void bcma_core_pcie2_hw_ltr_war(struct bcma_drv_pcie2 *pcie2) -+{ -+ u8 core_rev = pcie2->core->id.rev; -+ u32 devstsctr2; -+ -+ if (core_rev < 2 || core_rev == 10 || core_rev > 13) -+ return; -+ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, -+ PCIE2_CAP_DEVSTSCTRL2_OFFSET); -+ devstsctr2 = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA); -+ if (devstsctr2 & PCIE2_CAP_DEVSTSCTRL2_LTRENAB) { -+ /* force the right LTR values */ -+ bcma_core_pcie2_set_ltr_vals(pcie2); -+ -+ /* TODO: -+ si_core_wrapperreg(pcie2, 3, 0x60, 0x8080, 0); */ -+ -+ /* enable the LTR */ -+ devstsctr2 |= PCIE2_CAP_DEVSTSCTRL2_LTRENAB; -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, -+ PCIE2_CAP_DEVSTSCTRL2_OFFSET); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, devstsctr2); -+ -+ /* set the LTR state to be active */ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE, -+ PCIE2_LTR_ACTIVE); -+ usleep_range(1000, 2000); -+ -+ /* set the LTR state to be sleep */ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE, -+ PCIE2_LTR_SLEEP); -+ usleep_range(1000, 2000); -+ } -+} -+ -+static void pciedev_crwlpciegen2(struct bcma_drv_pcie2 *pcie2) -+{ -+ u8 core_rev = pcie2->core->id.rev; -+ bool pciewar160, pciewar162; -+ -+ pciewar160 = core_rev == 7 || core_rev == 9 || core_rev == 11; -+ pciewar162 = core_rev == 5 || core_rev == 7 || core_rev == 8 || -+ core_rev == 9 || core_rev == 11; -+ -+ if (!pciewar160 && !pciewar162) -+ return; -+ -+/* TODO */ -+#if 0 -+ pcie2_set32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL, -+ PCIE_DISABLE_L1CLK_GATING); -+#if 0 -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, -+ PCIEGEN2_COE_PVT_TL_CTRL_0); -+ pcie2_mask32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, -+ ~(1 << COE_PVT_TL_CTRL_0_PM_DIS_L1_REENTRY_BIT)); -+#endif -+#endif -+} -+ -+static void pciedev_crwlpciegen2_180(struct bcma_drv_pcie2 *pcie2) -+{ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_PMCR_REFUP); -+ pcie2_set32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x1f); -+} -+ -+static void pciedev_crwlpciegen2_182(struct bcma_drv_pcie2 *pcie2) -+{ -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_SBMBX); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 1 << 0); -+} -+ -+static void pciedev_reg_pm_clk_period(struct bcma_drv_pcie2 *pcie2) -+{ -+ struct bcma_drv_cc *drv_cc = &pcie2->core->bus->drv_cc; -+ u8 core_rev = pcie2->core->id.rev; -+ u32 alp_khz, pm_value; -+ -+ if (core_rev <= 13) { -+ alp_khz = bcma_pmu_get_alp_clock(drv_cc) / 1000; -+ pm_value = (1000000 * 2) / alp_khz; -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, -+ PCIE2_PVT_REG_PM_CLK_PERIOD); -+ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, pm_value); -+ } -+} -+ -+void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2) -+{ -+ struct bcma_chipinfo *ci = &pcie2->core->bus->chipinfo; -+ u32 tmp; -+ -+ tmp = pcie2_read32(pcie2, BCMA_CORE_PCIE2_SPROM(54)); -+ if ((tmp & 0xe) >> 1 == 2) -+ bcma_core_pcie2_cfg_write(pcie2, 0x4e0, 0x17); -+ -+ /* TODO: Do we need pcie_reqsize? */ -+ -+ if (ci->id == BCMA_CHIP_ID_BCM4360 && ci->rev > 3) -+ bcma_core_pcie2_war_delay_perst_enab(pcie2, true); -+ bcma_core_pcie2_hw_ltr_war(pcie2); -+ pciedev_crwlpciegen2(pcie2); -+ pciedev_reg_pm_clk_period(pcie2); -+ pciedev_crwlpciegen2_180(pcie2); -+ pciedev_crwlpciegen2_182(pcie2); -+} ---- a/drivers/bcma/host_pci.c -+++ b/drivers/bcma/host_pci.c -@@ -188,8 +188,11 @@ static int bcma_host_pci_probe(struct pc - pci_write_config_dword(dev, 0x40, val & 0xffff00ff); - - /* SSB needed additional powering up, do we have any AMBA PCI cards? */ -- if (!pci_is_pcie(dev)) -- bcma_err(bus, "PCI card detected, report problems.\n"); -+ if (!pci_is_pcie(dev)) { -+ bcma_err(bus, "PCI card detected, they are not supported.\n"); -+ err = -ENXIO; -+ goto err_pci_release_regions; -+ } - - /* Map MMIO */ - err = -ENOMEM; -@@ -205,6 +208,9 @@ static int bcma_host_pci_probe(struct pc - bus->boardinfo.vendor = bus->host_pci->subsystem_vendor; - bus->boardinfo.type = bus->host_pci->subsystem_device; - -+ /* Initialize struct, detect chip */ -+ bcma_init_bus(bus); -+ - /* Register */ - err = bcma_bus_register(bus); - if (err) -@@ -235,7 +241,6 @@ static void bcma_host_pci_remove(struct - pci_release_regions(dev); - pci_disable_device(dev); - kfree(bus); -- pci_set_drvdata(dev, NULL); - } - - #ifdef CONFIG_PM_SLEEP -@@ -267,15 +272,21 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc - - #endif /* CONFIG_PM_SLEEP */ - --static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = { -+static const struct pci_device_id bcma_pci_bridge_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, -- { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, /* 0xa8d8 */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xa8db, BCM43217 (sic!) */ -+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) }, /* 0xa8dc */ - { 0, }, - }; - MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl); ---- a/drivers/bcma/main.c -+++ b/drivers/bcma/main.c -@@ -10,6 +10,8 @@ - #include <linux/platform_device.h> - #include <linux/bcma/bcma.h> - #include <linux/slab.h> -+#include <linux/of_address.h> -+#include <linux/of_irq.h> - - MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); - MODULE_LICENSE("GPL"); -@@ -69,28 +71,36 @@ static u16 bcma_cc_core_id(struct bcma_b - return BCMA_CORE_CHIPCOMMON; - } - --struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid) -+struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid, -+ u8 unit) - { - struct bcma_device *core; - - list_for_each_entry(core, &bus->cores, list) { -- if (core->id.id == coreid) -+ if (core->id.id == coreid && core->core_unit == unit) - return core; - } - return NULL; - } --EXPORT_SYMBOL_GPL(bcma_find_core); -+EXPORT_SYMBOL_GPL(bcma_find_core_unit); - --struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid, -- u8 unit) -+bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value, -+ int timeout) - { -- struct bcma_device *core; -+ unsigned long deadline = jiffies + timeout; -+ u32 val; - -- list_for_each_entry(core, &bus->cores, list) { -- if (core->id.id == coreid && core->core_unit == unit) -- return core; -- } -- return NULL; -+ do { -+ val = bcma_read32(core, reg); -+ if ((val & mask) == value) -+ return true; -+ cpu_relax(); -+ udelay(10); -+ } while (!time_after_eq(jiffies, deadline)); -+ -+ bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg); -+ -+ return false; - } - - static void bcma_release_core_dev(struct device *dev) -@@ -103,55 +113,195 @@ static void bcma_release_core_dev(struct - kfree(core); - } - --static int bcma_register_cores(struct bcma_bus *bus) -+static bool bcma_is_core_needed_early(u16 core_id) -+{ -+ switch (core_id) { -+ case BCMA_CORE_NS_NAND: -+ case BCMA_CORE_NS_QSPI: -+ return true; -+ } -+ -+ return false; -+} -+ -+#if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS) -+static struct device_node *bcma_of_find_child_device(struct platform_device *parent, -+ struct bcma_device *core) -+{ -+ struct device_node *node; -+ u64 size; -+ const __be32 *reg; -+ -+ if (!parent || !parent->dev.of_node) -+ return NULL; -+ -+ for_each_child_of_node(parent->dev.of_node, node) { -+ reg = of_get_address(node, 0, &size, NULL); -+ if (!reg) -+ continue; -+ if (of_translate_address(node, reg) == core->addr) -+ return node; -+ } -+ return NULL; -+} -+ -+static int bcma_of_irq_parse(struct platform_device *parent, -+ struct bcma_device *core, -+ struct of_phandle_args *out_irq, int num) -+{ -+ __be32 laddr[1]; -+ int rc; -+ -+ if (core->dev.of_node) { -+ rc = of_irq_parse_one(core->dev.of_node, num, out_irq); -+ if (!rc) -+ return rc; -+ } -+ -+ out_irq->np = parent->dev.of_node; -+ out_irq->args_count = 1; -+ out_irq->args[0] = num; -+ -+ laddr[0] = cpu_to_be32(core->addr); -+ return of_irq_parse_raw(laddr, out_irq); -+} -+ -+static unsigned int bcma_of_get_irq(struct platform_device *parent, -+ struct bcma_device *core, int num) -+{ -+ struct of_phandle_args out_irq; -+ int ret; -+ -+ if (!parent || !parent->dev.of_node) -+ return 0; -+ -+ ret = bcma_of_irq_parse(parent, core, &out_irq, num); -+ if (ret) { -+ bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n", -+ ret); -+ return 0; -+ } -+ -+ return irq_create_of_mapping(&out_irq); -+} -+ -+static void bcma_of_fill_device(struct platform_device *parent, -+ struct bcma_device *core) -+{ -+ struct device_node *node; -+ -+ node = bcma_of_find_child_device(parent, core); -+ if (node) -+ core->dev.of_node = node; -+ -+ core->irq = bcma_of_get_irq(parent, core, 0); -+} -+#else -+static void bcma_of_fill_device(struct platform_device *parent, -+ struct bcma_device *core) -+{ -+} -+static inline unsigned int bcma_of_get_irq(struct platform_device *parent, -+ struct bcma_device *core, int num) -+{ -+ return 0; -+} -+#endif /* CONFIG_OF */ -+ -+unsigned int bcma_core_irq(struct bcma_device *core, int num) -+{ -+ struct bcma_bus *bus = core->bus; -+ unsigned int mips_irq; -+ -+ switch (bus->hosttype) { -+ case BCMA_HOSTTYPE_PCI: -+ return bus->host_pci->irq; -+ case BCMA_HOSTTYPE_SOC: -+ if (bus->drv_mips.core && num == 0) { -+ mips_irq = bcma_core_mips_irq(core); -+ return mips_irq <= 4 ? mips_irq + 2 : 0; -+ } -+ if (bus->host_pdev) -+ return bcma_of_get_irq(bus->host_pdev, core, num); -+ return 0; -+ case BCMA_HOSTTYPE_SDIO: -+ return 0; -+ } -+ -+ return 0; -+} -+EXPORT_SYMBOL(bcma_core_irq); -+ -+void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) -+{ -+ core->dev.release = bcma_release_core_dev; -+ core->dev.bus = &bcma_bus_type; -+ dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); -+ -+ switch (bus->hosttype) { -+ case BCMA_HOSTTYPE_PCI: -+ core->dev.parent = &bus->host_pci->dev; -+ core->dma_dev = &bus->host_pci->dev; -+ core->irq = bus->host_pci->irq; -+ break; -+ case BCMA_HOSTTYPE_SOC: -+ core->dev.dma_mask = &core->dev.coherent_dma_mask; -+ if (bus->host_pdev) { -+ core->dma_dev = &bus->host_pdev->dev; -+ core->dev.parent = &bus->host_pdev->dev; -+ bcma_of_fill_device(bus->host_pdev, core); -+ } else { -+ core->dma_dev = &core->dev; -+ } -+ break; -+ case BCMA_HOSTTYPE_SDIO: -+ break; -+ } -+} -+ -+static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core) -+{ -+ int err; -+ -+ err = device_register(&core->dev); -+ if (err) { -+ bcma_err(bus, "Could not register dev for core 0x%03X\n", -+ core->id.id); -+ put_device(&core->dev); -+ return; -+ } -+ core->dev_registered = true; -+} -+ -+static int bcma_register_devices(struct bcma_bus *bus) - { - struct bcma_device *core; -- int err, dev_id = 0; -+ int err; - - list_for_each_entry(core, &bus->cores, list) { - /* We support that cores ourself */ - switch (core->id.id) { - case BCMA_CORE_4706_CHIPCOMMON: - case BCMA_CORE_CHIPCOMMON: -+ case BCMA_CORE_NS_CHIPCOMMON_B: - case BCMA_CORE_PCI: - case BCMA_CORE_PCIE: -+ case BCMA_CORE_PCIE2: - case BCMA_CORE_MIPS_74K: - case BCMA_CORE_4706_MAC_GBIT_COMMON: - continue; - } - -+ /* Early cores were already registered */ -+ if (bcma_is_core_needed_early(core->id.id)) -+ continue; -+ - /* Only first GMAC core on BCM4706 is connected and working */ - if (core->id.id == BCMA_CORE_4706_MAC_GBIT && - core->core_unit > 0) - continue; - -- core->dev.release = bcma_release_core_dev; -- core->dev.bus = &bcma_bus_type; -- dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id); -- -- switch (bus->hosttype) { -- case BCMA_HOSTTYPE_PCI: -- core->dev.parent = &bus->host_pci->dev; -- core->dma_dev = &bus->host_pci->dev; -- core->irq = bus->host_pci->irq; -- break; -- case BCMA_HOSTTYPE_SOC: -- core->dev.dma_mask = &core->dev.coherent_dma_mask; -- core->dma_dev = &core->dev; -- break; -- case BCMA_HOSTTYPE_SDIO: -- break; -- } -- -- err = device_register(&core->dev); -- if (err) { -- bcma_err(bus, -- "Could not register dev for core 0x%03X\n", -- core->id.id); -- continue; -- } -- core->dev_registered = true; -- dev_id++; -+ bcma_register_core(bus, core); - } - - #ifdef CONFIG_BCMA_DRIVER_MIPS -@@ -218,7 +368,7 @@ int bcma_bus_register(struct bcma_bus *b - err = bcma_bus_scan(bus); - if (err) { - bcma_err(bus, "Failed to scan: %d\n", err); -- return -1; -+ return err; - } - - /* Early init CC core */ -@@ -228,6 +378,12 @@ int bcma_bus_register(struct bcma_bus *b - bcma_core_chipcommon_early_init(&bus->drv_cc); - } - -+ /* Cores providing flash access go before SPROM init */ -+ list_for_each_entry(core, &bus->cores, list) { -+ if (bcma_is_core_needed_early(core->id.id)) -+ bcma_register_core(bus, core); -+ } -+ - /* Try to get SPROM */ - err = bcma_sprom_get(bus); - if (err == -ENOENT) { -@@ -242,6 +398,13 @@ int bcma_bus_register(struct bcma_bus *b - bcma_core_chipcommon_init(&bus->drv_cc); - } - -+ /* Init CC core */ -+ core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B); -+ if (core) { -+ bus->drv_cc_b.core = core; -+ bcma_core_chipcommon_b_init(&bus->drv_cc_b); -+ } -+ - /* Init MIPS core */ - core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); - if (core) { -@@ -263,6 +426,13 @@ int bcma_bus_register(struct bcma_bus *b - bcma_core_pci_init(&bus->drv_pci[1]); - } - -+ /* Init PCIe Gen 2 core */ -+ core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0); -+ if (core) { -+ bus->drv_pcie2.core = core; -+ bcma_core_pcie2_init(&bus->drv_pcie2); -+ } -+ - /* Init GBIT MAC COMMON core */ - core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); - if (core) { -@@ -271,7 +441,7 @@ int bcma_bus_register(struct bcma_bus *b - } - - /* Register found cores */ -- bcma_register_cores(bus); -+ bcma_register_devices(bus); - - bcma_info(bus, "Bus registered\n"); - -@@ -289,6 +459,8 @@ void bcma_bus_unregister(struct bcma_bus - else if (err) - bcma_err(bus, "Can not unregister GPIO driver: %i\n", err); - -+ bcma_core_chipcommon_b_free(&bus->drv_cc_b); -+ - cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K); - cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE); - cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); -@@ -308,8 +480,6 @@ int __init bcma_bus_early_register(struc - struct bcma_device *core; - struct bcma_device_id match; - -- bcma_init_bus(bus); -- - match.manuf = BCMA_MANUF_BCM; - match.id = bcma_cc_core_id(bus); - match.class = BCMA_CL_SIM; -@@ -468,6 +638,11 @@ static int __init bcma_modinit(void) - if (err) - return err; - -+ err = bcma_host_soc_register_driver(); -+ if (err) { -+ pr_err("SoC host initialization failed\n"); -+ err = 0; -+ } - #ifdef CONFIG_BCMA_HOST_PCI - err = bcma_host_pci_init(); - if (err) { -@@ -485,6 +660,7 @@ static void __exit bcma_modexit(void) - #ifdef CONFIG_BCMA_HOST_PCI - bcma_host_pci_exit(); - #endif -+ bcma_host_soc_unregister_driver(); - bus_unregister(&bcma_bus_type); - } - module_exit(bcma_modexit) ---- a/drivers/bcma/scan.c -+++ b/drivers/bcma/scan.c -@@ -32,6 +32,18 @@ static const struct bcma_device_id_name - { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" }, - { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" }, - { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" }, -+ { BCMA_CORE_NS_PCIEG2, "PCIe Gen 2" }, -+ { BCMA_CORE_NS_DMA, "DMA" }, -+ { BCMA_CORE_NS_SDIO3, "SDIO3" }, -+ { BCMA_CORE_NS_USB20, "USB 2.0" }, -+ { BCMA_CORE_NS_USB30, "USB 3.0" }, -+ { BCMA_CORE_NS_A9JTAG, "ARM Cortex A9 JTAG" }, -+ { BCMA_CORE_NS_DDR23, "Denali DDR2/DDR3 memory controller" }, -+ { BCMA_CORE_NS_ROM, "ROM" }, -+ { BCMA_CORE_NS_NAND, "NAND flash controller" }, -+ { BCMA_CORE_NS_QSPI, "SPI flash controller" }, -+ { BCMA_CORE_NS_CHIPCOMMON_B, "Chipcommon B" }, -+ { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" }, - { BCMA_CORE_AMEMC, "AMEMC (DDR)" }, - { BCMA_CORE_ALTA, "ALTA (I2S)" }, - { BCMA_CORE_INVALID, "Invalid" }, -@@ -201,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct - return ent; - } - --static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, -+static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, - u32 type, u8 port) - { - u32 addrl, addrh, sizel, sizeh = 0; -@@ -213,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc - ((ent & SCAN_ADDR_TYPE) != type) || - (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) { - bcma_erom_push_ent(eromptr); -- return -EINVAL; -+ return (u32)-EINVAL; - } - - addrl = ent & SCAN_ADDR_ADDR; -@@ -257,12 +269,14 @@ static struct bcma_device *bcma_find_cor - return NULL; - } - -+#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO) -+ - static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, - struct bcma_device_id *match, int core_num, - struct bcma_device *core) - { -- s32 tmp; -- u8 i, j; -+ u32 tmp; -+ u8 i, j, k; - s32 cia, cib; - u8 ports[2], wrappers[2]; - -@@ -300,6 +314,7 @@ static int bcma_get_next_core(struct bcm - /* Some specific cores don't need wrappers */ - switch (core->id.id) { - case BCMA_CORE_4706_MAC_GBIT_COMMON: -+ case BCMA_CORE_NS_CHIPCOMMON_B: - /* Not used yet: case BCMA_CORE_OOB_ROUTER: */ - break; - default: -@@ -339,11 +354,11 @@ static int bcma_get_next_core(struct bcm - * the main register space for the core - */ - tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0); -- if (tmp <= 0) { -+ if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) { - /* Try again to see if it is a bridge */ - tmp = bcma_erom_get_addr_desc(bus, eromptr, - SCAN_ADDR_TYPE_BRIDGE, 0); -- if (tmp <= 0) { -+ if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) { - return -EILSEQ; - } else { - bcma_info(bus, "Bridge found\n"); -@@ -353,18 +368,19 @@ static int bcma_get_next_core(struct bcm - core->addr = tmp; - - /* get & parse slave ports */ -+ k = 0; - for (i = 0; i < ports[1]; i++) { - for (j = 0; ; j++) { - tmp = bcma_erom_get_addr_desc(bus, eromptr, - SCAN_ADDR_TYPE_SLAVE, i); -- if (tmp < 0) { -+ if (IS_ERR_VALUE_U32(tmp)) { - /* no more entries for port _i_ */ - /* pr_debug("erom: slave port %d " - * "has %d descriptors\n", i, j); */ - break; -- } else { -- if (i == 0 && j == 0) -- core->addr1 = tmp; -+ } else if (k < ARRAY_SIZE(core->addr_s)) { -+ core->addr_s[k] = tmp; -+ k++; - } - } - } -@@ -374,7 +390,7 @@ static int bcma_get_next_core(struct bcm - for (j = 0; ; j++) { - tmp = bcma_erom_get_addr_desc(bus, eromptr, - SCAN_ADDR_TYPE_MWRAP, i); -- if (tmp < 0) { -+ if (IS_ERR_VALUE_U32(tmp)) { - /* no more entries for port _i_ */ - /* pr_debug("erom: master wrapper %d " - * "has %d descriptors\n", i, j); */ -@@ -392,7 +408,7 @@ static int bcma_get_next_core(struct bcm - for (j = 0; ; j++) { - tmp = bcma_erom_get_addr_desc(bus, eromptr, - SCAN_ADDR_TYPE_SWRAP, i + hack); -- if (tmp < 0) { -+ if (IS_ERR_VALUE_U32(tmp)) { - /* no more entries for port _i_ */ - /* pr_debug("erom: master wrapper %d " - * has %d descriptors\n", i, j); */ -@@ -407,10 +423,13 @@ static int bcma_get_next_core(struct bcm - core->io_addr = ioremap_nocache(core->addr, BCMA_CORE_SIZE); - if (!core->io_addr) - return -ENOMEM; -- core->io_wrap = ioremap_nocache(core->wrap, BCMA_CORE_SIZE); -- if (!core->io_wrap) { -- iounmap(core->io_addr); -- return -ENOMEM; -+ if (core->wrap) { -+ core->io_wrap = ioremap_nocache(core->wrap, -+ BCMA_CORE_SIZE); -+ if (!core->io_wrap) { -+ iounmap(core->io_addr); -+ return -ENOMEM; -+ } - } - } - return 0; -@@ -420,9 +439,7 @@ void bcma_init_bus(struct bcma_bus *bus) - { - s32 tmp; - struct bcma_chipinfo *chipinfo = &(bus->chipinfo); -- -- if (bus->init_done) -- return; -+ char chip_id[8]; - - INIT_LIST_HEAD(&bus->cores); - bus->nr_cores = 0; -@@ -433,10 +450,11 @@ void bcma_init_bus(struct bcma_bus *bus) - chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT; - chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT; - chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT; -- bcma_info(bus, "Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n", -- chipinfo->id, chipinfo->rev, chipinfo->pkg); - -- bus->init_done = true; -+ snprintf(chip_id, ARRAY_SIZE(chip_id), -+ (chipinfo->id > 0x9999) ? "%d" : "0x%04X", chipinfo->id); -+ bcma_info(bus, "Found chip with id %s, rev 0x%02X and package 0x%02X\n", -+ chip_id, chipinfo->rev, chipinfo->pkg); - } - - int bcma_bus_scan(struct bcma_bus *bus) -@@ -446,8 +464,6 @@ int bcma_bus_scan(struct bcma_bus *bus) - - int err, core_num = 0; - -- bcma_init_bus(bus); -- - erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM); - if (bus->hosttype == BCMA_HOSTTYPE_SOC) { - eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE); -@@ -489,6 +505,7 @@ int bcma_bus_scan(struct bcma_bus *bus) - bus->nr_cores++; - other_core = bcma_find_core_reverse(bus, core->id.id); - core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1; -+ bcma_prepare_core(bus, core); - - bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n", - core->core_index, bcma_device_name(&core->id), ---- a/drivers/bcma/sprom.c -+++ b/drivers/bcma/sprom.c -@@ -72,12 +72,12 @@ fail: - * R/W ops. - **************************************************/ - --static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom) -+static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom, -+ size_t words) - { - int i; -- for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++) -- sprom[i] = bcma_read16(bus->drv_cc.core, -- offset + (i * 2)); -+ for (i = 0; i < words; i++) -+ sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2)); - } - - /************************************************** -@@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da - return t[crc ^ data]; - } - --static u8 bcma_sprom_crc(const u16 *sprom) -+static u8 bcma_sprom_crc(const u16 *sprom, size_t words) - { - int word; - u8 crc = 0xFF; - -- for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) { -+ for (word = 0; word < words - 1; word++) { - crc = bcma_crc8(crc, sprom[word] & 0x00FF); - crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8); - } -- crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF); -+ crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF); - crc ^= 0xFF; - - return crc; - } - --static int bcma_sprom_check_crc(const u16 *sprom) -+static int bcma_sprom_check_crc(const u16 *sprom, size_t words) - { - u8 crc; - u8 expected_crc; - u16 tmp; - -- crc = bcma_sprom_crc(sprom); -- tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC; -+ crc = bcma_sprom_crc(sprom, words); -+ tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC; - expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT; - if (crc != expected_crc) - return -EPROTO; -@@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1 - return 0; - } - --static int bcma_sprom_valid(const u16 *sprom) -+static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom, -+ size_t words) - { - u16 revision; - int err; - -- err = bcma_sprom_check_crc(sprom); -+ err = bcma_sprom_check_crc(sprom, words); - if (err) - return err; - -- revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV; -- if (revision != 8 && revision != 9) { -+ revision = sprom[words - 1] & SSB_SPROM_REVISION_REV; -+ if (revision != 8 && revision != 9 && revision != 10) { - pr_err("Unsupported SPROM revision: %d\n", revision); - return -ENOENT; - } - -+ bus->sprom.revision = revision; -+ bcma_debug(bus, "Found SPROM revision %d\n", revision); -+ - return 0; - } - -@@ -197,6 +201,23 @@ static int bcma_sprom_valid(const u16 *s - SPEX(_field[7], _offset + 14, _mask, _shift); \ - } while (0) - -+static s8 sprom_extract_antgain(const u16 *in, u16 offset, u16 mask, u16 shift) -+{ -+ u16 v; -+ u8 gain; -+ -+ v = in[SPOFF(offset)]; -+ gain = (v & mask) >> shift; -+ if (gain == 0xFF) { -+ gain = 8; /* If unset use 2dBm */ -+ } else { -+ /* Q5.2 Fractional part is stored in 0xC0 */ -+ gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2); -+ } -+ -+ return (s8)gain; -+} -+ - static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) - { - u16 v, o; -@@ -208,9 +229,6 @@ static void bcma_sprom_extract_r8(struct - BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) != - ARRAY_SIZE(bus->sprom.core_pwr_info)); - -- bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & -- SSB_SPROM_REVISION_REV; -- - for (i = 0; i < 3; i++) { - v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i]; - *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); -@@ -380,14 +398,22 @@ static void bcma_sprom_extract_r8(struct - SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0); - - /* Extract the antenna gain values. */ -- SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01, -- SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT); -- SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01, -- SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT); -- SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23, -- SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT); -- SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23, -- SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT); -+ bus->sprom.antenna_gain.a0 = sprom_extract_antgain(sprom, -+ SSB_SPROM8_AGAIN01, -+ SSB_SPROM8_AGAIN0, -+ SSB_SPROM8_AGAIN0_SHIFT); -+ bus->sprom.antenna_gain.a1 = sprom_extract_antgain(sprom, -+ SSB_SPROM8_AGAIN01, -+ SSB_SPROM8_AGAIN1, -+ SSB_SPROM8_AGAIN1_SHIFT); -+ bus->sprom.antenna_gain.a2 = sprom_extract_antgain(sprom, -+ SSB_SPROM8_AGAIN23, -+ SSB_SPROM8_AGAIN2, -+ SSB_SPROM8_AGAIN2_SHIFT); -+ bus->sprom.antenna_gain.a3 = sprom_extract_antgain(sprom, -+ SSB_SPROM8_AGAIN23, -+ SSB_SPROM8_AGAIN3, -+ SSB_SPROM8_AGAIN3_SHIFT); - - SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON, - SSB_SPROM8_LEDDC_ON_SHIFT); -@@ -502,12 +528,14 @@ static bool bcma_sprom_onchip_available( - case BCMA_CHIP_ID_BCM4331: - present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT; - break; -- -+ case BCMA_CHIP_ID_BCM43142: - case BCMA_CHIP_ID_BCM43224: - case BCMA_CHIP_ID_BCM43225: - /* for these chips OTP is always available */ - present = true; - break; -+ case BCMA_CHIP_ID_BCM43131: -+ case BCMA_CHIP_ID_BCM43217: - case BCMA_CHIP_ID_BCM43227: - case BCMA_CHIP_ID_BCM43228: - case BCMA_CHIP_ID_BCM43428: -@@ -550,7 +578,9 @@ int bcma_sprom_get(struct bcma_bus *bus) - { - u16 offset = BCMA_CC_SPROM; - u16 *sprom; -- int err = 0; -+ size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4, -+ SSB_SPROMSIZE_WORDS_R10, }; -+ int i, err = 0; - - if (!bus->drv_cc.core) - return -EOPNOTSUPP; -@@ -579,32 +609,37 @@ int bcma_sprom_get(struct bcma_bus *bus) - } - } - -- sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), -- GFP_KERNEL); -- if (!sprom) -- return -ENOMEM; -- - if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || - bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) - bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false); - - bcma_debug(bus, "SPROM offset 0x%x\n", offset); -- bcma_sprom_read(bus, offset, sprom); -+ for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) { -+ size_t words = sprom_sizes[i]; -+ -+ sprom = kcalloc(words, sizeof(u16), GFP_KERNEL); -+ if (!sprom) -+ return -ENOMEM; -+ -+ bcma_sprom_read(bus, offset, sprom, words); -+ err = bcma_sprom_valid(bus, sprom, words); -+ if (!err) -+ break; -+ -+ kfree(sprom); -+ } - - if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || - bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) - bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true); - -- err = bcma_sprom_valid(sprom); - if (err) { -- bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n"); -+ bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n"); - err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); -- goto out; -+ } else { -+ bcma_sprom_extract_r8(bus, sprom); -+ kfree(sprom); - } - -- bcma_sprom_extract_r8(bus, sprom); -- --out: -- kfree(sprom); - return err; - } ---- a/include/linux/bcma/bcma.h -+++ b/include/linux/bcma/bcma.h -@@ -6,6 +6,7 @@ - - #include <linux/bcma/bcma_driver_chipcommon.h> - #include <linux/bcma/bcma_driver_pci.h> -+#include <linux/bcma/bcma_driver_pcie2.h> - #include <linux/bcma/bcma_driver_mips.h> - #include <linux/bcma/bcma_driver_gmac_cmn.h> - #include <linux/ssb/ssb.h> /* SPROM sharing */ -@@ -72,7 +73,19 @@ struct bcma_host_ops { - /* Core-ID values. */ - #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */ - #define BCMA_CORE_4706_CHIPCOMMON 0x500 -+#define BCMA_CORE_NS_PCIEG2 0x501 -+#define BCMA_CORE_NS_DMA 0x502 -+#define BCMA_CORE_NS_SDIO3 0x503 -+#define BCMA_CORE_NS_USB20 0x504 -+#define BCMA_CORE_NS_USB30 0x505 -+#define BCMA_CORE_NS_A9JTAG 0x506 -+#define BCMA_CORE_NS_DDR23 0x507 -+#define BCMA_CORE_NS_ROM 0x508 -+#define BCMA_CORE_NS_NAND 0x509 -+#define BCMA_CORE_NS_QSPI 0x50A -+#define BCMA_CORE_NS_CHIPCOMMON_B 0x50B - #define BCMA_CORE_4706_SOC_RAM 0x50E -+#define BCMA_CORE_ARMCA9 0x510 - #define BCMA_CORE_4706_MAC_GBIT 0x52D - #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */ - #define BCMA_CORE_ALTA 0x534 /* I2S core */ -@@ -144,6 +157,10 @@ struct bcma_host_ops { - - /* Chip IDs of PCIe devices */ - #define BCMA_CHIP_ID_BCM4313 0x4313 -+#define BCMA_CHIP_ID_BCM43142 43142 -+#define BCMA_CHIP_ID_BCM43131 43131 -+#define BCMA_CHIP_ID_BCM43217 43217 -+#define BCMA_CHIP_ID_BCM43222 43222 - #define BCMA_CHIP_ID_BCM43224 43224 - #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8 - #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa -@@ -176,6 +193,11 @@ struct bcma_host_ops { - #define BCMA_PKG_ID_BCM5357 11 - #define BCMA_CHIP_ID_BCM53572 53572 - #define BCMA_PKG_ID_BCM47188 9 -+#define BCMA_CHIP_ID_BCM4707 53010 -+#define BCMA_PKG_ID_BCM4707 1 -+#define BCMA_PKG_ID_BCM4708 2 -+#define BCMA_PKG_ID_BCM4709 0 -+#define BCMA_CHIP_ID_BCM53018 53018 - - /* Board types (on PCI usually equals to the subsystem dev id) */ - /* BCM4313 */ -@@ -245,7 +267,7 @@ struct bcma_device { - u8 core_unit; - - u32 addr; -- u32 addr1; -+ u32 addr_s[8]; - u32 wrap; - - void __iomem *io_addr; -@@ -301,6 +323,8 @@ struct bcma_bus { - struct pci_dev *host_pci; - /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */ - struct sdio_func *host_sdio; -+ /* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */ -+ struct platform_device *host_pdev; - }; - - struct bcma_chipinfo chipinfo; -@@ -310,11 +334,12 @@ struct bcma_bus { - struct bcma_device *mapped_core; - struct list_head cores; - u8 nr_cores; -- u8 init_done:1; - u8 num; - - struct bcma_drv_cc drv_cc; -+ struct bcma_drv_cc_b drv_cc_b; - struct bcma_drv_pci drv_pci[2]; -+ struct bcma_drv_pcie2 drv_pcie2; - struct bcma_drv_mips drv_mips; - struct bcma_drv_gmac_cmn drv_gmac_cmn; - -@@ -400,7 +425,14 @@ static inline void bcma_maskset16(struct - bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set); - } - --extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid); -+extern struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid, -+ u8 unit); -+static inline struct bcma_device *bcma_find_core(struct bcma_bus *bus, -+ u16 coreid) -+{ -+ return bcma_find_core_unit(bus, coreid, 0); -+} -+ - extern bool bcma_core_is_enabled(struct bcma_device *core); - extern void bcma_core_disable(struct bcma_device *core, u32 flags); - extern int bcma_core_enable(struct bcma_device *core, u32 flags); -@@ -415,4 +447,6 @@ extern u32 bcma_chipco_pll_read(struct b - #define BCMA_DMA_TRANSLATION_DMA64_CMT 0x80000000 /* Client Mode Translation for 64-bit DMA */ - extern u32 bcma_core_dma_translation(struct bcma_device *core); - -+extern unsigned int bcma_core_irq(struct bcma_device *core, int num); -+ - #endif /* LINUX_BCMA_H_ */ ---- a/include/linux/bcma/bcma_driver_chipcommon.h -+++ b/include/linux/bcma/bcma_driver_chipcommon.h -@@ -330,6 +330,8 @@ - #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */ - #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */ - #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */ -+#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100 -+#define BCMA_CC_PMU_STAT_WDRESET 0x00000080 - #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */ - #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */ - #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */ -@@ -355,6 +357,11 @@ - #define BCMA_CC_REGCTL_DATA 0x065C - #define BCMA_CC_PLLCTL_ADDR 0x0660 - #define BCMA_CC_PLLCTL_DATA 0x0664 -+#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */ -+#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */ -+#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF -+#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000 -+#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31 - #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */ - /* NAND flash MLC controller registers (corerev >= 38) */ - #define BCMA_CC_NAND_REVISION 0x0C00 -@@ -435,6 +442,23 @@ - #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007 - #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0 - -+/* PMU rev 15 */ -+#define BCMA_CC_PMU15_PLL_PLLCTL0 0 -+#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003 -+#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0 -+#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC -+#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2 -+#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000 -+#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22 -+#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000 -+#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24 -+#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000 -+#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27 -+#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000 -+#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30 -+#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000 -+#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31 -+ - /* ALP clock on pre-PMU chips */ - #define BCMA_CC_PMU_ALP_CLOCK 20000000 - /* HT clock for systems with PMU-enabled chipcommon */ -@@ -507,6 +531,37 @@ - #define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18) - #define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19) - -+#define BCMA_RES_4314_LPLDO_PU BIT(0) -+#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1) -+#define BCMA_RES_4314_PMU_BG_PU BIT(2) -+#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3) -+#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4) -+#define BCMA_RES_4314_CLDO_PU BIT(5) -+#define BCMA_RES_4314_LPLDO2_LVM BIT(6) -+#define BCMA_RES_4314_WL_PMU_PU BIT(7) -+#define BCMA_RES_4314_LNLDO_PU BIT(8) -+#define BCMA_RES_4314_LDO3P3_PU BIT(9) -+#define BCMA_RES_4314_OTP_PU BIT(10) -+#define BCMA_RES_4314_XTAL_PU BIT(11) -+#define BCMA_RES_4314_WL_PWRSW_PU BIT(12) -+#define BCMA_RES_4314_LQ_AVAIL BIT(13) -+#define BCMA_RES_4314_LOGIC_RET BIT(14) -+#define BCMA_RES_4314_MEM_SLEEP BIT(15) -+#define BCMA_RES_4314_MACPHY_RET BIT(16) -+#define BCMA_RES_4314_WL_CORE_READY BIT(17) -+#define BCMA_RES_4314_ILP_REQ BIT(18) -+#define BCMA_RES_4314_ALP_AVAIL BIT(19) -+#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20) -+#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21) -+#define BCMA_RES_4314_RX_PWRSW_PU BIT(22) -+#define BCMA_RES_4314_RADIO_PU BIT(23) -+#define BCMA_RES_4314_VCO_LDO_PU BIT(24) -+#define BCMA_RES_4314_AFE_LDO_PU BIT(25) -+#define BCMA_RES_4314_RX_LDO_PU BIT(26) -+#define BCMA_RES_4314_TX_LDO_PU BIT(27) -+#define BCMA_RES_4314_HT_AVAIL BIT(28) -+#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29) -+ - /* Data for the PMU, if available. - * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU) - */ -@@ -585,9 +640,16 @@ struct bcma_drv_cc { - spinlock_t gpio_lock; - #ifdef CONFIG_BCMA_DRIVER_GPIO - struct gpio_chip gpio; -+ struct irq_domain *irq_domain; - #endif - }; - -+struct bcma_drv_cc_b { -+ struct bcma_device *core; -+ u8 setup_done:1; -+ void __iomem *mii; -+}; -+ - /* Register access */ - #define bcma_cc_read32(cc, offset) \ - bcma_read32((cc)->core, offset) -@@ -643,4 +705,6 @@ extern void bcma_pmu_spuravoid_pllupdate - - extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc); - -+void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value); -+ - #endif /* LINUX_BCMA_DRIVER_CC_H_ */ ---- a/include/linux/bcma/bcma_driver_mips.h -+++ b/include/linux/bcma/bcma_driver_mips.h -@@ -43,12 +43,12 @@ struct bcma_drv_mips { - extern void bcma_core_mips_init(struct bcma_drv_mips *mcore); - extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore); - --extern unsigned int bcma_core_irq(struct bcma_device *core); -+extern unsigned int bcma_core_mips_irq(struct bcma_device *dev); - #else - static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { } - static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { } - --static inline unsigned int bcma_core_irq(struct bcma_device *core) -+static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev) - { - return 0; - } ---- a/include/linux/bcma/bcma_driver_pci.h -+++ b/include/linux/bcma/bcma_driver_pci.h -@@ -181,10 +181,31 @@ struct pci_dev; - - #define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8 - -+#define BCMA_CORE_PCI_ -+ -+/* MDIO devices (SERDES modules) */ -+#define BCMA_CORE_PCI_MDIO_IEEE0 0x000 -+#define BCMA_CORE_PCI_MDIO_IEEE1 0x001 -+#define BCMA_CORE_PCI_MDIO_BLK0 0x800 -+#define BCMA_CORE_PCI_MDIO_BLK1 0x801 -+#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16 -+#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17 -+#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18 -+#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19 -+#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A -+#define BCMA_CORE_PCI_MDIO_BLK2 0x802 -+#define BCMA_CORE_PCI_MDIO_BLK3 0x803 -+#define BCMA_CORE_PCI_MDIO_BLK4 0x804 -+#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */ -+#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820 -+#define BCMA_CORE_PCI_MDIO_SERDESID 0x831 -+#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840 -+ - /* PCIE Root Capability Register bits (Host mode only) */ - #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001 - - struct bcma_drv_pci; -+struct bcma_bus; - - #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE - struct bcma_drv_pci_host { -@@ -219,7 +240,9 @@ struct bcma_drv_pci { - extern void bcma_core_pci_init(struct bcma_drv_pci *pc); - extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, - struct bcma_device *core, bool enable); --extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend); -+extern void bcma_core_pci_up(struct bcma_bus *bus); -+extern void bcma_core_pci_down(struct bcma_bus *bus); -+extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up); - - extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev); - extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev); ---- /dev/null -+++ b/include/linux/bcma/bcma_driver_pcie2.h -@@ -0,0 +1,158 @@ -+#ifndef LINUX_BCMA_DRIVER_PCIE2_H_ -+#define LINUX_BCMA_DRIVER_PCIE2_H_ -+ -+#define BCMA_CORE_PCIE2_CLK_CONTROL 0x0000 -+#define PCIE2_CLKC_RST_OE 0x0001 /* When set, drives PCI_RESET out to pin */ -+#define PCIE2_CLKC_RST 0x0002 /* Value driven out to pin */ -+#define PCIE2_CLKC_SPERST 0x0004 /* SurvivePeRst */ -+#define PCIE2_CLKC_DISABLE_L1CLK_GATING 0x0010 -+#define PCIE2_CLKC_DLYPERST 0x0100 /* Delay PeRst to CoE Core */ -+#define PCIE2_CLKC_DISSPROMLD 0x0200 /* DisableSpromLoadOnPerst */ -+#define PCIE2_CLKC_WAKE_MODE_L2 0x1000 /* Wake on L2 */ -+#define BCMA_CORE_PCIE2_RC_PM_CONTROL 0x0004 -+#define BCMA_CORE_PCIE2_RC_PM_STATUS 0x0008 -+#define BCMA_CORE_PCIE2_EP_PM_CONTROL 0x000C -+#define BCMA_CORE_PCIE2_EP_PM_STATUS 0x0010 -+#define BCMA_CORE_PCIE2_EP_LTR_CONTROL 0x0014 -+#define BCMA_CORE_PCIE2_EP_LTR_STATUS 0x0018 -+#define BCMA_CORE_PCIE2_EP_OBFF_STATUS 0x001C -+#define BCMA_CORE_PCIE2_PCIE_ERR_STATUS 0x0020 -+#define BCMA_CORE_PCIE2_RC_AXI_CONFIG 0x0100 -+#define BCMA_CORE_PCIE2_EP_AXI_CONFIG 0x0104 -+#define BCMA_CORE_PCIE2_RXDEBUG_STATUS0 0x0108 -+#define BCMA_CORE_PCIE2_RXDEBUG_CONTROL0 0x010C -+#define BCMA_CORE_PCIE2_CONFIGINDADDR 0x0120 -+#define BCMA_CORE_PCIE2_CONFIGINDDATA 0x0124 -+#define BCMA_CORE_PCIE2_MDIOCONTROL 0x0128 -+#define BCMA_CORE_PCIE2_MDIOWRDATA 0x012C -+#define BCMA_CORE_PCIE2_MDIORDDATA 0x0130 -+#define BCMA_CORE_PCIE2_DATAINTF 0x0180 -+#define BCMA_CORE_PCIE2_D2H_INTRLAZY_0 0x0188 -+#define BCMA_CORE_PCIE2_H2D_INTRLAZY_0 0x018c -+#define BCMA_CORE_PCIE2_H2D_INTSTAT_0 0x0190 -+#define BCMA_CORE_PCIE2_H2D_INTMASK_0 0x0194 -+#define BCMA_CORE_PCIE2_D2H_INTSTAT_0 0x0198 -+#define BCMA_CORE_PCIE2_D2H_INTMASK_0 0x019c -+#define BCMA_CORE_PCIE2_LTR_STATE 0x01A0 /* Latency Tolerance Reporting */ -+#define PCIE2_LTR_ACTIVE 2 -+#define PCIE2_LTR_ACTIVE_IDLE 1 -+#define PCIE2_LTR_SLEEP 0 -+#define PCIE2_LTR_FINAL_MASK 0x300 -+#define PCIE2_LTR_FINAL_SHIFT 8 -+#define BCMA_CORE_PCIE2_PWR_INT_STATUS 0x01A4 -+#define BCMA_CORE_PCIE2_PWR_INT_MASK 0x01A8 -+#define BCMA_CORE_PCIE2_CFG_ADDR 0x01F8 -+#define BCMA_CORE_PCIE2_CFG_DATA 0x01FC -+#define BCMA_CORE_PCIE2_SYS_EQ_PAGE 0x0200 -+#define BCMA_CORE_PCIE2_SYS_MSI_PAGE 0x0204 -+#define BCMA_CORE_PCIE2_SYS_MSI_INTREN 0x0208 -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL0 0x0210 -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL1 0x0214 -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL2 0x0218 -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL3 0x021C -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL4 0x0220 -+#define BCMA_CORE_PCIE2_SYS_MSI_CTRL5 0x0224 -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD0 0x0250 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL0 0x0254 -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD1 0x0258 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL1 0x025C -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD2 0x0260 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL2 0x0264 -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD3 0x0268 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL3 0x026C -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD4 0x0270 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL4 0x0274 -+#define BCMA_CORE_PCIE2_SYS_EQ_HEAD5 0x0278 -+#define BCMA_CORE_PCIE2_SYS_EQ_TAIL5 0x027C -+#define BCMA_CORE_PCIE2_SYS_RC_INTX_EN 0x0330 -+#define BCMA_CORE_PCIE2_SYS_RC_INTX_CSR 0x0334 -+#define BCMA_CORE_PCIE2_SYS_MSI_REQ 0x0340 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR_EN 0x0344 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR_CSR 0x0348 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR0 0x0350 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR1 0x0354 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR2 0x0358 -+#define BCMA_CORE_PCIE2_SYS_HOST_INTR3 0x035C -+#define BCMA_CORE_PCIE2_SYS_EP_INT_EN0 0x0360 -+#define BCMA_CORE_PCIE2_SYS_EP_INT_EN1 0x0364 -+#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR0 0x0370 -+#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR1 0x0374 -+#define BCMA_CORE_PCIE2_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_0 0x0C00 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_1 0x0C04 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_2 0x0C08 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_3 0x0C0C -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_4 0x0C10 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_5 0x0C14 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_6 0x0C18 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP0_7 0x0C1C -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_0 0x0C20 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_1 0x0C24 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_2 0x0C28 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_3 0x0C2C -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_4 0x0C30 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_5 0x0C34 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_6 0x0C38 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP0_7 0x0C3C -+#define BCMA_CORE_PCIE2_FUNC0_IMAP1 0x0C80 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP1 0x0C88 -+#define BCMA_CORE_PCIE2_FUNC0_IMAP2 0x0CC0 -+#define BCMA_CORE_PCIE2_FUNC1_IMAP2 0x0CC8 -+#define BCMA_CORE_PCIE2_IARR0_LOWER 0x0D00 -+#define BCMA_CORE_PCIE2_IARR0_UPPER 0x0D04 -+#define BCMA_CORE_PCIE2_IARR1_LOWER 0x0D08 -+#define BCMA_CORE_PCIE2_IARR1_UPPER 0x0D0C -+#define BCMA_CORE_PCIE2_IARR2_LOWER 0x0D10 -+#define BCMA_CORE_PCIE2_IARR2_UPPER 0x0D14 -+#define BCMA_CORE_PCIE2_OARR0 0x0D20 -+#define BCMA_CORE_PCIE2_OARR1 0x0D28 -+#define BCMA_CORE_PCIE2_OARR2 0x0D30 -+#define BCMA_CORE_PCIE2_OMAP0_LOWER 0x0D40 -+#define BCMA_CORE_PCIE2_OMAP0_UPPER 0x0D44 -+#define BCMA_CORE_PCIE2_OMAP1_LOWER 0x0D48 -+#define BCMA_CORE_PCIE2_OMAP1_UPPER 0x0D4C -+#define BCMA_CORE_PCIE2_OMAP2_LOWER 0x0D50 -+#define BCMA_CORE_PCIE2_OMAP2_UPPER 0x0D54 -+#define BCMA_CORE_PCIE2_FUNC1_IARR1_SIZE 0x0D58 -+#define BCMA_CORE_PCIE2_FUNC1_IARR2_SIZE 0x0D5C -+#define BCMA_CORE_PCIE2_MEM_CONTROL 0x0F00 -+#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG0 0x0F04 -+#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG1 0x0F08 -+#define BCMA_CORE_PCIE2_LINK_STATUS 0x0F0C -+#define BCMA_CORE_PCIE2_STRAP_STATUS 0x0F10 -+#define BCMA_CORE_PCIE2_RESET_STATUS 0x0F14 -+#define BCMA_CORE_PCIE2_RESETEN_IN_LINKDOWN 0x0F18 -+#define BCMA_CORE_PCIE2_MISC_INTR_EN 0x0F1C -+#define BCMA_CORE_PCIE2_TX_DEBUG_CFG 0x0F20 -+#define BCMA_CORE_PCIE2_MISC_CONFIG 0x0F24 -+#define BCMA_CORE_PCIE2_MISC_STATUS 0x0F28 -+#define BCMA_CORE_PCIE2_INTR_EN 0x0F30 -+#define BCMA_CORE_PCIE2_INTR_CLEAR 0x0F34 -+#define BCMA_CORE_PCIE2_INTR_STATUS 0x0F38 -+ -+/* PCIE gen2 config regs */ -+#define PCIE2_INTSTATUS 0x090 -+#define PCIE2_INTMASK 0x094 -+#define PCIE2_SBMBX 0x098 -+ -+#define PCIE2_PMCR_REFUP 0x1814 /* Trefup time */ -+ -+#define PCIE2_CAP_DEVSTSCTRL2_OFFSET 0xD4 -+#define PCIE2_CAP_DEVSTSCTRL2_LTRENAB 0x400 -+#define PCIE2_PVT_REG_PM_CLK_PERIOD 0x184c -+ -+struct bcma_drv_pcie2 { -+ struct bcma_device *core; -+}; -+ -+#define pcie2_read16(pcie2, offset) bcma_read16((pcie2)->core, offset) -+#define pcie2_read32(pcie2, offset) bcma_read32((pcie2)->core, offset) -+#define pcie2_write16(pcie2, offset, val) bcma_write16((pcie2)->core, offset, val) -+#define pcie2_write32(pcie2, offset, val) bcma_write32((pcie2)->core, offset, val) -+ -+#define pcie2_set32(pcie2, offset, set) bcma_set32((pcie2)->core, offset, set) -+#define pcie2_mask32(pcie2, offset, mask) bcma_mask32((pcie2)->core, offset, mask) -+ -+void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2); -+ -+#endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */ ---- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c -+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c -@@ -679,27 +679,6 @@ bool ai_clkctl_cc(struct si_pub *sih, en - return mode == BCMA_CLKMODE_FAST; - } - --void ai_pci_up(struct si_pub *sih) --{ -- struct si_info *sii; -- -- sii = container_of(sih, struct si_info, pub); -- -- if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI) -- bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true); --} -- --/* Unconfigure and/or apply various WARs when going down */ --void ai_pci_down(struct si_pub *sih) --{ -- struct si_info *sii; -- -- sii = container_of(sih, struct si_info, pub); -- -- if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI) -- bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false); --} -- - /* Enable BT-COEX & Ex-PA for 4313 */ - void ai_epa_4313war(struct si_pub *sih) - { ---- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h -+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h -@@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(st - extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode); - extern bool ai_deviceremoved(struct si_pub *sih); - --extern void ai_pci_down(struct si_pub *sih); --extern void ai_pci_up(struct si_pub *sih); -- - /* Enable Ex-PA for 4313 */ - extern void ai_epa_4313war(struct si_pub *sih); - ---- a/drivers/net/wireless/brcm80211/brcmsmac/main.c -+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c -@@ -4667,7 +4667,7 @@ static int brcms_b_attach(struct brcms_c - brcms_c_coredisable(wlc_hw); - - /* Match driver "down" state */ -- ai_pci_down(wlc_hw->sih); -+ bcma_core_pci_down(wlc_hw->d11core->bus); - - /* turn off pll and xtal to match driver "down" state */ - brcms_b_xtal(wlc_hw, OFF); -@@ -5010,12 +5010,12 @@ static int brcms_b_up_prep(struct brcms_ - */ - if (brcms_b_radio_read_hwdisabled(wlc_hw)) { - /* put SB PCI in down state again */ -- ai_pci_down(wlc_hw->sih); -+ bcma_core_pci_down(wlc_hw->d11core->bus); - brcms_b_xtal(wlc_hw, OFF); - return -ENOMEDIUM; - } - -- ai_pci_up(wlc_hw->sih); -+ bcma_core_pci_up(wlc_hw->d11core->bus); - - /* reset the d11 core */ - brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); -@@ -5212,7 +5212,7 @@ static int brcms_b_down_finish(struct br - - /* turn off primary xtal and pll */ - if (!wlc_hw->noreset) { -- ai_pci_down(wlc_hw->sih); -+ bcma_core_pci_down(wlc_hw->d11core->bus); - brcms_b_xtal(wlc_hw, OFF); - } - } ---- a/drivers/bcma/driver_mips.c -+++ b/drivers/bcma/driver_mips.c -@@ -21,6 +21,14 @@ - #include <linux/serial_reg.h> - #include <linux/time.h> - -+enum bcma_boot_dev { -+ BCMA_BOOT_DEV_UNK = 0, -+ BCMA_BOOT_DEV_ROM, -+ BCMA_BOOT_DEV_PARALLEL, -+ BCMA_BOOT_DEV_SERIAL, -+ BCMA_BOOT_DEV_NAND, -+}; -+ - static const char * const part_probes[] = { "bcm47xxpart", NULL }; - - static struct physmap_flash_data bcma_pflash_data = { -@@ -107,7 +115,7 @@ static u32 bcma_core_mips_irqflag(struct - * If disabled, 5 is returned. - * If not supported, 6 is returned. - */ --static unsigned int bcma_core_mips_irq(struct bcma_device *dev) -+unsigned int bcma_core_mips_irq(struct bcma_device *dev) - { - struct bcma_device *mdev = dev->bus->drv_mips.core; - u32 irqflag; -@@ -125,13 +133,6 @@ static unsigned int bcma_core_mips_irq(s - return 5; - } - --unsigned int bcma_core_irq(struct bcma_device *dev) --{ -- unsigned int mips_irq = bcma_core_mips_irq(dev); -- return mips_irq <= 4 ? mips_irq + 2 : 0; --} --EXPORT_SYMBOL(bcma_core_irq); -- - static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq) - { - unsigned int oldirq = bcma_core_mips_irq(dev); -@@ -229,11 +230,51 @@ u32 bcma_cpu_clock(struct bcma_drv_mips - } - EXPORT_SYMBOL(bcma_cpu_clock); - -+static enum bcma_boot_dev bcma_boot_dev(struct bcma_bus *bus) -+{ -+ struct bcma_drv_cc *cc = &bus->drv_cc; -+ u8 cc_rev = cc->core->id.rev; -+ -+ if (cc_rev == 42) { -+ struct bcma_device *core; -+ -+ core = bcma_find_core(bus, BCMA_CORE_NS_ROM); -+ if (core) { -+ switch (bcma_aread32(core, BCMA_IOST) & -+ BCMA_NS_ROM_IOST_BOOT_DEV_MASK) { -+ case BCMA_NS_ROM_IOST_BOOT_DEV_NOR: -+ return BCMA_BOOT_DEV_SERIAL; -+ case BCMA_NS_ROM_IOST_BOOT_DEV_NAND: -+ return BCMA_BOOT_DEV_NAND; -+ case BCMA_NS_ROM_IOST_BOOT_DEV_ROM: -+ default: -+ return BCMA_BOOT_DEV_ROM; -+ } -+ } -+ } else { -+ if (cc_rev == 38) { -+ if (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT) -+ return BCMA_BOOT_DEV_NAND; -+ else if (cc->status & BIT(5)) -+ return BCMA_BOOT_DEV_ROM; -+ } -+ -+ if ((cc->capabilities & BCMA_CC_CAP_FLASHT) == -+ BCMA_CC_FLASHT_PARA) -+ return BCMA_BOOT_DEV_PARALLEL; -+ else -+ return BCMA_BOOT_DEV_SERIAL; -+ } -+ -+ return BCMA_BOOT_DEV_SERIAL; -+} -+ - static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore) - { - struct bcma_bus *bus = mcore->core->bus; - struct bcma_drv_cc *cc = &bus->drv_cc; - struct bcma_pflash *pflash = &cc->pflash; -+ enum bcma_boot_dev boot_dev; - - switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { - case BCMA_CC_FLASHT_STSER: -@@ -269,6 +310,20 @@ static void bcma_core_mips_flash_detect( - bcma_nflash_init(cc); - } - } -+ -+ /* Determine flash type this SoC boots from */ -+ boot_dev = bcma_boot_dev(bus); -+ switch (boot_dev) { -+ case BCMA_BOOT_DEV_PARALLEL: -+ case BCMA_BOOT_DEV_SERIAL: -+ /* TODO: Init NVRAM using BCMA_SOC_FLASH2 window */ -+ break; -+ case BCMA_BOOT_DEV_NAND: -+ /* TODO: Init NVRAM using BCMA_SOC_FLASH1 window */ -+ break; -+ default: -+ break; -+ } - } - - void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) -@@ -361,7 +416,7 @@ void bcma_core_mips_init(struct bcma_drv - break; - default: - list_for_each_entry(core, &bus->cores, list) { -- core->irq = bcma_core_irq(core); -+ core->irq = bcma_core_irq(core, 0); - } - bcma_err(bus, - "Unknown device (0x%x) found, can not configure IRQs\n", ---- a/drivers/bcma/host_soc.c -+++ b/drivers/bcma/host_soc.c -@@ -7,6 +7,9 @@ - - #include "bcma_private.h" - #include "scan.h" -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/of_address.h> - #include <linux/bcma/bcma.h> - #include <linux/bcma/bcma_soc.h> - -@@ -134,12 +137,16 @@ static void bcma_host_soc_block_write(st - - static u32 bcma_host_soc_aread32(struct bcma_device *core, u16 offset) - { -+ if (WARN_ONCE(!core->io_wrap, "Accessed core has no wrapper/agent\n")) -+ return ~0; - return readl(core->io_wrap + offset); - } - - static void bcma_host_soc_awrite32(struct bcma_device *core, u16 offset, - u32 value) - { -+ if (WARN_ONCE(!core->io_wrap, "Accessed core has no wrapper/agent\n")) -+ return; - writel(value, core->io_wrap + offset); - } - -@@ -161,7 +168,6 @@ static const struct bcma_host_ops bcma_h - int __init bcma_host_soc_register(struct bcma_soc *soc) - { - struct bcma_bus *bus = &soc->bus; -- int err; - - /* iomap only first core. We have to read some register on this core - * to scan the bus. -@@ -173,11 +179,100 @@ int __init bcma_host_soc_register(struct - /* Host specific */ - bus->hosttype = BCMA_HOSTTYPE_SOC; - bus->ops = &bcma_host_soc_ops; -+ bus->host_pdev = NULL; - -- /* Register */ -+ /* Initialize struct, detect chip */ -+ bcma_init_bus(bus); -+ -+ return 0; -+} -+ -+int __init bcma_host_soc_init(struct bcma_soc *soc) -+{ -+ struct bcma_bus *bus = &soc->bus; -+ int err; -+ -+ /* Scan bus and initialize it */ - err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips); - if (err) - iounmap(bus->mmio); - - return err; - } -+ -+#ifdef CONFIG_OF -+static int bcma_host_soc_probe(struct platform_device *pdev) -+{ -+ struct device *dev = &pdev->dev; -+ struct device_node *np = dev->of_node; -+ struct bcma_bus *bus; -+ int err; -+ -+ /* Alloc */ -+ bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL); -+ if (!bus) -+ return -ENOMEM; -+ -+ /* Map MMIO */ -+ bus->mmio = of_iomap(np, 0); -+ if (!bus->mmio) -+ return -ENOMEM; -+ -+ /* Host specific */ -+ bus->hosttype = BCMA_HOSTTYPE_SOC; -+ bus->ops = &bcma_host_soc_ops; -+ bus->host_pdev = pdev; -+ -+ /* Initialize struct, detect chip */ -+ bcma_init_bus(bus); -+ -+ /* Register */ -+ err = bcma_bus_register(bus); -+ if (err) -+ goto err_unmap_mmio; -+ -+ platform_set_drvdata(pdev, bus); -+ -+ return err; -+ -+err_unmap_mmio: -+ iounmap(bus->mmio); -+ return err; -+} -+ -+static int bcma_host_soc_remove(struct platform_device *pdev) -+{ -+ struct bcma_bus *bus = platform_get_drvdata(pdev); -+ -+ bcma_bus_unregister(bus); -+ iounmap(bus->mmio); -+ platform_set_drvdata(pdev, NULL); -+ -+ return 0; -+} -+ -+static const struct of_device_id bcma_host_soc_of_match[] = { -+ { .compatible = "brcm,bus-axi", }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, bcma_host_soc_of_match); -+ -+static struct platform_driver bcma_host_soc_driver = { -+ .driver = { -+ .name = "bcma-host-soc", -+ .of_match_table = bcma_host_soc_of_match, -+ }, -+ .probe = bcma_host_soc_probe, -+ .remove = bcma_host_soc_remove, -+}; -+ -+int __init bcma_host_soc_register_driver(void) -+{ -+ return platform_driver_register(&bcma_host_soc_driver); -+} -+ -+void __exit bcma_host_soc_unregister_driver(void) -+{ -+ platform_driver_unregister(&bcma_host_soc_driver); -+} -+#endif /* CONFIG_OF */ ---- a/include/linux/bcma/bcma_regs.h -+++ b/include/linux/bcma/bcma_regs.h -@@ -39,6 +39,11 @@ - #define BCMA_RESET_CTL_RESET 0x0001 - #define BCMA_RESET_ST 0x0804 - -+#define BCMA_NS_ROM_IOST_BOOT_DEV_MASK 0x0003 -+#define BCMA_NS_ROM_IOST_BOOT_DEV_NOR 0x0000 -+#define BCMA_NS_ROM_IOST_BOOT_DEV_NAND 0x0001 -+#define BCMA_NS_ROM_IOST_BOOT_DEV_ROM 0x0002 -+ - /* BCMA PCI config space registers. */ - #define BCMA_PCI_PMCSR 0x44 - #define BCMA_PCI_PE 0x100 ---- a/drivers/usb/host/bcma-hcd.c -+++ b/drivers/usb/host/bcma-hcd.c -@@ -238,7 +238,7 @@ static int bcma_hcd_probe(struct bcma_de - bcma_hcd_init_chip(dev); - - /* In AI chips EHCI is addrspace 0, OHCI is 1 */ -- ohci_addr = dev->addr1; -+ ohci_addr = dev->addr_s[0]; - if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749) - && chipinfo->rev == 0) - ohci_addr = 0x18009000; ---- /dev/null -+++ b/drivers/bcma/driver_chipcommon_b.c -@@ -0,0 +1,61 @@ -+/* -+ * Broadcom specific AMBA -+ * ChipCommon B Unit driver -+ * -+ * Copyright 2014, Hauke Mehrtens <hauke@hauke-m.de> -+ * -+ * Licensed under the GNU/GPL. See COPYING for details. -+ */ -+ -+#include "bcma_private.h" -+#include <linux/export.h> -+#include <linux/bcma/bcma.h> -+ -+static bool bcma_wait_reg(struct bcma_bus *bus, void __iomem *addr, u32 mask, -+ u32 value, int timeout) -+{ -+ unsigned long deadline = jiffies + timeout; -+ u32 val; -+ -+ do { -+ val = readl(addr); -+ if ((val & mask) == value) -+ return true; -+ cpu_relax(); -+ udelay(10); -+ } while (!time_after_eq(jiffies, deadline)); -+ -+ bcma_err(bus, "Timeout waiting for register %p\n", addr); -+ -+ return false; -+} -+ -+void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value) -+{ -+ struct bcma_bus *bus = ccb->core->bus; -+ -+ writel(offset, ccb->mii + 0x00); -+ bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100); -+ writel(value, ccb->mii + 0x04); -+ bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100); -+} -+EXPORT_SYMBOL_GPL(bcma_chipco_b_mii_write); -+ -+int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb) -+{ -+ if (ccb->setup_done) -+ return 0; -+ -+ ccb->setup_done = 1; -+ ccb->mii = ioremap_nocache(ccb->core->addr_s[1], BCMA_CORE_SIZE); -+ if (!ccb->mii) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb) -+{ -+ if (ccb->mii) -+ iounmap(ccb->mii); -+} ---- a/include/linux/bcma/bcma_soc.h -+++ b/include/linux/bcma/bcma_soc.h -@@ -10,6 +10,7 @@ struct bcma_soc { - }; - - int __init bcma_host_soc_register(struct bcma_soc *soc); -+int __init bcma_host_soc_init(struct bcma_soc *soc); - - int bcma_bus_register(struct bcma_bus *bus); - ---- a/arch/mips/bcm47xx/setup.c -+++ b/arch/mips/bcm47xx/setup.c -@@ -194,6 +194,10 @@ static void __init bcm47xx_register_bcma - - err = bcma_host_soc_register(&bcm47xx_bus.bcma); - if (err) -+ panic("Failed to register BCMA bus (err %d)", err); -+ -+ err = bcma_host_soc_init(&bcm47xx_bus.bcma); -+ if (err) - panic("Failed to initialize BCMA bus (err %d)", err); - - bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL); ---- /dev/null -+++ b/Documentation/devicetree/bindings/bus/bcma.txt -@@ -0,0 +1,53 @@ -+Driver for ARM AXI Bus with Broadcom Plugins (bcma) -+ -+Required properties: -+ -+- compatible : brcm,bus-axi -+ -+- reg : iomem address range of chipcommon core -+ -+The cores on the AXI bus are automatically detected by bcma with the -+memory ranges they are using and they get registered afterwards. -+Automatic detection of the IRQ number is not working on -+BCM47xx/BCM53xx ARM SoCs. To assign IRQ numbers to the cores, provide -+them manually through device tree. Use an interrupt-map to specify the -+IRQ used by the devices on the bus. The first address is just an index, -+because we do not have any special register. -+ -+The top-level axi bus may contain children representing attached cores -+(devices). This is needed since some hardware details can't be auto -+detected (e.g. IRQ numbers). Also some of the cores may be responsible -+for extra things, e.g. ChipCommon providing access to the GPIO chip. -+ -+Example: -+ -+ axi@18000000 { -+ compatible = "brcm,bus-axi"; -+ reg = <0x18000000 0x1000>; -+ ranges = <0x00000000 0x18000000 0x00100000>; -+ #address-cells = <1>; -+ #size-cells = <1>; -+ #interrupt-cells = <1>; -+ interrupt-map-mask = <0x000fffff 0xffff>; -+ interrupt-map = -+ /* Ethernet Controller 0 */ -+ <0x00024000 0 &gic GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, -+ -+ /* Ethernet Controller 1 */ -+ <0x00025000 0 &gic GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; -+ -+ /* PCIe Controller 0 */ -+ <0x00012000 0 &gic GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>, -+ <0x00012000 1 &gic GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>, -+ <0x00012000 2 &gic GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>, -+ <0x00012000 3 &gic GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>, -+ <0x00012000 4 &gic GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, -+ <0x00012000 5 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>; -+ -+ chipcommon { -+ reg = <0x00000000 0x1000>; -+ -+ gpio-controller; -+ #gpio-cells = <2>; -+ }; -+ }; diff --git a/target/linux/generic/patches-3.10/026-bcma-disable-OF-code.patch b/target/linux/generic/patches-3.10/026-bcma-disable-OF-code.patch deleted file mode 100644 index 7fb4cf312f..0000000000 --- a/target/linux/generic/patches-3.10/026-bcma-disable-OF-code.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 527608f06505b2a014982dd8ac7c85d97af51510 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com> -Date: Sat, 31 Jan 2015 17:40:58 +0100 -Subject: [PATCH] bcma: disable OF code -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: RafaÅ‚ MiÅ‚ecki <zajec5@gmail.com> ---- - drivers/bcma/main.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c -index c44b8d6..e64900f 100644 ---- a/drivers/bcma/main.c -+++ b/drivers/bcma/main.c -@@ -124,7 +124,8 @@ static bool bcma_is_core_needed_early(u16 core_id) - return false; - } - --#if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS) -+/* Backported code requires OF API from kernel 3.13 at least. */ -+#if 0 - static struct device_node *bcma_of_find_child_device(struct platform_device *parent, - struct bcma_device *core) - { --- -1.8.4.5 - diff --git a/target/linux/generic/patches-3.10/040-UBI-R-O-block-driver-on-top-of-UBI-volumes.patch b/target/linux/generic/patches-3.10/040-UBI-R-O-block-driver-on-top-of-UBI-volumes.patch deleted file mode 100644 index b629466d93..0000000000 --- a/target/linux/generic/patches-3.10/040-UBI-R-O-block-driver-on-top-of-UBI-volumes.patch +++ /dev/null @@ -1,829 +0,0 @@ -From 9d54c8a33eec78289b1b3f6e10874719c27ce0a7 Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Date: Tue, 25 Feb 2014 13:25:22 -0300 -Subject: [PATCH] UBI: R/O block driver on top of UBI volumes - -This commit introduces read-only block device emulation on top of UBI volumes. - -Given UBI takes care of wear leveling and bad block management it's possible -to add a thin layer to enable block device access to UBI volumes. -This allows to use a block-oriented filesystem on a flash device. - -The UBI block devices are meant to be used in conjunction with any -regular, block-oriented file system (e.g. ext4), although it's primarily -targeted at read-only file systems, such as squashfs. - -Block devices are created upon user request through new ioctls: -UBI_IOCVOLATTBLK to attach and UBI_IOCVOLDETBLK to detach. -Also, a new UBI module parameter is added 'ubi.block'. This parameter is -needed in order to attach a block device on boot-up time, allowing to -mount the rootfs on a ubiblock device. -For instance, you could have these kernel parameters: - - ubi.mtd=5 ubi.block=0,0 root=/dev/ubiblock0_0 - -Or, if you compile ubi as a module: - - $ modprobe ubi mtd=/dev/mtd5 block=/dev/ubi0_0 - -Artem: amend commentaries and massage the patch a little bit. - -Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/Kconfig | 15 + - drivers/mtd/ubi/Makefile | 1 + - drivers/mtd/ubi/block.c | 646 ++++++++++++++++++++++++++++++++++++++++++++ - drivers/mtd/ubi/build.c | 11 + - drivers/mtd/ubi/cdev.c | 20 ++ - drivers/mtd/ubi/ubi.h | 14 + - include/uapi/mtd/ubi-user.h | 11 + - 7 files changed, 718 insertions(+) - create mode 100644 drivers/mtd/ubi/block.c - ---- a/drivers/mtd/ubi/Kconfig -+++ b/drivers/mtd/ubi/Kconfig -@@ -87,4 +87,19 @@ config MTD_UBI_GLUEBI - work on top of UBI. Do not enable this unless you use legacy - software. - -+config MTD_UBI_BLOCK -+ bool "Read-only block devices on top of UBI volumes" -+ default n -+ help -+ This option enables read-only UBI block devices support. UBI block -+ devices will be layered on top of UBI volumes, which means that the -+ UBI driver will transparently handle things like bad eraseblocks and -+ bit-flips. You can put any block-oriented file system on top of UBI -+ volumes in read-only mode (e.g., ext4), but it is probably most -+ practical for read-only file systems, like squashfs. -+ -+ When selected, this feature will be built in the UBI driver. -+ -+ If in doubt, say "N". -+ - endif # MTD_UBI ---- a/drivers/mtd/ubi/Makefile -+++ b/drivers/mtd/ubi/Makefile -@@ -3,5 +3,6 @@ obj-$(CONFIG_MTD_UBI) += ubi.o - ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o attach.o - ubi-y += misc.o debug.o - ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o -+ubi-$(CONFIG_MTD_UBI_BLOCK) += block.o - - obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o ---- /dev/null -+++ b/drivers/mtd/ubi/block.c -@@ -0,0 +1,646 @@ -+/* -+ * Copyright (c) 2014 Ezequiel Garcia -+ * Copyright (c) 2011 Free Electrons -+ * -+ * Driver parameter handling strongly based on drivers/mtd/ubi/build.c -+ * Copyright (c) International Business Machines Corp., 2006 -+ * Copyright (c) Nokia Corporation, 2007 -+ * Authors: Artem Bityutskiy, Frank Haverkamp -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, version 2. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ * the GNU General Public License for more details. -+ */ -+ -+/* -+ * Read-only block devices on top of UBI volumes -+ * -+ * A simple implementation to allow a block device to be layered on top of a -+ * UBI volume. The implementation is provided by creating a static 1-to-1 -+ * mapping between the block device and the UBI volume. -+ * -+ * The addressed byte is obtained from the addressed block sector, which is -+ * mapped linearly into the corresponding LEB: -+ * -+ * LEB number = addressed byte / LEB size -+ * -+ * This feature is compiled in the UBI core, and adds a new 'block' parameter -+ * to allow early block device attaching. Runtime block attach/detach for UBI -+ * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and -+ * UBI_IOCVOLDETBLK. -+ */ -+ -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/err.h> -+#include <linux/kernel.h> -+#include <linux/list.h> -+#include <linux/mutex.h> -+#include <linux/slab.h> -+#include <linux/vmalloc.h> -+#include <linux/mtd/ubi.h> -+#include <linux/workqueue.h> -+#include <linux/blkdev.h> -+#include <linux/hdreg.h> -+#include <asm/div64.h> -+ -+#include "ubi-media.h" -+#include "ubi.h" -+ -+/* Maximum number of supported devices */ -+#define UBIBLOCK_MAX_DEVICES 32 -+ -+/* Maximum length of the 'block=' parameter */ -+#define UBIBLOCK_PARAM_LEN 63 -+ -+/* Maximum number of comma-separated items in the 'block=' parameter */ -+#define UBIBLOCK_PARAM_COUNT 2 -+ -+struct ubiblock_param { -+ int ubi_num; -+ int vol_id; -+ char name[UBIBLOCK_PARAM_LEN+1]; -+}; -+ -+/* Numbers of elements set in the @ubiblock_param array */ -+static int ubiblock_devs __initdata; -+ -+/* MTD devices specification parameters */ -+static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES] __initdata; -+ -+struct ubiblock { -+ struct ubi_volume_desc *desc; -+ int ubi_num; -+ int vol_id; -+ int refcnt; -+ int leb_size; -+ -+ struct gendisk *gd; -+ struct request_queue *rq; -+ -+ struct workqueue_struct *wq; -+ struct work_struct work; -+ -+ struct mutex dev_mutex; -+ spinlock_t queue_lock; -+ struct list_head list; -+}; -+ -+/* Linked list of all ubiblock instances */ -+static LIST_HEAD(ubiblock_devices); -+static DEFINE_MUTEX(devices_mutex); -+static int ubiblock_major; -+ -+static int __init ubiblock_set_param(const char *val, -+ const struct kernel_param *kp) -+{ -+ int i, ret; -+ size_t len; -+ struct ubiblock_param *param; -+ char buf[UBIBLOCK_PARAM_LEN]; -+ char *pbuf = &buf[0]; -+ char *tokens[UBIBLOCK_PARAM_COUNT]; -+ -+ if (!val) -+ return -EINVAL; -+ -+ len = strnlen(val, UBIBLOCK_PARAM_LEN); -+ if (len == 0) { -+ ubi_warn("block: empty 'block=' parameter - ignored\n"); -+ return 0; -+ } -+ -+ if (len == UBIBLOCK_PARAM_LEN) { -+ ubi_err("block: parameter \"%s\" is too long, max. is %d\n", -+ val, UBIBLOCK_PARAM_LEN); -+ return -EINVAL; -+ } -+ -+ strcpy(buf, val); -+ -+ /* Get rid of the final newline */ -+ if (buf[len - 1] == '\n') -+ buf[len - 1] = '\0'; -+ -+ for (i = 0; i < UBIBLOCK_PARAM_COUNT; i++) -+ tokens[i] = strsep(&pbuf, ","); -+ -+ param = &ubiblock_param[ubiblock_devs]; -+ if (tokens[1]) { -+ /* Two parameters: can be 'ubi, vol_id' or 'ubi, vol_name' */ -+ ret = kstrtoint(tokens[0], 10, ¶m->ubi_num); -+ if (ret < 0) -+ return -EINVAL; -+ -+ /* Second param can be a number or a name */ -+ ret = kstrtoint(tokens[1], 10, ¶m->vol_id); -+ if (ret < 0) { -+ param->vol_id = -1; -+ strcpy(param->name, tokens[1]); -+ } -+ -+ } else { -+ /* One parameter: must be device path */ -+ strcpy(param->name, tokens[0]); -+ param->ubi_num = -1; -+ param->vol_id = -1; -+ } -+ -+ ubiblock_devs++; -+ -+ return 0; -+} -+ -+static const struct kernel_param_ops ubiblock_param_ops = { -+ .set = ubiblock_set_param, -+}; -+module_param_cb(block, &ubiblock_param_ops, NULL, 0); -+MODULE_PARM_DESC(block, "Attach block devices to UBI volumes. Parameter format: block=<path|dev,num|dev,name>.\n" -+ "Multiple \"block\" parameters may be specified.\n" -+ "UBI volumes may be specified by their number, name, or path to the device node.\n" -+ "Examples\n" -+ "Using the UBI volume path:\n" -+ "ubi.block=/dev/ubi0_0\n" -+ "Using the UBI device, and the volume name:\n" -+ "ubi.block=0,rootfs\n" -+ "Using both UBI device number and UBI volume number:\n" -+ "ubi.block=0,0\n"); -+ -+static struct ubiblock *find_dev_nolock(int ubi_num, int vol_id) -+{ -+ struct ubiblock *dev; -+ -+ list_for_each_entry(dev, &ubiblock_devices, list) -+ if (dev->ubi_num == ubi_num && dev->vol_id == vol_id) -+ return dev; -+ return NULL; -+} -+ -+static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer, -+ int leb, int offset, int len) -+{ -+ int ret; -+ -+ ret = ubi_read(dev->desc, leb, buffer, offset, len); -+ if (ret) { -+ ubi_err("%s ubi_read error %d", -+ dev->gd->disk_name, ret); -+ return ret; -+ } -+ return 0; -+} -+ -+static int ubiblock_read(struct ubiblock *dev, char *buffer, -+ sector_t sec, int len) -+{ -+ int ret, leb, offset; -+ int bytes_left = len; -+ int to_read = len; -+ loff_t pos = sec << 9; -+ -+ /* Get LEB:offset address to read from */ -+ offset = do_div(pos, dev->leb_size); -+ leb = pos; -+ -+ while (bytes_left) { -+ /* -+ * We can only read one LEB at a time. Therefore if the read -+ * length is larger than one LEB size, we split the operation. -+ */ -+ if (offset + to_read > dev->leb_size) -+ to_read = dev->leb_size - offset; -+ -+ ret = ubiblock_read_to_buf(dev, buffer, leb, offset, to_read); -+ if (ret) -+ return ret; -+ -+ buffer += to_read; -+ bytes_left -= to_read; -+ to_read = bytes_left; -+ leb += 1; -+ offset = 0; -+ } -+ return 0; -+} -+ -+static int do_ubiblock_request(struct ubiblock *dev, struct request *req) -+{ -+ int len, ret; -+ sector_t sec; -+ -+ if (req->cmd_type != REQ_TYPE_FS) -+ return -EIO; -+ -+ if (blk_rq_pos(req) + blk_rq_cur_sectors(req) > -+ get_capacity(req->rq_disk)) -+ return -EIO; -+ -+ if (rq_data_dir(req) != READ) -+ return -ENOSYS; /* Write not implemented */ -+ -+ sec = blk_rq_pos(req); -+ len = blk_rq_cur_bytes(req); -+ -+ /* -+ * Let's prevent the device from being removed while we're doing I/O -+ * work. Notice that this means we serialize all the I/O operations, -+ * but it's probably of no impact given the NAND core serializes -+ * flash access anyway. -+ */ -+ mutex_lock(&dev->dev_mutex); -+ ret = ubiblock_read(dev, req->buffer, sec, len); -+ mutex_unlock(&dev->dev_mutex); -+ -+ return ret; -+} -+ -+static void ubiblock_do_work(struct work_struct *work) -+{ -+ struct ubiblock *dev = -+ container_of(work, struct ubiblock, work); -+ struct request_queue *rq = dev->rq; -+ struct request *req; -+ int res; -+ -+ spin_lock_irq(rq->queue_lock); -+ -+ req = blk_fetch_request(rq); -+ while (req) { -+ -+ spin_unlock_irq(rq->queue_lock); -+ res = do_ubiblock_request(dev, req); -+ spin_lock_irq(rq->queue_lock); -+ -+ /* -+ * If we're done with this request, -+ * we need to fetch a new one -+ */ -+ if (!__blk_end_request_cur(req, res)) -+ req = blk_fetch_request(rq); -+ } -+ -+ spin_unlock_irq(rq->queue_lock); -+} -+ -+static void ubiblock_request(struct request_queue *rq) -+{ -+ struct ubiblock *dev; -+ struct request *req; -+ -+ dev = rq->queuedata; -+ -+ if (!dev) -+ while ((req = blk_fetch_request(rq)) != NULL) -+ __blk_end_request_all(req, -ENODEV); -+ else -+ queue_work(dev->wq, &dev->work); -+} -+ -+static int ubiblock_open(struct block_device *bdev, fmode_t mode) -+{ -+ struct ubiblock *dev = bdev->bd_disk->private_data; -+ int ret; -+ -+ mutex_lock(&dev->dev_mutex); -+ if (dev->refcnt > 0) { -+ /* -+ * The volume is already open, just increase the reference -+ * counter. -+ */ -+ goto out_done; -+ } -+ -+ /* -+ * We want users to be aware they should only mount us as read-only. -+ * It's just a paranoid check, as write requests will get rejected -+ * in any case. -+ */ -+ if (mode & FMODE_WRITE) { -+ ret = -EPERM; -+ goto out_unlock; -+ } -+ -+ dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY); -+ if (IS_ERR(dev->desc)) { -+ ubi_err("%s failed to open ubi volume %d_%d", -+ dev->gd->disk_name, dev->ubi_num, dev->vol_id); -+ ret = PTR_ERR(dev->desc); -+ dev->desc = NULL; -+ goto out_unlock; -+ } -+ -+out_done: -+ dev->refcnt++; -+ mutex_unlock(&dev->dev_mutex); -+ return 0; -+ -+out_unlock: -+ mutex_unlock(&dev->dev_mutex); -+ return ret; -+} -+ -+static void ubiblock_release(struct gendisk *gd, fmode_t mode) -+{ -+ struct ubiblock *dev = gd->private_data; -+ -+ mutex_lock(&dev->dev_mutex); -+ dev->refcnt--; -+ if (dev->refcnt == 0) { -+ ubi_close_volume(dev->desc); -+ dev->desc = NULL; -+ } -+ mutex_unlock(&dev->dev_mutex); -+} -+ -+static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo) -+{ -+ /* Some tools might require this information */ -+ geo->heads = 1; -+ geo->cylinders = 1; -+ geo->sectors = get_capacity(bdev->bd_disk); -+ geo->start = 0; -+ return 0; -+} -+ -+static const struct block_device_operations ubiblock_ops = { -+ .owner = THIS_MODULE, -+ .open = ubiblock_open, -+ .release = ubiblock_release, -+ .getgeo = ubiblock_getgeo, -+}; -+ -+int ubiblock_add(struct ubi_volume_info *vi) -+{ -+ struct ubiblock *dev; -+ struct gendisk *gd; -+ int disk_capacity; -+ int ret; -+ -+ /* Check that the volume isn't already handled */ -+ mutex_lock(&devices_mutex); -+ if (find_dev_nolock(vi->ubi_num, vi->vol_id)) { -+ mutex_unlock(&devices_mutex); -+ return -EEXIST; -+ } -+ mutex_unlock(&devices_mutex); -+ -+ dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL); -+ if (!dev) -+ return -ENOMEM; -+ -+ mutex_init(&dev->dev_mutex); -+ -+ dev->ubi_num = vi->ubi_num; -+ dev->vol_id = vi->vol_id; -+ dev->leb_size = vi->usable_leb_size; -+ -+ /* Initialize the gendisk of this ubiblock device */ -+ gd = alloc_disk(1); -+ if (!gd) { -+ ubi_err("block: alloc_disk failed"); -+ ret = -ENODEV; -+ goto out_free_dev; -+ } -+ -+ gd->fops = &ubiblock_ops; -+ gd->major = ubiblock_major; -+ gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id; -+ gd->private_data = dev; -+ sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); -+ disk_capacity = (vi->size * vi->usable_leb_size) >> 9; -+ set_capacity(gd, disk_capacity); -+ dev->gd = gd; -+ -+ spin_lock_init(&dev->queue_lock); -+ dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock); -+ if (!dev->rq) { -+ ubi_err("block: blk_init_queue failed"); -+ ret = -ENODEV; -+ goto out_put_disk; -+ } -+ -+ dev->rq->queuedata = dev; -+ dev->gd->queue = dev->rq; -+ -+ /* -+ * Create one workqueue per volume (per registered block device). -+ * Rembember workqueues are cheap, they're not threads. -+ */ -+ dev->wq = alloc_workqueue(gd->disk_name, 0, 0); -+ if (!dev->wq) -+ goto out_free_queue; -+ INIT_WORK(&dev->work, ubiblock_do_work); -+ -+ mutex_lock(&devices_mutex); -+ list_add_tail(&dev->list, &ubiblock_devices); -+ mutex_unlock(&devices_mutex); -+ -+ /* Must be the last step: anyone can call file ops from now on */ -+ add_disk(dev->gd); -+ ubi_msg("%s created from ubi%d:%d(%s)", -+ dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name); -+ return 0; -+ -+out_free_queue: -+ blk_cleanup_queue(dev->rq); -+out_put_disk: -+ put_disk(dev->gd); -+out_free_dev: -+ kfree(dev); -+ -+ return ret; -+} -+ -+static void ubiblock_cleanup(struct ubiblock *dev) -+{ -+ del_gendisk(dev->gd); -+ blk_cleanup_queue(dev->rq); -+ ubi_msg("%s released", dev->gd->disk_name); -+ put_disk(dev->gd); -+} -+ -+int ubiblock_del(struct ubi_volume_info *vi) -+{ -+ struct ubiblock *dev; -+ -+ mutex_lock(&devices_mutex); -+ dev = find_dev_nolock(vi->ubi_num, vi->vol_id); -+ if (!dev) { -+ mutex_unlock(&devices_mutex); -+ return -ENODEV; -+ } -+ -+ /* Found a device, let's lock it so we can check if it's busy */ -+ mutex_lock(&dev->dev_mutex); -+ if (dev->refcnt > 0) { -+ mutex_unlock(&dev->dev_mutex); -+ mutex_unlock(&devices_mutex); -+ return -EBUSY; -+ } -+ -+ /* Remove from device list */ -+ list_del(&dev->list); -+ mutex_unlock(&devices_mutex); -+ -+ /* Flush pending work and stop this workqueue */ -+ destroy_workqueue(dev->wq); -+ -+ ubiblock_cleanup(dev); -+ mutex_unlock(&dev->dev_mutex); -+ kfree(dev); -+ return 0; -+} -+ -+static void ubiblock_resize(struct ubi_volume_info *vi) -+{ -+ struct ubiblock *dev; -+ int disk_capacity; -+ -+ /* -+ * Need to lock the device list until we stop using the device, -+ * otherwise the device struct might get released in 'ubiblock_del()'. -+ */ -+ mutex_lock(&devices_mutex); -+ dev = find_dev_nolock(vi->ubi_num, vi->vol_id); -+ if (!dev) { -+ mutex_unlock(&devices_mutex); -+ return; -+ } -+ -+ mutex_lock(&dev->dev_mutex); -+ disk_capacity = (vi->size * vi->usable_leb_size) >> 9; -+ set_capacity(dev->gd, disk_capacity); -+ ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size); -+ mutex_unlock(&dev->dev_mutex); -+ mutex_unlock(&devices_mutex); -+} -+ -+static int ubiblock_notify(struct notifier_block *nb, -+ unsigned long notification_type, void *ns_ptr) -+{ -+ struct ubi_notification *nt = ns_ptr; -+ -+ switch (notification_type) { -+ case UBI_VOLUME_ADDED: -+ /* -+ * We want to enforce explicit block device attaching for -+ * volumes, so when a volume is added we do nothing. -+ */ -+ break; -+ case UBI_VOLUME_REMOVED: -+ ubiblock_del(&nt->vi); -+ break; -+ case UBI_VOLUME_RESIZED: -+ ubiblock_resize(&nt->vi); -+ break; -+ default: -+ break; -+ } -+ return NOTIFY_OK; -+} -+ -+static struct notifier_block ubiblock_notifier = { -+ .notifier_call = ubiblock_notify, -+}; -+ -+static struct ubi_volume_desc * __init -+open_volume_desc(const char *name, int ubi_num, int vol_id) -+{ -+ if (ubi_num == -1) -+ /* No ubi num, name must be a vol device path */ -+ return ubi_open_volume_path(name, UBI_READONLY); -+ else if (vol_id == -1) -+ /* No vol_id, must be vol_name */ -+ return ubi_open_volume_nm(ubi_num, name, UBI_READONLY); -+ else -+ return ubi_open_volume(ubi_num, vol_id, UBI_READONLY); -+} -+ -+static int __init ubiblock_attach_from_param(void) -+{ -+ int i, ret; -+ struct ubiblock_param *p; -+ struct ubi_volume_desc *desc; -+ struct ubi_volume_info vi; -+ -+ for (i = 0; i < ubiblock_devs; i++) { -+ p = &ubiblock_param[i]; -+ -+ desc = open_volume_desc(p->name, p->ubi_num, p->vol_id); -+ if (IS_ERR(desc)) { -+ ubi_err("block: can't open volume, err=%ld\n", -+ PTR_ERR(desc)); -+ ret = PTR_ERR(desc); -+ break; -+ } -+ -+ ubi_get_volume_info(desc, &vi); -+ ubi_close_volume(desc); -+ -+ ret = ubiblock_add(&vi); -+ if (ret) { -+ ubi_err("block: can't add '%s' volume, err=%d\n", -+ vi.name, ret); -+ break; -+ } -+ } -+ return ret; -+} -+ -+static void ubiblock_detach_all(void) -+{ -+ struct ubiblock *next; -+ struct ubiblock *dev; -+ -+ list_for_each_entry_safe(dev, next, &ubiblock_devices, list) { -+ /* Flush pending work and stop workqueue */ -+ destroy_workqueue(dev->wq); -+ /* The module is being forcefully removed */ -+ WARN_ON(dev->desc); -+ /* Remove from device list */ -+ list_del(&dev->list); -+ ubiblock_cleanup(dev); -+ kfree(dev); -+ } -+} -+ -+int __init ubiblock_init(void) -+{ -+ int ret; -+ -+ ubiblock_major = register_blkdev(0, "ubiblock"); -+ if (ubiblock_major < 0) -+ return ubiblock_major; -+ -+ /* Attach block devices from 'block=' module param */ -+ ret = ubiblock_attach_from_param(); -+ if (ret) -+ goto err_detach; -+ -+ /* -+ * Block devices needs to be attached to volumes explicitly -+ * upon user request. So we ignore existing volumes. -+ */ -+ ret = ubi_register_volume_notifier(&ubiblock_notifier, 1); -+ if (ret) -+ goto err_unreg; -+ return 0; -+ -+err_unreg: -+ unregister_blkdev(ubiblock_major, "ubiblock"); -+err_detach: -+ ubiblock_detach_all(); -+ return ret; -+} -+ -+void __exit ubiblock_exit(void) -+{ -+ ubi_unregister_volume_notifier(&ubiblock_notifier); -+ ubiblock_detach_all(); -+ unregister_blkdev(ubiblock_major, "ubiblock"); -+} ---- a/drivers/mtd/ubi/build.c -+++ b/drivers/mtd/ubi/build.c -@@ -1290,6 +1290,15 @@ static int __init ubi_init(void) - } - } - -+ err = ubiblock_init(); -+ if (err) { -+ ubi_err("block: cannot initialize, error %d", err); -+ -+ /* See comment above re-ubi_is_module(). */ -+ if (ubi_is_module()) -+ goto out_detach; -+ } -+ - return 0; - - out_detach: -@@ -1318,6 +1327,8 @@ static void __exit ubi_exit(void) - { - int i; - -+ ubiblock_exit(); -+ - for (i = 0; i < UBI_MAX_DEVICES; i++) - if (ubi_devices[i]) { - mutex_lock(&ubi_devices_mutex); ---- a/drivers/mtd/ubi/cdev.c -+++ b/drivers/mtd/ubi/cdev.c -@@ -585,6 +585,26 @@ static long vol_cdev_ioctl(struct file * - break; - } - -+ /* Attach a block device to an UBI volume */ -+ case UBI_IOCVOLATTBLK: -+ { -+ struct ubi_volume_info vi; -+ -+ ubi_get_volume_info(desc, &vi); -+ err = ubiblock_add(&vi); -+ break; -+ } -+ -+ /* Dettach a block device from an UBI volume */ -+ case UBI_IOCVOLDETBLK: -+ { -+ struct ubi_volume_info vi; -+ -+ ubi_get_volume_info(desc, &vi); -+ err = ubiblock_del(&vi); -+ break; -+ } -+ - default: - err = -ENOTTY; - break; ---- a/drivers/mtd/ubi/ubi.h -+++ b/drivers/mtd/ubi/ubi.h -@@ -864,6 +864,20 @@ int ubi_update_fastmap(struct ubi_device - int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, - int fm_anchor); - -+/* block.c */ -+#ifdef CONFIG_MTD_UBI_BLOCK -+int ubiblock_init(void); -+void ubiblock_exit(void); -+int ubiblock_add(struct ubi_volume_info *vi); -+int ubiblock_del(struct ubi_volume_info *vi); -+#else -+static inline int ubiblock_init(void) { return 0; } -+static inline void ubiblock_exit(void) {} -+static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; } -+static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; } -+#endif -+ -+ - /* - * ubi_rb_for_each_entry - walk an RB-tree. - * @rb: a pointer to type 'struct rb_node' to use as a loop counter ---- a/include/uapi/mtd/ubi-user.h -+++ b/include/uapi/mtd/ubi-user.h -@@ -134,6 +134,13 @@ - * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be - * passed. The object describes which property should be set, and to which value - * it should be set. -+ * -+ * Block devices on UBI volumes -+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * -+ * To attach or detach a block device from an UBI volume the %UBI_IOCVOLATTBLK -+ * and %UBI_IOCVOLDETBLK ioctl commands should be used, respectively. -+ * These commands take no arguments. - */ - - /* -@@ -188,6 +195,10 @@ - /* Set an UBI volume property */ - #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \ - struct ubi_set_vol_prop_req) -+/* Attach a block device to an UBI volume */ -+#define UBI_IOCVOLATTBLK _IO(UBI_VOL_IOC_MAGIC, 7) -+/* Detach a block device from an UBI volume */ -+#define UBI_IOCVOLDETBLK _IO(UBI_VOL_IOC_MAGIC, 8) - - /* Maximum MTD device name length supported by UBI */ - #define MAX_UBI_MTD_NAME_LEN 127 diff --git a/target/linux/generic/patches-3.10/041-UBI-block-do-not-use-term-attach.patch b/target/linux/generic/patches-3.10/041-UBI-block-do-not-use-term-attach.patch deleted file mode 100644 index 08b38dae53..0000000000 --- a/target/linux/generic/patches-3.10/041-UBI-block-do-not-use-term-attach.patch +++ /dev/null @@ -1,185 +0,0 @@ -From 4d283ee2517303afa54ad6cbd9342a2f748cf509 Mon Sep 17 00:00:00 2001 -From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> -Date: Tue, 4 Mar 2014 12:00:26 +0200 -Subject: [PATCH] UBI: block: do not use term "attach" - -We already use term attach/detach for UBI->MTD relations, let's not use this -for UBI->ubiblock relations to avoid confusion. Just use 'create' and 'remove' -instead. E.g., "create a R/O block device on top of a UBI volume". - -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/block.c | 39 ++++++++++++++++++++------------------- - drivers/mtd/ubi/cdev.c | 4 ++-- - drivers/mtd/ubi/ubi.h | 14 ++++++++++---- - 3 files changed, 32 insertions(+), 25 deletions(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -29,10 +29,10 @@ - * - * LEB number = addressed byte / LEB size - * -- * This feature is compiled in the UBI core, and adds a new 'block' parameter -- * to allow early block device attaching. Runtime block attach/detach for UBI -- * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and -- * UBI_IOCVOLDETBLK. -+ * This feature is compiled in the UBI core, and adds a 'block' parameter -+ * to allow early creation of block devices on top of UBI volumes. Runtime -+ * block creation/removal for UBI volumes is provided through two UBI ioctls: -+ * UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK. - */ - - #include <linux/module.h> -@@ -374,7 +374,7 @@ static const struct block_device_operati - .getgeo = ubiblock_getgeo, - }; - --int ubiblock_add(struct ubi_volume_info *vi) -+int ubiblock_create(struct ubi_volume_info *vi) - { - struct ubiblock *dev; - struct gendisk *gd; -@@ -464,7 +464,7 @@ static void ubiblock_cleanup(struct ubib - put_disk(dev->gd); - } - --int ubiblock_del(struct ubi_volume_info *vi) -+int ubiblock_remove(struct ubi_volume_info *vi) - { - struct ubiblock *dev; - -@@ -503,7 +503,8 @@ static void ubiblock_resize(struct ubi_v - - /* - * Need to lock the device list until we stop using the device, -- * otherwise the device struct might get released in 'ubiblock_del()'. -+ * otherwise the device struct might get released in -+ * 'ubiblock_remove()'. - */ - mutex_lock(&devices_mutex); - dev = find_dev_nolock(vi->ubi_num, vi->vol_id); -@@ -528,12 +529,12 @@ static int ubiblock_notify(struct notifi - switch (notification_type) { - case UBI_VOLUME_ADDED: - /* -- * We want to enforce explicit block device attaching for -+ * We want to enforce explicit block device creation for - * volumes, so when a volume is added we do nothing. - */ - break; - case UBI_VOLUME_REMOVED: -- ubiblock_del(&nt->vi); -+ ubiblock_remove(&nt->vi); - break; - case UBI_VOLUME_RESIZED: - ubiblock_resize(&nt->vi); -@@ -561,7 +562,7 @@ open_volume_desc(const char *name, int u - return ubi_open_volume(ubi_num, vol_id, UBI_READONLY); - } - --static int __init ubiblock_attach_from_param(void) -+static int __init ubiblock_create_from_param(void) - { - int i, ret; - struct ubiblock_param *p; -@@ -582,7 +583,7 @@ static int __init ubiblock_attach_from_p - ubi_get_volume_info(desc, &vi); - ubi_close_volume(desc); - -- ret = ubiblock_add(&vi); -+ ret = ubiblock_create(&vi); - if (ret) { - ubi_err("block: can't add '%s' volume, err=%d\n", - vi.name, ret); -@@ -592,7 +593,7 @@ static int __init ubiblock_attach_from_p - return ret; - } - --static void ubiblock_detach_all(void) -+static void ubiblock_remove_all(void) - { - struct ubiblock *next; - struct ubiblock *dev; -@@ -618,13 +619,13 @@ int __init ubiblock_init(void) - return ubiblock_major; - - /* Attach block devices from 'block=' module param */ -- ret = ubiblock_attach_from_param(); -+ ret = ubiblock_create_from_param(); - if (ret) -- goto err_detach; -+ goto err_remove; - - /* -- * Block devices needs to be attached to volumes explicitly -- * upon user request. So we ignore existing volumes. -+ * Block devices are only created upon user requests, so we ignore -+ * existing volumes. - */ - ret = ubi_register_volume_notifier(&ubiblock_notifier, 1); - if (ret) -@@ -633,14 +634,14 @@ int __init ubiblock_init(void) - - err_unreg: - unregister_blkdev(ubiblock_major, "ubiblock"); --err_detach: -- ubiblock_detach_all(); -+err_remove: -+ ubiblock_remove_all(); - return ret; - } - - void __exit ubiblock_exit(void) - { - ubi_unregister_volume_notifier(&ubiblock_notifier); -- ubiblock_detach_all(); -+ ubiblock_remove_all(); - unregister_blkdev(ubiblock_major, "ubiblock"); - } ---- a/drivers/mtd/ubi/cdev.c -+++ b/drivers/mtd/ubi/cdev.c -@@ -591,7 +591,7 @@ static long vol_cdev_ioctl(struct file * - struct ubi_volume_info vi; - - ubi_get_volume_info(desc, &vi); -- err = ubiblock_add(&vi); -+ err = ubiblock_create(&vi); - break; - } - -@@ -601,7 +601,7 @@ static long vol_cdev_ioctl(struct file * - struct ubi_volume_info vi; - - ubi_get_volume_info(desc, &vi); -- err = ubiblock_del(&vi); -+ err = ubiblock_remove(&vi); - break; - } - ---- a/drivers/mtd/ubi/ubi.h -+++ b/drivers/mtd/ubi/ubi.h -@@ -868,13 +868,19 @@ int ubi_scan_fastmap(struct ubi_device * - #ifdef CONFIG_MTD_UBI_BLOCK - int ubiblock_init(void); - void ubiblock_exit(void); --int ubiblock_add(struct ubi_volume_info *vi); --int ubiblock_del(struct ubi_volume_info *vi); -+int ubiblock_create(struct ubi_volume_info *vi); -+int ubiblock_remove(struct ubi_volume_info *vi); - #else - static inline int ubiblock_init(void) { return 0; } - static inline void ubiblock_exit(void) {} --static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; } --static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; } -+static inline int ubiblock_create(struct ubi_volume_info *vi) -+{ -+ return -ENOTTY; -+} -+static inline int ubiblock_remove(struct ubi_volume_info *vi) -+{ -+ return -ENOTTY; -+} - #endif - - diff --git a/target/linux/generic/patches-3.10/042-UBI-block-Mark-init-only-symbol-as-__initdata.patch b/target/linux/generic/patches-3.10/042-UBI-block-Mark-init-only-symbol-as-__initdata.patch deleted file mode 100644 index 54660992c2..0000000000 --- a/target/linux/generic/patches-3.10/042-UBI-block-Mark-init-only-symbol-as-__initdata.patch +++ /dev/null @@ -1,37 +0,0 @@ -From ca2b722d1ab5bc3ffc34b5995248968cd8a7cb6f Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Date: Mon, 3 Mar 2014 13:42:38 -0300 -Subject: [PATCH] UBI: block: Mark init-only symbol as __initdata - -ubiblock_param_ops should be marked as __init as it's only used to set -a driver parameter on insertion time. This commit fixes the following: - - WARNING: drivers/mtd/built-in.o(.text+0x653ac): Section mismatch in - reference from the variable ubiblock_param_ops to the function - .init.text:ubiblock_set_param() - - The function ubiblock_param_ops() references the function __init - ubiblock_set_param(). This is often because ubiblock_param_ops lacks a - __init annotation or the annotation of ubiblock_set_param is wrong. - -Given gcc errors if the struct is marked const __initdata, this commit -drops the const mark from it. - -Reported-by: kbuild test robot <fengguang.wu@intel.com> -Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/block.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -156,7 +156,7 @@ static int __init ubiblock_set_param(con - return 0; - } - --static const struct kernel_param_ops ubiblock_param_ops = { -+static struct kernel_param_ops ubiblock_param_ops __initdata = { - .set = ubiblock_set_param, - }; - module_param_cb(block, &ubiblock_param_ops, NULL, 0); diff --git a/target/linux/generic/patches-3.10/043-UBI-block-Use-u64-for-the-64-bit-dividend.patch b/target/linux/generic/patches-3.10/043-UBI-block-Use-u64-for-the-64-bit-dividend.patch deleted file mode 100644 index 260927d024..0000000000 --- a/target/linux/generic/patches-3.10/043-UBI-block-Use-u64-for-the-64-bit-dividend.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 9981e14ab2f7c6a4d2bb45e51a6371964919837d Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Date: Mon, 3 Mar 2014 13:42:39 -0300 -Subject: [PATCH] UBI: block: Use 'u64' for the 64-bit dividend - -Fixes the following warning on ARCH=avr32: - - drivers/mtd/ubi/block.c: In function 'ubiblock_read': - drivers/mtd/ubi/block.c:207: warning: comparison of distinct pointer types lacks a cast - -Reported-by: kbuild test robot <fengguang.wu@intel.com> -Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/block.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -201,7 +201,7 @@ static int ubiblock_read(struct ubiblock - int ret, leb, offset; - int bytes_left = len; - int to_read = len; -- loff_t pos = sec << 9; -+ u64 pos = sec << 9; - - /* Get LEB:offset address to read from */ - offset = do_div(pos, dev->leb_size); diff --git a/target/linux/generic/patches-3.10/044-UBI-rename-block-device-ioctls.patch b/target/linux/generic/patches-3.10/044-UBI-rename-block-device-ioctls.patch deleted file mode 100644 index c784dceb29..0000000000 --- a/target/linux/generic/patches-3.10/044-UBI-rename-block-device-ioctls.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 8af871887fcba470ff9265c65cff7d14d9e0e3f9 Mon Sep 17 00:00:00 2001 -From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> -Date: Wed, 5 Mar 2014 13:01:56 +0200 -Subject: [PATCH] UBI: rename block device ioctls - -Rename the UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK to UBI_IOCVOLCRBLK and -UBI_IOCVOLRMBLK, because we do not use terms "attach" and "detach" for the R/O -block devices on top of UBI volumes. Instead, we use terms "create" and -"remove". This patch also amends the related commentaries. - -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> -Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> ---- - drivers/mtd/ubi/block.c | 2 +- - drivers/mtd/ubi/cdev.c | 8 ++++---- - include/uapi/mtd/ubi-user.h | 14 +++++++------- - 3 files changed, 12 insertions(+), 12 deletions(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -32,7 +32,7 @@ - * This feature is compiled in the UBI core, and adds a 'block' parameter - * to allow early creation of block devices on top of UBI volumes. Runtime - * block creation/removal for UBI volumes is provided through two UBI ioctls: -- * UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK. -+ * UBI_IOCVOLCRBLK and UBI_IOCVOLRMBLK. - */ - - #include <linux/module.h> ---- a/drivers/mtd/ubi/cdev.c -+++ b/drivers/mtd/ubi/cdev.c -@@ -585,8 +585,8 @@ static long vol_cdev_ioctl(struct file * - break; - } - -- /* Attach a block device to an UBI volume */ -- case UBI_IOCVOLATTBLK: -+ /* Create a R/O block device on top of the UBI volume */ -+ case UBI_IOCVOLCRBLK: - { - struct ubi_volume_info vi; - -@@ -595,8 +595,8 @@ static long vol_cdev_ioctl(struct file * - break; - } - -- /* Dettach a block device from an UBI volume */ -- case UBI_IOCVOLDETBLK: -+ /* Remove the R/O block device */ -+ case UBI_IOCVOLRMBLK: - { - struct ubi_volume_info vi; - ---- a/include/uapi/mtd/ubi-user.h -+++ b/include/uapi/mtd/ubi-user.h -@@ -138,9 +138,9 @@ - * Block devices on UBI volumes - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * -- * To attach or detach a block device from an UBI volume the %UBI_IOCVOLATTBLK -- * and %UBI_IOCVOLDETBLK ioctl commands should be used, respectively. -- * These commands take no arguments. -+ * To create or remove a R/O block device on top of an UBI volume the -+ * %UBI_IOCVOLCRBLK and %UBI_IOCVOLRMBLK ioctl commands should be used, -+ * respectively. These commands take no arguments. - */ - - /* -@@ -195,10 +195,10 @@ - /* Set an UBI volume property */ - #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \ - struct ubi_set_vol_prop_req) --/* Attach a block device to an UBI volume */ --#define UBI_IOCVOLATTBLK _IO(UBI_VOL_IOC_MAGIC, 7) --/* Detach a block device from an UBI volume */ --#define UBI_IOCVOLDETBLK _IO(UBI_VOL_IOC_MAGIC, 8) -+/* Create a R/O block device on top of an UBI volume */ -+#define UBI_IOCVOLCRBLK _IO(UBI_VOL_IOC_MAGIC, 7) -+/* Remove the R/O block device */ -+#define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8) - - /* Maximum MTD device name length supported by UBI */ - #define MAX_UBI_MTD_NAME_LEN 127 diff --git a/target/linux/generic/patches-3.10/045-UBI-block-Remove-__initdata-from-ubiblock_param_ops.patch b/target/linux/generic/patches-3.10/045-UBI-block-Remove-__initdata-from-ubiblock_param_ops.patch deleted file mode 100644 index badfcb0afe..0000000000 --- a/target/linux/generic/patches-3.10/045-UBI-block-Remove-__initdata-from-ubiblock_param_ops.patch +++ /dev/null @@ -1,30 +0,0 @@ -From d56030ac25d383218045c5d87e98e0494d6af3ad Mon Sep 17 00:00:00 2001 -From: Richard Weinberger <richard@nod.at> -Date: Wed, 19 Mar 2014 11:43:22 +0100 -Subject: [PATCH] UBI: block: Remove __initdata from ubiblock_param_ops - -You cannot mark these parameters as __initdata. -Otherwise the data is gone upon module exit. - -Fixes: -[ 172.045465] BUG: unable to handle kernel paging request at ffffffffa001db38 -[ 172.046020] IP: [<ffffffff81067aa4>] destroy_params+0x24/0x50 - -Signed-off-by: Richard Weinberger <richard@nod.at> -Acked-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/block.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -156,7 +156,7 @@ static int __init ubiblock_set_param(con - return 0; - } - --static struct kernel_param_ops ubiblock_param_ops __initdata = { -+static struct kernel_param_ops ubiblock_param_ops = { - .set = ubiblock_set_param, - }; - module_param_cb(block, &ubiblock_param_ops, NULL, 0); diff --git a/target/linux/generic/patches-3.10/046-UBI-avoid-workqueue-format-string-leak.patch b/target/linux/generic/patches-3.10/046-UBI-avoid-workqueue-format-string-leak.patch deleted file mode 100644 index 41ef6b8499..0000000000 --- a/target/linux/generic/patches-3.10/046-UBI-avoid-workqueue-format-string-leak.patch +++ /dev/null @@ -1,25 +0,0 @@ -From bebfef150e0b8fa68704cddacf05b8c26462d565 Mon Sep 17 00:00:00 2001 -From: Kees Cook <keescook@chromium.org> -Date: Mon, 7 Apr 2014 21:44:07 -0700 -Subject: [PATCH] UBI: avoid workqueue format string leak - -When building the name for the workqueue thread, make sure a format -string cannot leak in from the disk name. - -Signed-off-by: Kees Cook <keescook@chromium.org> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - drivers/mtd/ubi/block.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -431,7 +431,7 @@ int ubiblock_create(struct ubi_volume_in - * Create one workqueue per volume (per registered block device). - * Rembember workqueues are cheap, they're not threads. - */ -- dev->wq = alloc_workqueue(gd->disk_name, 0, 0); -+ dev->wq = alloc_workqueue("%s", 0, 0, gd->disk_name); - if (!dev->wq) - goto out_free_queue; - INIT_WORK(&dev->work, ubiblock_do_work); diff --git a/target/linux/generic/patches-3.10/047-UBI-make-UBI_IOCVOLCRBLK-take-a-parameter-for-future.patch b/target/linux/generic/patches-3.10/047-UBI-make-UBI_IOCVOLCRBLK-take-a-parameter-for-future.patch deleted file mode 100644 index e7cba446f3..0000000000 --- a/target/linux/generic/patches-3.10/047-UBI-make-UBI_IOCVOLCRBLK-take-a-parameter-for-future.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 463c5eedb4a13b9aa91f05498a0f2c20bd03f8c4 Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Date: Wed, 5 Mar 2014 11:16:14 -0300 -Subject: [PATCH] UBI: make UBI_IOCVOLCRBLK take a parameter for future usage - -In order to allow a future ioctl parameter, such as a creation flag, -we change the UBI_IOCVOLCRBLK so it accepts a struct ubi_blkcreate_req. -For the time being the structure is not in use, but fully reserved. - -This ABI change is still possible and harmless, because the ioctl has just -been introduced and there's no userspace program which uses it. - -Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> -Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> ---- - include/uapi/mtd/ubi-user.h | 19 +++++++++++++++---- - 1 file changed, 15 insertions(+), 4 deletions(-) - ---- a/include/uapi/mtd/ubi-user.h -+++ b/include/uapi/mtd/ubi-user.h -@@ -138,9 +138,12 @@ - * Block devices on UBI volumes - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * -- * To create or remove a R/O block device on top of an UBI volume the -- * %UBI_IOCVOLCRBLK and %UBI_IOCVOLRMBLK ioctl commands should be used, -- * respectively. These commands take no arguments. -+ * To create a R/O block device on top of an UBI volume the %UBI_IOCVOLCRBLK -+ * should be used. A pointer to a &struct ubi_blkcreate_req object is expected -+ * to be passed, which is not used and reserved for future usage. -+ * -+ * Conversely, to remove a block device the %UBI_IOCVOLRMBLK should be used, -+ * which takes no arguments. - */ - - /* -@@ -196,7 +199,7 @@ - #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \ - struct ubi_set_vol_prop_req) - /* Create a R/O block device on top of an UBI volume */ --#define UBI_IOCVOLCRBLK _IO(UBI_VOL_IOC_MAGIC, 7) -+#define UBI_IOCVOLCRBLK _IOW(UBI_VOL_IOC_MAGIC, 7, struct ubi_blkcreate_req) - /* Remove the R/O block device */ - #define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8) - -@@ -428,4 +431,12 @@ struct ubi_set_vol_prop_req { - __u64 value; - } __packed; - -+/** -+ * struct ubi_blkcreate_req - a data structure used in block creation requests. -+ * @padding: reserved for future, not used, has to be zeroed -+ */ -+struct ubi_blkcreate_req { -+ __s8 padding[128]; -+} __packed; -+ - #endif /* __UBI_USER_H__ */ diff --git a/target/linux/generic/patches-3.10/060-hso_devices.patch b/target/linux/generic/patches-3.10/060-hso_devices.patch deleted file mode 100644 index 376abfbee4..0000000000 --- a/target/linux/generic/patches-3.10/060-hso_devices.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/drivers/net/usb/hso.c -+++ b/drivers/net/usb/hso.c -@@ -468,8 +468,10 @@ static const struct usb_device_id hso_id - {USB_DEVICE(0x0af0, 0x8400)}, - {USB_DEVICE(0x0af0, 0x8600)}, - {USB_DEVICE(0x0af0, 0x8800)}, -- {USB_DEVICE(0x0af0, 0x8900)}, -- {USB_DEVICE(0x0af0, 0x9000)}, -+ {USB_DEVICE(0x0af0, 0x8900)}, /* GTM 67xx */ -+ {USB_DEVICE(0x0af0, 0x9000)}, /* GTM 66xx */ -+ {USB_DEVICE(0x0af0, 0x9200)}, /* GTM 67xxWFS */ -+ {USB_DEVICE(0x0af0, 0x9300)}, /* GTM 66xxWFS */ - {USB_DEVICE(0x0af0, 0xd035)}, - {USB_DEVICE(0x0af0, 0xd055)}, - {USB_DEVICE(0x0af0, 0xd155)}, ---- a/drivers/usb/storage/unusual_devs.h -+++ b/drivers/usb/storage/unusual_devs.h -@@ -1304,6 +1304,18 @@ UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0 - USB_SC_DEVICE, USB_PR_DEVICE, NULL, - 0 ), - -+UNUSUAL_DEV( 0x0af0, 0x9200, 0x0000, 0x0000, -+ "Option", -+ "Globetrotter 67xxWFS SD-Card", -+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, -+ 0 ), -+ -+UNUSUAL_DEV( 0x0af0, 0x9300, 0x0000, 0x0000, -+ "Option", -+ "Globetrotter 66xxWFS SD-Card", -+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, -+ 0 ), -+ - UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000, - "Option", - "GI 070x SD-Card", diff --git a/target/linux/generic/patches-3.10/061-arm_xz_decompressor_build_fix.patch b/target/linux/generic/patches-3.10/061-arm_xz_decompressor_build_fix.patch deleted file mode 100644 index e69ca259a6..0000000000 --- a/target/linux/generic/patches-3.10/061-arm_xz_decompressor_build_fix.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/arch/arm/boot/compressed/decompress.c -+++ b/arch/arm/boot/compressed/decompress.c -@@ -48,6 +48,7 @@ extern char * strstr(const char * s1, co - #ifdef CONFIG_KERNEL_XZ - #define memmove memmove - #define memcpy memcpy -+extern char * strstr(const char *, const char *); - #include "../../../../lib/decompress_unxz.c" - #endif - diff --git a/target/linux/generic/patches-3.10/062-mips_decompressor_memcpy_memset_redefinition.patch b/target/linux/generic/patches-3.10/062-mips_decompressor_memcpy_memset_redefinition.patch deleted file mode 100644 index 4a9a714fb4..0000000000 --- a/target/linux/generic/patches-3.10/062-mips_decompressor_memcpy_memset_redefinition.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/arch/mips/boot/compressed/decompress.c -+++ b/arch/mips/boot/compressed/decompress.c -@@ -45,6 +45,7 @@ void error(char *x) - #define STATIC static - - #ifdef CONFIG_KERNEL_GZIP -+#undef memcpy - void *memcpy(void *dest, const void *src, size_t n) - { - int i; -@@ -59,6 +60,7 @@ void *memcpy(void *dest, const void *src - #endif - - #ifdef CONFIG_KERNEL_BZIP2 -+#undef memset - void *memset(void *s, int c, size_t n) - { - int i; diff --git a/target/linux/generic/patches-3.10/063-arm-fix-fiq-vivt.patch b/target/linux/generic/patches-3.10/063-arm-fix-fiq-vivt.patch deleted file mode 100644 index 8c2d3da8bd..0000000000 --- a/target/linux/generic/patches-3.10/063-arm-fix-fiq-vivt.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 2ba85e7af4c639d933c9a87a6d7363f2983d5ada Mon Sep 17 00:00:00 2001 -From: Russell King <rmk+kernel@arm.linux.org.uk> -Date: Thu, 08 Aug 2013 10:51:21 +0000 -Subject: ARM: Fix FIQ code on VIVT CPUs - -Aaro Koskinen reports the following oops: -Installing fiq handler from c001b110, length 0x164 -Unable to handle kernel paging request at virtual address ffff1224 -pgd = c0004000 -[ffff1224] *pgd=00000000, *pte=11fff0cb, *ppte=11fff00a -... -[<c0013154>] (set_fiq_handler+0x0/0x6c) from [<c0365d38>] (ams_delta_init_fiq+0xa8/0x160) - r6:00000164 r5:c001b110 r4:00000000 r3:fefecb4c -[<c0365c90>] (ams_delta_init_fiq+0x0/0x160) from [<c0365b14>] (ams_delta_init+0xd4/0x114) - r6:00000000 r5:fffece10 r4:c037a9e0 -[<c0365a40>] (ams_delta_init+0x0/0x114) from [<c03613b4>] (customize_machine+0x24/0x30) - -This is because the vectors page is now write-protected, and to change -code in there we must write to its original alias. Make that change, -and adjust the cache flushing such that the code will become visible -to the instruction stream on VIVT CPUs. - -Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi> -Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> -Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> ---- -(limited to 'arch/arm/kernel/fiq.c') - ---- a/arch/arm/kernel/fiq.c -+++ b/arch/arm/kernel/fiq.c -@@ -84,17 +84,13 @@ int show_fiq_list(struct seq_file *p, in - - void set_fiq_handler(void *start, unsigned int length) - { --#if defined(CONFIG_CPU_USE_DOMAINS) -- void *base = (void *)0xffff0000; --#else - void *base = vectors_page; --#endif - unsigned offset = FIQ_OFFSET; - - memcpy(base + offset, start, length); -+ if (!cache_is_vipt_nonaliasing()) -+ flush_icache_range(base + offset, offset + length); - flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length); -- if (!vectors_high()) -- flush_icache_range(offset, offset + length); - } - - int claim_fiq(struct fiq_handler *f) diff --git a/target/linux/generic/patches-3.10/065-iio_ad799x_backport_fixes.patch b/target/linux/generic/patches-3.10/065-iio_ad799x_backport_fixes.patch deleted file mode 100644 index 41f88bf586..0000000000 --- a/target/linux/generic/patches-3.10/065-iio_ad799x_backport_fixes.patch +++ /dev/null @@ -1,157 +0,0 @@ -Backport essential fixes from 3.15 - -From Linux 3.10 on this driver required platform data to load, which makes it -unusable in OpenWRT. This commit backports the following fixes: - * Move to regulator framework for scaling - * Set endianness of the ADC to Big endian - * Fix device-removal path -This commit should not be moved to newer kernel versions! - -Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> ---- ---- a/drivers/staging/iio/adc/ad799x_core.c -+++ b/drivers/staging/iio/adc/ad799x_core.c -@@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_de - { - int ret; - struct ad799x_state *st = iio_priv(indio_dev); -- unsigned int scale_uv; - - switch (m) { - case IIO_CHAN_INFO_RAW: -@@ -180,10 +179,12 @@ static int ad799x_read_raw(struct iio_de - RES_MASK(chan->scan_type.realbits); - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: -- scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits; -- *val = scale_uv / 1000; -- *val2 = (scale_uv % 1000) * 1000; -- return IIO_VAL_INT_PLUS_MICRO; -+ ret = regulator_get_voltage(st->vref); -+ if (ret < 0) -+ return ret; -+ *val = ret / 1000; -+ *val2 = chan->scan_type.realbits; -+ return IIO_VAL_FRACTIONAL_LOG2; - } - return -EINVAL; - } -@@ -474,7 +475,13 @@ static const struct iio_info ad7993_4_7_ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .scan_index = (_index), \ -- .scan_type = IIO_ST('u', _realbits, 16, 12 - (_realbits)), \ -+ .scan_type = { \ -+ .sign = 'u', \ -+ .realbits = (_realbits), \ -+ .storagebits = 16, \ -+ .shift = 12 - (_realbits), \ -+ .endianness = IIO_BE, \ -+ }, \ - .event_mask = (_evmask), \ - } - -@@ -584,7 +591,6 @@ static int ad799x_probe(struct i2c_clien - const struct i2c_device_id *id) - { - int ret; -- struct ad799x_platform_data *pdata = client->dev.platform_data; - struct ad799x_state *st; - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); - -@@ -601,17 +607,21 @@ static int ad799x_probe(struct i2c_clien - - /* TODO: Add pdata options for filtering and bit delay */ - -- if (!pdata) -- return -EINVAL; -- -- st->int_vref_mv = pdata->vref_mv; -- -- st->reg = regulator_get(&client->dev, "vcc"); -- if (!IS_ERR(st->reg)) { -- ret = regulator_enable(st->reg); -- if (ret) -- goto error_put_reg; -+ st->reg = devm_regulator_get(&client->dev, "vcc"); -+ if (IS_ERR(st->reg)) -+ return PTR_ERR(st->reg); -+ ret = regulator_enable(st->reg); -+ if (ret) -+ return ret; -+ st->vref = devm_regulator_get(&client->dev, "vref"); -+ if (IS_ERR(st->vref)) { -+ ret = PTR_ERR(st->vref); -+ goto error_disable_reg; - } -+ ret = regulator_enable(st->vref); -+ if (ret) -+ goto error_disable_reg; -+ - st->client = client; - - indio_dev->dev.parent = &client->dev; -@@ -624,7 +634,7 @@ static int ad799x_probe(struct i2c_clien - - ret = ad799x_register_ring_funcs_and_init(indio_dev); - if (ret) -- goto error_disable_reg; -+ goto error_disable_vref; - - if (client->irq > 0) { - ret = request_threaded_irq(client->irq, -@@ -648,12 +658,10 @@ error_free_irq: - free_irq(client->irq, indio_dev); - error_cleanup_ring: - ad799x_ring_cleanup(indio_dev); -+error_disable_vref: -+ regulator_disable(st->vref); - error_disable_reg: -- if (!IS_ERR(st->reg)) -- regulator_disable(st->reg); --error_put_reg: -- if (!IS_ERR(st->reg)) -- regulator_put(st->reg); -+ regulator_disable(st->reg); - iio_device_free(indio_dev); - - return ret; -@@ -669,10 +677,8 @@ static int ad799x_remove(struct i2c_clie - free_irq(client->irq, indio_dev); - - ad799x_ring_cleanup(indio_dev); -- if (!IS_ERR(st->reg)) { -- regulator_disable(st->reg); -- regulator_put(st->reg); -- } -+ regulator_disable(st->vref); -+ regulator_disable(st->reg); - kfree(st->rx_buf); - iio_device_free(indio_dev); - ---- a/drivers/staging/iio/adc/ad799x.h -+++ b/drivers/staging/iio/adc/ad799x.h -@@ -103,7 +103,7 @@ struct ad799x_state { - struct i2c_client *client; - const struct ad799x_chip_info *chip_info; - struct regulator *reg; -- u16 int_vref_mv; -+ struct regulator *vref; - unsigned id; - u16 config; - -@@ -111,14 +111,6 @@ struct ad799x_state { - unsigned int transfer_size; - }; - --/* -- * TODO: struct ad799x_platform_data needs to go into include/linux/iio -- */ -- --struct ad799x_platform_data { -- u16 vref_mv; --}; -- - #ifdef CONFIG_AD799X_RING_BUFFER - int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); - void ad799x_ring_cleanup(struct iio_dev *indio_dev); diff --git a/target/linux/generic/patches-3.10/070-net_bridge_backports.patch b/target/linux/generic/patches-3.10/070-net_bridge_backports.patch deleted file mode 100644 index 48d6eda024..0000000000 --- a/target/linux/generic/patches-3.10/070-net_bridge_backports.patch +++ /dev/null @@ -1,1098 +0,0 @@ -commit f0b4eeced518c632210ef2aea44fc92cc9e86cce -Author: Linus Lüssing <linus.luessing@web.de> -Date: Mon Nov 17 12:20:28 2014 +0100 - - bridge: fix netfilter/NF_BR_LOCAL_OUT for own, locally generated queries - - Ebtables on the OUTPUT chain (NF_BR_LOCAL_OUT) would not work as expected - for both locally generated IGMP and MLD queries. The IP header specific - filter options are off by 14 Bytes for netfilter (actual output on - interfaces is fine). - - NF_HOOK() expects the skb->data to point to the IP header, not the - ethernet one (while dev_queue_xmit() does not). Luckily there is an - br_dev_queue_push_xmit() helper function already - let's just use that. - - Introduced by eb1d16414339a6e113d89e2cca2556005d7ce919 - ("bridge: Add core IGMP snooping support") - - Ebtables example: - - $ ebtables -I OUTPUT -p IPv6 -o eth1 --logical-out br0 \ - --log --log-level 6 --log-ip6 --log-prefix="~EBT: " -j DROP - - before (broken): - - ~EBT: IN= OUT=eth1 MAC source = 02:04:64:a4:39:c2 \ - MAC dest = 33:33:00:00:00:01 proto = 0x86dd IPv6 \ - SRC=64a4:39c2:86dd:6000:0000:0020:0001:fe80 IPv6 \ - DST=0000:0000:0000:0004:64ff:fea4:39c2:ff02, \ - IPv6 priority=0x3, Next Header=2 - - after (working): - - ~EBT: IN= OUT=eth1 MAC source = 02:04:64:a4:39:c2 \ - MAC dest = 33:33:00:00:00:01 proto = 0x86dd IPv6 \ - SRC=fe80:0000:0000:0000:0004:64ff:fea4:39c2 IPv6 \ - DST=ff02:0000:0000:0000:0000:0000:0000:0001, \ - IPv6 priority=0x0, Next Header=0 - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Acked-by: Herbert Xu <herbert@gondor.apana.org.au> - Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> - -commit 20a599bec95a52fa72432b2376a2ce47c5bb68fb -Author: Linus Lüssing <linus.luessing@web.de> -Date: Mon Mar 10 22:25:25 2014 +0100 - - bridge: multicast: enable snooping on general queries only - - Without this check someone could easily create a denial of service - by injecting multicast-specific queries to enable the bridge - snooping part if no real querier issuing periodic general queries - is present on the link which would result in the bridge wrongly - shutting down ports for multicast traffic as the bridge did not learn - about these listeners. - - With this patch the snooping code is enabled upon receiving valid, - general queries only. - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit 9ed973cc40c588abeaa58aea0683ea665132d11d -Author: Linus Lüssing <linus.luessing@web.de> -Date: Mon Mar 10 22:25:24 2014 +0100 - - bridge: multicast: add sanity check for general query destination - - General IGMP and MLD queries are supposed to have the multicast - link-local all-nodes address as their destination according to RFC2236 - section 9, RFC3376 section 4.1.12/9.1, RFC2710 section 8 and RFC3810 - section 5.1.15. - - Without this check, such malformed IGMP/MLD queries can result in a - denial of service: The queries are ignored by most IGMP/MLD listeners - therefore they will not respond with an IGMP/MLD report. However, - without this patch these malformed MLD queries would enable the - snooping part in the bridge code, potentially shutting down the - according ports towards these hosts for multicast traffic as the - bridge did not learn about these listeners. - - Reported-by: Jan Stancek <jstancek@redhat.com> - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit 3c3769e63301fd92fcaf51870c371583dd0282ce -Author: Linus Lüssing <linus.luessing@web.de> -Date: Wed Sep 4 02:13:39 2013 +0200 - - bridge: apply multicast snooping to IPv6 link-local, too - - The multicast snooping code should have matured enough to be safely - applicable to IPv6 link-local multicast addresses (excluding the - link-local all nodes address, ff02::1), too. - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit 8fad9c39f31f9ed7bf3526c43a4537b2fcf1a5d5 -Author: Linus Lüssing <linus.luessing@web.de> -Date: Wed Sep 4 02:13:38 2013 +0200 - - bridge: prevent flooding IPv6 packets that do not have a listener - - Currently if there is no listener for a certain group then IPv6 packets - for that group are flooded on all ports, even though there might be no - host and router interested in it on a port. - - With this commit they are only forwarded to ports with a multicast - router. - - Just like commit bd4265fe36 ("bridge: Only flood unregistered groups - to routers") did for IPv4, let's do the same for IPv6 with the same - reasoning. - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit cc0fdd802859eaeb00e1c87dbb655594bed2844c -Author: Linus Lüssing <linus.luessing@web.de> -Date: Fri Aug 30 17:28:17 2013 +0200 - - bridge: separate querier and query timer into IGMP/IPv4 and MLD/IPv6 ones - - Currently we would still potentially suffer multicast packet loss if there - is just either an IGMP or an MLD querier: For the former case, we would - possibly drop IPv6 multicast packets, for the latter IPv4 ones. This is - because we are currently assuming that if either an IGMP or MLD querier - is present that the other one is present, too. - - This patch makes the behaviour and fix added in - "bridge: disable snooping if there is no querier" (b00589af3b04) - to also work if there is either just an IGMP or an MLD querier on the - link: It refines the deactivation of the snooping to be protocol - specific by using separate timers for the snooped IGMP and MLD queries - as well as separate timers for our internal IGMP and MLD queriers. - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit b00589af3b04736376f24625ab0b394642e89e29 -Author: Linus Lüssing <linus.luessing@web.de> -Date: Thu Aug 1 01:06:20 2013 +0200 - - bridge: disable snooping if there is no querier - - If there is no querier on a link then we won't get periodic reports and - therefore won't be able to learn about multicast listeners behind ports, - potentially leading to lost multicast packets, especially for multicast - listeners that joined before the creation of the bridge. - - These lost multicast packets can appear since c5c23260594 - ("bridge: Add multicast_querier toggle and disable queries by default") - in particular. - - With this patch we are flooding multicast packets if our querier is - disabled and if we didn't detect any other querier. - - A grace period of the Maximum Response Delay of the querier is added to - give multicast responses enough time to arrive and to be learned from - before disabling the flooding behaviour again. - - Signed-off-by: Linus Lüssing <linus.luessing@web.de> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit 6b7df111ece130fa979a0c4f58e53674c1e47d3e -Author: Cong Wang <amwang@redhat.com> -Date: Tue May 21 21:52:56 2013 +0000 - - bridge: send query as soon as leave is received - - Continue sending queries when leave is received if the user marks - it as a querier. - - Cc: Herbert Xu <herbert@gondor.apana.org.au> - Cc: Stephen Hemminger <stephen@networkplumber.org> - Cc: "David S. Miller" <davem@davemloft.net> - Cc: Adam Baker <linux@baker-net.org.uk> - Signed-off-by: Cong Wang <amwang@redhat.com> - Acked-by: Herbert Xu <herbert@gondor.apana.org.au> - Signed-off-by: David S. Miller <davem@davemloft.net> - -commit 1c8ad5bfa2be5025b0c81e3c2decd0574d453ab1 -Author: Cong Wang <amwang@redhat.com> -Date: Tue May 21 21:52:54 2013 +0000 - - bridge: use the bridge IP addr as source addr for querier - - Quote from Adam: - "If it is believed that the use of 0.0.0.0 - as the IP address is what is causing strange behaviour on other devices - then is there a good reason that a bridge rather than a router shouldn't - be the active querier? If not then using the bridge IP address and - having the querier enabled by default may be a reasonable solution - (provided that our querier obeys the election rules and shuts up if it - sees a query from a lower IP address that isn't 0.0.0.0). Just because a - device is the elected querier for IGMP doesn't appear to mean it is - required to perform any other routing functions." - - And introduce a new troggle for it, as suggested by Herbert. - - Suggested-by: Adam Baker <linux@baker-net.org.uk> - Cc: Herbert Xu <herbert@gondor.apana.org.au> - Cc: Stephen Hemminger <stephen@networkplumber.org> - Cc: "David S. Miller" <davem@davemloft.net> - Cc: Adam Baker <linux@baker-net.org.uk> - Signed-off-by: Cong Wang <amwang@redhat.com> - Acked-by: Herbert Xu <herbert@gondor.apana.org.au> - Signed-off-by: David S. Miller <davem@davemloft.net> - ---- a/net/bridge/br_device.c -+++ b/net/bridge/br_device.c -@@ -67,7 +67,8 @@ netdev_tx_t br_dev_xmit(struct sk_buff * - } - - mdst = br_mdb_get(br, skb, vid); -- if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) -+ if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && -+ br_multicast_querier_exists(br, eth_hdr(skb))) - br_multicast_deliver(mdst, skb); - else - br_flood_deliver(br, skb); ---- a/net/bridge/br_input.c -+++ b/net/bridge/br_input.c -@@ -98,7 +98,8 @@ int br_handle_frame_finish(struct sk_buf - skb2 = skb; - else if (is_multicast_ether_addr(dest)) { - mdst = br_mdb_get(br, skb, vid); -- if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) { -+ if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && -+ br_multicast_querier_exists(br, eth_hdr(skb))) { - if ((mdst && mdst->mglist) || - br_multicast_is_router(br)) - skb2 = skb; ---- a/net/bridge/br_multicast.c -+++ b/net/bridge/br_multicast.c -@@ -23,16 +23,19 @@ - #include <linux/skbuff.h> - #include <linux/slab.h> - #include <linux/timer.h> -+#include <linux/inetdevice.h> - #include <net/ip.h> - #if IS_ENABLED(CONFIG_IPV6) - #include <net/ipv6.h> - #include <net/mld.h> - #include <net/ip6_checksum.h> -+#include <net/addrconf.h> - #endif - - #include "br_private.h" - --static void br_multicast_start_querier(struct net_bridge *br); -+static void br_multicast_start_querier(struct net_bridge *br, -+ struct bridge_mcast_query *query); - unsigned int br_mdb_rehash_seq; - - static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b) -@@ -381,7 +384,8 @@ static struct sk_buff *br_ip4_multicast_ - iph->frag_off = htons(IP_DF); - iph->ttl = 1; - iph->protocol = IPPROTO_IGMP; -- iph->saddr = 0; -+ iph->saddr = br->multicast_query_use_ifaddr ? -+ inet_select_addr(br->dev, 0, RT_SCOPE_LINK) : 0; - iph->daddr = htonl(INADDR_ALLHOSTS_GROUP); - ((u8 *)&iph[1])[0] = IPOPT_RA; - ((u8 *)&iph[1])[1] = 4; -@@ -724,7 +728,7 @@ static int br_ip6_multicast_add_group(st - { - struct br_ip br_group; - -- if (!ipv6_is_transient_multicast(group)) -+ if (ipv6_addr_is_ll_all_nodes(group)) - return 0; - - br_group.u.ip6 = *group; -@@ -756,20 +760,35 @@ static void br_multicast_local_router_ex - { - } - --static void br_multicast_querier_expired(unsigned long data) -+static void br_multicast_querier_expired(struct net_bridge *br, -+ struct bridge_mcast_query *query) - { -- struct net_bridge *br = (void *)data; -- - spin_lock(&br->multicast_lock); - if (!netif_running(br->dev) || br->multicast_disabled) - goto out; - -- br_multicast_start_querier(br); -+ br_multicast_start_querier(br, query); - - out: - spin_unlock(&br->multicast_lock); - } - -+static void br_ip4_multicast_querier_expired(unsigned long data) -+{ -+ struct net_bridge *br = (void *)data; -+ -+ br_multicast_querier_expired(br, &br->ip4_query); -+} -+ -+#if IS_ENABLED(CONFIG_IPV6) -+static void br_ip6_multicast_querier_expired(unsigned long data) -+{ -+ struct net_bridge *br = (void *)data; -+ -+ br_multicast_querier_expired(br, &br->ip6_query); -+} -+#endif -+ - static void __br_multicast_send_query(struct net_bridge *br, - struct net_bridge_port *port, - struct br_ip *ip) -@@ -781,46 +800,53 @@ static void __br_multicast_send_query(st - return; - - if (port) { -- __skb_push(skb, sizeof(struct ethhdr)); - skb->dev = port->dev; - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, -- dev_queue_xmit); -+ br_dev_queue_push_xmit); - } else - netif_rx(skb); - } - - static void br_multicast_send_query(struct net_bridge *br, -- struct net_bridge_port *port, u32 sent) -+ struct net_bridge_port *port, -+ struct bridge_mcast_query *query) - { - unsigned long time; - struct br_ip br_group; -+ struct bridge_mcast_querier *querier = NULL; - - if (!netif_running(br->dev) || br->multicast_disabled || -- !br->multicast_querier || -- timer_pending(&br->multicast_querier_timer)) -+ !br->multicast_querier) - return; - - memset(&br_group.u, 0, sizeof(br_group.u)); - -- br_group.proto = htons(ETH_P_IP); -- __br_multicast_send_query(br, port, &br_group); -- -+ if (port ? (query == &port->ip4_query) : -+ (query == &br->ip4_query)) { -+ querier = &br->ip4_querier; -+ br_group.proto = htons(ETH_P_IP); - #if IS_ENABLED(CONFIG_IPV6) -- br_group.proto = htons(ETH_P_IPV6); -- __br_multicast_send_query(br, port, &br_group); -+ } else { -+ querier = &br->ip6_querier; -+ br_group.proto = htons(ETH_P_IPV6); - #endif -+ } -+ -+ if (!querier || timer_pending(&querier->timer)) -+ return; -+ -+ __br_multicast_send_query(br, port, &br_group); - - time = jiffies; -- time += sent < br->multicast_startup_query_count ? -+ time += query->startup_sent < br->multicast_startup_query_count ? - br->multicast_startup_query_interval : - br->multicast_query_interval; -- mod_timer(port ? &port->multicast_query_timer : -- &br->multicast_query_timer, time); -+ mod_timer(&query->timer, time); - } - --static void br_multicast_port_query_expired(unsigned long data) -+static void br_multicast_port_query_expired(struct net_bridge_port *port, -+ struct bridge_mcast_query *query) - { -- struct net_bridge_port *port = (void *)data; - struct net_bridge *br = port->br; - - spin_lock(&br->multicast_lock); -@@ -828,25 +854,43 @@ static void br_multicast_port_query_expi - port->state == BR_STATE_BLOCKING) - goto out; - -- if (port->multicast_startup_queries_sent < -- br->multicast_startup_query_count) -- port->multicast_startup_queries_sent++; -+ if (query->startup_sent < br->multicast_startup_query_count) -+ query->startup_sent++; - -- br_multicast_send_query(port->br, port, -- port->multicast_startup_queries_sent); -+ br_multicast_send_query(port->br, port, query); - - out: - spin_unlock(&br->multicast_lock); - } - -+static void br_ip4_multicast_port_query_expired(unsigned long data) -+{ -+ struct net_bridge_port *port = (void *)data; -+ -+ br_multicast_port_query_expired(port, &port->ip4_query); -+} -+ -+#if IS_ENABLED(CONFIG_IPV6) -+static void br_ip6_multicast_port_query_expired(unsigned long data) -+{ -+ struct net_bridge_port *port = (void *)data; -+ -+ br_multicast_port_query_expired(port, &port->ip6_query); -+} -+#endif -+ - void br_multicast_add_port(struct net_bridge_port *port) - { - port->multicast_router = 1; - - setup_timer(&port->multicast_router_timer, br_multicast_router_expired, - (unsigned long)port); -- setup_timer(&port->multicast_query_timer, -- br_multicast_port_query_expired, (unsigned long)port); -+ setup_timer(&port->ip4_query.timer, br_ip4_multicast_port_query_expired, -+ (unsigned long)port); -+#if IS_ENABLED(CONFIG_IPV6) -+ setup_timer(&port->ip6_query.timer, br_ip6_multicast_port_query_expired, -+ (unsigned long)port); -+#endif - } - - void br_multicast_del_port(struct net_bridge_port *port) -@@ -854,13 +898,13 @@ void br_multicast_del_port(struct net_br - del_timer_sync(&port->multicast_router_timer); - } - --static void __br_multicast_enable_port(struct net_bridge_port *port) -+static void br_multicast_enable(struct bridge_mcast_query *query) - { -- port->multicast_startup_queries_sent = 0; -+ query->startup_sent = 0; - -- if (try_to_del_timer_sync(&port->multicast_query_timer) >= 0 || -- del_timer(&port->multicast_query_timer)) -- mod_timer(&port->multicast_query_timer, jiffies); -+ if (try_to_del_timer_sync(&query->timer) >= 0 || -+ del_timer(&query->timer)) -+ mod_timer(&query->timer, jiffies); - } - - void br_multicast_enable_port(struct net_bridge_port *port) -@@ -871,7 +915,10 @@ void br_multicast_enable_port(struct net - if (br->multicast_disabled || !netif_running(br->dev)) - goto out; - -- __br_multicast_enable_port(port); -+ br_multicast_enable(&port->ip4_query); -+#if IS_ENABLED(CONFIG_IPV6) -+ br_multicast_enable(&port->ip6_query); -+#endif - - out: - spin_unlock(&br->multicast_lock); -@@ -890,7 +937,10 @@ void br_multicast_disable_port(struct ne - if (!hlist_unhashed(&port->rlist)) - hlist_del_init_rcu(&port->rlist); - del_timer(&port->multicast_router_timer); -- del_timer(&port->multicast_query_timer); -+ del_timer(&port->ip4_query.timer); -+#if IS_ENABLED(CONFIG_IPV6) -+ del_timer(&port->ip6_query.timer); -+#endif - spin_unlock(&br->multicast_lock); - } - -@@ -1015,6 +1065,17 @@ static int br_ip6_multicast_mld2_report( - } - #endif - -+static void -+br_multicast_update_querier_timer(struct net_bridge *br, -+ struct bridge_mcast_querier *querier, -+ unsigned long max_delay) -+{ -+ if (!timer_pending(&querier->timer)) -+ querier->delay_time = jiffies + max_delay; -+ -+ mod_timer(&querier->timer, jiffies + br->multicast_querier_interval); -+} -+ - /* - * Add port to rotuer_list - * list is maintained ordered by pointer value -@@ -1065,12 +1126,14 @@ timer: - - static void br_multicast_query_received(struct net_bridge *br, - struct net_bridge_port *port, -- int saddr) --{ -- if (saddr) -- mod_timer(&br->multicast_querier_timer, -- jiffies + br->multicast_querier_interval); -- else if (timer_pending(&br->multicast_querier_timer)) -+ struct bridge_mcast_querier *querier, -+ int saddr, -+ bool is_general_query, -+ unsigned long max_delay) -+{ -+ if (saddr && is_general_query) -+ br_multicast_update_querier_timer(br, querier, max_delay); -+ else if (timer_pending(&querier->timer)) - return; - - br_multicast_mark_router(br, port); -@@ -1097,8 +1160,6 @@ static int br_ip4_multicast_query(struct - (port && port->state == BR_STATE_DISABLED)) - goto out; - -- br_multicast_query_received(br, port, !!iph->saddr); -- - group = ih->group; - - if (skb->len == sizeof(*ih)) { -@@ -1122,6 +1183,17 @@ static int br_ip4_multicast_query(struct - IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1; - } - -+ /* RFC2236+RFC3376 (IGMPv2+IGMPv3) require the multicast link layer -+ * all-systems destination addresses (224.0.0.1) for general queries -+ */ -+ if (!group && iph->daddr != htonl(INADDR_ALLHOSTS_GROUP)) { -+ err = -EINVAL; -+ goto out; -+ } -+ -+ br_multicast_query_received(br, port, &br->ip4_querier, !!iph->saddr, -+ !group, max_delay); -+ - if (!group) - goto out; - -@@ -1166,6 +1238,7 @@ static int br_ip6_multicast_query(struct - unsigned long max_delay; - unsigned long now = jiffies; - const struct in6_addr *group = NULL; -+ bool is_general_query; - int err = 0; - u16 vid = 0; - -@@ -1174,8 +1247,6 @@ static int br_ip6_multicast_query(struct - (port && port->state == BR_STATE_DISABLED)) - goto out; - -- br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr)); -- - /* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */ - if (!(ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL)) { - err = -EINVAL; -@@ -1203,6 +1274,20 @@ static int br_ip6_multicast_query(struct - max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mld2q->mld2q_mrc))), 1UL); - } - -+ is_general_query = group && ipv6_addr_any(group); -+ -+ /* RFC2710+RFC3810 (MLDv1+MLDv2) require the multicast link layer -+ * all-nodes destination address (ff02::1) for general queries -+ */ -+ if (is_general_query && !ipv6_addr_is_ll_all_nodes(&ip6h->daddr)) { -+ err = -EINVAL; -+ goto out; -+ } -+ -+ br_multicast_query_received(br, port, &br->ip6_querier, -+ !ipv6_addr_any(&ip6h->saddr), -+ is_general_query, max_delay); -+ - if (!group) - goto out; - -@@ -1235,7 +1320,9 @@ out: - - static void br_multicast_leave_group(struct net_bridge *br, - struct net_bridge_port *port, -- struct br_ip *group) -+ struct br_ip *group, -+ struct bridge_mcast_querier *querier, -+ struct bridge_mcast_query *query) - { - struct net_bridge_mdb_htable *mdb; - struct net_bridge_mdb_entry *mp; -@@ -1246,7 +1333,7 @@ static void br_multicast_leave_group(str - spin_lock(&br->multicast_lock); - if (!netif_running(br->dev) || - (port && port->state == BR_STATE_DISABLED) || -- timer_pending(&br->multicast_querier_timer)) -+ timer_pending(&querier->timer)) - goto out; - - mdb = mlock_dereference(br->mdb, br); -@@ -1254,6 +1341,31 @@ static void br_multicast_leave_group(str - if (!mp) - goto out; - -+ if (br->multicast_querier) { -+ __br_multicast_send_query(br, port, &mp->addr); -+ -+ time = jiffies + br->multicast_last_member_count * -+ br->multicast_last_member_interval; -+ -+ mod_timer(&query->timer, time); -+ -+ for (p = mlock_dereference(mp->ports, br); -+ p != NULL; -+ p = mlock_dereference(p->next, br)) { -+ if (p->port != port) -+ continue; -+ -+ if (!hlist_unhashed(&p->mglist) && -+ (timer_pending(&p->timer) ? -+ time_after(p->timer.expires, time) : -+ try_to_del_timer_sync(&p->timer) >= 0)) { -+ mod_timer(&p->timer, time); -+ } -+ -+ break; -+ } -+ } -+ - if (port && (port->flags & BR_MULTICAST_FAST_LEAVE)) { - struct net_bridge_port_group __rcu **pp; - -@@ -1306,7 +1418,6 @@ static void br_multicast_leave_group(str - - break; - } -- - out: - spin_unlock(&br->multicast_lock); - } -@@ -1317,6 +1428,8 @@ static void br_ip4_multicast_leave_group - __u16 vid) - { - struct br_ip br_group; -+ struct bridge_mcast_query *query = port ? &port->ip4_query : -+ &br->ip4_query; - - if (ipv4_is_local_multicast(group)) - return; -@@ -1325,7 +1438,7 @@ static void br_ip4_multicast_leave_group - br_group.proto = htons(ETH_P_IP); - br_group.vid = vid; - -- br_multicast_leave_group(br, port, &br_group); -+ br_multicast_leave_group(br, port, &br_group, &br->ip4_querier, query); - } - - #if IS_ENABLED(CONFIG_IPV6) -@@ -1335,15 +1448,18 @@ static void br_ip6_multicast_leave_group - __u16 vid) - { - struct br_ip br_group; -+ struct bridge_mcast_query *query = port ? &port->ip6_query : -+ &br->ip6_query; - -- if (!ipv6_is_transient_multicast(group)) -+ -+ if (ipv6_addr_is_ll_all_nodes(group)) - return; - - br_group.u.ip6 = *group; - br_group.proto = htons(ETH_P_IPV6); - br_group.vid = vid; - -- br_multicast_leave_group(br, port, &br_group); -+ br_multicast_leave_group(br, port, &br_group, &br->ip6_querier, query); - } - #endif - -@@ -1473,8 +1589,14 @@ static int br_multicast_ipv6_rcv(struct - * - MLD has always Router Alert hop-by-hop option - * - But we do not support jumbrograms. - */ -- if (ip6h->version != 6 || -- ip6h->nexthdr != IPPROTO_HOPOPTS || -+ if (ip6h->version != 6) -+ return 0; -+ -+ /* Prevent flooding this packet if there is no listener present */ -+ if (!ipv6_addr_is_ll_all_nodes(&ip6h->daddr)) -+ BR_INPUT_SKB_CB(skb)->mrouters_only = 1; -+ -+ if (ip6h->nexthdr != IPPROTO_HOPOPTS || - ip6h->payload_len == 0) - return 0; - -@@ -1605,19 +1727,32 @@ int br_multicast_rcv(struct net_bridge * - return 0; - } - --static void br_multicast_query_expired(unsigned long data) -+static void br_multicast_query_expired(struct net_bridge *br, -+ struct bridge_mcast_query *query) -+{ -+ spin_lock(&br->multicast_lock); -+ if (query->startup_sent < br->multicast_startup_query_count) -+ query->startup_sent++; -+ -+ br_multicast_send_query(br, NULL, query); -+ spin_unlock(&br->multicast_lock); -+} -+ -+static void br_ip4_multicast_query_expired(unsigned long data) - { - struct net_bridge *br = (void *)data; - -- spin_lock(&br->multicast_lock); -- if (br->multicast_startup_queries_sent < -- br->multicast_startup_query_count) -- br->multicast_startup_queries_sent++; -+ br_multicast_query_expired(br, &br->ip4_query); -+} - -- br_multicast_send_query(br, NULL, br->multicast_startup_queries_sent); -+#if IS_ENABLED(CONFIG_IPV6) -+static void br_ip6_multicast_query_expired(unsigned long data) -+{ -+ struct net_bridge *br = (void *)data; - -- spin_unlock(&br->multicast_lock); -+ br_multicast_query_expired(br, &br->ip6_query); - } -+#endif - - void br_multicast_init(struct net_bridge *br) - { -@@ -1626,6 +1761,7 @@ void br_multicast_init(struct net_bridge - - br->multicast_router = 1; - br->multicast_querier = 0; -+ br->multicast_query_use_ifaddr = 0; - br->multicast_last_member_count = 2; - br->multicast_startup_query_count = 2; - -@@ -1636,23 +1772,43 @@ void br_multicast_init(struct net_bridge - br->multicast_querier_interval = 255 * HZ; - br->multicast_membership_interval = 260 * HZ; - -+ br->ip4_querier.delay_time = 0; -+#if IS_ENABLED(CONFIG_IPV6) -+ br->ip6_querier.delay_time = 0; -+#endif -+ - spin_lock_init(&br->multicast_lock); - setup_timer(&br->multicast_router_timer, - br_multicast_local_router_expired, 0); -- setup_timer(&br->multicast_querier_timer, -- br_multicast_querier_expired, (unsigned long)br); -- setup_timer(&br->multicast_query_timer, br_multicast_query_expired, -+ setup_timer(&br->ip4_querier.timer, br_ip4_multicast_querier_expired, - (unsigned long)br); -+ setup_timer(&br->ip4_query.timer, br_ip4_multicast_query_expired, -+ (unsigned long)br); -+#if IS_ENABLED(CONFIG_IPV6) -+ setup_timer(&br->ip6_querier.timer, br_ip6_multicast_querier_expired, -+ (unsigned long)br); -+ setup_timer(&br->ip6_query.timer, br_ip6_multicast_query_expired, -+ (unsigned long)br); -+#endif - } - --void br_multicast_open(struct net_bridge *br) -+static void __br_multicast_open(struct net_bridge *br, -+ struct bridge_mcast_query *query) - { -- br->multicast_startup_queries_sent = 0; -+ query->startup_sent = 0; - - if (br->multicast_disabled) - return; - -- mod_timer(&br->multicast_query_timer, jiffies); -+ mod_timer(&query->timer, jiffies); -+} -+ -+void br_multicast_open(struct net_bridge *br) -+{ -+ __br_multicast_open(br, &br->ip4_query); -+#if IS_ENABLED(CONFIG_IPV6) -+ __br_multicast_open(br, &br->ip6_query); -+#endif - } - - void br_multicast_stop(struct net_bridge *br) -@@ -1664,8 +1820,12 @@ void br_multicast_stop(struct net_bridge - int i; - - del_timer_sync(&br->multicast_router_timer); -- del_timer_sync(&br->multicast_querier_timer); -- del_timer_sync(&br->multicast_query_timer); -+ del_timer_sync(&br->ip4_querier.timer); -+ del_timer_sync(&br->ip4_query.timer); -+#if IS_ENABLED(CONFIG_IPV6) -+ del_timer_sync(&br->ip6_querier.timer); -+ del_timer_sync(&br->ip6_query.timer); -+#endif - - spin_lock_bh(&br->multicast_lock); - mdb = mlock_dereference(br->mdb, br); -@@ -1767,18 +1927,24 @@ unlock: - return err; - } - --static void br_multicast_start_querier(struct net_bridge *br) -+static void br_multicast_start_querier(struct net_bridge *br, -+ struct bridge_mcast_query *query) - { - struct net_bridge_port *port; - -- br_multicast_open(br); -+ __br_multicast_open(br, query); - - list_for_each_entry(port, &br->port_list, list) { - if (port->state == BR_STATE_DISABLED || - port->state == BR_STATE_BLOCKING) - continue; - -- __br_multicast_enable_port(port); -+ if (query == &br->ip4_query) -+ br_multicast_enable(&port->ip4_query); -+#if IS_ENABLED(CONFIG_IPV6) -+ else -+ br_multicast_enable(&port->ip6_query); -+#endif - } - } - -@@ -1813,7 +1979,10 @@ rollback: - goto rollback; - } - -- br_multicast_start_querier(br); -+ br_multicast_start_querier(br, &br->ip4_query); -+#if IS_ENABLED(CONFIG_IPV6) -+ br_multicast_start_querier(br, &br->ip6_query); -+#endif - - unlock: - spin_unlock_bh(&br->multicast_lock); -@@ -1823,6 +1992,8 @@ unlock: - - int br_multicast_set_querier(struct net_bridge *br, unsigned long val) - { -+ unsigned long max_delay; -+ - val = !!val; - - spin_lock_bh(&br->multicast_lock); -@@ -1830,8 +2001,22 @@ int br_multicast_set_querier(struct net_ - goto unlock; - - br->multicast_querier = val; -- if (val) -- br_multicast_start_querier(br); -+ if (!val) -+ goto unlock; -+ -+ max_delay = br->multicast_query_response_interval; -+ -+ if (!timer_pending(&br->ip4_querier.timer)) -+ br->ip4_querier.delay_time = jiffies + max_delay; -+ -+ br_multicast_start_querier(br, &br->ip4_query); -+ -+#if IS_ENABLED(CONFIG_IPV6) -+ if (!timer_pending(&br->ip6_querier.timer)) -+ br->ip6_querier.delay_time = jiffies + max_delay; -+ -+ br_multicast_start_querier(br, &br->ip6_query); -+#endif - - unlock: - spin_unlock_bh(&br->multicast_lock); ---- a/net/bridge/br_private.h -+++ b/net/bridge/br_private.h -@@ -66,6 +66,20 @@ struct br_ip - __u16 vid; - }; - -+#ifdef CONFIG_BRIDGE_IGMP_SNOOPING -+/* our own querier */ -+struct bridge_mcast_query { -+ struct timer_list timer; -+ u32 startup_sent; -+}; -+ -+/* other querier */ -+struct bridge_mcast_querier { -+ struct timer_list timer; -+ unsigned long delay_time; -+}; -+#endif -+ - struct net_port_vlans { - u16 port_idx; - u16 pvid; -@@ -159,10 +173,12 @@ struct net_bridge_port - #define BR_ADMIN_COST 0x00000010 - - #ifdef CONFIG_BRIDGE_IGMP_SNOOPING -- u32 multicast_startup_queries_sent; -+ struct bridge_mcast_query ip4_query; -+#if IS_ENABLED(CONFIG_IPV6) -+ struct bridge_mcast_query ip6_query; -+#endif /* IS_ENABLED(CONFIG_IPV6) */ - unsigned char multicast_router; - struct timer_list multicast_router_timer; -- struct timer_list multicast_query_timer; - struct hlist_head mglist; - struct hlist_node rlist; - #endif -@@ -246,12 +262,12 @@ struct net_bridge - - u8 multicast_disabled:1; - u8 multicast_querier:1; -+ u8 multicast_query_use_ifaddr:1; - - u32 hash_elasticity; - u32 hash_max; - - u32 multicast_last_member_count; -- u32 multicast_startup_queries_sent; - u32 multicast_startup_query_count; - - unsigned long multicast_last_member_interval; -@@ -266,8 +282,12 @@ struct net_bridge - struct hlist_head router_list; - - struct timer_list multicast_router_timer; -- struct timer_list multicast_querier_timer; -- struct timer_list multicast_query_timer; -+ struct bridge_mcast_querier ip4_querier; -+ struct bridge_mcast_query ip4_query; -+#if IS_ENABLED(CONFIG_IPV6) -+ struct bridge_mcast_querier ip6_querier; -+ struct bridge_mcast_query ip6_query; -+#endif /* IS_ENABLED(CONFIG_IPV6) */ - #endif - - struct timer_list hello_timer; -@@ -477,22 +497,35 @@ extern void br_mdb_notify(struct net_dev - #define mlock_dereference(X, br) \ - rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock)) - --#if IS_ENABLED(CONFIG_IPV6) --#include <net/addrconf.h> --static inline int ipv6_is_transient_multicast(const struct in6_addr *addr) --{ -- if (ipv6_addr_is_multicast(addr) && IPV6_ADDR_MC_FLAG_TRANSIENT(addr)) -- return 1; -- return 0; --} --#endif -- - static inline bool br_multicast_is_router(struct net_bridge *br) - { - return br->multicast_router == 2 || - (br->multicast_router == 1 && - timer_pending(&br->multicast_router_timer)); - } -+ -+static inline bool -+__br_multicast_querier_exists(struct net_bridge *br, -+ struct bridge_mcast_querier *querier) -+{ -+ return time_is_before_jiffies(querier->delay_time) && -+ (br->multicast_querier || timer_pending(&querier->timer)); -+} -+ -+static inline bool br_multicast_querier_exists(struct net_bridge *br, -+ struct ethhdr *eth) -+{ -+ switch (eth->h_proto) { -+ case (htons(ETH_P_IP)): -+ return __br_multicast_querier_exists(br, &br->ip4_querier); -+#if IS_ENABLED(CONFIG_IPV6) -+ case (htons(ETH_P_IPV6)): -+ return __br_multicast_querier_exists(br, &br->ip6_querier); -+#endif -+ default: -+ return false; -+ } -+} - #else - static inline int br_multicast_rcv(struct net_bridge *br, - struct net_bridge_port *port, -@@ -549,6 +582,11 @@ static inline bool br_multicast_is_route - { - return 0; - } -+static inline bool br_multicast_querier_exists(struct net_bridge *br, -+ struct ethhdr *eth) -+{ -+ return false; -+} - static inline void br_mdb_init(void) - { - } ---- a/net/bridge/br_sysfs_br.c -+++ b/net/bridge/br_sysfs_br.c -@@ -375,6 +375,31 @@ static ssize_t store_multicast_snooping( - static DEVICE_ATTR(multicast_snooping, S_IRUGO | S_IWUSR, - show_multicast_snooping, store_multicast_snooping); - -+static ssize_t show_multicast_query_use_ifaddr(struct device *d, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct net_bridge *br = to_bridge(d); -+ return sprintf(buf, "%d\n", br->multicast_query_use_ifaddr); -+} -+ -+static int set_query_use_ifaddr(struct net_bridge *br, unsigned long val) -+{ -+ br->multicast_query_use_ifaddr = !!val; -+ return 0; -+} -+ -+static ssize_t -+store_multicast_query_use_ifaddr(struct device *d, -+ struct device_attribute *attr, -+ const char *buf, size_t len) -+{ -+ return store_bridge_parm(d, buf, len, set_query_use_ifaddr); -+} -+static DEVICE_ATTR(multicast_query_use_ifaddr, S_IRUGO | S_IWUSR, -+ show_multicast_query_use_ifaddr, -+ store_multicast_query_use_ifaddr); -+ - static ssize_t show_multicast_querier(struct device *d, - struct device_attribute *attr, - char *buf) -@@ -734,6 +759,7 @@ static struct attribute *bridge_attrs[] - &dev_attr_multicast_router.attr, - &dev_attr_multicast_snooping.attr, - &dev_attr_multicast_querier.attr, -+ &dev_attr_multicast_query_use_ifaddr.attr, - &dev_attr_hash_elasticity.attr, - &dev_attr_hash_max.attr, - &dev_attr_multicast_last_member_count.attr, ---- a/net/bridge/br_mdb.c -+++ b/net/bridge/br_mdb.c -@@ -9,6 +9,7 @@ - #include <net/netlink.h> - #if IS_ENABLED(CONFIG_IPV6) - #include <net/ipv6.h> -+#include <net/addrconf.h> - #endif - - #include "br_private.h" -@@ -253,7 +254,7 @@ static bool is_valid_mdb_entry(struct br - return false; - #if IS_ENABLED(CONFIG_IPV6) - } else if (entry->addr.proto == htons(ETH_P_IPV6)) { -- if (!ipv6_is_transient_multicast(&entry->addr.u.ip6)) -+ if (ipv6_addr_is_ll_all_nodes(&entry->addr.u.ip6)) - return false; - #endif - } else -@@ -414,16 +415,20 @@ static int __br_mdb_del(struct net_bridg - if (!netif_running(br->dev) || br->multicast_disabled) - return -EINVAL; - -- if (timer_pending(&br->multicast_querier_timer)) -- return -EBUSY; -- - ip.proto = entry->addr.proto; -- if (ip.proto == htons(ETH_P_IP)) -+ if (ip.proto == htons(ETH_P_IP)) { -+ if (timer_pending(&br->ip4_querier.timer)) -+ return -EBUSY; -+ - ip.u.ip4 = entry->addr.u.ip4; - #if IS_ENABLED(CONFIG_IPV6) -- else -+ } else { -+ if (timer_pending(&br->ip6_querier.timer)) -+ return -EBUSY; -+ - ip.u.ip6 = entry->addr.u.ip6; - #endif -+ } - - spin_lock_bh(&br->multicast_lock); - mdb = mlock_dereference(br->mdb, br); diff --git a/target/linux/generic/patches-3.10/100-overlayfs.patch b/target/linux/generic/patches-3.10/100-overlayfs.patch deleted file mode 100644 index 47da90bcc3..0000000000 --- a/target/linux/generic/patches-3.10/100-overlayfs.patch +++ /dev/null @@ -1,3232 +0,0 @@ ---- a/Documentation/filesystems/Locking -+++ b/Documentation/filesystems/Locking -@@ -66,6 +66,7 @@ prototypes: - int (*atomic_open)(struct inode *, struct dentry *, - struct file *, unsigned open_flag, - umode_t create_mode, int *opened); -+ int (*dentry_open)(struct dentry *, struct file *, const struct cred *); - - locking rules: - all may block -@@ -93,6 +94,7 @@ removexattr: yes - fiemap: no - update_time: no - atomic_open: yes -+dentry_open: no - - Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on - victim. ---- /dev/null -+++ b/Documentation/filesystems/overlayfs.txt -@@ -0,0 +1,199 @@ -+Written by: Neil Brown <neilb@suse.de> -+ -+Overlay Filesystem -+================== -+ -+This document describes a prototype for a new approach to providing -+overlay-filesystem functionality in Linux (sometimes referred to as -+union-filesystems). An overlay-filesystem tries to present a -+filesystem which is the result over overlaying one filesystem on top -+of the other. -+ -+The result will inevitably fail to look exactly like a normal -+filesystem for various technical reasons. The expectation is that -+many use cases will be able to ignore these differences. -+ -+This approach is 'hybrid' because the objects that appear in the -+filesystem do not all appear to belong to that filesystem. In many -+cases an object accessed in the union will be indistinguishable -+from accessing the corresponding object from the original filesystem. -+This is most obvious from the 'st_dev' field returned by stat(2). -+ -+While directories will report an st_dev from the overlay-filesystem, -+all non-directory objects will report an st_dev from the lower or -+upper filesystem that is providing the object. Similarly st_ino will -+only be unique when combined with st_dev, and both of these can change -+over the lifetime of a non-directory object. Many applications and -+tools ignore these values and will not be affected. -+ -+Upper and Lower -+--------------- -+ -+An overlay filesystem combines two filesystems - an 'upper' filesystem -+and a 'lower' filesystem. When a name exists in both filesystems, the -+object in the 'upper' filesystem is visible while the object in the -+'lower' filesystem is either hidden or, in the case of directories, -+merged with the 'upper' object. -+ -+It would be more correct to refer to an upper and lower 'directory -+tree' rather than 'filesystem' as it is quite possible for both -+directory trees to be in the same filesystem and there is no -+requirement that the root of a filesystem be given for either upper or -+lower. -+ -+The lower filesystem can be any filesystem supported by Linux and does -+not need to be writable. The lower filesystem can even be another -+overlayfs. The upper filesystem will normally be writable and if it -+is it must support the creation of trusted.* extended attributes, and -+must provide valid d_type in readdir responses, at least for symbolic -+links - so NFS is not suitable. -+ -+A read-only overlay of two read-only filesystems may use any -+filesystem type. -+ -+Directories -+----------- -+ -+Overlaying mainly involves directories. If a given name appears in both -+upper and lower filesystems and refers to a non-directory in either, -+then the lower object is hidden - the name refers only to the upper -+object. -+ -+Where both upper and lower objects are directories, a merged directory -+is formed. -+ -+At mount time, the two directories given as mount options are combined -+into a merged directory: -+ -+ mount -t overlayfs overlayfs -olowerdir=/lower,upperdir=/upper /overlay -+ -+Then whenever a lookup is requested in such a merged directory, the -+lookup is performed in each actual directory and the combined result -+is cached in the dentry belonging to the overlay filesystem. If both -+actual lookups find directories, both are stored and a merged -+directory is created, otherwise only one is stored: the upper if it -+exists, else the lower. -+ -+Only the lists of names from directories are merged. Other content -+such as metadata and extended attributes are reported for the upper -+directory only. These attributes of the lower directory are hidden. -+ -+whiteouts and opaque directories -+-------------------------------- -+ -+In order to support rm and rmdir without changing the lower -+filesystem, an overlay filesystem needs to record in the upper filesystem -+that files have been removed. This is done using whiteouts and opaque -+directories (non-directories are always opaque). -+ -+The overlay filesystem uses extended attributes with a -+"trusted.overlay." prefix to record these details. -+ -+A whiteout is created as a symbolic link with target -+"(overlay-whiteout)" and with xattr "trusted.overlay.whiteout" set to "y". -+When a whiteout is found in the upper level of a merged directory, any -+matching name in the lower level is ignored, and the whiteout itself -+is also hidden. -+ -+A directory is made opaque by setting the xattr "trusted.overlay.opaque" -+to "y". Where the upper filesystem contains an opaque directory, any -+directory in the lower filesystem with the same name is ignored. -+ -+readdir -+------- -+ -+When a 'readdir' request is made on a merged directory, the upper and -+lower directories are each read and the name lists merged in the -+obvious way (upper is read first, then lower - entries that already -+exist are not re-added). This merged name list is cached in the -+'struct file' and so remains as long as the file is kept open. If the -+directory is opened and read by two processes at the same time, they -+will each have separate caches. A seekdir to the start of the -+directory (offset 0) followed by a readdir will cause the cache to be -+discarded and rebuilt. -+ -+This means that changes to the merged directory do not appear while a -+directory is being read. This is unlikely to be noticed by many -+programs. -+ -+seek offsets are assigned sequentially when the directories are read. -+Thus if -+ - read part of a directory -+ - remember an offset, and close the directory -+ - re-open the directory some time later -+ - seek to the remembered offset -+ -+there may be little correlation between the old and new locations in -+the list of filenames, particularly if anything has changed in the -+directory. -+ -+Readdir on directories that are not merged is simply handled by the -+underlying directory (upper or lower). -+ -+ -+Non-directories -+--------------- -+ -+Objects that are not directories (files, symlinks, device-special -+files etc.) are presented either from the upper or lower filesystem as -+appropriate. When a file in the lower filesystem is accessed in a way -+the requires write-access, such as opening for write access, changing -+some metadata etc., the file is first copied from the lower filesystem -+to the upper filesystem (copy_up). Note that creating a hard-link -+also requires copy_up, though of course creation of a symlink does -+not. -+ -+The copy_up may turn out to be unnecessary, for example if the file is -+opened for read-write but the data is not modified. -+ -+The copy_up process first makes sure that the containing directory -+exists in the upper filesystem - creating it and any parents as -+necessary. It then creates the object with the same metadata (owner, -+mode, mtime, symlink-target etc.) and then if the object is a file, the -+data is copied from the lower to the upper filesystem. Finally any -+extended attributes are copied up. -+ -+Once the copy_up is complete, the overlay filesystem simply -+provides direct access to the newly created file in the upper -+filesystem - future operations on the file are barely noticed by the -+overlay filesystem (though an operation on the name of the file such as -+rename or unlink will of course be noticed and handled). -+ -+ -+Non-standard behavior -+--------------------- -+ -+The copy_up operation essentially creates a new, identical file and -+moves it over to the old name. The new file may be on a different -+filesystem, so both st_dev and st_ino of the file may change. -+ -+Any open files referring to this inode will access the old data and -+metadata. Similarly any file locks obtained before copy_up will not -+apply to the copied up file. -+ -+On a file opened with O_RDONLY fchmod(2), fchown(2), futimesat(2) and -+fsetxattr(2) will fail with EROFS. -+ -+If a file with multiple hard links is copied up, then this will -+"break" the link. Changes will not be propagated to other names -+referring to the same inode. -+ -+Symlinks in /proc/PID/ and /proc/PID/fd which point to a non-directory -+object in overlayfs will not contain valid absolute paths, only -+relative paths leading up to the filesystem's root. This will be -+fixed in the future. -+ -+Some operations are not atomic, for example a crash during copy_up or -+rename will leave the filesystem in an inconsistent state. This will -+be addressed in the future. -+ -+Changes to underlying filesystems -+--------------------------------- -+ -+Offline changes, when the overlay is not mounted, are allowed to either -+the upper or the lower trees. -+ -+Changes to the underlying filesystems while part of a mounted overlay -+filesystem are not allowed. If the underlying filesystem is changed, -+the behavior of the overlay is undefined, though it will not result in -+a crash or deadlock. ---- a/Documentation/filesystems/vfs.txt -+++ b/Documentation/filesystems/vfs.txt -@@ -362,6 +362,7 @@ struct inode_operations { - int (*atomic_open)(struct inode *, struct dentry *, - struct file *, unsigned open_flag, - umode_t create_mode, int *opened); -+ int (*dentry_open)(struct dentry *, struct file *, const struct cred *); - }; - - Again, all methods are called without any locks being held, unless -@@ -681,6 +682,12 @@ struct address_space_operations { - but instead uses bmap to find out where the blocks in the file - are and uses those addresses directly. - -+ dentry_open: this is an alternative to f_op->open(), the difference is that -+ this method may open a file not necessarily originating from the same -+ filesystem as the one i_op->open() was called on. It may be -+ useful for stacking filesystems which want to allow native I/O directly -+ on underlying files. -+ - - invalidatepage: If a page has PagePrivate set, then invalidatepage - will be called when part or all of the page is to be removed ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -6019,6 +6019,13 @@ F: drivers/scsi/osd/ - F: include/scsi/osd_* - F: fs/exofs/ - -+OVERLAYFS FILESYSTEM -+M: Miklos Szeredi <miklos@szeredi.hu> -+L: linux-fsdevel@vger.kernel.org -+S: Supported -+F: fs/overlayfs/* -+F: Documentation/filesystems/overlayfs.txt -+ - P54 WIRELESS DRIVER - M: Christian Lamparter <chunkeey@googlemail.com> - L: linux-wireless@vger.kernel.org ---- a/fs/Kconfig -+++ b/fs/Kconfig -@@ -67,6 +67,7 @@ source "fs/quota/Kconfig" - - source "fs/autofs4/Kconfig" - source "fs/fuse/Kconfig" -+source "fs/overlayfs/Kconfig" - - config GENERIC_ACL - bool ---- a/fs/Makefile -+++ b/fs/Makefile -@@ -105,6 +105,7 @@ obj-$(CONFIG_QNX6FS_FS) += qnx6/ - obj-$(CONFIG_AUTOFS4_FS) += autofs4/ - obj-$(CONFIG_ADFS_FS) += adfs/ - obj-$(CONFIG_FUSE_FS) += fuse/ -+obj-$(CONFIG_OVERLAYFS_FS) += overlayfs/ - obj-$(CONFIG_UDF_FS) += udf/ - obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ - obj-$(CONFIG_OMFS_FS) += omfs/ ---- a/fs/ecryptfs/main.c -+++ b/fs/ecryptfs/main.c -@@ -567,6 +567,13 @@ static struct dentry *ecryptfs_mount(str - s->s_maxbytes = path.dentry->d_sb->s_maxbytes; - s->s_blocksize = path.dentry->d_sb->s_blocksize; - s->s_magic = ECRYPTFS_SUPER_MAGIC; -+ s->s_stack_depth = path.dentry->d_sb->s_stack_depth + 1; -+ -+ rc = -EINVAL; -+ if (s->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) { -+ pr_err("eCryptfs: maximum fs stacking depth exceeded\n"); -+ goto out_free; -+ } - - inode = ecryptfs_get_inode(path.dentry->d_inode, s); - rc = PTR_ERR(inode); ---- a/fs/internal.h -+++ b/fs/internal.h -@@ -42,11 +42,6 @@ static inline int __sync_blockdev(struct - extern void __init chrdev_init(void); - - /* -- * namei.c -- */ --extern int __inode_permission(struct inode *, int); -- --/* - * namespace.c - */ - extern int copy_mount_options(const void __user *, unsigned long *); -@@ -132,12 +127,6 @@ extern struct dentry *__d_alloc(struct s - extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); - - /* -- * splice.c -- */ --extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, -- loff_t *opos, size_t len, unsigned int flags); -- --/* - * pipe.c - */ - extern const struct file_operations pipefifo_fops; ---- a/fs/namei.c -+++ b/fs/namei.c -@@ -404,6 +404,7 @@ int __inode_permission(struct inode *ino - - return security_inode_permission(inode, mask); - } -+EXPORT_SYMBOL(__inode_permission); - - /** - * sb_permission - Check superblock-level permissions -@@ -2869,9 +2870,12 @@ finish_open_created: - error = may_open(&nd->path, acc_mode, open_flag); - if (error) - goto out; -- file->f_path.mnt = nd->path.mnt; -- error = finish_open(file, nd->path.dentry, NULL, opened); -- if (error) { -+ -+ BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ -+ error = vfs_open(&nd->path, file, current_cred()); -+ if (!error) { -+ *opened |= FILE_OPENED; -+ } else { - if (error == -EOPENSTALE) - goto stale_open; - goto out; ---- a/fs/namespace.c -+++ b/fs/namespace.c -@@ -1455,6 +1455,33 @@ void drop_collected_mounts(struct vfsmou - namespace_unlock(); - } - -+/** -+ * clone_private_mount - create a private clone of a path -+ * -+ * This creates a new vfsmount, which will be the clone of @path. The new will -+ * not be attached anywhere in the namespace and will be private (i.e. changes -+ * to the originating mount won't be propagated into this). -+ * -+ * Release with mntput(). -+ */ -+struct vfsmount *clone_private_mount(struct path *path) -+{ -+ struct mount *old_mnt = real_mount(path->mnt); -+ struct mount *new_mnt; -+ -+ if (IS_MNT_UNBINDABLE(old_mnt)) -+ return ERR_PTR(-EINVAL); -+ -+ down_read(&namespace_sem); -+ new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE); -+ up_read(&namespace_sem); -+ if (IS_ERR(new_mnt)) -+ return ERR_CAST(new_mnt); -+ -+ return &new_mnt->mnt; -+} -+EXPORT_SYMBOL_GPL(clone_private_mount); -+ - int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, - struct vfsmount *root) - { ---- a/fs/open.c -+++ b/fs/open.c -@@ -788,8 +788,7 @@ struct file *dentry_open(const struct pa - f = get_empty_filp(); - if (!IS_ERR(f)) { - f->f_flags = flags; -- f->f_path = *path; -- error = do_dentry_open(f, NULL, cred); -+ error = vfs_open(path, f, cred); - if (!error) { - /* from now on we need fput() to dispose of f */ - error = open_check_o_direct(f); -@@ -806,6 +805,26 @@ struct file *dentry_open(const struct pa - } - EXPORT_SYMBOL(dentry_open); - -+/** -+ * vfs_open - open the file at the given path -+ * @path: path to open -+ * @filp: newly allocated file with f_flag initialized -+ * @cred: credentials to use -+ */ -+int vfs_open(const struct path *path, struct file *filp, -+ const struct cred *cred) -+{ -+ struct inode *inode = path->dentry->d_inode; -+ -+ if (inode->i_op->dentry_open) -+ return inode->i_op->dentry_open(path->dentry, filp, cred); -+ else { -+ filp->f_path = *path; -+ return do_dentry_open(filp, NULL, cred); -+ } -+} -+EXPORT_SYMBOL(vfs_open); -+ - static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op) - { - int lookup_flags = 0; ---- /dev/null -+++ b/fs/overlayfs/Kconfig -@@ -0,0 +1,10 @@ -+config OVERLAYFS_FS -+ tristate "Overlay filesystem support" -+ help -+ An overlay filesystem combines two filesystems - an 'upper' filesystem -+ and a 'lower' filesystem. When a name exists in both filesystems, the -+ object in the 'upper' filesystem is visible while the object in the -+ 'lower' filesystem is either hidden or, in the case of directories, -+ merged with the 'upper' object. -+ -+ For more information see Documentation/filesystems/overlayfs.txt ---- /dev/null -+++ b/fs/overlayfs/Makefile -@@ -0,0 +1,7 @@ -+# -+# Makefile for the overlay filesystem. -+# -+ -+obj-$(CONFIG_OVERLAYFS_FS) += overlayfs.o -+ -+overlayfs-objs := super.o inode.o dir.o readdir.o copy_up.o ---- /dev/null -+++ b/fs/overlayfs/copy_up.c -@@ -0,0 +1,387 @@ -+/* -+ * -+ * Copyright (C) 2011 Novell Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License version 2 as published by -+ * the Free Software Foundation. -+ */ -+ -+#include <linux/fs.h> -+#include <linux/slab.h> -+#include <linux/file.h> -+#include <linux/splice.h> -+#include <linux/xattr.h> -+#include <linux/security.h> -+#include <linux/uaccess.h> -+#include <linux/sched.h> -+#include "overlayfs.h" -+ -+#define OVL_COPY_UP_CHUNK_SIZE (1 << 20) -+ -+static int ovl_copy_up_xattr(struct dentry *old, struct dentry *new) -+{ -+ ssize_t list_size, size; -+ char *buf, *name, *value; -+ int error; -+ -+ if (!old->d_inode->i_op->getxattr || -+ !new->d_inode->i_op->getxattr) -+ return 0; -+ -+ list_size = vfs_listxattr(old, NULL, 0); -+ if (list_size <= 0) { -+ if (list_size == -EOPNOTSUPP) -+ return 0; -+ return list_size; -+ } -+ -+ buf = kzalloc(list_size, GFP_KERNEL); -+ if (!buf) -+ return -ENOMEM; -+ -+ error = -ENOMEM; -+ value = kmalloc(XATTR_SIZE_MAX, GFP_KERNEL); -+ if (!value) -+ goto out; -+ -+ list_size = vfs_listxattr(old, buf, list_size); -+ if (list_size <= 0) { -+ error = list_size; -+ goto out_free_value; -+ } -+ -+ for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { -+ size = vfs_getxattr(old, name, value, XATTR_SIZE_MAX); -+ if (size <= 0) { -+ error = size; -+ goto out_free_value; -+ } -+ error = vfs_setxattr(new, name, value, size, 0); -+ if (error) -+ goto out_free_value; -+ } -+ -+out_free_value: -+ kfree(value); -+out: -+ kfree(buf); -+ return error; -+} -+ -+static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) -+{ -+ struct file *old_file; -+ struct file *new_file; -+ loff_t old_pos = 0; -+ loff_t new_pos = 0; -+ int error = 0; -+ -+ if (len == 0) -+ return 0; -+ -+ old_file = ovl_path_open(old, O_RDONLY); -+ if (IS_ERR(old_file)) -+ return PTR_ERR(old_file); -+ -+ new_file = ovl_path_open(new, O_WRONLY); -+ if (IS_ERR(new_file)) { -+ error = PTR_ERR(new_file); -+ goto out_fput; -+ } -+ -+ /* FIXME: copy up sparse files efficiently */ -+ while (len) { -+ size_t this_len = OVL_COPY_UP_CHUNK_SIZE; -+ long bytes; -+ -+ if (len < this_len) -+ this_len = len; -+ -+ if (signal_pending_state(TASK_KILLABLE, current)) { -+ error = -EINTR; -+ break; -+ } -+ -+ bytes = do_splice_direct(old_file, &old_pos, -+ new_file, &new_pos, -+ this_len, SPLICE_F_MOVE); -+ if (bytes <= 0) { -+ error = bytes; -+ break; -+ } -+ -+ len -= bytes; -+ } -+ -+ fput(new_file); -+out_fput: -+ fput(old_file); -+ return error; -+} -+ -+static char *ovl_read_symlink(struct dentry *realdentry) -+{ -+ int res; -+ char *buf; -+ struct inode *inode = realdentry->d_inode; -+ mm_segment_t old_fs; -+ -+ res = -EINVAL; -+ if (!inode->i_op->readlink) -+ goto err; -+ -+ res = -ENOMEM; -+ buf = (char *) __get_free_page(GFP_KERNEL); -+ if (!buf) -+ goto err; -+ -+ old_fs = get_fs(); -+ set_fs(get_ds()); -+ /* The cast to a user pointer is valid due to the set_fs() */ -+ res = inode->i_op->readlink(realdentry, -+ (char __user *)buf, PAGE_SIZE - 1); -+ set_fs(old_fs); -+ if (res < 0) { -+ free_page((unsigned long) buf); -+ goto err; -+ } -+ buf[res] = '\0'; -+ -+ return buf; -+ -+err: -+ return ERR_PTR(res); -+} -+ -+static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat) -+{ -+ struct iattr attr = { -+ .ia_valid = -+ ATTR_ATIME | ATTR_MTIME | ATTR_ATIME_SET | ATTR_MTIME_SET, -+ .ia_atime = stat->atime, -+ .ia_mtime = stat->mtime, -+ }; -+ -+ return notify_change(upperdentry, &attr); -+} -+ -+static int ovl_set_mode(struct dentry *upperdentry, umode_t mode) -+{ -+ struct iattr attr = { -+ .ia_valid = ATTR_MODE, -+ .ia_mode = mode, -+ }; -+ -+ return notify_change(upperdentry, &attr); -+} -+ -+static int ovl_copy_up_locked(struct dentry *upperdir, struct dentry *dentry, -+ struct path *lowerpath, struct kstat *stat, -+ const char *link) -+{ -+ int err; -+ struct path newpath; -+ umode_t mode = stat->mode; -+ -+ /* Can't properly set mode on creation because of the umask */ -+ stat->mode &= S_IFMT; -+ -+ ovl_path_upper(dentry, &newpath); -+ WARN_ON(newpath.dentry); -+ newpath.dentry = ovl_upper_create(upperdir, dentry, stat, link); -+ if (IS_ERR(newpath.dentry)) -+ return PTR_ERR(newpath.dentry); -+ -+ if (S_ISREG(stat->mode)) { -+ err = ovl_copy_up_data(lowerpath, &newpath, stat->size); -+ if (err) -+ goto err_remove; -+ } -+ -+ err = ovl_copy_up_xattr(lowerpath->dentry, newpath.dentry); -+ if (err) -+ goto err_remove; -+ -+ mutex_lock(&newpath.dentry->d_inode->i_mutex); -+ if (!S_ISLNK(stat->mode)) -+ err = ovl_set_mode(newpath.dentry, mode); -+ if (!err) -+ err = ovl_set_timestamps(newpath.dentry, stat); -+ mutex_unlock(&newpath.dentry->d_inode->i_mutex); -+ if (err) -+ goto err_remove; -+ -+ ovl_dentry_update(dentry, newpath.dentry); -+ -+ /* -+ * Easiest way to get rid of the lower dentry reference is to -+ * drop this dentry. This is neither needed nor possible for -+ * directories. -+ */ -+ if (!S_ISDIR(stat->mode)) -+ d_drop(dentry); -+ -+ return 0; -+ -+err_remove: -+ if (S_ISDIR(stat->mode)) -+ vfs_rmdir(upperdir->d_inode, newpath.dentry); -+ else -+ vfs_unlink(upperdir->d_inode, newpath.dentry); -+ -+ dput(newpath.dentry); -+ -+ return err; -+} -+ -+/* -+ * Copy up a single dentry -+ * -+ * Directory renames only allowed on "pure upper" (already created on -+ * upper filesystem, never copied up). Directories which are on lower or -+ * are merged may not be renamed. For these -EXDEV is returned and -+ * userspace has to deal with it. This means, when copying up a -+ * directory we can rely on it and ancestors being stable. -+ * -+ * Non-directory renames start with copy up of source if necessary. The -+ * actual rename will only proceed once the copy up was successful. Copy -+ * up uses upper parent i_mutex for exclusion. Since rename can change -+ * d_parent it is possible that the copy up will lock the old parent. At -+ * that point the file will have already been copied up anyway. -+ */ -+static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, -+ struct path *lowerpath, struct kstat *stat) -+{ -+ int err; -+ struct kstat pstat; -+ struct path parentpath; -+ struct dentry *upperdir; -+ const struct cred *old_cred; -+ struct cred *override_cred; -+ char *link = NULL; -+ -+ ovl_path_upper(parent, &parentpath); -+ upperdir = parentpath.dentry; -+ -+ err = vfs_getattr(&parentpath, &pstat); -+ if (err) -+ return err; -+ -+ if (S_ISLNK(stat->mode)) { -+ link = ovl_read_symlink(lowerpath->dentry); -+ if (IS_ERR(link)) -+ return PTR_ERR(link); -+ } -+ -+ err = -ENOMEM; -+ override_cred = prepare_creds(); -+ if (!override_cred) -+ goto out_free_link; -+ -+ override_cred->fsuid = stat->uid; -+ override_cred->fsgid = stat->gid; -+ /* -+ * CAP_SYS_ADMIN for copying up extended attributes -+ * CAP_DAC_OVERRIDE for create -+ * CAP_FOWNER for chmod, timestamp update -+ * CAP_FSETID for chmod -+ * CAP_MKNOD for mknod -+ */ -+ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN); -+ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE); -+ cap_raise(override_cred->cap_effective, CAP_FOWNER); -+ cap_raise(override_cred->cap_effective, CAP_FSETID); -+ cap_raise(override_cred->cap_effective, CAP_MKNOD); -+ old_cred = override_creds(override_cred); -+ -+ mutex_lock_nested(&upperdir->d_inode->i_mutex, I_MUTEX_PARENT); -+ if (ovl_path_type(dentry) != OVL_PATH_LOWER) { -+ err = 0; -+ } else { -+ err = ovl_copy_up_locked(upperdir, dentry, lowerpath, -+ stat, link); -+ if (!err) { -+ /* Restore timestamps on parent (best effort) */ -+ ovl_set_timestamps(upperdir, &pstat); -+ } -+ } -+ -+ mutex_unlock(&upperdir->d_inode->i_mutex); -+ -+ revert_creds(old_cred); -+ put_cred(override_cred); -+ -+out_free_link: -+ if (link) -+ free_page((unsigned long) link); -+ -+ return err; -+} -+ -+int ovl_copy_up(struct dentry *dentry) -+{ -+ int err; -+ -+ err = 0; -+ while (!err) { -+ struct dentry *next; -+ struct dentry *parent; -+ struct path lowerpath; -+ struct kstat stat; -+ enum ovl_path_type type = ovl_path_type(dentry); -+ -+ if (type != OVL_PATH_LOWER) -+ break; -+ -+ next = dget(dentry); -+ /* find the topmost dentry not yet copied up */ -+ for (;;) { -+ parent = dget_parent(next); -+ -+ type = ovl_path_type(parent); -+ if (type != OVL_PATH_LOWER) -+ break; -+ -+ dput(next); -+ next = parent; -+ } -+ -+ ovl_path_lower(next, &lowerpath); -+ err = vfs_getattr(&lowerpath, &stat); -+ if (!err) -+ err = ovl_copy_up_one(parent, next, &lowerpath, &stat); -+ -+ dput(parent); -+ dput(next); -+ } -+ -+ return err; -+} -+ -+/* Optimize by not copying up the file first and truncating later */ -+int ovl_copy_up_truncate(struct dentry *dentry, loff_t size) -+{ -+ int err; -+ struct kstat stat; -+ struct path lowerpath; -+ struct dentry *parent = dget_parent(dentry); -+ -+ err = ovl_copy_up(parent); -+ if (err) -+ goto out_dput_parent; -+ -+ ovl_path_lower(dentry, &lowerpath); -+ err = vfs_getattr(&lowerpath, &stat); -+ if (err) -+ goto out_dput_parent; -+ -+ if (size < stat.size) -+ stat.size = size; -+ -+ err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat); -+ -+out_dput_parent: -+ dput(parent); -+ return err; -+} ---- /dev/null -+++ b/fs/overlayfs/dir.c -@@ -0,0 +1,605 @@ -+/* -+ * -+ * Copyright (C) 2011 Novell Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License version 2 as published by -+ * the Free Software Foundation. -+ */ -+ -+#include <linux/fs.h> -+#include <linux/namei.h> -+#include <linux/xattr.h> -+#include <linux/security.h> -+#include <linux/cred.h> -+#include "overlayfs.h" -+ -+static const char *ovl_whiteout_symlink = "(overlay-whiteout)"; -+ -+static int ovl_whiteout(struct dentry *upperdir, struct dentry *dentry) -+{ -+ int err; -+ struct dentry *newdentry; -+ const struct cred *old_cred; -+ struct cred *override_cred; -+ -+ /* FIXME: recheck lower dentry to see if whiteout is really needed */ -+ -+ err = -ENOMEM; -+ override_cred = prepare_creds(); -+ if (!override_cred) -+ goto out; -+ -+ /* -+ * CAP_SYS_ADMIN for setxattr -+ * CAP_DAC_OVERRIDE for symlink creation -+ * CAP_FOWNER for unlink in sticky directory -+ */ -+ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN); -+ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE); -+ cap_raise(override_cred->cap_effective, CAP_FOWNER); -+ override_cred->fsuid = GLOBAL_ROOT_UID; -+ override_cred->fsgid = GLOBAL_ROOT_GID; -+ old_cred = override_creds(override_cred); -+ -+ newdentry = lookup_one_len(dentry->d_name.name, upperdir, -+ dentry->d_name.len); -+ err = PTR_ERR(newdentry); -+ if (IS_ERR(newdentry)) -+ goto out_put_cred; -+ -+ /* Just been removed within the same locked region */ -+ WARN_ON(newdentry->d_inode); -+ -+ err = vfs_symlink(upperdir->d_inode, newdentry, ovl_whiteout_symlink); -+ if (err) -+ goto out_dput; -+ -+ ovl_dentry_version_inc(dentry->d_parent); -+ -+ err = vfs_setxattr(newdentry, ovl_whiteout_xattr, "y", 1, 0); -+ if (err) -+ vfs_unlink(upperdir->d_inode, newdentry); -+ -+out_dput: -+ dput(newdentry); -+out_put_cred: -+ revert_creds(old_cred); -+ put_cred(override_cred); -+out: -+ if (err) { -+ /* -+ * There's no way to recover from failure to whiteout. -+ * What should we do? Log a big fat error and... ? -+ */ -+ pr_err("overlayfs: ERROR - failed to whiteout '%s'\n", -+ dentry->d_name.name); -+ } -+ -+ return err; -+} -+ -+static struct dentry *ovl_lookup_create(struct dentry *upperdir, -+ struct dentry *template) -+{ -+ int err; -+ struct dentry *newdentry; -+ struct qstr *name = &template->d_name; -+ -+ newdentry = lookup_one_len(name->name, upperdir, name->len); -+ if (IS_ERR(newdentry)) -+ return newdentry; -+ -+ if (newdentry->d_inode) { -+ const struct cred *old_cred; -+ struct cred *override_cred; -+ -+ /* No need to check whiteout if lower parent is non-existent */ -+ err = -EEXIST; -+ if (!ovl_dentry_lower(template->d_parent)) -+ goto out_dput; -+ -+ if (!S_ISLNK(newdentry->d_inode->i_mode)) -+ goto out_dput; -+ -+ err = -ENOMEM; -+ override_cred = prepare_creds(); -+ if (!override_cred) -+ goto out_dput; -+ -+ /* -+ * CAP_SYS_ADMIN for getxattr -+ * CAP_FOWNER for unlink in sticky directory -+ */ -+ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN); -+ cap_raise(override_cred->cap_effective, CAP_FOWNER); -+ old_cred = override_creds(override_cred); -+ -+ err = -EEXIST; -+ if (ovl_is_whiteout(newdentry)) -+ err = vfs_unlink(upperdir->d_inode, newdentry); -+ -+ revert_creds(old_cred); -+ put_cred(override_cred); -+ if (err) -+ goto out_dput; -+ -+ dput(newdentry); -+ newdentry = lookup_one_len(name->name, upperdir, name->len); -+ if (IS_ERR(newdentry)) { -+ ovl_whiteout(upperdir, template); -+ return newdentry; -+ } -+ -+ /* -+ * Whiteout just been successfully removed, parent -+ * i_mutex is still held, there's no way the lookup -+ * could return positive. -+ */ -+ WARN_ON(newdentry->d_inode); -+ } -+ -+ return newdentry; -+ -+out_dput: -+ dput(newdentry); -+ return ERR_PTR(err); -+} -+ -+struct dentry *ovl_upper_create(struct dentry *upperdir, struct dentry *dentry, -+ struct kstat *stat, const char *link) -+{ -+ int err; -+ struct dentry *newdentry; -+ struct inode *dir = upperdir->d_inode; -+ generated by cgit v1.2.3 (git 2.25.1) at 2025-03-09 04:24:51 +0000
|