All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project
@ 2017-04-05 10:31 Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 01/32] ARM: BCM5301X: Add back handler ignoring external imprecise aborts Amit Pundir
                   ` (32 more replies)
  0 siblings, 33 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh

Hi Greg,

2nd attempt at sending stable commits taken from lede source tree
https://github.com/lede-project/source for your consideration for
4.9.y. I Forgot to update the Subject line of the individual patches
in my 1st attempt. They didn't explicitly mention that they were
targeted for stable-4.9 and that led to some confusion.

Cherry-picked and build tested on Linux 4.9.20 for
ARCH=arm/arm64/i386/x86_64 + allmodconfig.

Arnd Bergmann (1):
  rt2500usb: don't mark register accesses as inline

Bjorn Helgaas (1):
  PCI: iproc: Save host bridge window resource in struct iproc_pcie

Boris Brezillon (3):
  clk: bcm: Support rate change propagation on bcm2835 clocks
  clk: bcm: Allow rate change propagation to PLLH_AUX on VEC clock
  clk: bcm: Fix 'maybe-uninitialized' warning in
    bcm2835_clock_choose_div_and_prate()

Eric Anholt (3):
  clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers.
  clk: bcm2835: Register the DSI0/DSI1 pixel clocks.
  clk: bcm2835: Add leaf clock measurement support, disabled by default

Felix Fietkau (1):
  MIPS: Lantiq: Fix cascaded IRQ setup

John Youn (1):
  usb: dwc2: Remove unnecessary kfree

Jon Mason (1):
  ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags

Matthias Reichl (1):
  dmaengine: bcm2835: Fix cyclic DMA period splitting

Noralf Trønnes (4):
  i2c: bcm2835: Fix hang for writing messages larger than 16 bytes
  i2c: bcm2835: Protect against unexpected TXW/RXR interrupts
  i2c: bcm2835: Use dev_dbg logging on transfer errors
  i2c: bcm2835: Can't support I2C_M_IGNORE_NAK

Rafał Miłecki (10):
  ARM: BCM5301X: Add back handler ignoring external imprecise aborts
  mtd: bcm47xxpart: fix parsing first block after aligned TRX
  net: add devm version of alloc_etherdev_mqs function
  net: bgmac: allocate struct bgmac just once & don't copy it
  net: bgmac: drop struct bcma_mdio we don't need anymore
  brcmfmac: check brcmf_bus_get_memdump result for error
  brcmfmac: be more verbose when PSM's watchdog fires
  brcmfmac: merge two brcmf_err macros into one
  brcmfmac: switch to C function (__brcmf_err) for printing errors
  brcmfmac: merge two remaining brcmf_err macros

Stanislaw Gruszka (3):
  rt2x00usb: do not anchor rx and tx urb's
  rt2x00usb: fix anchor initialization
  rt2x00: avoid introducing a USB dependency in the rt2x00lib module

Tobias Klauser (1):
  brcmfmac: Use net_device_stats from struct net_device

Tobias Wolf (1):
  of: Add check to of_scan_flat_dt() before accessing
    initial_boot_params

Vishal Thanki (1):
  rt2x00: Fix incorrect usage of CONFIG_RT2X00_LIB_USB

 .../bindings/clock/brcm,bcm2835-cprman.txt         |  15 +-
 arch/arm/boot/dts/bcm5301x.dtsi                    |   4 +-
 arch/arm/mach-bcm/bcm_5301x.c                      |  28 ++
 arch/mips/lantiq/irq.c                             |  38 +--
 drivers/clk/bcm/clk-bcm2835.c                      | 375 ++++++++++++++++++---
 drivers/dma/bcm2835-dma.c                          |   5 +-
 drivers/i2c/busses/i2c-bcm2835.c                   |  68 ++--
 drivers/mtd/bcm47xxpart.c                          |  10 +-
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c    |  98 +++---
 drivers/net/ethernet/broadcom/bgmac-bcma.c         |   6 +-
 drivers/net/ethernet/broadcom/bgmac-platform.c     |   2 +-
 drivers/net/ethernet/broadcom/bgmac.c              |  25 +-
 drivers/net/ethernet/broadcom/bgmac.h              |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  16 +
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    |  26 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.h    |   2 -
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c   |  35 +-
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   |  24 +-
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c     |  19 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c     |  23 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c     |  22 +-
 drivers/of/fdt.c                                   |   9 +-
 drivers/pci/host/pcie-iproc-bcma.c                 |  24 +-
 drivers/pci/host/pcie-iproc-platform.c             |  19 +-
 drivers/pci/host/pcie-iproc.h                      |   1 +
 drivers/usb/dwc2/hcd.c                             |   1 -
 include/dt-bindings/clock/bcm2835.h                |   2 +
 include/linux/etherdevice.h                        |   5 +
 net/ethernet/eth.c                                 |  28 ++
 29 files changed, 648 insertions(+), 287 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 01/32] ARM: BCM5301X: Add back handler ignoring external imprecise aborts
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags Amit Pundir
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Florian Fainelli

From: Rafał Miłecki <rafal@milecki.pl>

Since early BCM5301X days we got abort handler that was removed by
commit 937b12306ea79 ("ARM: BCM5301X: remove workaround imprecise abort
fault handler"). It assumed we need to deal only with pending aborts
left by the bootloader. Unfortunately this isn't true for BCM5301X.

When probing PCI config space (device enumeration) it is expected to
have master aborts on the PCI bus. Most bridges don't forward (or they
allow disabling it) these errors onto the AXI/AMBA bus but not the
Northstar (BCM5301X) one.

iProc PCIe controller on Northstar seems to be some older one, without
a control register for errors forwarding. It means we need to workaround
this at platform level. All newer platforms are not affected by this
issue.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
(cherry picked from commit 09f3510fb70a46c8921f2cf4a90dbcae460a6820)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/arm/mach-bcm/bcm_5301x.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/mach-bcm/bcm_5301x.c b/arch/arm/mach-bcm/bcm_5301x.c
index c8830a2..fe067f6 100644
--- a/arch/arm/mach-bcm/bcm_5301x.c
+++ b/arch/arm/mach-bcm/bcm_5301x.c
@@ -9,14 +9,42 @@
 #include <asm/hardware/cache-l2x0.h>
 
 #include <asm/mach/arch.h>
+#include <asm/siginfo.h>
+#include <asm/signal.h>
+
+#define FSR_EXTERNAL		(1 << 12)
+#define FSR_READ		(0 << 10)
+#define FSR_IMPRECISE		0x0406
 
 static const char *const bcm5301x_dt_compat[] __initconst = {
 	"brcm,bcm4708",
 	NULL,
 };
 
+static int bcm5301x_abort_handler(unsigned long addr, unsigned int fsr,
+				  struct pt_regs *regs)
+{
+	/*
+	 * We want to ignore aborts forwarded from the PCIe bus that are
+	 * expected and shouldn't really be passed by the PCIe controller.
+	 * The biggest disadvantage is the same FSR code may be reported when
+	 * reading non-existing APB register and we shouldn't ignore that.
+	 */
+	if (fsr == (FSR_EXTERNAL | FSR_READ | FSR_IMPRECISE))
+		return 0;
+
+	return 1;
+}
+
+static void __init bcm5301x_init_early(void)
+{
+	hook_fault_code(16 + 6, bcm5301x_abort_handler, SIGBUS, BUS_OBJERR,
+			"imprecise external abort");
+}
+
 DT_MACHINE_START(BCM5301X, "BCM5301X")
 	.l2c_aux_val	= 0,
 	.l2c_aux_mask	= ~0,
 	.dt_compat	= bcm5301x_dt_compat,
+	.init_early	= bcm5301x_init_early,
 MACHINE_END
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 01/32] ARM: BCM5301X: Add back handler ignoring external imprecise aborts Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-06  7:33   ` Greg KH
  2017-04-05 10:31 ` [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie Amit Pundir
                   ` (30 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Jon Mason, Florian Fainelli

From: Jon Mason <jon.mason@broadcom.com>

GIC_PPI flags were misconfigured for the timers, resulting in errors
like:
[    0.000000] GIC: PPI11 is secure or misconfigured

Changing them to being edge triggered corrects the issue

Suggested-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
Fixes: d27509f1 ("ARM: BCM5301X: add dts files for BCM4708 SoC")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
(cherry picked from commit 0c2bf9f95983fe30aa2f6463cb761cd42c2d521a)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/arm/boot/dts/bcm5301x.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
index ae4b388..4616452 100644
--- a/arch/arm/boot/dts/bcm5301x.dtsi
+++ b/arch/arm/boot/dts/bcm5301x.dtsi
@@ -66,14 +66,14 @@
 		timer@20200 {
 			compatible = "arm,cortex-a9-global-timer";
 			reg = <0x20200 0x100>;
-			interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>;
+			interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&periph_clk>;
 		};
 
 		local-timer@20600 {
 			compatible = "arm,cortex-a9-twd-timer";
 			reg = <0x20600 0x100>;
-			interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>;
+			interrupts = <GIC_PPI 13 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&periph_clk>;
 		};
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 01/32] ARM: BCM5301X: Add back handler ignoring external imprecise aborts Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-06  7:33   ` Greg KH
  2017-04-05 10:31 ` [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
                   ` (29 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Bjorn Helgaas

From: Bjorn Helgaas <bhelgaas@google.com>

The host bridge memory window resource is inserted into the iomem_resource
tree and cannot be deallocated until the host bridge itself is removed.

Previously, the window was on the stack, which meant the iomem_resource
entry pointed into the stack and was corrupted as soon as the probe
function returned, which caused memory corruption and errors like this:

  pcie_iproc_bcma bcma0:8: resource collision: [mem 0x40000000-0x47ffffff] conflicts with PCIe MEM space [mem 0x40000000-0x47ffffff]

Move the memory window resource from the stack into struct iproc_pcie so
its lifetime matches that of the host bridge.

Fixes: c3245a566400 ("PCI: iproc: Request host bridge window resources")
Reported-and-tested-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
(cherry picked from commit 6e347b5e05ea2ac4ac467a5a1cfaebb2c7f06f80)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/pci/host/pcie-iproc-bcma.c     | 24 ++++++++++++------------
 drivers/pci/host/pcie-iproc-platform.c | 19 ++++++++++---------
 drivers/pci/host/pcie-iproc.h          |  1 +
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c
index 8ce0890..46ca8ed 100644
--- a/drivers/pci/host/pcie-iproc-bcma.c
+++ b/drivers/pci/host/pcie-iproc-bcma.c
@@ -44,8 +44,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
 {
 	struct device *dev = &bdev->dev;
 	struct iproc_pcie *pcie;
-	LIST_HEAD(res);
-	struct resource res_mem;
+	LIST_HEAD(resources);
 	int ret;
 
 	pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
@@ -62,22 +61,23 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
 
 	pcie->base_addr = bdev->addr;
 
-	res_mem.start = bdev->addr_s[0];
-	res_mem.end = bdev->addr_s[0] + SZ_128M - 1;
-	res_mem.name = "PCIe MEM space";
-	res_mem.flags = IORESOURCE_MEM;
-	pci_add_resource(&res, &res_mem);
+	pcie->mem.start = bdev->addr_s[0];
+	pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1;
+	pcie->mem.name = "PCIe MEM space";
+	pcie->mem.flags = IORESOURCE_MEM;
+	pci_add_resource(&resources, &pcie->mem);
 
 	pcie->map_irq = iproc_pcie_bcma_map_irq;
 
-	ret = iproc_pcie_setup(pcie, &res);
-	if (ret)
+	ret = iproc_pcie_setup(pcie, &resources);
+	if (ret) {
 		dev_err(dev, "PCIe controller setup failed\n");
-
-	pci_free_resource_list(&res);
+		pci_free_resource_list(&resources);
+		return ret;
+	}
 
 	bcma_set_drvdata(bdev, pcie);
-	return ret;
+	return 0;
 }
 
 static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c
index a3de087..7dcaddc 100644
--- a/drivers/pci/host/pcie-iproc-platform.c
+++ b/drivers/pci/host/pcie-iproc-platform.c
@@ -46,7 +46,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct resource reg;
 	resource_size_t iobase = 0;
-	LIST_HEAD(res);
+	LIST_HEAD(resources);
 	int ret;
 
 	of_id = of_match_device(iproc_pcie_of_match_table, dev);
@@ -108,23 +108,24 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
 		pcie->phy = NULL;
 	}
 
-	ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase);
+	ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &resources,
+					       &iobase);
 	if (ret) {
-		dev_err(dev,
-			"unable to get PCI host bridge resources\n");
+		dev_err(dev, "unable to get PCI host bridge resources\n");
 		return ret;
 	}
 
 	pcie->map_irq = of_irq_parse_and_map_pci;
 
-	ret = iproc_pcie_setup(pcie, &res);
-	if (ret)
+	ret = iproc_pcie_setup(pcie, &resources);
+	if (ret) {
 		dev_err(dev, "PCIe controller setup failed\n");
-
-	pci_free_resource_list(&res);
+		pci_free_resource_list(&resources);
+		return ret;
+	}
 
 	platform_set_drvdata(pdev, pcie);
-	return ret;
+	return 0;
 }
 
 static int iproc_pcie_pltfm_remove(struct platform_device *pdev)
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h
index e84d93c..fa42267 100644
--- a/drivers/pci/host/pcie-iproc.h
+++ b/drivers/pci/host/pcie-iproc.h
@@ -68,6 +68,7 @@ struct iproc_pcie {
 #ifdef CONFIG_ARM
 	struct pci_sys_data sysdata;
 #endif
+	struct resource mem;
 	struct pci_bus *root_bus;
 	struct phy *phy;
 	int (*map_irq)(const struct pci_dev *, u8, u8);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (2 preceding siblings ...)
  2017-04-05 10:31 ` [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-06  7:34   ` Greg KH
  2017-04-06  9:29     ` James Hogan
  2017-04-05 10:31 ` [PATCH v2 for-4.9 05/32] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes Amit Pundir
                   ` (28 subsequent siblings)
  32 siblings, 2 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Felix Fietkau, linux-mips, James Hogan

From: Felix Fietkau <nbd@nbd.name>

With the IRQ stack changes integrated, the XRX200 devices started
emitting a constant stream of kernel messages like this:

[  565.415310] Spurious IRQ: CAUSE=0x1100c300

This is caused by IP0 getting handled by plat_irq_dispatch() rather than
its vectored interrupt handler, which is fixed by commit de856416e714
("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").

Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
for all MIPS CPU interrupts.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/15077/
[james.hogan@imgtec.com: tweaked commit message]
Signed-off-by: James Hogan <james.hogan@imgtec.com>

(cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/lantiq/irq.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index 8ac0e59..0ddf369 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -269,6 +269,11 @@ static void ltq_hw5_irqdispatch(void)
 DEFINE_HWx_IRQDISPATCH(5)
 #endif
 
+static void ltq_hw_irq_handler(struct irq_desc *desc)
+{
+	ltq_hw_irqdispatch(irq_desc_get_irq(desc) - 2);
+}
+
 #ifdef CONFIG_MIPS_MT_SMP
 void __init arch_init_ipiirq(int irq, struct irqaction *action)
 {
@@ -313,23 +318,19 @@ static struct irqaction irq_call = {
 asmlinkage void plat_irq_dispatch(void)
 {
 	unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
-	unsigned int i;
-
-	if ((MIPS_CPU_TIMER_IRQ == 7) && (pending & CAUSEF_IP7)) {
-		do_IRQ(MIPS_CPU_TIMER_IRQ);
-		goto out;
-	} else {
-		for (i = 0; i < MAX_IM; i++) {
-			if (pending & (CAUSEF_IP2 << i)) {
-				ltq_hw_irqdispatch(i);
-				goto out;
-			}
-		}
+	int irq;
+
+	if (!pending) {
+		spurious_interrupt();
+		return;
 	}
-	pr_alert("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status());
 
-out:
-	return;
+	pending >>= CAUSEB_IP;
+	while (pending) {
+		irq = fls(pending) - 1;
+		do_IRQ(MIPS_CPU_IRQ_BASE + irq);
+		pending &= ~BIT(irq);
+	}
 }
 
 static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
@@ -354,11 +355,6 @@ static const struct irq_domain_ops irq_domain_ops = {
 	.map = icu_map,
 };
 
-static struct irqaction cascade = {
-	.handler = no_action,
-	.name = "cascade",
-};
-
 int __init icu_of_init(struct device_node *node, struct device_node *parent)
 {
 	struct device_node *eiu_node;
@@ -390,7 +386,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
 	mips_cpu_irq_init();
 
 	for (i = 0; i < MAX_IM; i++)
-		setup_irq(i + 2, &cascade);
+		irq_set_chained_handler(i + 2, ltq_hw_irq_handler);
 
 	if (cpu_has_vint) {
 		pr_info("Setting up vectored interrupts\n");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 05/32] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (3 preceding siblings ...)
  2017-04-05 10:31 ` [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 06/32] i2c: bcm2835: Protect against unexpected TXW/RXR interrupts Amit Pundir
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Noralf Trønnes, Wolfram Sang

From: Noralf Trønnes <noralf@tronnes.org>

Writing messages larger than the FIFO size results in a hang, rendering
the machine unusable. This is because the RXD status flag is set on the
first interrupt which results in bcm2835_drain_rxfifo() stealing bytes
from the buffer. The controller continues to trigger interrupts waiting
for the missing bytes, but bcm2835_fill_txfifo() has none to give.
In this situation wait_for_completion_timeout() apparently is unable to
stop the madness.

The BCM2835 ARM Peripherals datasheet has this to say about the flags:
  TXD: is set when the FIFO has space for at least one byte of data.
  RXD: is set when the FIFO contains at least one byte of data.
  TXW: is set during a write transfer and the FIFO is less than full.
  RXR: is set during a read transfer and the FIFO is or more full.

Implementing the logic from the downstream i2c-bcm2708 driver solved
the hang problem.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit e2474541032db65d02bf88b6a8c2f954654b443f)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/i2c/busses/i2c-bcm2835.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index d4f3239..f283b71 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -64,6 +64,7 @@ struct bcm2835_i2c_dev {
 	int irq;
 	struct i2c_adapter adapter;
 	struct completion completion;
+	struct i2c_msg *curr_msg;
 	u32 msg_err;
 	u8 *msg_buf;
 	size_t msg_buf_remaining;
@@ -126,14 +127,13 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data)
 		return IRQ_HANDLED;
 	}
 
-	if (val & BCM2835_I2C_S_RXD) {
-		bcm2835_drain_rxfifo(i2c_dev);
-		if (!(val & BCM2835_I2C_S_DONE))
-			return IRQ_HANDLED;
-	}
-
 	if (val & BCM2835_I2C_S_DONE) {
-		if (i2c_dev->msg_buf_remaining)
+		if (i2c_dev->curr_msg->flags & I2C_M_RD) {
+			bcm2835_drain_rxfifo(i2c_dev);
+			val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S);
+		}
+
+		if ((val & BCM2835_I2C_S_RXD) || i2c_dev->msg_buf_remaining)
 			i2c_dev->msg_err = BCM2835_I2C_S_LEN;
 		else
 			i2c_dev->msg_err = 0;
@@ -141,11 +141,16 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data)
 		return IRQ_HANDLED;
 	}
 
-	if (val & BCM2835_I2C_S_TXD) {
+	if (val & BCM2835_I2C_S_TXW) {
 		bcm2835_fill_txfifo(i2c_dev);
 		return IRQ_HANDLED;
 	}
 
+	if (val & BCM2835_I2C_S_RXR) {
+		bcm2835_drain_rxfifo(i2c_dev);
+		return IRQ_HANDLED;
+	}
+
 	return IRQ_NONE;
 }
 
@@ -155,6 +160,7 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev,
 	u32 c;
 	unsigned long time_left;
 
+	i2c_dev->curr_msg = msg;
 	i2c_dev->msg_buf = msg->buf;
 	i2c_dev->msg_buf_remaining = msg->len;
 	reinit_completion(&i2c_dev->completion);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 06/32] i2c: bcm2835: Protect against unexpected TXW/RXR interrupts
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (4 preceding siblings ...)
  2017-04-05 10:31 ` [PATCH v2 for-4.9 05/32] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-05 10:31 ` [PATCH v2 for-4.9 07/32] i2c: bcm2835: Use dev_dbg logging on transfer errors Amit Pundir
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Noralf Trønnes, Wolfram Sang

From: Noralf Trønnes <noralf@tronnes.org>

If an unexpected TXW or RXR interrupt occurs (msg_buf_remaining == 0),
the driver has no way to fill/drain the FIFO to stop the interrupts.
In this case the controller has to be disabled and the transfer
completed to avoid hang.

(CLKT | ERR) and DONE interrupts are completed in their own paths, and
the controller is disabled in the transfer function after completion.
Unite the code paths and do disabling inside the interrupt routine.

Clear interrupt status bits in the united completion path instead of
trying to do it on every interrupt which isn't necessary.
Only CLKT, ERR and DONE can be cleared that way.

Add the status value to the error value in case of TXW/RXR errors to
distinguish them from the other S_LEN error.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit d4030d75c7cbb434b2a3e5f6af5065879d2615a5)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/i2c/busses/i2c-bcm2835.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index f283b71..d2ba1a4 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -50,8 +50,6 @@
 #define BCM2835_I2C_S_CLKT	BIT(9)
 #define BCM2835_I2C_S_LEN	BIT(10) /* Fake bit for SW error reporting */
 
-#define BCM2835_I2C_BITMSK_S	0x03FF
-
 #define BCM2835_I2C_CDIV_MIN	0x0002
 #define BCM2835_I2C_CDIV_MAX	0xFFFE
 
@@ -111,20 +109,26 @@ static void bcm2835_drain_rxfifo(struct bcm2835_i2c_dev *i2c_dev)
 	}
 }
 
+/*
+ * Note about I2C_C_CLEAR on error:
+ * The I2C_C_CLEAR on errors will take some time to resolve -- if you were in
+ * non-idle state and I2C_C_READ, it sets an abort_rx flag and runs through
+ * the state machine to send a NACK and a STOP. Since we're setting CLEAR
+ * without I2CEN, that NACK will be hanging around queued up for next time
+ * we start the engine.
+ */
+
 static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data)
 {
 	struct bcm2835_i2c_dev *i2c_dev = data;
 	u32 val, err;
 
 	val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S);
-	val &= BCM2835_I2C_BITMSK_S;
-	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_S, val);
 
 	err = val & (BCM2835_I2C_S_CLKT | BCM2835_I2C_S_ERR);
 	if (err) {
 		i2c_dev->msg_err = err;
-		complete(&i2c_dev->completion);
-		return IRQ_HANDLED;
+		goto complete;
 	}
 
 	if (val & BCM2835_I2C_S_DONE) {
@@ -137,21 +141,38 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data)
 			i2c_dev->msg_err = BCM2835_I2C_S_LEN;
 		else
 			i2c_dev->msg_err = 0;
-		complete(&i2c_dev->completion);
-		return IRQ_HANDLED;
+		goto complete;
 	}
 
 	if (val & BCM2835_I2C_S_TXW) {
+		if (!i2c_dev->msg_buf_remaining) {
+			i2c_dev->msg_err = val | BCM2835_I2C_S_LEN;
+			goto complete;
+		}
+
 		bcm2835_fill_txfifo(i2c_dev);
 		return IRQ_HANDLED;
 	}
 
 	if (val & BCM2835_I2C_S_RXR) {
+		if (!i2c_dev->msg_buf_remaining) {
+			i2c_dev->msg_err = val | BCM2835_I2C_S_LEN;
+			goto complete;
+		}
+
 		bcm2835_drain_rxfifo(i2c_dev);
 		return IRQ_HANDLED;
 	}
 
 	return IRQ_NONE;
+
+complete:
+	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, BCM2835_I2C_C_CLEAR);
+	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_S, BCM2835_I2C_S_CLKT |
+			   BCM2835_I2C_S_ERR | BCM2835_I2C_S_DONE);
+	complete(&i2c_dev->completion);
+
+	return IRQ_HANDLED;
 }
 
 static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev,
@@ -181,8 +202,9 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev,
 
 	time_left = wait_for_completion_timeout(&i2c_dev->completion,
 						BCM2835_I2C_TIMEOUT);
-	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, BCM2835_I2C_C_CLEAR);
 	if (!time_left) {
+		bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C,
+				   BCM2835_I2C_C_CLEAR);
 		dev_err(i2c_dev->dev, "i2c transfer timed out\n");
 		return -ETIMEDOUT;
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 07/32] i2c: bcm2835: Use dev_dbg logging on transfer errors
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (5 preceding siblings ...)
  2017-04-05 10:31 ` [PATCH v2 for-4.9 06/32] i2c: bcm2835: Protect against unexpected TXW/RXR interrupts Amit Pundir
@ 2017-04-05 10:31 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 08/32] i2c: bcm2835: Can't support I2C_M_IGNORE_NAK Amit Pundir
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:31 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Noralf Trønnes, Wolfram Sang

From: Noralf Trønnes <noralf@tronnes.org>

Writing to an AT24C32 generates on average 2x i2c transfer errors per
32-byte page write. Which amounts to a lot for a 4k write. This is due
to the fact that the chip doesn't respond during it's internal write
cycle when the at24 driver tries and retries the next write.
Only a handful drivers use dev_err() on transfer error, so switch to
dev_dbg() instead.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 23c9540b3ad1d7473fe40df80074d0fb0bf04869)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/i2c/busses/i2c-bcm2835.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index d2ba1a4..54d510a 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -216,7 +216,7 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev,
 	    (msg->flags & I2C_M_IGNORE_NAK))
 		return 0;
 
-	dev_err(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err);
+	dev_dbg(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err);
 
 	if (i2c_dev->msg_err & BCM2835_I2C_S_ERR)
 		return -EREMOTEIO;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 08/32] i2c: bcm2835: Can't support I2C_M_IGNORE_NAK
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (6 preceding siblings ...)
  2017-04-05 10:31 ` [PATCH v2 for-4.9 07/32] i2c: bcm2835: Use dev_dbg logging on transfer errors Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks Amit Pundir
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Noralf Trønnes, Wolfram Sang

From: Noralf Trønnes <noralf@tronnes.org>

The controller can't support this flag, so remove it.

Documentation/i2c/i2c-protocol states that all of the message is sent:

I2C_M_IGNORE_NAK:
    Normally message is interrupted immediately if there is [NA] from the
    client. Setting this flag treats any [NA] as [A], and all of
    message is sent.

>>From the BCM2835 ARM Peripherals datasheet:

    The ERR field is set when the slave fails to acknowledge either
    its address or a data byte written to it.

So when the controller doesn't receive an ack, it sets ERR and raises
an interrupt. In other words, the whole message is not sent.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 8d2cc5cc6ee5c0fc48a96bb29af55fc700f66fdf)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/i2c/busses/i2c-bcm2835.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 54d510a..565ef69 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -212,10 +212,6 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev,
 	if (likely(!i2c_dev->msg_err))
 		return 0;
 
-	if ((i2c_dev->msg_err & BCM2835_I2C_S_ERR) &&
-	    (msg->flags & I2C_M_IGNORE_NAK))
-		return 0;
-
 	dev_dbg(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err);
 
 	if (i2c_dev->msg_err & BCM2835_I2C_S_ERR)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (7 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 08/32] i2c: bcm2835: Can't support I2C_M_IGNORE_NAK Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-12 13:17   ` Greg KH
  2017-04-05 10:32 ` [PATCH v2 for-4.9 10/32] clk: bcm: Allow rate change propagation to PLLH_AUX on VEC clock Amit Pundir
                   ` (23 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Boris Brezillon, Stephen Boyd

From: Boris Brezillon <boris.brezillon@free-electrons.com>

Some peripheral clocks, like the VEC (Video EnCoder) clock need to be set
to a precise rate (in our case 108MHz). With the current implementation,
where peripheral clocks are not allowed to forward rate change requests
to their parents, it is impossible to match this requirement unless the
bootloader has configured things correctly, or a specific rate has been
assigned through the DT (with the assigned-clk-rates property).

Add a new field to struct bcm2835_clock_data to specify which parent
clocks accept rate change propagation, and support set rate propagation
in bcm2835_clock_determine_rate().

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 155e8b3b0ee320ae866b97dd31eba8a1f080a772)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 67 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 2acaa77..df96fe6 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -436,6 +436,9 @@ struct bcm2835_clock_data {
 	const char *const *parents;
 	int num_mux_parents;
 
+	/* Bitmap encoding which parents accept rate change propagation. */
+	unsigned int set_rate_parent;
+
 	u32 ctl_reg;
 	u32 div_reg;
 
@@ -1017,10 +1020,60 @@ bcm2835_clk_is_pllc(struct clk_hw *hw)
 	return strncmp(clk_hw_get_name(hw), "pllc", 4) == 0;
 }
 
+static unsigned long bcm2835_clock_choose_div_and_prate(struct clk_hw *hw,
+							int parent_idx,
+							unsigned long rate,
+							u32 *div,
+							unsigned long *prate)
+{
+	struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
+	struct bcm2835_cprman *cprman = clock->cprman;
+	const struct bcm2835_clock_data *data = clock->data;
+	unsigned long best_rate;
+	u32 curdiv, mindiv, maxdiv;
+	struct clk_hw *parent;
+
+	parent = clk_hw_get_parent_by_index(hw, parent_idx);
+
+	if (!(BIT(parent_idx) & data->set_rate_parent)) {
+		*prate = clk_hw_get_rate(parent);
+		*div = bcm2835_clock_choose_div(hw, rate, *prate, true);
+
+		return bcm2835_clock_rate_from_divisor(clock, *prate,
+						       *div);
+	}
+
+	if (data->frac_bits)
+		dev_warn(cprman->dev,
+			"frac bits are not used when propagating rate change");
+
+	/* clamp to min divider of 2 if we're dealing with a mash clock */
+	mindiv = data->is_mash_clock ? 2 : 1;
+	maxdiv = BIT(data->int_bits) - 1;
+
+	/* TODO: Be smart, and only test a subset of the available divisors. */
+	for (curdiv = mindiv; curdiv <= maxdiv; curdiv++) {
+		unsigned long tmp_rate;
+
+		tmp_rate = clk_hw_round_rate(parent, rate * curdiv);
+		tmp_rate /= curdiv;
+		if (curdiv == mindiv ||
+		    (tmp_rate > best_rate && tmp_rate <= rate))
+			best_rate = tmp_rate;
+
+		if (best_rate == rate)
+			break;
+	}
+
+	*div = curdiv << CM_DIV_FRAC_BITS;
+	*prate = curdiv * best_rate;
+
+	return best_rate;
+}
+
 static int bcm2835_clock_determine_rate(struct clk_hw *hw,
 					struct clk_rate_request *req)
 {
-	struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
 	struct clk_hw *parent, *best_parent = NULL;
 	bool current_parent_is_pllc;
 	unsigned long rate, best_rate = 0;
@@ -1048,9 +1101,8 @@ static int bcm2835_clock_determine_rate(struct clk_hw *hw,
 		if (bcm2835_clk_is_pllc(parent) && !current_parent_is_pllc)
 			continue;
 
-		prate = clk_hw_get_rate(parent);
-		div = bcm2835_clock_choose_div(hw, req->rate, prate, true);
-		rate = bcm2835_clock_rate_from_divisor(clock, prate, div);
+		rate = bcm2835_clock_choose_div_and_prate(hw, i, req->rate,
+							  &div, &prate);
 		if (rate > best_rate && rate <= req->rate) {
 			best_parent = parent;
 			best_prate = prate;
@@ -1262,6 +1314,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
 	init.name = data->name;
 	init.flags = data->flags | CLK_IGNORE_UNUSED;
 
+	/*
+	 * Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate
+	 * rate changes on at least of the parents.
+	 */
+	if (data->set_rate_parent)
+		init.flags |= CLK_SET_RATE_PARENT;
+
 	if (data->is_vpu_clock) {
 		init.ops = &bcm2835_vpu_clock_clk_ops;
 	} else {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 10/32] clk: bcm: Allow rate change propagation to PLLH_AUX on VEC clock
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (8 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 11/32] clk: bcm: Fix 'maybe-uninitialized' warning in bcm2835_clock_choose_div_and_prate() Amit Pundir
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Boris Brezillon, Stephen Boyd

From: Boris Brezillon <boris.brezillon@free-electrons.com>

The VEC clock requires needs to be set at exactly 108MHz. Allow rate
change propagation on PLLH_AUX to match this requirement wihtout
impacting other IPs (PLLH is currently only used by the HDMI encoder,
which cannot be enabled when the VEC encoder is enabled).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit d86d46af84855403c00018be1c3e7bc190f2a6cd)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index df96fe6..eaf82f4 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1861,7 +1861,12 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_VECCTL,
 		.div_reg = CM_VECDIV,
 		.int_bits = 4,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		/*
+		 * Allow rate change propagation only on PLLH_AUX which is
+		 * assigned index 7 in the parent array.
+		 */
+		.set_rate_parent = BIT(7)),
 
 	/* dsi clocks */
 	[BCM2835_CLOCK_DSI0E]	= REGISTER_PER_CLK(
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 11/32] clk: bcm: Fix 'maybe-uninitialized' warning in bcm2835_clock_choose_div_and_prate()
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (9 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 10/32] clk: bcm: Allow rate change propagation to PLLH_AUX on VEC clock Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers Amit Pundir
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Boris Brezillon, Stephen Boyd

From: Boris Brezillon <boris.brezillon@free-electrons.com>

best_rate is reported as potentially uninitialized by gcc.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Fixes: 155e8b3b0ee3 ("clk: bcm: Support rate change propagation on bcm2835 clocks")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 2aab7a2055a1705c9e30920d95a596226999eb21)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index eaf82f4..0d14409 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1029,7 +1029,7 @@ static unsigned long bcm2835_clock_choose_div_and_prate(struct clk_hw *hw,
 	struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
 	struct bcm2835_cprman *cprman = clock->cprman;
 	const struct bcm2835_clock_data *data = clock->data;
-	unsigned long best_rate;
+	unsigned long best_rate = 0;
 	u32 curdiv, mindiv, maxdiv;
 	struct clk_hw *parent;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers.
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (10 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 11/32] clk: bcm: Fix 'maybe-uninitialized' warning in bcm2835_clock_choose_div_and_prate() Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-06 16:53   ` Eric Anholt
  2017-04-05 10:32 ` [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks Amit Pundir
                   ` (20 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Eric Anholt, Stephen Boyd

From: Eric Anholt <eric@anholt.net>

Our core PLLs are intended to be configured once and left alone.  With
the SET_RATE_PARENT, asking to set the PLLD_DSI1 clock rate would
change PLLD just to get closer to the requested DSI clock, thus
changing PLLD_PER, the UART and ethernet PHY clock rates downstream of
it, and breaking ethernet.

We *do* want PLLH to change so that PLLH_AUX can be exactly the value
we want, though.  Thus, we need to have a per-divider policy of
whether to pass rate changes up.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 55486091bd1e1c5ed28c43c0d6b3392468a9adb5)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 0d14409..3d0848d 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -428,6 +428,7 @@ struct bcm2835_pll_divider_data {
 	u32 load_mask;
 	u32 hold_mask;
 	u32 fixed_divider;
+	u32 flags;
 };
 
 struct bcm2835_clock_data {
@@ -1252,7 +1253,7 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
 	init.num_parents = 1;
 	init.name = divider_name;
 	init.ops = &bcm2835_pll_divider_clk_ops;
-	init.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED;
+	init.flags = data->flags | CLK_IGNORE_UNUSED;
 
 	divider = devm_kzalloc(cprman->dev, sizeof(*divider), GFP_KERNEL);
 	if (!divider)
@@ -1466,7 +1467,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLA_CORE,
 		.load_mask = CM_PLLA_LOADCORE,
 		.hold_mask = CM_PLLA_HOLDCORE,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLA_PER]	= REGISTER_PLL_DIV(
 		.name = "plla_per",
 		.source_pll = "plla",
@@ -1474,7 +1476,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLA_PER,
 		.load_mask = CM_PLLA_LOADPER,
 		.hold_mask = CM_PLLA_HOLDPER,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLA_DSI0]	= REGISTER_PLL_DIV(
 		.name = "plla_dsi0",
 		.source_pll = "plla",
@@ -1490,7 +1493,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLA_CCP2,
 		.load_mask = CM_PLLA_LOADCCP2,
 		.hold_mask = CM_PLLA_HOLDCCP2,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 
 	/* PLLB is used for the ARM's clock. */
 	[BCM2835_PLLB]		= REGISTER_PLL(
@@ -1514,7 +1518,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLB_ARM,
 		.load_mask = CM_PLLB_LOADARM,
 		.hold_mask = CM_PLLB_HOLDARM,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 
 	/*
 	 * PLLC is the core PLL, used to drive the core VPU clock.
@@ -1543,7 +1548,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLC_CORE0,
 		.load_mask = CM_PLLC_LOADCORE0,
 		.hold_mask = CM_PLLC_HOLDCORE0,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLC_CORE1]	= REGISTER_PLL_DIV(
 		.name = "pllc_core1",
 		.source_pll = "pllc",
@@ -1551,7 +1557,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLC_CORE1,
 		.load_mask = CM_PLLC_LOADCORE1,
 		.hold_mask = CM_PLLC_HOLDCORE1,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLC_CORE2]	= REGISTER_PLL_DIV(
 		.name = "pllc_core2",
 		.source_pll = "pllc",
@@ -1559,7 +1566,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLC_CORE2,
 		.load_mask = CM_PLLC_LOADCORE2,
 		.hold_mask = CM_PLLC_HOLDCORE2,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLC_PER]	= REGISTER_PLL_DIV(
 		.name = "pllc_per",
 		.source_pll = "pllc",
@@ -1567,7 +1575,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLC_PER,
 		.load_mask = CM_PLLC_LOADPER,
 		.hold_mask = CM_PLLC_HOLDPER,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 
 	/*
 	 * PLLD is the display PLL, used to drive DSI display panels.
@@ -1596,7 +1605,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLD_CORE,
 		.load_mask = CM_PLLD_LOADCORE,
 		.hold_mask = CM_PLLD_HOLDCORE,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLD_PER]	= REGISTER_PLL_DIV(
 		.name = "plld_per",
 		.source_pll = "plld",
@@ -1604,7 +1614,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLD_PER,
 		.load_mask = CM_PLLD_LOADPER,
 		.hold_mask = CM_PLLD_HOLDPER,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLD_DSI0]	= REGISTER_PLL_DIV(
 		.name = "plld_dsi0",
 		.source_pll = "plld",
@@ -1649,7 +1660,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLH_RCAL,
 		.load_mask = CM_PLLH_LOADRCAL,
 		.hold_mask = 0,
-		.fixed_divider = 10),
+		.fixed_divider = 10,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLH_AUX]	= REGISTER_PLL_DIV(
 		.name = "pllh_aux",
 		.source_pll = "pllh",
@@ -1657,7 +1669,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLH_AUX,
 		.load_mask = CM_PLLH_LOADAUX,
 		.hold_mask = 0,
-		.fixed_divider = 1),
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 	[BCM2835_PLLH_PIX]	= REGISTER_PLL_DIV(
 		.name = "pllh_pix",
 		.source_pll = "pllh",
@@ -1665,7 +1678,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.a2w_reg = A2W_PLLH_PIX,
 		.load_mask = CM_PLLH_LOADPIX,
 		.hold_mask = 0,
-		.fixed_divider = 10),
+		.fixed_divider = 10,
+		.flags = CLK_SET_RATE_PARENT),
 
 	/* the clocks */
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks.
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (11 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-12 13:15   ` Greg KH
  2017-04-05 10:32 ` [PATCH v2 for-4.9 14/32] clk: bcm2835: Add leaf clock measurement support, disabled by default Amit Pundir
                   ` (19 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Eric Anholt, Stephen Boyd

From: Eric Anholt <eric@anholt.net>

The DSI pixel clocks are muxed from clocks generated in the analog phy
by the DSI driver.  In order to set them as parents, we need to do the
same name lookup dance on them as we do for our root oscillator.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 8a39e9fa578229fd4604266c6ebb1a3a77d7994c)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 .../bindings/clock/brcm,bcm2835-cprman.txt         |  15 ++-
 drivers/clk/bcm/clk-bcm2835.c                      | 121 +++++++++++++++++++--
 include/dt-bindings/clock/bcm2835.h                |   2 +
 3 files changed, 125 insertions(+), 13 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
index e56a1df..dd906db 100644
--- a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
+++ b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
@@ -16,7 +16,20 @@ Required properties:
 - #clock-cells:	Should be <1>. The permitted clock-specifier values can be
 		  found in include/dt-bindings/clock/bcm2835.h
 - reg:		Specifies base physical address and size of the registers
-- clocks:	The external oscillator clock phandle
+- clocks:	phandles to the parent clocks used as input to the module, in
+		  the following order:
+
+		  - External oscillator
+		  - DSI0 byte clock
+		  - DSI0 DDR2 clock
+		  - DSI0 DDR clock
+		  - DSI1 byte clock
+		  - DSI1 DDR2 clock
+		  - DSI1 DDR clock
+
+		  Only external oscillator is required.  The DSI clocks may
+		  not be present, in which case their children will be
+		  unusable.
 
 Example:
 
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 3d0848d..2e7423d 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -297,11 +297,32 @@
 #define LOCK_TIMEOUT_NS		100000000
 #define BCM2835_MAX_FB_RATE	1750000000u
 
+/*
+ * Names of clocks used within the driver that need to be replaced
+ * with an external parent's name.  This array is in the order that
+ * the clocks node in the DT references external clocks.
+ */
+static const char *const cprman_parent_names[] = {
+	"xosc",
+	"dsi0_byte",
+	"dsi0_ddr2",
+	"dsi0_ddr",
+	"dsi1_byte",
+	"dsi1_ddr2",
+	"dsi1_ddr",
+};
+
 struct bcm2835_cprman {
 	struct device *dev;
 	void __iomem *regs;
 	spinlock_t regs_lock; /* spinlock for all clocks */
-	const char *osc_name;
+
+	/*
+	 * Real names of cprman clock parents looked up through
+	 * of_clk_get_parent_name(), which will be used in the
+	 * parent_names[] arrays for clock registration.
+	 */
+	const char *real_parent_names[ARRAY_SIZE(cprman_parent_names)];
 
 	/* Must be last */
 	struct clk_hw_onecell_data onecell;
@@ -907,6 +928,9 @@ static long bcm2835_clock_rate_from_divisor(struct bcm2835_clock *clock,
 	const struct bcm2835_clock_data *data = clock->data;
 	u64 temp;
 
+	if (data->int_bits == 0 && data->frac_bits == 0)
+		return parent_rate;
+
 	/*
 	 * The divisor is a 12.12 fixed point field, but only some of
 	 * the bits are populated in any given clock.
@@ -930,7 +954,12 @@ static unsigned long bcm2835_clock_get_rate(struct clk_hw *hw,
 	struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
 	struct bcm2835_cprman *cprman = clock->cprman;
 	const struct bcm2835_clock_data *data = clock->data;
-	u32 div = cprman_read(cprman, data->div_reg);
+	u32 div;
+
+	if (data->int_bits == 0 && data->frac_bits == 0)
+		return parent_rate;
+
+	div = cprman_read(cprman, data->div_reg);
 
 	return bcm2835_clock_rate_from_divisor(clock, parent_rate, div);
 }
@@ -1209,7 +1238,7 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
 	memset(&init, 0, sizeof(init));
 
 	/* All of the PLLs derive from the external oscillator. */
-	init.parent_names = &cprman->osc_name;
+	init.parent_names = &cprman->real_parent_names[0];
 	init.num_parents = 1;
 	init.name = data->name;
 	init.ops = &bcm2835_pll_clk_ops;
@@ -1295,18 +1324,22 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
 	struct bcm2835_clock *clock;
 	struct clk_init_data init;
 	const char *parents[1 << CM_SRC_BITS];
-	size_t i;
+	size_t i, j;
 	int ret;
 
 	/*
-	 * Replace our "xosc" references with the oscillator's
-	 * actual name.
+	 * Replace our strings referencing parent clocks with the
+	 * actual clock-output-name of the parent.
 	 */
 	for (i = 0; i < data->num_mux_parents; i++) {
-		if (strcmp(data->parents[i], "xosc") == 0)
-			parents[i] = cprman->osc_name;
-		else
-			parents[i] = data->parents[i];
+		parents[i] = data->parents[i];
+
+		for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) {
+			if (strcmp(parents[i], cprman_parent_names[j]) == 0) {
+				parents[i] = cprman->real_parent_names[j];
+				break;
+			}
+		}
 	}
 
 	memset(&init, 0, sizeof(init));
@@ -1433,6 +1466,47 @@ static const char *const bcm2835_clock_vpu_parents[] = {
 	__VA_ARGS__)
 
 /*
+ * DSI parent clocks.  The DSI byte/DDR/DDR2 clocks come from the DSI
+ * analog PHY.  The _inv variants are generated internally to cprman,
+ * but we don't use them so they aren't hooked up.
+ */
+static const char *const bcm2835_clock_dsi0_parents[] = {
+	"gnd",
+	"xosc",
+	"testdebug0",
+	"testdebug1",
+	"dsi0_ddr",
+	"dsi0_ddr_inv",
+	"dsi0_ddr2",
+	"dsi0_ddr2_inv",
+	"dsi0_byte",
+	"dsi0_byte_inv",
+};
+
+static const char *const bcm2835_clock_dsi1_parents[] = {
+	"gnd",
+	"xosc",
+	"testdebug0",
+	"testdebug1",
+	"dsi1_ddr",
+	"dsi1_ddr_inv",
+	"dsi1_ddr2",
+	"dsi1_ddr2_inv",
+	"dsi1_byte",
+	"dsi1_byte_inv",
+};
+
+#define REGISTER_DSI0_CLK(...)	REGISTER_CLK(				\
+	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_dsi0_parents),	\
+	.parents = bcm2835_clock_dsi0_parents,				\
+	__VA_ARGS__)
+
+#define REGISTER_DSI1_CLK(...)	REGISTER_CLK(				\
+	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_dsi1_parents),	\
+	.parents = bcm2835_clock_dsi1_parents,				\
+	__VA_ARGS__)
+
+/*
  * the real definition of all the pll, pll_dividers and clocks
  * these make use of the above REGISTER_* macros
  */
@@ -1895,6 +1969,18 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.div_reg = CM_DSI1EDIV,
 		.int_bits = 4,
 		.frac_bits = 8),
+	[BCM2835_CLOCK_DSI0P]	= REGISTER_DSI0_CLK(
+		.name = "dsi0p",
+		.ctl_reg = CM_DSI0PCTL,
+		.div_reg = CM_DSI0PDIV,
+		.int_bits = 0,
+		.frac_bits = 0),
+	[BCM2835_CLOCK_DSI1P]	= REGISTER_DSI1_CLK(
+		.name = "dsi1p",
+		.ctl_reg = CM_DSI1PCTL,
+		.div_reg = CM_DSI1PDIV,
+		.int_bits = 0,
+		.frac_bits = 0),
 
 	/* the gates */
 
@@ -1953,8 +2039,19 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
 	if (IS_ERR(cprman->regs))
 		return PTR_ERR(cprman->regs);
 
-	cprman->osc_name = of_clk_get_parent_name(dev->of_node, 0);
-	if (!cprman->osc_name)
+	memcpy(cprman->real_parent_names, cprman_parent_names,
+	       sizeof(cprman_parent_names));
+	of_clk_parent_fill(dev->of_node, cprman->real_parent_names,
+			   ARRAY_SIZE(cprman_parent_names));
+
+	/*
+	 * Make sure the external oscillator has been registered.
+	 *
+	 * The other (DSI) clocks are not present on older device
+	 * trees, which we still need to support for backwards
+	 * compatibility.
+	 */
+	if (!cprman->real_parent_names[0])
 		return -ENODEV;
 
 	platform_set_drvdata(pdev, cprman);
diff --git a/include/dt-bindings/clock/bcm2835.h b/include/dt-bindings/clock/bcm2835.h
index 360e00c..a0c812b 100644
--- a/include/dt-bindings/clock/bcm2835.h
+++ b/include/dt-bindings/clock/bcm2835.h
@@ -64,3 +64,5 @@
 #define BCM2835_CLOCK_CAM1		46
 #define BCM2835_CLOCK_DSI0E		47
 #define BCM2835_CLOCK_DSI1E		48
+#define BCM2835_CLOCK_DSI0P		49
+#define BCM2835_CLOCK_DSI1P		50
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 14/32] clk: bcm2835: Add leaf clock measurement support, disabled by default
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (12 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 15/32] dmaengine: bcm2835: Fix cyclic DMA period splitting Amit Pundir
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Eric Anholt, Stephen Boyd

From: Eric Anholt <eric@anholt.net>

This proved incredibly useful during debugging of the DSI driver, to
see if our clocks were running at rate we requested.  Let's leave it
here for the next person interacting with clocks on the platform (and
so that hopefully we can just hook it up to debugfs some day).

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 3f9195811d8d829556c4cd88d3f9e56a80d5ba60)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 144 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 119 insertions(+), 25 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 2e7423d..0258538 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -39,6 +39,7 @@
 #include <linux/clk.h>
 #include <linux/clk/bcm2835.h>
 #include <linux/debugfs.h>
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -98,7 +99,8 @@
 #define CM_SMIDIV		0x0b4
 /* no definition for 0x0b8  and 0x0bc */
 #define CM_TCNTCTL		0x0c0
-#define CM_TCNTDIV		0x0c4
+# define CM_TCNT_SRC1_SHIFT		12
+#define CM_TCNTCNT		0x0c4
 #define CM_TECCTL		0x0c8
 #define CM_TECDIV		0x0cc
 #define CM_TD0CTL		0x0d0
@@ -338,6 +340,61 @@ static inline u32 cprman_read(struct bcm2835_cprman *cprman, u32 reg)
 	return readl(cprman->regs + reg);
 }
 
+/* Does a cycle of measuring a clock through the TCNT clock, which may
+ * source from many other clocks in the system.
+ */
+static unsigned long bcm2835_measure_tcnt_mux(struct bcm2835_cprman *cprman,
+					      u32 tcnt_mux)
+{
+	u32 osccount = 19200; /* 1ms */
+	u32 count;
+	ktime_t timeout;
+
+	spin_lock(&cprman->regs_lock);
+
+	cprman_write(cprman, CM_TCNTCTL, CM_KILL);
+
+	cprman_write(cprman, CM_TCNTCTL,
+		     (tcnt_mux & CM_SRC_MASK) |
+		     (tcnt_mux >> CM_SRC_BITS) << CM_TCNT_SRC1_SHIFT);
+
+	cprman_write(cprman, CM_OSCCOUNT, osccount);
+
+	/* do a kind delay at the start */
+	mdelay(1);
+
+	/* Finish off whatever is left of OSCCOUNT */
+	timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
+	while (cprman_read(cprman, CM_OSCCOUNT)) {
+		if (ktime_after(ktime_get(), timeout)) {
+			dev_err(cprman->dev, "timeout waiting for OSCCOUNT\n");
+			count = 0;
+			goto out;
+		}
+		cpu_relax();
+	}
+
+	/* Wait for BUSY to clear. */
+	timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
+	while (cprman_read(cprman, CM_TCNTCTL) & CM_BUSY) {
+		if (ktime_after(ktime_get(), timeout)) {
+			dev_err(cprman->dev, "timeout waiting for !BUSY\n");
+			count = 0;
+			goto out;
+		}
+		cpu_relax();
+	}
+
+	count = cprman_read(cprman, CM_TCNTCNT);
+
+	cprman_write(cprman, CM_TCNTCTL, 0);
+
+out:
+	spin_unlock(&cprman->regs_lock);
+
+	return count * 1000;
+}
+
 static int bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base,
 				  struct debugfs_reg32 *regs, size_t nregs,
 				  struct dentry *dentry)
@@ -473,6 +530,8 @@ struct bcm2835_clock_data {
 
 	bool is_vpu_clock;
 	bool is_mash_clock;
+
+	u32 tcnt_mux;
 };
 
 struct bcm2835_gate_data {
@@ -1008,6 +1067,17 @@ static int bcm2835_clock_on(struct clk_hw *hw)
 		     CM_GATE);
 	spin_unlock(&cprman->regs_lock);
 
+	/* Debug code to measure the clock once it's turned on to see
+	 * if it's ticking at the rate we expect.
+	 */
+	if (data->tcnt_mux && false) {
+		dev_info(cprman->dev,
+			 "clk %s: rate %ld, measure %ld\n",
+			 data->name,
+			 clk_hw_get_rate(hw),
+			 bcm2835_measure_tcnt_mux(cprman, data->tcnt_mux));
+	}
+
 	return 0;
 }
 
@@ -1765,7 +1835,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_OTPCTL,
 		.div_reg = CM_OTPDIV,
 		.int_bits = 4,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		.tcnt_mux = 6),
 	/*
 	 * Used for a 1Mhz clock for the system clocksource, and also used
 	 * bythe watchdog timer and the camera pulse generator.
@@ -1799,13 +1870,15 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_H264CTL,
 		.div_reg = CM_H264DIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 1),
 	[BCM2835_CLOCK_ISP]	= REGISTER_VPU_CLK(
 		.name = "isp",
 		.ctl_reg = CM_ISPCTL,
 		.div_reg = CM_ISPDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 2),
 
 	/*
 	 * Secondary SDRAM clock.  Used for low-voltage modes when the PLL
@@ -1816,13 +1889,15 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_SDCCTL,
 		.div_reg = CM_SDCDIV,
 		.int_bits = 6,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		.tcnt_mux = 3),
 	[BCM2835_CLOCK_V3D]	= REGISTER_VPU_CLK(
 		.name = "v3d",
 		.ctl_reg = CM_V3DCTL,
 		.div_reg = CM_V3DDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 4),
 	/*
 	 * VPU clock.  This doesn't have an enable bit, since it drives
 	 * the bus for everything else, and is special so it doesn't need
@@ -1836,7 +1911,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.int_bits = 12,
 		.frac_bits = 8,
 		.flags = CLK_IS_CRITICAL,
-		.is_vpu_clock = true),
+		.is_vpu_clock = true,
+		.tcnt_mux = 5),
 
 	/* clocks with per parent mux */
 	[BCM2835_CLOCK_AVEO]	= REGISTER_PER_CLK(
@@ -1844,19 +1920,22 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_AVEOCTL,
 		.div_reg = CM_AVEODIV,
 		.int_bits = 4,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		.tcnt_mux = 38),
 	[BCM2835_CLOCK_CAM0]	= REGISTER_PER_CLK(
 		.name = "cam0",
 		.ctl_reg = CM_CAM0CTL,
 		.div_reg = CM_CAM0DIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 14),
 	[BCM2835_CLOCK_CAM1]	= REGISTER_PER_CLK(
 		.name = "cam1",
 		.ctl_reg = CM_CAM1CTL,
 		.div_reg = CM_CAM1DIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 15),
 	[BCM2835_CLOCK_DFT]	= REGISTER_PER_CLK(
 		.name = "dft",
 		.ctl_reg = CM_DFTCTL,
@@ -1868,7 +1947,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_DPICTL,
 		.div_reg = CM_DPIDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 17),
 
 	/* Arasan EMMC clock */
 	[BCM2835_CLOCK_EMMC]	= REGISTER_PER_CLK(
@@ -1876,7 +1956,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_EMMCCTL,
 		.div_reg = CM_EMMCDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 39),
 
 	/* General purpose (GPIO) clocks */
 	[BCM2835_CLOCK_GP0]	= REGISTER_PER_CLK(
@@ -1885,7 +1966,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.div_reg = CM_GP0DIV,
 		.int_bits = 12,
 		.frac_bits = 12,
-		.is_mash_clock = true),
+		.is_mash_clock = true,
+		.tcnt_mux = 20),
 	[BCM2835_CLOCK_GP1]	= REGISTER_PER_CLK(
 		.name = "gp1",
 		.ctl_reg = CM_GP1CTL,
@@ -1893,7 +1975,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.int_bits = 12,
 		.frac_bits = 12,
 		.flags = CLK_IS_CRITICAL,
-		.is_mash_clock = true),
+		.is_mash_clock = true,
+		.tcnt_mux = 21),
 	[BCM2835_CLOCK_GP2]	= REGISTER_PER_CLK(
 		.name = "gp2",
 		.ctl_reg = CM_GP2CTL,
@@ -1908,40 +1991,46 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_HSMCTL,
 		.div_reg = CM_HSMDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 22),
 	[BCM2835_CLOCK_PCM]	= REGISTER_PER_CLK(
 		.name = "pcm",
 		.ctl_reg = CM_PCMCTL,
 		.div_reg = CM_PCMDIV,
 		.int_bits = 12,
 		.frac_bits = 12,
-		.is_mash_clock = true),
+		.is_mash_clock = true,
+		.tcnt_mux = 23),
 	[BCM2835_CLOCK_PWM]	= REGISTER_PER_CLK(
 		.name = "pwm",
 		.ctl_reg = CM_PWMCTL,
 		.div_reg = CM_PWMDIV,
 		.int_bits = 12,
 		.frac_bits = 12,
-		.is_mash_clock = true),
+		.is_mash_clock = true,
+		.tcnt_mux = 24),
 	[BCM2835_CLOCK_SLIM]	= REGISTER_PER_CLK(
 		.name = "slim",
 		.ctl_reg = CM_SLIMCTL,
 		.div_reg = CM_SLIMDIV,
 		.int_bits = 12,
 		.frac_bits = 12,
-		.is_mash_clock = true),
+		.is_mash_clock = true,
+		.tcnt_mux = 25),
 	[BCM2835_CLOCK_SMI]	= REGISTER_PER_CLK(
 		.name = "smi",
 		.ctl_reg = CM_SMICTL,
 		.div_reg = CM_SMIDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 27),
 	[BCM2835_CLOCK_UART]	= REGISTER_PER_CLK(
 		.name = "uart",
 		.ctl_reg = CM_UARTCTL,
 		.div_reg = CM_UARTDIV,
 		.int_bits = 10,
-		.frac_bits = 12),
+		.frac_bits = 12,
+		.tcnt_mux = 28),
 
 	/* TV encoder clock.  Only operating frequency is 108Mhz.  */
 	[BCM2835_CLOCK_VEC]	= REGISTER_PER_CLK(
@@ -1954,7 +2043,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		 * Allow rate change propagation only on PLLH_AUX which is
 		 * assigned index 7 in the parent array.
 		 */
-		.set_rate_parent = BIT(7)),
+		.set_rate_parent = BIT(7),
+		.tcnt_mux = 29),
 
 	/* dsi clocks */
 	[BCM2835_CLOCK_DSI0E]	= REGISTER_PER_CLK(
@@ -1962,25 +2052,29 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.ctl_reg = CM_DSI0ECTL,
 		.div_reg = CM_DSI0EDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 18),
 	[BCM2835_CLOCK_DSI1E]	= REGISTER_PER_CLK(
 		.name = "dsi1e",
 		.ctl_reg = CM_DSI1ECTL,
 		.div_reg = CM_DSI1EDIV,
 		.int_bits = 4,
-		.frac_bits = 8),
+		.frac_bits = 8,
+		.tcnt_mux = 19),
 	[BCM2835_CLOCK_DSI0P]	= REGISTER_DSI0_CLK(
 		.name = "dsi0p",
 		.ctl_reg = CM_DSI0PCTL,
 		.div_reg = CM_DSI0PDIV,
 		.int_bits = 0,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		.tcnt_mux = 12),
 	[BCM2835_CLOCK_DSI1P]	= REGISTER_DSI1_CLK(
 		.name = "dsi1p",
 		.ctl_reg = CM_DSI1PCTL,
 		.div_reg = CM_DSI1PDIV,
 		.int_bits = 0,
-		.frac_bits = 0),
+		.frac_bits = 0,
+		.tcnt_mux = 13),
 
 	/* the gates */
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 15/32] dmaengine: bcm2835: Fix cyclic DMA period splitting
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (13 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 14/32] clk: bcm2835: Add leaf clock measurement support, disabled by default Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 16/32] usb: dwc2: Remove unnecessary kfree Amit Pundir
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Matthias Reichl, Martin Sperl, Vinod Koul

From: Matthias Reichl <hias@horus.com>

The code responsible for splitting periods into chunks that
can be handled by the DMA controller missed to update total_len,
the number of bytes processed in the current period, when there
are more chunks to follow.

Therefore total_len was stuck at 0 and the code didn't work at all.
This resulted in a wrong control block layout and audio issues because
the cyclic DMA callback wasn't executing on period boundaries.

Fix this by adding the missing total_len update.

Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Tested-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
(cherry picked from commit 2201ac6129fa162ac24da089a034bb0971648ebb)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/dma/bcm2835-dma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index e18dc59..6204cc3 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -251,8 +251,11 @@ static void bcm2835_dma_create_cb_set_length(
 	 */
 
 	/* have we filled in period_length yet? */
-	if (*total_len + control_block->length < period_len)
+	if (*total_len + control_block->length < period_len) {
+		/* update number of bytes in this period so far */
+		*total_len += control_block->length;
 		return;
+	}
 
 	/* calculate the length that remains to reach period_length */
 	control_block->length = period_len - *total_len;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 16/32] usb: dwc2: Remove unnecessary kfree
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (14 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 15/32] dmaengine: bcm2835: Fix cyclic DMA period splitting Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 17/32] mtd: bcm47xxpart: fix parsing first block after aligned TRX Amit Pundir
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, John Youn, Felipe Balbi

From: John Youn <johnyoun@synopsys.com>

This shouldn't be freed by the HCD as it is owned by the core and
allocated with devm_kzalloc.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
(cherry picked from commit cd4b1e34655d46950c065d9284b596cd8d7b28cd)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/usb/dwc2/hcd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index df5a065..1b6f5e1 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5184,7 +5184,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 error2:
 	usb_put_hcd(hcd);
 error1:
-	kfree(hsotg->core_params);
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
 	kfree(hsotg->last_frame_num_array);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 17/32] mtd: bcm47xxpart: fix parsing first block after aligned TRX
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (15 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 16/32] usb: dwc2: Remove unnecessary kfree Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 18/32] net: add devm version of alloc_etherdev_mqs function Amit Pundir
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Brian Norris

From: Rafał Miłecki <rafal@milecki.pl>

After parsing TRX we should skip to the first block placed behind it.
Our code was working only with TRX with length not aligned to the
blocksize. In other cases (length aligned) it was missing the block
places right after TRX.

This fixes calculation and simplifies the comment.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
(cherry picked from commit bd5d21310133921021d78995ad6346f908483124)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/mtd/bcm47xxpart.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 3779475..283ff7e 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -229,12 +229,10 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 
 			last_trx_part = curr_part - 1;
 
-			/*
-			 * We have whole TRX scanned, skip to the next part. Use
-			 * roundown (not roundup), as the loop will increase
-			 * offset in next step.
-			 */
-			offset = rounddown(offset + trx->length, blocksize);
+			/* Jump to the end of TRX */
+			offset = roundup(offset + trx->length, blocksize);
+			/* Next loop iteration will increase the offset */
+			offset -= blocksize;
 			continue;
 		}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 18/32] net: add devm version of alloc_etherdev_mqs function
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (16 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 17/32] mtd: bcm47xxpart: fix parsing first block after aligned TRX Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 19/32] net: bgmac: allocate struct bgmac just once & don't copy it Amit Pundir
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, David S . Miller

From: Rafał Miłecki <rafal@milecki.pl>

This patch adds devm_alloc_etherdev_mqs function and devm_alloc_etherdev
macro. These can be used for simpler netdev allocation without having to
care about calling free_netdev.

Thanks to this change drivers, their error paths and removal paths may
get simpler by a bit.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 40be0dda0725886b623d67868db3219a2e74683b)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 include/linux/etherdevice.h |  5 +++++
 net/ethernet/eth.c          | 28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 6fec9e8..83ae88c 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -54,6 +54,11 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
 #define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
 #define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
 
+struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
+					   unsigned int txqs,
+					   unsigned int rxqs);
+#define devm_alloc_etherdev(dev, sizeof_priv) devm_alloc_etherdev_mqs(dev, sizeof_priv, 1, 1)
+
 struct sk_buff **eth_gro_receive(struct sk_buff **head,
 				 struct sk_buff *skb);
 int eth_gro_complete(struct sk_buff *skb, int nhoff);
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 24d7aff..fbf1de9 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -391,6 +391,34 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
 }
 EXPORT_SYMBOL(alloc_etherdev_mqs);
 
+static void devm_free_netdev(struct device *dev, void *res)
+{
+	free_netdev(*(struct net_device **)res);
+}
+
+struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
+					   unsigned int txqs, unsigned int rxqs)
+{
+	struct net_device **dr;
+	struct net_device *netdev;
+
+	dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return NULL;
+
+	netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs);
+	if (!netdev) {
+		devres_free(dr);
+		return NULL;
+	}
+
+	*dr = netdev;
+	devres_add(dev, dr);
+
+	return netdev;
+}
+EXPORT_SYMBOL(devm_alloc_etherdev_mqs);
+
 ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
 {
 	return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 19/32] net: bgmac: allocate struct bgmac just once & don't copy it
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (17 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 18/32] net: add devm version of alloc_etherdev_mqs function Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 20/32] net: bgmac: drop struct bcma_mdio we don't need anymore Amit Pundir
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, David S . Miller

From: Rafał Miłecki <rafal@milecki.pl>

So far were were allocating struct bgmac in 3 places: platform code,
bcma code and shared bgmac_enet_probe function. The reason for this was
bgmac_enet_probe:
1) Requiring early-filled struct bgmac
2) Calling alloc_etherdev on its own in order to use netdev_priv later

This solution got few drawbacks:
1) Was duplicating allocating code
2) Required copying early-filled struct
3) Resulted in platform/bcma code having access only to unused struct

Solve this situation by simply extracting some probe code into the new
bgmac_alloc function.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 34a5102c3235c470a6c77fba16cb971964d9c136)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/ethernet/broadcom/bgmac-bcma.c     |  4 +---
 drivers/net/ethernet/broadcom/bgmac-platform.c |  2 +-
 drivers/net/ethernet/broadcom/bgmac.c          | 25 +++++++++++++++++--------
 drivers/net/ethernet/broadcom/bgmac.h          |  3 ++-
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index c16ec3a..5b0c7a7 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -99,12 +99,11 @@ static int bgmac_probe(struct bcma_device *core)
 	u8 *mac;
 	int err;
 
-	bgmac = kzalloc(sizeof(*bgmac), GFP_KERNEL);
+	bgmac = bgmac_alloc(&core->dev);
 	if (!bgmac)
 		return -ENOMEM;
 
 	bgmac->bcma.core = core;
-	bgmac->dev = &core->dev;
 	bgmac->dma_dev = core->dma_dev;
 	bgmac->irq = core->irq;
 
@@ -285,7 +284,6 @@ static int bgmac_probe(struct bcma_device *core)
 err1:
 	bcma_mdio_mii_unregister(bgmac->mii_bus);
 err:
-	kfree(bgmac);
 	bcma_set_drvdata(core, NULL);
 
 	return err;
diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c b/drivers/net/ethernet/broadcom/bgmac-platform.c
index be52f27..020f487 100644
--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
@@ -93,7 +93,7 @@ static int bgmac_probe(struct platform_device *pdev)
 	struct resource *regs;
 	const u8 *mac_addr;
 
-	bgmac = devm_kzalloc(&pdev->dev, sizeof(*bgmac), GFP_KERNEL);
+	bgmac = bgmac_alloc(&pdev->dev);
 	if (!bgmac)
 		return -ENOMEM;
 
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 49f4cafe..537b00b 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1459,22 +1459,32 @@ static int bgmac_phy_connect(struct bgmac *bgmac)
 	return 0;
 }
 
-int bgmac_enet_probe(struct bgmac *info)
+struct bgmac *bgmac_alloc(struct device *dev)
 {
 	struct net_device *net_dev;
 	struct bgmac *bgmac;
-	int err;
 
 	/* Allocation and references */
-	net_dev = alloc_etherdev(sizeof(*bgmac));
+	net_dev = devm_alloc_etherdev(dev, sizeof(*bgmac));
 	if (!net_dev)
-		return -ENOMEM;
+		return NULL;
 
 	net_dev->netdev_ops = &bgmac_netdev_ops;
 	net_dev->ethtool_ops = &bgmac_ethtool_ops;
+
 	bgmac = netdev_priv(net_dev);
-	memcpy(bgmac, info, sizeof(*bgmac));
+	bgmac->dev = dev;
 	bgmac->net_dev = net_dev;
+
+	return bgmac;
+}
+EXPORT_SYMBOL_GPL(bgmac_alloc);
+
+int bgmac_enet_probe(struct bgmac *bgmac)
+{
+	struct net_device *net_dev = bgmac->net_dev;
+	int err;
+
 	net_dev->irq = bgmac->irq;
 	SET_NETDEV_DEV(net_dev, bgmac->dev);
 
@@ -1501,7 +1511,7 @@ int bgmac_enet_probe(struct bgmac *info)
 	err = bgmac_dma_alloc(bgmac);
 	if (err) {
 		dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
-		goto err_netdev_free;
+		goto err_out;
 	}
 
 	bgmac->int_mask = BGMAC_IS_ERRMASK | BGMAC_IS_RX | BGMAC_IS_TX_MASK;
@@ -1537,8 +1547,7 @@ int bgmac_enet_probe(struct bgmac *info)
 	phy_disconnect(net_dev->phydev);
 err_dma_free:
 	bgmac_dma_free(bgmac);
-err_netdev_free:
-	free_netdev(net_dev);
+err_out:
 
 	return err;
 }
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
index 80836b4..69d478a 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -515,7 +515,8 @@ struct bgmac {
 			      u32 set);
 };
 
-int bgmac_enet_probe(struct bgmac *info);
+struct bgmac *bgmac_alloc(struct device *dev);
+int bgmac_enet_probe(struct bgmac *bgmac);
 void bgmac_enet_remove(struct bgmac *bgmac);
 
 struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 20/32] net: bgmac: drop struct bcma_mdio we don't need anymore
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (18 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 19/32] net: bgmac: allocate struct bgmac just once & don't copy it Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 21/32] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Amit Pundir
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, David S . Miller

From: Rafał Miłecki <rafal@milecki.pl>

Adding struct bcma_mdio was a workaround for bcma code not having access
to the struct bgmac used in the core code. Now we don't duplicate this
struct we can just use it internally in bcma code.

This simplifies code & allows access to all bgmac driver details from
all places in bcma code.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit aa8863e5d49417094b9457a0d53e8505e95a1863)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 98 ++++++++++---------------
 drivers/net/ethernet/broadcom/bgmac-bcma.c      |  2 +-
 drivers/net/ethernet/broadcom/bgmac.h           |  2 +-
 3 files changed, 42 insertions(+), 60 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
index 7c19c8e..9d99849 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
@@ -12,11 +12,6 @@
 #include <linux/brcmphy.h>
 #include "bgmac.h"
 
-struct bcma_mdio {
-	struct bcma_device *core;
-	u8 phyaddr;
-};
-
 static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
 				 u32 value, int timeout)
 {
@@ -37,7 +32,7 @@ static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
  * PHY ops
  **************************************************/
 
-static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
+static u16 bcma_mdio_phy_read(struct bgmac *bgmac, u8 phyaddr, u8 reg)
 {
 	struct bcma_device *core;
 	u16 phy_access_addr;
@@ -56,12 +51,12 @@ static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
 	BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
 	BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
 
-	if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-		core = bcma_mdio->core->bus->drv_gmac_cmn.core;
+	if (bgmac->bcma.core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+		core = bgmac->bcma.core->bus->drv_gmac_cmn.core;
 		phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
 		phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
 	} else {
-		core = bcma_mdio->core;
+		core = bgmac->bcma.core;
 		phy_access_addr = BGMAC_PHY_ACCESS;
 		phy_ctl_addr = BGMAC_PHY_CNTL;
 	}
@@ -87,7 +82,7 @@ static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
 }
 
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
-static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
+static int bcma_mdio_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg,
 			       u16 value)
 {
 	struct bcma_device *core;
@@ -95,12 +90,12 @@ static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
 	u16 phy_ctl_addr;
 	u32 tmp;
 
-	if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-		core = bcma_mdio->core->bus->drv_gmac_cmn.core;
+	if (bgmac->bcma.core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+		core = bgmac->bcma.core->bus->drv_gmac_cmn.core;
 		phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
 		phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
 	} else {
-		core = bcma_mdio->core;
+		core = bgmac->bcma.core;
 		phy_access_addr = BGMAC_PHY_ACCESS;
 		phy_ctl_addr = BGMAC_PHY_CNTL;
 	}
@@ -110,8 +105,8 @@ static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
 	tmp |= phyaddr;
 	bcma_write32(core, phy_ctl_addr, tmp);
 
-	bcma_write32(bcma_mdio->core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
-	if (bcma_read32(bcma_mdio->core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
+	bcma_write32(bgmac->bcma.core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
+	if (bcma_read32(bgmac->bcma.core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
 		dev_warn(&core->dev, "Error setting MDIO int\n");
 
 	tmp = BGMAC_PA_START;
@@ -132,39 +127,39 @@ static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
 }
 
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
-static void bcma_mdio_phy_init(struct bcma_mdio *bcma_mdio)
+static void bcma_mdio_phy_init(struct bgmac *bgmac)
 {
-	struct bcma_chipinfo *ci = &bcma_mdio->core->bus->chipinfo;
+	struct bcma_chipinfo *ci = &bgmac->bcma.core->bus->chipinfo;
 	u8 i;
 
 	if (ci->id == BCMA_CHIP_ID_BCM5356) {
 		for (i = 0; i < 5; i++) {
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x008b);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x15, 0x0100);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x12, 0x2aaa);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x008b);
+			bcma_mdio_phy_write(bgmac, i, 0x15, 0x0100);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
+			bcma_mdio_phy_write(bgmac, i, 0x12, 0x2aaa);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
 		}
 	}
 	if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
 	    (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
 	    (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
-		struct bcma_drv_cc *cc = &bcma_mdio->core->bus->drv_cc;
+		struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
 
 		bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
 		bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
 		for (i = 0; i < 5; i++) {
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5284);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x0010);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5296);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x1073);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9073);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x52b6);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9273);
-			bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
+			bcma_mdio_phy_write(bgmac, i, 0x16, 0x5284);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
+			bcma_mdio_phy_write(bgmac, i, 0x17, 0x0010);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
+			bcma_mdio_phy_write(bgmac, i, 0x16, 0x5296);
+			bcma_mdio_phy_write(bgmac, i, 0x17, 0x1073);
+			bcma_mdio_phy_write(bgmac, i, 0x17, 0x9073);
+			bcma_mdio_phy_write(bgmac, i, 0x16, 0x52b6);
+			bcma_mdio_phy_write(bgmac, i, 0x17, 0x9273);
+			bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
 		}
 	}
 }
@@ -172,17 +167,17 @@ static void bcma_mdio_phy_init(struct bcma_mdio *bcma_mdio)
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
 static int bcma_mdio_phy_reset(struct mii_bus *bus)
 {
-	struct bcma_mdio *bcma_mdio = bus->priv;
-	u8 phyaddr = bcma_mdio->phyaddr;
+	struct bgmac *bgmac = bus->priv;
+	u8 phyaddr = bgmac->phyaddr;
 
-	if (bcma_mdio->phyaddr == BGMAC_PHY_NOREGS)
+	if (phyaddr == BGMAC_PHY_NOREGS)
 		return 0;
 
-	bcma_mdio_phy_write(bcma_mdio, phyaddr, MII_BMCR, BMCR_RESET);
+	bcma_mdio_phy_write(bgmac, phyaddr, MII_BMCR, BMCR_RESET);
 	udelay(100);
-	if (bcma_mdio_phy_read(bcma_mdio, phyaddr, MII_BMCR) & BMCR_RESET)
-		dev_err(&bcma_mdio->core->dev, "PHY reset failed\n");
-	bcma_mdio_phy_init(bcma_mdio);
+	if (bcma_mdio_phy_read(bgmac, phyaddr, MII_BMCR) & BMCR_RESET)
+		dev_err(bgmac->dev, "PHY reset failed\n");
+	bcma_mdio_phy_init(bgmac);
 
 	return 0;
 }
@@ -202,16 +197,12 @@ static int bcma_mdio_mii_write(struct mii_bus *bus, int mii_id, int regnum,
 	return bcma_mdio_phy_write(bus->priv, mii_id, regnum, value);
 }
 
-struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
+struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac)
 {
-	struct bcma_mdio *bcma_mdio;
+	struct bcma_device *core = bgmac->bcma.core;
 	struct mii_bus *mii_bus;
 	int err;
 
-	bcma_mdio = kzalloc(sizeof(*bcma_mdio), GFP_KERNEL);
-	if (!bcma_mdio)
-		return ERR_PTR(-ENOMEM);
-
 	mii_bus = mdiobus_alloc();
 	if (!mii_bus) {
 		err = -ENOMEM;
@@ -221,15 +212,12 @@ struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
 	mii_bus->name = "bcma_mdio mii bus";
 	sprintf(mii_bus->id, "%s-%d-%d", "bcma_mdio", core->bus->num,
 		core->core_unit);
-	mii_bus->priv = bcma_mdio;
+	mii_bus->priv = bgmac;
 	mii_bus->read = bcma_mdio_mii_read;
 	mii_bus->write = bcma_mdio_mii_write;
 	mii_bus->reset = bcma_mdio_phy_reset;
 	mii_bus->parent = &core->dev;
-	mii_bus->phy_mask = ~(1 << phyaddr);
-
-	bcma_mdio->core = core;
-	bcma_mdio->phyaddr = phyaddr;
+	mii_bus->phy_mask = ~(1 << bgmac->phyaddr);
 
 	err = mdiobus_register(mii_bus);
 	if (err) {
@@ -242,23 +230,17 @@ struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
 err_free_bus:
 	mdiobus_free(mii_bus);
 err:
-	kfree(bcma_mdio);
 	return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(bcma_mdio_mii_register);
 
 void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
 {
-	struct bcma_mdio *bcma_mdio;
-
 	if (!mii_bus)
 		return;
 
-	bcma_mdio = mii_bus->priv;
-
 	mdiobus_unregister(mii_bus);
 	mdiobus_free(mii_bus);
-	kfree(bcma_mdio);
 }
 EXPORT_SYMBOL_GPL(bcma_mdio_mii_unregister);
 
diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index 5b0c7a7..e0e4509 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_device *core)
 
 	if (!bgmac_is_bcm4707_family(core) &&
 	    !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
-		mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
+		mii_bus = bcma_mdio_mii_register(bgmac);
 		if (IS_ERR(mii_bus)) {
 			err = PTR_ERR(mii_bus);
 			goto err;
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
index 69d478a..780cef2 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -519,7 +519,7 @@ struct bgmac *bgmac_alloc(struct device *dev);
 int bgmac_enet_probe(struct bgmac *bgmac);
 void bgmac_enet_remove(struct bgmac *bgmac);
 
-struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
+struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac);
 void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
 
 static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 21/32] of: Add check to of_scan_flat_dt() before accessing initial_boot_params
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (19 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 20/32] net: bgmac: drop struct bcma_mdio we don't need anymore Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 22/32] rt2500usb: don't mark register accesses as inline Amit Pundir
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Tobias Wolf, Sergei Shtylyov, linux-mips, Ralf Baechle

From: Tobias Wolf <dev-NTEO@vplace.de>

An empty __dtb_start to __dtb_end section might result in
initial_boot_params being null for arch/mips/ralink. This showed that the
boot process hangs indefinitely in of_scan_flat_dt().

Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14605/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit 3ec754410cb3e931a6c4920b1a150f21a94a2bf4)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/of/fdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index c89d5d2..6c07f2c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -738,9 +738,12 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 	const char *pathp;
 	int offset, rc = 0, depth = -1;
 
-        for (offset = fdt_next_node(blob, -1, &depth);
-             offset >= 0 && depth >= 0 && !rc;
-             offset = fdt_next_node(blob, offset, &depth)) {
+	if (!blob)
+		return 0;
+
+	for (offset = fdt_next_node(blob, -1, &depth);
+	     offset >= 0 && depth >= 0 && !rc;
+	     offset = fdt_next_node(blob, offset, &depth)) {
 
 		pathp = fdt_get_name(blob, offset, NULL);
 		if (*pathp == '/')
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 22/32] rt2500usb: don't mark register accesses as inline
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (20 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 21/32] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 23/32] brcmfmac: check brcmf_bus_get_memdump result for error Amit Pundir
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Arnd Bergmann, Kalle Valo

From: Arnd Bergmann <arnd@arndb.de>

When CONFIG_KASAN is set, we get a rather large stack here:

drivers/net/wireless/ralink/rt2x00/rt2500usb.c: In function 'rt2500usb_set_device_state':
drivers/net/wireless/ralink/rt2x00/rt2500usb.c:1074:1: error: the frame size of 3032 bytes is larger than 100 bytes [-Werror=frame-larger-than=]

If we don't force those functions to be inline, the compiler can figure this
out better itself and not inline the functions when doing so would be harmful,
reducing the stack size to a merge 256 bytes.

Note that there is another problem that manifests in this driver, as a result
of the typecheck() macro causing even larger stack frames.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 7272416609126e8910b7f0d0e3dba008aa87830c)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
index 2d64611..5b3aae3 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
  * If the csr_mutex is already held then the _lock variants must
  * be used instead.
  */
-static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
+static void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
 					   const unsigned int offset,
 					   u16 *value)
 {
@@ -66,7 +66,7 @@ static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
 	*value = le16_to_cpu(reg);
 }
 
-static inline void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
+static void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
 						const unsigned int offset,
 						u16 *value)
 {
@@ -77,16 +77,7 @@ static inline void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
 	*value = le16_to_cpu(reg);
 }
 
-static inline void rt2500usb_register_multiread(struct rt2x00_dev *rt2x00dev,
-						const unsigned int offset,
-						void *value, const u16 length)
-{
-	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
-				      USB_VENDOR_REQUEST_IN, offset,
-				      value, length);
-}
-
-static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
+static void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
 					    const unsigned int offset,
 					    u16 value)
 {
@@ -96,7 +87,7 @@ static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
 				      &reg, sizeof(reg));
 }
 
-static inline void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
+static void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
 						 const unsigned int offset,
 						 u16 value)
 {
@@ -106,7 +97,7 @@ static inline void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
 				       &reg, sizeof(reg), REGISTER_TIMEOUT);
 }
 
-static inline void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
+static void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
 						 const unsigned int offset,
 						 void *value, const u16 length)
 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 23/32] brcmfmac: check brcmf_bus_get_memdump result for error
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (21 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 22/32] rt2500usb: don't mark register accesses as inline Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 24/32] brcmfmac: be more verbose when PSM's watchdog fires Amit Pundir
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Kalle Valo

From: Rafał Miłecki <rafal@milecki.pl>

This method may be unsupported (see: USB bus) or may just fail (see:
SDIO bus).
While at it rework logic in brcmf_sdio_bus_get_memdump function to avoid
too many conditional code nesting levels.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit f4737a62033d7f3e0db740c449fc62119da7ab8a)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c   | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
index e64557c..6f8a4b0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
@@ -32,16 +32,25 @@ static int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
 {
 	void *dump;
 	size_t ramsize;
+	int err;
 
 	ramsize = brcmf_bus_get_ramsize(bus);
-	if (ramsize) {
-		dump = vzalloc(len + ramsize);
-		if (!dump)
-			return -ENOMEM;
-		memcpy(dump, data, len);
-		brcmf_bus_get_memdump(bus, dump + len, ramsize);
-		dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
+	if (!ramsize)
+		return -ENOTSUPP;
+
+	dump = vzalloc(len + ramsize);
+	if (!dump)
+		return -ENOMEM;
+
+	memcpy(dump, data, len);
+	err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
+	if (err) {
+		vfree(dump);
+		return err;
 	}
+
+	dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 24/32] brcmfmac: be more verbose when PSM's watchdog fires
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (22 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 23/32] brcmfmac: check brcmf_bus_get_memdump result for error Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 25/32] brcmfmac: merge two brcmf_err macros into one Amit Pundir
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Kalle Valo

From: Rafał Miłecki <rafal@milecki.pl>

It's important to inform user so he knows things went wrong. He may also
want to get memory dump for further debugging purposes.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 36401cb7ffae731295a6dd1ce2b40d7ad74245f4)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
index 6f8a4b0..f4644cf 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
@@ -58,10 +58,18 @@ static int brcmf_debug_psm_watchdog_notify(struct brcmf_if *ifp,
 					   const struct brcmf_event_msg *evtmsg,
 					   void *data)
 {
+	int err;
+
 	brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
 
-	return brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
-					  evtmsg->datalen);
+	brcmf_err("PSM's watchdog has fired!\n");
+
+	err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
+					 evtmsg->datalen);
+	if (err)
+		brcmf_err("Failed to get memory dump, %d\n", err);
+
+	return err;
 }
 
 void brcmf_debugfs_init(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 25/32] brcmfmac: merge two brcmf_err macros into one
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (23 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 24/32] brcmfmac: be more verbose when PSM's watchdog fires Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 26/32] brcmfmac: switch to C function (__brcmf_err) for printing errors Amit Pundir
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Kalle Valo

From: Rafał Miłecki <rafal@milecki.pl>

This allows simplifying the code by adding a simple IS_ENABLED check for
CONFIG_BRCMDB symbol.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 9587a01a7ead9efc5032c16e0d9668de58be1186)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
index 6687812..1fe4aa9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
@@ -45,20 +45,16 @@
 #undef pr_fmt
 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
 
+#ifndef CONFIG_BRCM_TRACING
 /* Macro for error messages. net_ratelimit() is used when driver
  * debugging is not selected. When debugging the driver error
  * messages are as important as other tracing or even more so.
  */
-#ifndef CONFIG_BRCM_TRACING
-#ifdef CONFIG_BRCMDBG
-#define brcmf_err(fmt, ...)	pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
-#else
 #define brcmf_err(fmt, ...)						\
 	do {								\
-		if (net_ratelimit())					\
+		if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit())	\
 			pr_err("%s: " fmt, __func__, ##__VA_ARGS__);	\
 	} while (0)
-#endif
 #else
 __printf(2, 3)
 void __brcmf_err(const char *func, const char *fmt, ...);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 26/32] brcmfmac: switch to C function (__brcmf_err) for printing errors
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (24 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 25/32] brcmfmac: merge two brcmf_err macros into one Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 27/32] brcmfmac: merge two remaining brcmf_err macros Amit Pundir
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Kalle Valo

From: Rafał Miłecki <rafal@milecki.pl>

This will allow extending code and using more detailed messages e.g.
with the help of dev_err.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 087fa712a00685dac4bcc64b7c3dc8ae6bee8026)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c    | 16 ++++++++++++++++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h |  6 +++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 3e15d64..2dcca71 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -218,6 +218,22 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	return err;
 }
 
+#ifndef CONFIG_BRCM_TRACING
+void __brcmf_err(const char *func, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	pr_err("%s: %pV", func, &vaf);
+
+	va_end(args);
+}
+#endif
+
 #if defined(CONFIG_BRCM_TRACING) || defined(CONFIG_BRCMDBG)
 void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...)
 {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
index 1fe4aa9..441a666 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
@@ -45,6 +45,8 @@
 #undef pr_fmt
 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
 
+__printf(2, 3)
+void __brcmf_err(const char *func, const char *fmt, ...);
 #ifndef CONFIG_BRCM_TRACING
 /* Macro for error messages. net_ratelimit() is used when driver
  * debugging is not selected. When debugging the driver error
@@ -53,11 +55,9 @@
 #define brcmf_err(fmt, ...)						\
 	do {								\
 		if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit())	\
-			pr_err("%s: " fmt, __func__, ##__VA_ARGS__);	\
+			__brcmf_err(__func__, fmt, ##__VA_ARGS__);	\
 	} while (0)
 #else
-__printf(2, 3)
-void __brcmf_err(const char *func, const char *fmt, ...);
 #define brcmf_err(fmt, ...) \
 	__brcmf_err(__func__, fmt, ##__VA_ARGS__)
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 27/32] brcmfmac: merge two remaining brcmf_err macros
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (25 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 26/32] brcmfmac: switch to C function (__brcmf_err) for printing errors Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 28/32] rt2x00usb: do not anchor rx and tx urb's Amit Pundir
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Rafał Miłecki, Kalle Valo

From: Rafał Miłecki <rafal@milecki.pl>

Now we always have __brcmf_err function we can do perfectly fine with
just one macro.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit d0630555650a394cf5743268820511f527a561a5)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
index 441a666..0661261 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
@@ -47,20 +47,16 @@
 
 __printf(2, 3)
 void __brcmf_err(const char *func, const char *fmt, ...);
-#ifndef CONFIG_BRCM_TRACING
-/* Macro for error messages. net_ratelimit() is used when driver
- * debugging is not selected. When debugging the driver error
- * messages are as important as other tracing or even more so.
+/* Macro for error messages. When debugging / tracing the driver all error
+ * messages are important to us.
  */
 #define brcmf_err(fmt, ...)						\
 	do {								\
-		if (IS_ENABLED(CONFIG_BRCMDBG) || net_ratelimit())	\
+		if (IS_ENABLED(CONFIG_BRCMDBG) ||			\
+		    IS_ENABLED(CONFIG_BRCM_TRACING) ||			\
+		    net_ratelimit())					\
 			__brcmf_err(__func__, fmt, ##__VA_ARGS__);	\
 	} while (0)
-#else
-#define brcmf_err(fmt, ...) \
-	__brcmf_err(__func__, fmt, ##__VA_ARGS__)
-#endif
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
 __printf(3, 4)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 28/32] rt2x00usb: do not anchor rx and tx urb's
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (26 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 27/32] brcmfmac: merge two remaining brcmf_err macros Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 29/32] rt2x00usb: fix anchor initialization Amit Pundir
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Stanislaw Gruszka, Vishal Thanki, Kalle Valo

From: Stanislaw Gruszka <sgruszka@redhat.com>

We might kill TX or RX urb during rt2x00usb_flush_entry(), what can
cause anchor list corruption like shown below:

[ 2074.035633] WARNING: CPU: 2 PID: 14480 at lib/list_debug.c:33 __list_add+0xac/0xc0
[ 2074.035634] list_add corruption. prev->next should be next (ffff88020f362c28), but was dead000000000100. (prev=ffff8801d161bb70).
<snip>
[ 2074.035670] Call Trace:
[ 2074.035672]  [<ffffffff813bde47>] dump_stack+0x63/0x8c
[ 2074.035674]  [<ffffffff810a2231>] __warn+0xd1/0xf0
[ 2074.035676]  [<ffffffff810a22af>] warn_slowpath_fmt+0x5f/0x80
[ 2074.035678]  [<ffffffffa073855d>] ? rt2x00usb_register_write_lock+0x3d/0x60 [rt2800usb]
[ 2074.035679]  [<ffffffff813dbe4c>] __list_add+0xac/0xc0
[ 2074.035681]  [<ffffffff81591c6c>] usb_anchor_urb+0x4c/0xa0
[ 2074.035683]  [<ffffffffa07322af>] rt2x00usb_kick_rx_entry+0xaf/0x100 [rt2x00usb]
[ 2074.035684]  [<ffffffffa0732322>] rt2x00usb_clear_entry+0x22/0x30 [rt2x00usb]

To fix do not anchor TX and RX urb's, it is not needed as during
shutdown we kill those urbs in rt2x00usb_free_entries().

Cc: Vishal Thanki <vishalthanki@gmail.com>
Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 93c7018ec16bb83399dd4db61c361a6d6aba0d5a)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index 6005e14..efe2501 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -319,10 +319,8 @@ static bool rt2x00usb_kick_tx_entry(struct queue_entry *entry, void *data)
 			  entry->skb->data, length,
 			  rt2x00usb_interrupt_txdone, entry);
 
-	usb_anchor_urb(entry_priv->urb, rt2x00dev->anchor);
 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
 	if (status) {
-		usb_unanchor_urb(entry_priv->urb);
 		if (status == -ENODEV)
 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
@@ -410,10 +408,8 @@ static bool rt2x00usb_kick_rx_entry(struct queue_entry *entry, void *data)
 			  entry->skb->data, entry->skb->len,
 			  rt2x00usb_interrupt_rxdone, entry);
 
-	usb_anchor_urb(entry_priv->urb, rt2x00dev->anchor);
 	status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
 	if (status) {
-		usb_unanchor_urb(entry_priv->urb);
 		if (status == -ENODEV)
 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
 		set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 29/32] rt2x00usb: fix anchor initialization
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (27 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 28/32] rt2x00usb: do not anchor rx and tx urb's Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device Amit Pundir
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Stanislaw Gruszka, Vishal Thanki, Kalle Valo

From: Stanislaw Gruszka <sgruszka@redhat.com>

If device fail to initialize we can OOPS in rt2x00lib_remove_dev(), due
to using uninitialized usb_anchor structure:

[  855.435820] ieee80211 phy3: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x1000 with error -19
[  855.435826] ieee80211 phy3: rt2800_probe_rt: Error - Invalid RT chipset 0x0000, rev 0000 detected
[  855.435829] ieee80211 phy3: rt2x00lib_probe_dev: Error - Failed to allocate device
[  855.435845] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[  855.435900] IP: _raw_spin_lock_irq+0xd/0x30
[  855.435926] PGD 0
[  855.435953] Oops: 0002 [#1] SMP
<snip>
[  855.437011] Call Trace:
[  855.437029]  ? usb_kill_anchored_urbs+0x27/0xc0
[  855.437061]  rt2x00lib_remove_dev+0x190/0x1c0 [rt2x00lib]
[  855.437097]  rt2x00lib_probe_dev+0x246/0x7a0 [rt2x00lib]
[  855.437149]  ? ieee80211_roc_setup+0x9e/0xd0 [mac80211]
[  855.437183]  ? __kmalloc+0x1af/0x1f0
[  855.437207]  ? rt2x00usb_probe+0x13d/0xc50 [rt2x00usb]
[  855.437240]  rt2x00usb_probe+0x155/0xc50 [rt2x00usb]
[  855.437273]  rt2800usb_probe+0x15/0x20 [rt2800usb]
[  855.437304]  usb_probe_interface+0x159/0x2d0
[  855.437333]  driver_probe_device+0x2bb/0x460

Patch changes initialization sequence to fix the problem.

Cc: Vishal Thanki <vishalthanki@gmail.com>
Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 0488a6121dfe6cbd44de15ea3627913b7549a1e9)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index efe2501..662705e 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -820,10 +820,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
 	if (retval)
 		goto exit_free_device;
 
-	retval = rt2x00lib_probe_dev(rt2x00dev);
-	if (retval)
-		goto exit_free_reg;
-
 	rt2x00dev->anchor = devm_kmalloc(&usb_dev->dev,
 					sizeof(struct usb_anchor),
 					GFP_KERNEL);
@@ -831,10 +827,17 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
 		retval = -ENOMEM;
 		goto exit_free_reg;
 	}
-
 	init_usb_anchor(rt2x00dev->anchor);
+
+	retval = rt2x00lib_probe_dev(rt2x00dev);
+	if (retval)
+		goto exit_free_anchor;
+
 	return 0;
 
+exit_free_anchor:
+	usb_kill_anchored_urbs(rt2x00dev->anchor);
+
 exit_free_reg:
 	rt2x00usb_free_reg(rt2x00dev);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (28 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 29/32] rt2x00usb: fix anchor initialization Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-12 13:18   ` Greg KH
  2017-04-05 10:32 ` [PATCH v2 for-4.9 31/32] rt2x00: Fix incorrect usage of CONFIG_RT2X00_LIB_USB Amit Pundir
                   ` (2 subsequent siblings)
  32 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Tobias Klauser, Kalle Valo

From: Tobias Klauser <tklauser@distanz.ch>

Instead of using a private copy of struct net_device_stats in struct
brcm_if, use stats from struct net_device.  Also remove the now
unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 91b632803ee4e47c5a5c4dc3d8bf5abf9c16107a)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 26 +++++++---------------
 .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  2 --
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 5eaac13..cf1ae5a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -243,10 +243,10 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
 
 done:
 	if (ret) {
-		ifp->stats.tx_dropped++;
+		ndev->stats.tx_dropped++;
 	} else {
-		ifp->stats.tx_packets++;
-		ifp->stats.tx_bytes += skb->len;
+		ndev->stats.tx_packets++;
+		ndev->stats.tx_bytes += skb->len;
 	}
 
 	/* Return ok: we always eat the packet */
@@ -290,15 +290,15 @@ void brcmf_txflowblock(struct device *dev, bool state)
 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb)
 {
 	if (skb->pkt_type == PACKET_MULTICAST)
-		ifp->stats.multicast++;
+		ifp->ndev->stats.multicast++;
 
 	if (!(ifp->ndev->flags & IFF_UP)) {
 		brcmu_pkt_buf_free_skb(skb);
 		return;
 	}
 
-	ifp->stats.rx_bytes += skb->len;
-	ifp->stats.rx_packets++;
+	ifp->ndev->stats.rx_bytes += skb->len;
+	ifp->ndev->stats.rx_packets++;
 
 	brcmf_dbg(DATA, "rx proto=0x%X\n", ntohs(skb->protocol));
 	if (in_interrupt())
@@ -321,7 +321,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
 
 	if (ret || !(*ifp) || !(*ifp)->ndev) {
 		if (ret != -ENODATA && *ifp)
-			(*ifp)->stats.rx_errors++;
+			(*ifp)->ndev->stats.rx_errors++;
 		brcmu_pkt_buf_free_skb(skb);
 		return -ENODATA;
 	}
@@ -382,7 +382,7 @@ void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success)
 	}
 
 	if (!success)
-		ifp->stats.tx_errors++;
+		ifp->ndev->stats.tx_errors++;
 
 	brcmu_pkt_buf_free_skb(txp);
 }
@@ -405,15 +405,6 @@ void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success)
 	}
 }
 
-static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev)
-{
-	struct brcmf_if *ifp = netdev_priv(ndev);
-
-	brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
-
-	return &ifp->stats;
-}
-
 static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
 				    struct ethtool_drvinfo *info)
 {
@@ -486,7 +477,6 @@ static int brcmf_netdev_open(struct net_device *ndev)
 static const struct net_device_ops brcmf_netdev_ops_pri = {
 	.ndo_open = brcmf_netdev_open,
 	.ndo_stop = brcmf_netdev_stop,
-	.ndo_get_stats = brcmf_netdev_get_stats,
 	.ndo_start_xmit = brcmf_netdev_start_xmit,
 	.ndo_set_mac_address = brcmf_netdev_set_mac_address,
 	.ndo_set_rx_mode = brcmf_netdev_set_multicast_list
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index c94dcab..397c912 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -171,7 +171,6 @@ enum brcmf_netif_stop_reason {
  * @drvr: points to device related information.
  * @vif: points to cfg80211 specific interface information.
  * @ndev: associated network device.
- * @stats: interface specific network statistics.
  * @multicast_work: worker object for multicast provisioning.
  * @ndoffload_work: worker object for neighbor discovery offload configuration.
  * @fws_desc: interface specific firmware-signalling descriptor.
@@ -187,7 +186,6 @@ struct brcmf_if {
 	struct brcmf_pub *drvr;
 	struct brcmf_cfg80211_vif *vif;
 	struct net_device *ndev;
-	struct net_device_stats stats;
 	struct work_struct multicast_work;
 	struct work_struct ndoffload_work;
 	struct brcmf_fws_mac_descriptor *fws_desc;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 31/32] rt2x00: Fix incorrect usage of CONFIG_RT2X00_LIB_USB
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (29 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-05 10:32 ` [PATCH v2 for-4.9 32/32] rt2x00: avoid introducing a USB dependency in the rt2x00lib module Amit Pundir
  2017-04-06  7:29 ` [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Greg KH
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Vishal Thanki, Kalle Valo

From: Vishal Thanki <vishalthanki@gmail.com>

In device removal routine, usage of "#ifdef CONFIG_RT2X00_LIB_USB"
will not cover the case when it is configured as module. This will
omit the entire if-block which does cleanup of URBs and cancellation
of pending work. Changing the #ifdef to #if IS_ENABLED() to fix it.

Signed-off-by: Vishal Thanki <vishalthanki@gmail.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit a083c8fd277b4122c804f18ec8c84165f345c71c)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
index 4e0c565..b7273be 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -1422,7 +1422,7 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
 	cancel_work_sync(&rt2x00dev->intf_work);
 	cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
 	cancel_work_sync(&rt2x00dev->sleep_work);
-#ifdef CONFIG_RT2X00_LIB_USB
+#if IS_ENABLED(CONFIG_RT2X00_LIB_USB)
 	if (rt2x00_is_usb(rt2x00dev)) {
 		usb_kill_anchored_urbs(rt2x00dev->anchor);
 		hrtimer_cancel(&rt2x00dev->txstatus_timer);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH v2 for-4.9 32/32] rt2x00: avoid introducing a USB dependency in the rt2x00lib module
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (30 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 31/32] rt2x00: Fix incorrect usage of CONFIG_RT2X00_LIB_USB Amit Pundir
@ 2017-04-05 10:32 ` Amit Pundir
  2017-04-06  7:29 ` [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Greg KH
  32 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-05 10:32 UTC (permalink / raw)
  To: stable; +Cc: gregkh, Stanislaw Gruszka, Vishal Thanki, Kalle Valo

From: Stanislaw Gruszka <sgruszka@redhat.com>

As reported by Felix:

Though protected by an ifdef, introducing an usb symbol dependency in
the rt2x00lib module is a major inconvenience for distributions that
package kernel modules split into individual packages.

Get rid of this unnecessary dependency by calling the usb related
function from a more suitable place.

Cc: Vishal Thanki <vishalthanki@gmail.com>
Reported-by: Felix Fietkau <nbd@nbd.name>
Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 6232c17438ed01f43665197db5a98a4a4f77ef47)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 23 ++++++++---------------
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c |  5 +++++
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
index b7273be..c8d9075 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -1422,21 +1422,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
 	cancel_work_sync(&rt2x00dev->intf_work);
 	cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
 	cancel_work_sync(&rt2x00dev->sleep_work);
-#if IS_ENABLED(CONFIG_RT2X00_LIB_USB)
-	if (rt2x00_is_usb(rt2x00dev)) {
-		usb_kill_anchored_urbs(rt2x00dev->anchor);
-		hrtimer_cancel(&rt2x00dev->txstatus_timer);
-		cancel_work_sync(&rt2x00dev->rxdone_work);
-		cancel_work_sync(&rt2x00dev->txdone_work);
-	}
-#endif
-	if (rt2x00dev->workqueue)
-		destroy_workqueue(rt2x00dev->workqueue);
-
-	/*
-	 * Free the tx status fifo.
-	 */
-	kfifo_free(&rt2x00dev->txstatus_fifo);
 
 	/*
 	 * Kill the tx status tasklet.
@@ -1452,6 +1437,14 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
 	 */
 	rt2x00lib_uninitialize(rt2x00dev);
 
+	if (rt2x00dev->workqueue)
+		destroy_workqueue(rt2x00dev->workqueue);
+
+	/*
+	 * Free the tx status fifo.
+	 */
+	kfifo_free(&rt2x00dev->txstatus_fifo);
+
 	/*
 	 * Free extra components
 	 */
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index 662705e..631df69 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -740,6 +740,11 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev)
 {
 	struct data_queue *queue;
 
+	usb_kill_anchored_urbs(rt2x00dev->anchor);
+	hrtimer_cancel(&rt2x00dev->txstatus_timer);
+	cancel_work_sync(&rt2x00dev->rxdone_work);
+	cancel_work_sync(&rt2x00dev->txdone_work);
+
 	queue_for_each(rt2x00dev, queue)
 		rt2x00usb_free_entries(queue);
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project
  2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
                   ` (31 preceding siblings ...)
  2017-04-05 10:32 ` [PATCH v2 for-4.9 32/32] rt2x00: avoid introducing a USB dependency in the rt2x00lib module Amit Pundir
@ 2017-04-06  7:29 ` Greg KH
  2017-04-06  7:44   ` Amit Pundir
  32 siblings, 1 reply; 52+ messages in thread
From: Greg KH @ 2017-04-06  7:29 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable

On Wed, Apr 05, 2017 at 04:01:52PM +0530, Amit Pundir wrote:
> Hi Greg,
> 
> 2nd attempt at sending stable commits taken from lede source tree
> https://github.com/lede-project/source for your consideration for
> 4.9.y. I Forgot to update the Subject line of the individual patches
> in my 1st attempt. They didn't explicitly mention that they were
> targeted for stable-4.9 and that led to some confusion.
> 
> Cherry-picked and build tested on Linux 4.9.20 for
> ARCH=arm/arm64/i386/x86_64 + allmodconfig.

I'm guessing you also dropped one patch?  Also, are any of these
applicable for 4.10 or 4.4-stable?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
  2017-04-05 10:31 ` [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags Amit Pundir
@ 2017-04-06  7:33   ` Greg KH
  0 siblings, 0 replies; 52+ messages in thread
From: Greg KH @ 2017-04-06  7:33 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Jon Mason, Florian Fainelli

On Wed, Apr 05, 2017 at 04:01:54PM +0530, Amit Pundir wrote:
> From: Jon Mason <jon.mason@broadcom.com>
> 
> GIC_PPI flags were misconfigured for the timers, resulting in errors
> like:
> [    0.000000] GIC: PPI11 is secure or misconfigured
> 
> Changing them to being edge triggered corrects the issue
> 
> Suggested-by: Rafał Miłecki <rafal@milecki.pl>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> Fixes: d27509f1 ("ARM: BCM5301X: add dts files for BCM4708 SoC")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> (cherry picked from commit 0c2bf9f95983fe30aa2f6463cb761cd42c2d521a)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  arch/arm/boot/dts/bcm5301x.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

This also should go into 4.10-stable, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie
  2017-04-05 10:31 ` [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie Amit Pundir
@ 2017-04-06  7:33   ` Greg KH
  0 siblings, 0 replies; 52+ messages in thread
From: Greg KH @ 2017-04-06  7:33 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Bjorn Helgaas

On Wed, Apr 05, 2017 at 04:01:55PM +0530, Amit Pundir wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> The host bridge memory window resource is inserted into the iomem_resource
> tree and cannot be deallocated until the host bridge itself is removed.
> 
> Previously, the window was on the stack, which meant the iomem_resource
> entry pointed into the stack and was corrupted as soon as the probe
> function returned, which caused memory corruption and errors like this:
> 
>   pcie_iproc_bcma bcma0:8: resource collision: [mem 0x40000000-0x47ffffff] conflicts with PCIe MEM space [mem 0x40000000-0x47ffffff]
> 
> Move the memory window resource from the stack into struct iproc_pcie so
> its lifetime matches that of the host bridge.
> 
> Fixes: c3245a566400 ("PCI: iproc: Request host bridge window resources")
> Reported-and-tested-by: Rafał Miłecki <zajec5@gmail.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> (cherry picked from commit 6e347b5e05ea2ac4ac467a5a1cfaebb2c7f06f80)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  drivers/pci/host/pcie-iproc-bcma.c     | 24 ++++++++++++------------
>  drivers/pci/host/pcie-iproc-platform.c | 19 ++++++++++---------
>  drivers/pci/host/pcie-iproc.h          |  1 +
>  3 files changed, 23 insertions(+), 21 deletions(-)

This is already in my stable queue, why include it again?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-05 10:31 ` [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
@ 2017-04-06  7:34   ` Greg KH
  2017-04-06  9:29     ` James Hogan
  1 sibling, 0 replies; 52+ messages in thread
From: Greg KH @ 2017-04-06  7:34 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Felix Fietkau, linux-mips, James Hogan

On Wed, Apr 05, 2017 at 04:01:56PM +0530, Amit Pundir wrote:
> From: Felix Fietkau <nbd@nbd.name>
> 
> With the IRQ stack changes integrated, the XRX200 devices started
> emitting a constant stream of kernel messages like this:
> 
> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
> 
> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
> its vectored interrupt handler, which is fixed by commit de856416e714
> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
> 
> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
> for all MIPS CPU interrupts.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: John Crispin <john@phrozen.org>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/15077/
> [james.hogan@imgtec.com: tweaked commit message]
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> 
> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  arch/mips/lantiq/irq.c | 38 +++++++++++++++++---------------------
>  1 file changed, 17 insertions(+), 21 deletions(-)

Also works for 4.4 and 4.10-stable...

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project
  2017-04-06  7:29 ` [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Greg KH
@ 2017-04-06  7:44   ` Amit Pundir
  0 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-06  7:44 UTC (permalink / raw)
  To: Greg KH; +Cc: stable

On 6 April 2017 at 12:59, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Apr 05, 2017 at 04:01:52PM +0530, Amit Pundir wrote:
>> Hi Greg,
>>
>> 2nd attempt at sending stable commits taken from lede source tree
>> https://github.com/lede-project/source for your consideration for
>> 4.9.y. I Forgot to update the Subject line of the individual patches
>> in my 1st attempt. They didn't explicitly mention that they were
>> targeted for stable-4.9 and that led to some confusion.
>>
>> Cherry-picked and build tested on Linux 4.9.20 for
>> ARCH=arm/arm64/i386/x86_64 + allmodconfig.
>
> I'm guessing you also dropped one patch?  Also, are any of these
> applicable for 4.10 or 4.4-stable?

Yes I dropped one [ 5d1f2d2 ("ARM: dts: BCM5301X: Set 5 GHz wireless
frequency limits on Netgear R8000") ] because that was incomplete. I
might have to pull in few more patches to make that one work. I tried
cherry-picking 1 or 2 relevant patches but the patchset didn't build.
So I gave up on that one. Lede distro doesn't pull those dependent
patches too, so I'm pretty sure this patch doesn't work for them as
well.

Few of these patches are applicable for 4.10 stable as well. I'll send
them across. Didn't yet look at 4.4 patchset.

Regards,
Amit Pundir

>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06  9:29     ` James Hogan
  0 siblings, 0 replies; 52+ messages in thread
From: James Hogan @ 2017-04-06  9:29 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, gregkh, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Hi Amit,

On Wed, Apr 05, 2017 at 04:01:56PM +0530, Amit Pundir wrote:
> From: Felix Fietkau <nbd@nbd.name>
> 
> With the IRQ stack changes integrated, the XRX200 devices started
> emitting a constant stream of kernel messages like this:
> 
> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
> 
> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
> its vectored interrupt handler, which is fixed by commit de856416e714
> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
> 
> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
> for all MIPS CPU interrupts.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: John Crispin <john@phrozen.org>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/15077/
> [james.hogan@imgtec.com: tweaked commit message]
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> 
> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

Is there a particular reason this is desired in stable? I was under the
impression it was only helpful in the presence of a bug in the separate
IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
plat_irq_dispatch"), and otherwise just a nice to have cleanup.

If you've cherry picked the IRQ stack work, have you also cherry-picked
de856416e714?

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06  9:29     ` James Hogan
  0 siblings, 0 replies; 52+ messages in thread
From: James Hogan @ 2017-04-06  9:29 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, gregkh, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Hi Amit,

On Wed, Apr 05, 2017 at 04:01:56PM +0530, Amit Pundir wrote:
> From: Felix Fietkau <nbd@nbd.name>
> 
> With the IRQ stack changes integrated, the XRX200 devices started
> emitting a constant stream of kernel messages like this:
> 
> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
> 
> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
> its vectored interrupt handler, which is fixed by commit de856416e714
> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
> 
> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
> for all MIPS CPU interrupts.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: John Crispin <john@phrozen.org>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/15077/
> [james.hogan@imgtec.com: tweaked commit message]
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> 
> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

Is there a particular reason this is desired in stable? I was under the
impression it was only helpful in the presence of a bug in the separate
IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
plat_irq_dispatch"), and otherwise just a nice to have cleanup.

If you've cherry picked the IRQ stack work, have you also cherry-picked
de856416e714?

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-06  9:29     ` James Hogan
  (?)
@ 2017-04-06 10:53     ` Amit Pundir
  2017-04-06 11:25         ` James Hogan
  -1 siblings, 1 reply; 52+ messages in thread
From: Amit Pundir @ 2017-04-06 10:53 UTC (permalink / raw)
  To: James Hogan; +Cc: stable, Greg Kroah-Hartman, Felix Fietkau, linux-mips

Hi James,

On 6 April 2017 at 14:59, James Hogan <james.hogan@imgtec.com> wrote:
> Hi Amit,
>
> On Wed, Apr 05, 2017 at 04:01:56PM +0530, Amit Pundir wrote:
>> From: Felix Fietkau <nbd@nbd.name>
>>
>> With the IRQ stack changes integrated, the XRX200 devices started
>> emitting a constant stream of kernel messages like this:
>>
>> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
>>
>> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
>> its vectored interrupt handler, which is fixed by commit de856416e714
>> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
>>
>> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
>> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
>> for all MIPS CPU interrupts.
>>
>> Signed-off-by: Felix Fietkau <nbd@nbd.name>
>> Acked-by: John Crispin <john@phrozen.org>
>> Cc: linux-mips@linux-mips.org
>> Patchwork: https://patchwork.linux-mips.org/patch/15077/
>> [james.hogan@imgtec.com: tweaked commit message]
>> Signed-off-by: James Hogan <james.hogan@imgtec.com>
>>
>> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
>> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
>
> Is there a particular reason this is desired in stable? I was under the
> impression it was only helpful in the presence of a bug in the separate
> IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
> de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
> plat_irq_dispatch"), and otherwise just a nice to have cleanup.

I picked up this patch from Lede source tree
https://github.com/lede-project/source/ for stable 4.9.

>
> If you've cherry picked the IRQ stack work, have you also cherry-picked
> de856416e714?

Thanks for pointing it out. I indeed missed out on picking
de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
plat_irq_dispatch") and dda45f701c9d ("MIPS: Switch to the irq_stack
in interrupts"). Should I pick them too for 4.9/4.10 stable or drop
these 3 IRQ stack patches altogether if they are not stable material?

Regards,
Amit Pundir

>
> Cheers
> James

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06 11:25         ` James Hogan
  0 siblings, 0 replies; 52+ messages in thread
From: James Hogan @ 2017-04-06 11:25 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Greg Kroah-Hartman, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

On Thu, Apr 06, 2017 at 04:23:24PM +0530, Amit Pundir wrote:
> On 6 April 2017 at 14:59, James Hogan <james.hogan@imgtec.com> wrote:
> > Is there a particular reason this is desired in stable? I was under the
> > impression it was only helpful in the presence of a bug in the separate
> > IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
> > de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
> > plat_irq_dispatch"), and otherwise just a nice to have cleanup.
> 
> I picked up this patch from Lede source tree
> https://github.com/lede-project/source/ for stable 4.9.
> 
> >
> > If you've cherry picked the IRQ stack work, have you also cherry-picked
> > de856416e714?
> 
> Thanks for pointing it out. I indeed missed out on picking
> de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
> plat_irq_dispatch") and dda45f701c9d ("MIPS: Switch to the irq_stack
> in interrupts"). Should I pick them too for 4.9/4.10 stable or drop
> these 3 IRQ stack patches altogether if they are not stable material?

I'd definitely drop this one.

Greg said he doesn't object to accepting the IRQ stack work once its
been shaken out in mainline, at which point the fixes will be needed
too:

https://marc.info/?l=linux-mips&m=148449064421154&w=2

Though note that its more than just the one patch:

https://patchwork.linux-mips.org/project/linux-mips/list/?series=23&state=*

(I seem to remember somebody saying LEDE had applied these patches).

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06 11:25         ` James Hogan
  0 siblings, 0 replies; 52+ messages in thread
From: James Hogan @ 2017-04-06 11:25 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Greg Kroah-Hartman, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

On Thu, Apr 06, 2017 at 04:23:24PM +0530, Amit Pundir wrote:
> On 6 April 2017 at 14:59, James Hogan <james.hogan@imgtec.com> wrote:
> > Is there a particular reason this is desired in stable? I was under the
> > impression it was only helpful in the presence of a bug in the separate
> > IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
> > de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
> > plat_irq_dispatch"), and otherwise just a nice to have cleanup.
> 
> I picked up this patch from Lede source tree
> https://github.com/lede-project/source/ for stable 4.9.
> 
> >
> > If you've cherry picked the IRQ stack work, have you also cherry-picked
> > de856416e714?
> 
> Thanks for pointing it out. I indeed missed out on picking
> de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
> plat_irq_dispatch") and dda45f701c9d ("MIPS: Switch to the irq_stack
> in interrupts"). Should I pick them too for 4.9/4.10 stable or drop
> these 3 IRQ stack patches altogether if they are not stable material?

I'd definitely drop this one.

Greg said he doesn't object to accepting the IRQ stack work once its
been shaken out in mainline, at which point the fixes will be needed
too:

https://marc.info/?l=linux-mips&m=148449064421154&w=2

Though note that its more than just the one patch:

https://patchwork.linux-mips.org/project/linux-mips/list/?series=23&state=*

(I seem to remember somebody saying LEDE had applied these patches).

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-06 11:25         ` James Hogan
  (?)
@ 2017-04-06 11:44         ` Amit Pundir
  -1 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-06 11:44 UTC (permalink / raw)
  To: James Hogan; +Cc: stable, Greg Kroah-Hartman, Felix Fietkau, linux-mips

On 6 April 2017 at 16:55, James Hogan <james.hogan@imgtec.com> wrote:
> On Thu, Apr 06, 2017 at 04:23:24PM +0530, Amit Pundir wrote:
>> On 6 April 2017 at 14:59, James Hogan <james.hogan@imgtec.com> wrote:
>> > Is there a particular reason this is desired in stable? I was under the
>> > impression it was only helpful in the presence of a bug in the separate
>> > IRQ stack stuff in 4.11, which was fixed in the above mentioned commit
>> > de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
>> > plat_irq_dispatch"), and otherwise just a nice to have cleanup.
>>
>> I picked up this patch from Lede source tree
>> https://github.com/lede-project/source/ for stable 4.9.
>>
>> >
>> > If you've cherry picked the IRQ stack work, have you also cherry-picked
>> > de856416e714?
>>
>> Thanks for pointing it out. I indeed missed out on picking
>> de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to
>> plat_irq_dispatch") and dda45f701c9d ("MIPS: Switch to the irq_stack
>> in interrupts"). Should I pick them too for 4.9/4.10 stable or drop
>> these 3 IRQ stack patches altogether if they are not stable material?
>
> I'd definitely drop this one.

Yes I'd drop this lone survivor too. I'll send the complete batch separately.

>
> Greg said he doesn't object to accepting the IRQ stack work once its
> been shaken out in mainline, at which point the fixes will be needed
> too:
>
> https://marc.info/?l=linux-mips&m=148449064421154&w=2
>
> Though note that its more than just the one patch:
>
> https://patchwork.linux-mips.org/project/linux-mips/list/?series=23&state=*
>
> (I seem to remember somebody saying LEDE had applied these patches).

I see all these patches in LEDE source too. Sorted out for both 4.4
and 4.9 already. I'll send them on stable shortly.

Regards,
Amit Pundir

>
> Cheers
> James

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers.
  2017-04-05 10:32 ` [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers Amit Pundir
@ 2017-04-06 16:53   ` Eric Anholt
  0 siblings, 0 replies; 52+ messages in thread
From: Eric Anholt @ 2017-04-06 16:53 UTC (permalink / raw)
  To: Amit Pundir, stable; +Cc: gregkh, Stephen Boyd

[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

Amit Pundir <amit.pundir@linaro.org> writes:

> From: Eric Anholt <eric@anholt.net>
>
> Our core PLLs are intended to be configured once and left alone.  With
> the SET_RATE_PARENT, asking to set the PLLD_DSI1 clock rate would
> change PLLD just to get closer to the requested DSI clock, thus
> changing PLLD_PER, the UART and ethernet PHY clock rates downstream of
> it, and breaking ethernet.
>
> We *do* want PLLH to change so that PLLH_AUX can be exactly the value
> we want, though.  Thus, we need to have a per-divider policy of
> whether to pass rate changes up.

I don't have the full series so I'm not sure why these 3 are being sent
to stable, but they don't seem like stable candidates to me.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks.
  2017-04-05 10:32 ` [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks Amit Pundir
@ 2017-04-12 13:15   ` Greg KH
  0 siblings, 0 replies; 52+ messages in thread
From: Greg KH @ 2017-04-12 13:15 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Eric Anholt, Stephen Boyd

On Wed, Apr 05, 2017 at 04:02:05PM +0530, Amit Pundir wrote:
> From: Eric Anholt <eric@anholt.net>
> 
> The DSI pixel clocks are muxed from clocks generated in the analog phy
> by the DSI driver.  In order to set them as parents, we need to do the
> same name lookup dance on them as we do for our root oscillator.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> (cherry picked from commit 8a39e9fa578229fd4604266c6ebb1a3a77d7994c)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  .../bindings/clock/brcm,bcm2835-cprman.txt         |  15 ++-
>  drivers/clk/bcm/clk-bcm2835.c                      | 121 +++++++++++++++++++--
>  include/dt-bindings/clock/bcm2835.h                |   2 +
>  3 files changed, 125 insertions(+), 13 deletions(-)

How does this match the stable kernel rules?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks
  2017-04-05 10:32 ` [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks Amit Pundir
@ 2017-04-12 13:17   ` Greg KH
  2017-04-12 13:33     ` Amit Pundir
  0 siblings, 1 reply; 52+ messages in thread
From: Greg KH @ 2017-04-12 13:17 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Boris Brezillon, Stephen Boyd

On Wed, Apr 05, 2017 at 04:02:01PM +0530, Amit Pundir wrote:
> From: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> Some peripheral clocks, like the VEC (Video EnCoder) clock need to be set
> to a precise rate (in our case 108MHz). With the current implementation,
> where peripheral clocks are not allowed to forward rate change requests
> to their parents, it is impossible to match this requirement unless the
> bootloader has configured things correctly, or a specific rate has been
> assigned through the DT (with the assigned-clk-rates property).
> 
> Add a new field to struct bcm2835_clock_data to specify which parent
> clocks accept rate change propagation, and support set rate propagation
> in bcm2835_clock_determine_rate().
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Reviewed-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> (cherry picked from commit 155e8b3b0ee320ae866b97dd31eba8a1f080a772)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  drivers/clk/bcm/clk-bcm2835.c | 67 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 63 insertions(+), 4 deletions(-)

How does this match the stable kernel rules?

I'm confused.  Just because a distro/product includes patches in their
tree, does not mean they are all applicable for stable kernel releases.
Adding new device support in ways that is not just a simple quirk or
other table addition, isn't ok.

So this clk series isn't ok.  I'm going to drop this whole patch series
now.  Can you please review it, and resend any that you think are
applicable?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device
  2017-04-05 10:32 ` [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device Amit Pundir
@ 2017-04-12 13:18   ` Greg KH
  2017-04-12 13:46     ` Tobias Klauser
  2017-04-12 13:52     ` Kalle Valo
  0 siblings, 2 replies; 52+ messages in thread
From: Greg KH @ 2017-04-12 13:18 UTC (permalink / raw)
  To: Amit Pundir; +Cc: stable, Tobias Klauser, Kalle Valo

On Wed, Apr 05, 2017 at 04:02:22PM +0530, Amit Pundir wrote:
> From: Tobias Klauser <tklauser@distanz.ch>
> 
> Instead of using a private copy of struct net_device_stats in struct
> brcm_if, use stats from struct net_device.  Also remove the now
> unnecessary .ndo_get_stats function.
> 
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> (cherry picked from commit 91b632803ee4e47c5a5c4dc3d8bf5abf9c16107a)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
>  .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 26 +++++++---------------
>  .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  2 --
>  2 files changed, 8 insertions(+), 20 deletions(-)

Again, how is this a proper stable patch?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks
  2017-04-12 13:17   ` Greg KH
@ 2017-04-12 13:33     ` Amit Pundir
  0 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-12 13:33 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, Boris Brezillon, Stephen Boyd

On 12 April 2017 at 18:47, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Apr 05, 2017 at 04:02:01PM +0530, Amit Pundir wrote:
>> From: Boris Brezillon <boris.brezillon@free-electrons.com>
>>
>> Some peripheral clocks, like the VEC (Video EnCoder) clock need to be set
>> to a precise rate (in our case 108MHz). With the current implementation,
>> where peripheral clocks are not allowed to forward rate change requests
>> to their parents, it is impossible to match this requirement unless the
>> bootloader has configured things correctly, or a specific rate has been
>> assigned through the DT (with the assigned-clk-rates property).
>>
>> Add a new field to struct bcm2835_clock_data to specify which parent
>> clocks accept rate change propagation, and support set rate propagation
>> in bcm2835_clock_determine_rate().
>>
>> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>> Reviewed-by: Eric Anholt <eric@anholt.net>
>> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
>> (cherry picked from commit 155e8b3b0ee320ae866b97dd31eba8a1f080a772)
>> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
>> ---
>>  drivers/clk/bcm/clk-bcm2835.c | 67 ++++++++++++++++++++++++++++++++++++++++---
>>  1 file changed, 63 insertions(+), 4 deletions(-)
>
> How does this match the stable kernel rules?
>
> I'm confused.  Just because a distro/product includes patches in their
> tree, does not mean they are all applicable for stable kernel releases.
> Adding new device support in ways that is not just a simple quirk or
> other table addition, isn't ok.
>
> So this clk series isn't ok.  I'm going to drop this whole patch series
> now.  Can you please review it, and resend any that you think are
> applicable?

Ack. I'll review the series and resend the relevant patches.

Regards,
Amit Pundir

>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device
  2017-04-12 13:18   ` Greg KH
@ 2017-04-12 13:46     ` Tobias Klauser
  2017-04-12 13:52     ` Kalle Valo
  1 sibling, 0 replies; 52+ messages in thread
From: Tobias Klauser @ 2017-04-12 13:46 UTC (permalink / raw)
  To: Greg KH; +Cc: Amit Pundir, stable, Kalle Valo

On 2017-04-12 at 15:18:06 +0200, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Apr 05, 2017 at 04:02:22PM +0530, Amit Pundir wrote:
> > From: Tobias Klauser <tklauser@distanz.ch>
> > 
> > Instead of using a private copy of struct net_device_stats in struct
> > brcm_if, use stats from struct net_device.  Also remove the now
> > unnecessary .ndo_get_stats function.
> > 
> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> > Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> > Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> > (cherry picked from commit 91b632803ee4e47c5a5c4dc3d8bf5abf9c16107a)
> > Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> > ---
> >  .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 26 +++++++---------------
> >  .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  2 --
> >  2 files changed, 8 insertions(+), 20 deletions(-)
> 
> Again, how is this a proper stable patch?

I don't know how this ended up being submitted for inclusion in stable,
but from by perspective this patch clearly doesn't qualify for
inclusion.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device
  2017-04-12 13:18   ` Greg KH
  2017-04-12 13:46     ` Tobias Klauser
@ 2017-04-12 13:52     ` Kalle Valo
  2017-04-12 14:29       ` Amit Pundir
  1 sibling, 1 reply; 52+ messages in thread
From: Kalle Valo @ 2017-04-12 13:52 UTC (permalink / raw)
  To: Greg KH; +Cc: Amit Pundir, stable, Tobias Klauser, Arend van Spriel

+ arend

Greg KH <gregkh@linuxfoundation.org> writes:

> On Wed, Apr 05, 2017 at 04:02:22PM +0530, Amit Pundir wrote:
>> From: Tobias Klauser <tklauser@distanz.ch>
>> 
>> Instead of using a private copy of struct net_device_stats in struct
>> brcm_if, use stats from struct net_device.  Also remove the now
>> unnecessary .ndo_get_stats function.
>> 
>> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
>> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
>> (cherry picked from commit 91b632803ee4e47c5a5c4dc3d8bf5abf9c16107a)
>> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
>> ---
>>  .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 26 +++++++---------------
>>  .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  2 --
>>  2 files changed, 8 insertions(+), 20 deletions(-)
>
> Again, how is this a proper stable patch?

I have no idea. At least me nor Arend didn't tag it for stable.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device
  2017-04-12 13:52     ` Kalle Valo
@ 2017-04-12 14:29       ` Amit Pundir
  0 siblings, 0 replies; 52+ messages in thread
From: Amit Pundir @ 2017-04-12 14:29 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Greg KH, stable, Tobias Klauser, Arend van Spriel

On 12 April 2017 at 19:22, Kalle Valo <kvalo@codeaurora.org> wrote:
> + arend
>
> Greg KH <gregkh@linuxfoundation.org> writes:
>
>> On Wed, Apr 05, 2017 at 04:02:22PM +0530, Amit Pundir wrote:
>>> From: Tobias Klauser <tklauser@distanz.ch>
>>>
>>> Instead of using a private copy of struct net_device_stats in struct
>>> brcm_if, use stats from struct net_device.  Also remove the now
>>> unnecessary .ndo_get_stats function.
>>>
>>> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
>>> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>>> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
>>> (cherry picked from commit 91b632803ee4e47c5a5c4dc3d8bf5abf9c16107a)
>>> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
>>> ---
>>>  .../wireless/broadcom/brcm80211/brcmfmac/core.c    | 26 +++++++---------------
>>>  .../wireless/broadcom/brcm80211/brcmfmac/core.h    |  2 --
>>>  2 files changed, 8 insertions(+), 20 deletions(-)
>>
>> Again, how is this a proper stable patch?
>
> I have no idea. At least me nor Arend didn't tag it for stable.

I picked it up along with few other patches from LEDE 4.9 stable
source and sent them @ stable. I'll review the series again. My
apologies for the confusion.

Regards,
Amit Pundir

>
> --
> Kalle Valo

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2017-04-12 14:30 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-05 10:31 [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Amit Pundir
2017-04-05 10:31 ` [PATCH v2 for-4.9 01/32] ARM: BCM5301X: Add back handler ignoring external imprecise aborts Amit Pundir
2017-04-05 10:31 ` [PATCH v2 for-4.9 02/32] ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags Amit Pundir
2017-04-06  7:33   ` Greg KH
2017-04-05 10:31 ` [PATCH v2 for-4.9 03/32] PCI: iproc: Save host bridge window resource in struct iproc_pcie Amit Pundir
2017-04-06  7:33   ` Greg KH
2017-04-05 10:31 ` [PATCH v2 for-4.9 04/32] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
2017-04-06  7:34   ` Greg KH
2017-04-06  9:29   ` James Hogan
2017-04-06  9:29     ` James Hogan
2017-04-06 10:53     ` Amit Pundir
2017-04-06 11:25       ` James Hogan
2017-04-06 11:25         ` James Hogan
2017-04-06 11:44         ` Amit Pundir
2017-04-05 10:31 ` [PATCH v2 for-4.9 05/32] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes Amit Pundir
2017-04-05 10:31 ` [PATCH v2 for-4.9 06/32] i2c: bcm2835: Protect against unexpected TXW/RXR interrupts Amit Pundir
2017-04-05 10:31 ` [PATCH v2 for-4.9 07/32] i2c: bcm2835: Use dev_dbg logging on transfer errors Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 08/32] i2c: bcm2835: Can't support I2C_M_IGNORE_NAK Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 09/32] clk: bcm: Support rate change propagation on bcm2835 clocks Amit Pundir
2017-04-12 13:17   ` Greg KH
2017-04-12 13:33     ` Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 10/32] clk: bcm: Allow rate change propagation to PLLH_AUX on VEC clock Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 11/32] clk: bcm: Fix 'maybe-uninitialized' warning in bcm2835_clock_choose_div_and_prate() Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 12/32] clk: bcm2835: Don't rate change PLLs on behalf of DSI PLL dividers Amit Pundir
2017-04-06 16:53   ` Eric Anholt
2017-04-05 10:32 ` [PATCH v2 for-4.9 13/32] clk: bcm2835: Register the DSI0/DSI1 pixel clocks Amit Pundir
2017-04-12 13:15   ` Greg KH
2017-04-05 10:32 ` [PATCH v2 for-4.9 14/32] clk: bcm2835: Add leaf clock measurement support, disabled by default Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 15/32] dmaengine: bcm2835: Fix cyclic DMA period splitting Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 16/32] usb: dwc2: Remove unnecessary kfree Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 17/32] mtd: bcm47xxpart: fix parsing first block after aligned TRX Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 18/32] net: add devm version of alloc_etherdev_mqs function Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 19/32] net: bgmac: allocate struct bgmac just once & don't copy it Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 20/32] net: bgmac: drop struct bcma_mdio we don't need anymore Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 21/32] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 22/32] rt2500usb: don't mark register accesses as inline Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 23/32] brcmfmac: check brcmf_bus_get_memdump result for error Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 24/32] brcmfmac: be more verbose when PSM's watchdog fires Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 25/32] brcmfmac: merge two brcmf_err macros into one Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 26/32] brcmfmac: switch to C function (__brcmf_err) for printing errors Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 27/32] brcmfmac: merge two remaining brcmf_err macros Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 28/32] rt2x00usb: do not anchor rx and tx urb's Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 29/32] rt2x00usb: fix anchor initialization Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 30/32] brcmfmac: Use net_device_stats from struct net_device Amit Pundir
2017-04-12 13:18   ` Greg KH
2017-04-12 13:46     ` Tobias Klauser
2017-04-12 13:52     ` Kalle Valo
2017-04-12 14:29       ` Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 31/32] rt2x00: Fix incorrect usage of CONFIG_RT2X00_LIB_USB Amit Pundir
2017-04-05 10:32 ` [PATCH v2 for-4.9 32/32] rt2x00: avoid introducing a USB dependency in the rt2x00lib module Amit Pundir
2017-04-06  7:29 ` [PATCH v2 for-4.9 00/32] Stable commits picked up from lede project Greg KH
2017-04-06  7:44   ` Amit Pundir

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.