linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
@ 2019-01-02 12:51 Rafał Miłecki
  2019-01-02 15:50 ` Hauke Mehrtens
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rafał Miłecki @ 2019-01-02 12:51 UTC (permalink / raw)
  To: Paul Burton
  Cc: Ralf Baechle, James Hogan, Christoph Hellwig, Linus Walleij,
	Hauke Mehrtens, linux-mips, linux-kernel, linux-wireless,
	Rafał Miłecki

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

So far we never had any device registered for the SoC. This resulted in
some small issues that we kept ignoring like:
1) Not working GPIOLIB_IRQCHIP (gpiochip_irqchip_add_key() failing)
2) Lack of proper tree in the /sys/devices/
3) mips_dma_alloc_coherent() silently handling empty coherent_dma_mask

Kernel 4.19 came with a lot of DMA changes and caused a regression on
bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic dma
noncoherent ops for simple noncoherent platforms") DMA coherent
allocations just fail. Example:
[    1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
[    1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA
[    1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12
[    1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded

The bgmac driver also triggers a WARNING:
[    0.959486] ------------[ cut here ]------------
[    0.964387] WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 bgmac_enet_probe+0x1b4/0x5c4
[    0.973751] Modules linked in:
[    0.976913] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.9 #0
[    0.982750] Stack : 804a0000 804597c4 00000000 00000000 80458fd8 8381bc2c 838282d4 80481a47
[    0.991367]         8042e3ec 00000001 804d38f0 00000204 83980000 00000065 8381bbe0 6f55b24f
[    0.999975]         00000000 00000000 80520000 00002018 00000000 00000075 00000007 00000000
[    1.008583]         00000000 80480000 000ee811 00000000 00000000 00000000 80432c00 80248db8
[    1.017196]         00000009 00000204 83980000 803ad7b0 00000000 801feeec 00000000 804d0000
[    1.025804]         ...
[    1.028325] Call Trace:
[    1.030875] [<8000aef8>] show_stack+0x58/0x100
[    1.035513] [<8001f8b4>] __warn+0xe4/0x118
[    1.039708] [<8001f9a4>] warn_slowpath_null+0x48/0x64
[    1.044935] [<80248db8>] bgmac_enet_probe+0x1b4/0x5c4
[    1.050101] [<802498e0>] bgmac_probe+0x558/0x590
[    1.054906] [<80252fd0>] bcma_device_probe+0x38/0x70
[    1.060017] [<8020e1e8>] really_probe+0x170/0x2e8
[    1.064891] [<8020e714>] __driver_attach+0xa4/0xec
[    1.069784] [<8020c1e0>] bus_for_each_dev+0x58/0xb0
[    1.074833] [<8020d590>] bus_add_driver+0xf8/0x218
[    1.079731] [<8020ef24>] driver_register+0xcc/0x11c
[    1.084804] [<804b54cc>] bgmac_init+0x1c/0x44
[    1.089258] [<8000121c>] do_one_initcall+0x7c/0x1a0
[    1.094343] [<804a1d34>] kernel_init_freeable+0x150/0x218
[    1.099886] [<803a082c>] kernel_init+0x10/0x104
[    1.104583] [<80005878>] ret_from_kernel_thread+0x14/0x1c
[    1.110107] ---[ end trace f441c0d873d1fb5b ]---

This patch setups a "struct device" (and passes it to the bcma) which
allows fixing all the mentioned problems. It'll also require a tiny bcma
patch which will follow through the wireless tree & its maintainer.

Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
Cc: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 arch/mips/bcm47xx/setup.c     | 30 ++++++++++++++++++++++++++++++
 include/linux/bcma/bcma_soc.h |  1 +
 2 files changed, 31 insertions(+)

diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 6054d49e608e..9339a31a0a87 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -173,6 +173,31 @@ void __init plat_mem_setup(void)
 	pm_power_off = bcm47xx_machine_halt;
 }
 
+#ifdef CONFIG_BCM47XX_BCMA
+static struct device * __init bcm47xx_setup_device(void)
+{
+	struct device *dev;
+	int err;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	err = dev_set_name(dev, "bcm47xx_soc");
+	if (err) {
+		pr_err("Failed to set SoC device name: %d\n", err);
+		kfree(dev);
+		return NULL;
+	}
+
+	err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
+	if (err)
+		pr_err("Failed to set SoC DMA mask: %d\n", err);
+
+	return dev;
+}
+#endif
+
 /*
  * This finishes bus initialization doing things that were not possible without
  * kmalloc. Make sure to call it late enough (after mm_init).
@@ -183,6 +208,10 @@ void __init bcm47xx_bus_setup(void)
 	if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) {
 		int err;
 
+		bcm47xx_bus.bcma.dev = bcm47xx_setup_device();
+		if (!bcm47xx_bus.bcma.dev)
+			panic("Failed to setup SoC device\n");
+
 		err = bcma_host_soc_init(&bcm47xx_bus.bcma);
 		if (err)
 			panic("Failed to initialize BCMA bus (err %d)", err);
@@ -235,6 +264,7 @@ static int __init bcm47xx_register_bus_complete(void)
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
 	case BCM47XX_BUS_TYPE_BCMA:
+		device_register(bcm47xx_bus.bcma.dev);
 		bcma_bus_register(&bcm47xx_bus.bcma.bus);
 		break;
 #endif
diff --git a/include/linux/bcma/bcma_soc.h b/include/linux/bcma/bcma_soc.h
index 7cca5f859a90..72a9a5cf962b 100644
--- a/include/linux/bcma/bcma_soc.h
+++ b/include/linux/bcma/bcma_soc.h
@@ -5,6 +5,7 @@
 #include <linux/bcma/bcma.h>
 
 struct bcma_soc {
+	struct device *dev;
 	struct bcma_bus bus;
 };
 
-- 
2.20.1


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

* Re: [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
  2019-01-02 12:51 [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC Rafał Miłecki
@ 2019-01-02 15:50 ` Hauke Mehrtens
  2019-01-03  7:42   ` Rafał Miłecki
  2019-01-03  7:34 ` [PATCH V2 " Rafał Miłecki
  2019-01-06 22:32 ` [PATCH " kbuild test robot
  2 siblings, 1 reply; 6+ messages in thread
From: Hauke Mehrtens @ 2019-01-02 15:50 UTC (permalink / raw)
  To: Rafał Miłecki, Paul Burton
  Cc: Ralf Baechle, James Hogan, Christoph Hellwig, Linus Walleij,
	linux-mips, linux-kernel, linux-wireless,
	Rafał Miłecki

On 1/2/19 1:51 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> So far we never had any device registered for the SoC. This resulted in
> some small issues that we kept ignoring like:
> 1) Not working GPIOLIB_IRQCHIP (gpiochip_irqchip_add_key() failing)
> 2) Lack of proper tree in the /sys/devices/
> 3) mips_dma_alloc_coherent() silently handling empty coherent_dma_mask
> 
> Kernel 4.19 came with a lot of DMA changes and caused a regression on
> bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic dma
> noncoherent ops for simple noncoherent platforms") DMA coherent
> allocations just fail. Example:
> [    1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
> [    1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA
> [    1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12
> [    1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded
> 
> The bgmac driver also triggers a WARNING:
> [    0.959486] ------------[ cut here ]------------
> [    0.964387] WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 bgmac_enet_probe+0x1b4/0x5c4
> [    0.973751] Modules linked in:
> [    0.976913] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.9 #0
> [    0.982750] Stack : 804a0000 804597c4 00000000 00000000 80458fd8 8381bc2c 838282d4 80481a47
> [    0.991367]         8042e3ec 00000001 804d38f0 00000204 83980000 00000065 8381bbe0 6f55b24f
> [    0.999975]         00000000 00000000 80520000 00002018 00000000 00000075 00000007 00000000
> [    1.008583]         00000000 80480000 000ee811 00000000 00000000 00000000 80432c00 80248db8
> [    1.017196]         00000009 00000204 83980000 803ad7b0 00000000 801feeec 00000000 804d0000
> [    1.025804]         ...
> [    1.028325] Call Trace:
> [    1.030875] [<8000aef8>] show_stack+0x58/0x100
> [    1.035513] [<8001f8b4>] __warn+0xe4/0x118
> [    1.039708] [<8001f9a4>] warn_slowpath_null+0x48/0x64
> [    1.044935] [<80248db8>] bgmac_enet_probe+0x1b4/0x5c4
> [    1.050101] [<802498e0>] bgmac_probe+0x558/0x590
> [    1.054906] [<80252fd0>] bcma_device_probe+0x38/0x70
> [    1.060017] [<8020e1e8>] really_probe+0x170/0x2e8
> [    1.064891] [<8020e714>] __driver_attach+0xa4/0xec
> [    1.069784] [<8020c1e0>] bus_for_each_dev+0x58/0xb0
> [    1.074833] [<8020d590>] bus_add_driver+0xf8/0x218
> [    1.079731] [<8020ef24>] driver_register+0xcc/0x11c
> [    1.084804] [<804b54cc>] bgmac_init+0x1c/0x44
> [    1.089258] [<8000121c>] do_one_initcall+0x7c/0x1a0
> [    1.094343] [<804a1d34>] kernel_init_freeable+0x150/0x218
> [    1.099886] [<803a082c>] kernel_init+0x10/0x104
> [    1.104583] [<80005878>] ret_from_kernel_thread+0x14/0x1c
> [    1.110107] ---[ end trace f441c0d873d1fb5b ]---
> 
> This patch setups a "struct device" (and passes it to the bcma) which
> allows fixing all the mentioned problems. It'll also require a tiny bcma
> patch which will follow through the wireless tree & its maintainer.
> 
> Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: stable@vger.kernel.org # v4.19+
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

I assume that the old ssb based devices also have such problems did you 
had a look into those?

> ---
>   arch/mips/bcm47xx/setup.c     | 30 ++++++++++++++++++++++++++++++
>   include/linux/bcma/bcma_soc.h |  1 +
>   2 files changed, 31 insertions(+)
> 
> diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
> index 6054d49e608e..9339a31a0a87 100644
> --- a/arch/mips/bcm47xx/setup.c
> +++ b/arch/mips/bcm47xx/setup.c
> @@ -173,6 +173,31 @@ void __init plat_mem_setup(void)
>   	pm_power_off = bcm47xx_machine_halt;
>   }
>   
> +#ifdef CONFIG_BCM47XX_BCMA
> +static struct device * __init bcm47xx_setup_device(void)
> +{
> +	struct device *dev;
> +	int err;
> +
> +	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> +	if (!dev)
> +		return NULL;
> +
> +	err = dev_set_name(dev, "bcm47xx_soc");
> +	if (err) {
> +		pr_err("Failed to set SoC device name: %d\n", err);
> +		kfree(dev);
> +		return NULL;
> +	}
> +
> +	err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
> +	if (err)
> +		pr_err("Failed to set SoC DMA mask: %d\n", err);
> +
> +	return dev;
> +}
> +#endif
> +
>   /*
>    * This finishes bus initialization doing things that were not possible without
>    * kmalloc. Make sure to call it late enough (after mm_init).
> @@ -183,6 +208,10 @@ void __init bcm47xx_bus_setup(void)
>   	if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) {
>   		int err;
>   
> +		bcm47xx_bus.bcma.dev = bcm47xx_setup_device();
> +		if (!bcm47xx_bus.bcma.dev)
> +			panic("Failed to setup SoC device\n");
> +
>   		err = bcma_host_soc_init(&bcm47xx_bus.bcma);
>   		if (err)
>   			panic("Failed to initialize BCMA bus (err %d)", err);
> @@ -235,6 +264,7 @@ static int __init bcm47xx_register_bus_complete(void)
>   #endif
>   #ifdef CONFIG_BCM47XX_BCMA
>   	case BCM47XX_BUS_TYPE_BCMA:
> +		device_register(bcm47xx_bus.bcma.dev);
>   		bcma_bus_register(&bcm47xx_bus.bcma.bus);
>   		break;
>   #endif
> diff --git a/include/linux/bcma/bcma_soc.h b/include/linux/bcma/bcma_soc.h
> index 7cca5f859a90..72a9a5cf962b 100644
> --- a/include/linux/bcma/bcma_soc.h
> +++ b/include/linux/bcma/bcma_soc.h
> @@ -5,6 +5,7 @@
>   #include <linux/bcma/bcma.h>
>   
>   struct bcma_soc {
> +	struct device *dev;
>   	struct bcma_bus bus;

I would add this to the end, the access to the first member should be 
faster.

Hauke

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

* [PATCH V2 mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
  2019-01-02 12:51 [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC Rafał Miłecki
  2019-01-02 15:50 ` Hauke Mehrtens
@ 2019-01-03  7:34 ` Rafał Miłecki
  2019-01-09 22:19   ` Paul Burton
  2019-01-06 22:32 ` [PATCH " kbuild test robot
  2 siblings, 1 reply; 6+ messages in thread
From: Rafał Miłecki @ 2019-01-03  7:34 UTC (permalink / raw)
  To: Paul Burton
  Cc: Ralf Baechle, James Hogan, Christoph Hellwig, Linus Walleij,
	Hauke Mehrtens, linux-mips, linux-kernel, linux-wireless,
	Rafał Miłecki

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

So far we never had any device registered for the SoC. This resulted in
some small issues that we kept ignoring like:
1) Not working GPIOLIB_IRQCHIP (gpiochip_irqchip_add_key() failing)
2) Lack of proper tree in the /sys/devices/
3) mips_dma_alloc_coherent() silently handling empty coherent_dma_mask

Kernel 4.19 came with a lot of DMA changes and caused a regression on
bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic dma
noncoherent ops for simple noncoherent platforms") DMA coherent
allocations just fail. Example:
[    1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
[    1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA
[    1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12
[    1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded

The bgmac driver also triggers a WARNING:
[    0.959486] ------------[ cut here ]------------
[    0.964387] WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 bgmac_enet_probe+0x1b4/0x5c4
[    0.973751] Modules linked in:
[    0.976913] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.9 #0
[    0.982750] Stack : 804a0000 804597c4 00000000 00000000 80458fd8 8381bc2c 838282d4 80481a47
[    0.991367]         8042e3ec 00000001 804d38f0 00000204 83980000 00000065 8381bbe0 6f55b24f
[    0.999975]         00000000 00000000 80520000 00002018 00000000 00000075 00000007 00000000
[    1.008583]         00000000 80480000 000ee811 00000000 00000000 00000000 80432c00 80248db8
[    1.017196]         00000009 00000204 83980000 803ad7b0 00000000 801feeec 00000000 804d0000
[    1.025804]         ...
[    1.028325] Call Trace:
[    1.030875] [<8000aef8>] show_stack+0x58/0x100
[    1.035513] [<8001f8b4>] __warn+0xe4/0x118
[    1.039708] [<8001f9a4>] warn_slowpath_null+0x48/0x64
[    1.044935] [<80248db8>] bgmac_enet_probe+0x1b4/0x5c4
[    1.050101] [<802498e0>] bgmac_probe+0x558/0x590
[    1.054906] [<80252fd0>] bcma_device_probe+0x38/0x70
[    1.060017] [<8020e1e8>] really_probe+0x170/0x2e8
[    1.064891] [<8020e714>] __driver_attach+0xa4/0xec
[    1.069784] [<8020c1e0>] bus_for_each_dev+0x58/0xb0
[    1.074833] [<8020d590>] bus_add_driver+0xf8/0x218
[    1.079731] [<8020ef24>] driver_register+0xcc/0x11c
[    1.084804] [<804b54cc>] bgmac_init+0x1c/0x44
[    1.089258] [<8000121c>] do_one_initcall+0x7c/0x1a0
[    1.094343] [<804a1d34>] kernel_init_freeable+0x150/0x218
[    1.099886] [<803a082c>] kernel_init+0x10/0x104
[    1.104583] [<80005878>] ret_from_kernel_thread+0x14/0x1c
[    1.110107] ---[ end trace f441c0d873d1fb5b ]---

This patch setups a "struct device" (and passes it to the bcma) which
allows fixing all the mentioned problems. It'll also require a tiny bcma
patch which will follow through the wireless tree & its maintainer.

Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-wireless@vger.kernel.org
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
---
V2: Reorder struct bcma_soc fields (trivial optimization - thanks Hauke)
    Add pr_err on error
---
 arch/mips/bcm47xx/setup.c     | 31 +++++++++++++++++++++++++++++++
 include/linux/bcma/bcma_soc.h |  1 +
 2 files changed, 32 insertions(+)

diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 6054d49e608e..fe3773539eff 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -173,6 +173,31 @@ void __init plat_mem_setup(void)
 	pm_power_off = bcm47xx_machine_halt;
 }
 
+#ifdef CONFIG_BCM47XX_BCMA
+static struct device * __init bcm47xx_setup_device(void)
+{
+	struct device *dev;
+	int err;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	err = dev_set_name(dev, "bcm47xx_soc");
+	if (err) {
+		pr_err("Failed to set SoC device name: %d\n", err);
+		kfree(dev);
+		return NULL;
+	}
+
+	err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
+	if (err)
+		pr_err("Failed to set SoC DMA mask: %d\n", err);
+
+	return dev;
+}
+#endif
+
 /*
  * This finishes bus initialization doing things that were not possible without
  * kmalloc. Make sure to call it late enough (after mm_init).
@@ -183,6 +208,10 @@ void __init bcm47xx_bus_setup(void)
 	if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) {
 		int err;
 
+		bcm47xx_bus.bcma.dev = bcm47xx_setup_device();
+		if (!bcm47xx_bus.bcma.dev)
+			panic("Failed to setup SoC device\n");
+
 		err = bcma_host_soc_init(&bcm47xx_bus.bcma);
 		if (err)
 			panic("Failed to initialize BCMA bus (err %d)", err);
@@ -235,6 +264,8 @@ static int __init bcm47xx_register_bus_complete(void)
 #endif
 #ifdef CONFIG_BCM47XX_BCMA
 	case BCM47XX_BUS_TYPE_BCMA:
+		if (device_register(bcm47xx_bus.bcma.dev))
+			pr_err("Failed to register SoC device\n");
 		bcma_bus_register(&bcm47xx_bus.bcma.bus);
 		break;
 #endif
diff --git a/include/linux/bcma/bcma_soc.h b/include/linux/bcma/bcma_soc.h
index 7cca5f859a90..f3c43519baa7 100644
--- a/include/linux/bcma/bcma_soc.h
+++ b/include/linux/bcma/bcma_soc.h
@@ -6,6 +6,7 @@
 
 struct bcma_soc {
 	struct bcma_bus bus;
+	struct device *dev;
 };
 
 int __init bcma_host_soc_register(struct bcma_soc *soc);
-- 
2.20.1


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

* Re: [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
  2019-01-02 15:50 ` Hauke Mehrtens
@ 2019-01-03  7:42   ` Rafał Miłecki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafał Miłecki @ 2019-01-03  7:42 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: Rafał Miłecki, Paul Burton, Ralf Baechle, James Hogan,
	Christoph Hellwig, Linus Walleij, linux-mips, linux-kernel,
	linux-wireless

On 2019-01-02 16:50, Hauke Mehrtens wrote:
> On 1/2/19 1:51 PM, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>> 
>> So far we never had any device registered for the SoC. This resulted 
>> in
>> some small issues that we kept ignoring like:
>> 1) Not working GPIOLIB_IRQCHIP (gpiochip_irqchip_add_key() failing)
>> 2) Lack of proper tree in the /sys/devices/
>> 3) mips_dma_alloc_coherent() silently handling empty coherent_dma_mask
>> 
>> Kernel 4.19 came with a lot of DMA changes and caused a regression on
>> bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic dma
>> noncoherent ops for simple noncoherent platforms") DMA coherent
>> allocations just fail. Example:
>> [    1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
>> [    1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA
>> [    1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12
>> [    1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded
>> 
>> The bgmac driver also triggers a WARNING:
>> [    0.959486] ------------[ cut here ]------------
>> [    0.964387] WARNING: CPU: 0 PID: 1 at 
>> ./include/linux/dma-mapping.h:516 bgmac_enet_probe+0x1b4/0x5c4
>> [    0.973751] Modules linked in:
>> [    0.976913] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.9 #0
>> [    0.982750] Stack : 804a0000 804597c4 00000000 00000000 80458fd8 
>> 8381bc2c 838282d4 80481a47
>> [    0.991367]         8042e3ec 00000001 804d38f0 00000204 83980000 
>> 00000065 8381bbe0 6f55b24f
>> [    0.999975]         00000000 00000000 80520000 00002018 00000000 
>> 00000075 00000007 00000000
>> [    1.008583]         00000000 80480000 000ee811 00000000 00000000 
>> 00000000 80432c00 80248db8
>> [    1.017196]         00000009 00000204 83980000 803ad7b0 00000000 
>> 801feeec 00000000 804d0000
>> [    1.025804]         ...
>> [    1.028325] Call Trace:
>> [    1.030875] [<8000aef8>] show_stack+0x58/0x100
>> [    1.035513] [<8001f8b4>] __warn+0xe4/0x118
>> [    1.039708] [<8001f9a4>] warn_slowpath_null+0x48/0x64
>> [    1.044935] [<80248db8>] bgmac_enet_probe+0x1b4/0x5c4
>> [    1.050101] [<802498e0>] bgmac_probe+0x558/0x590
>> [    1.054906] [<80252fd0>] bcma_device_probe+0x38/0x70
>> [    1.060017] [<8020e1e8>] really_probe+0x170/0x2e8
>> [    1.064891] [<8020e714>] __driver_attach+0xa4/0xec
>> [    1.069784] [<8020c1e0>] bus_for_each_dev+0x58/0xb0
>> [    1.074833] [<8020d590>] bus_add_driver+0xf8/0x218
>> [    1.079731] [<8020ef24>] driver_register+0xcc/0x11c
>> [    1.084804] [<804b54cc>] bgmac_init+0x1c/0x44
>> [    1.089258] [<8000121c>] do_one_initcall+0x7c/0x1a0
>> [    1.094343] [<804a1d34>] kernel_init_freeable+0x150/0x218
>> [    1.099886] [<803a082c>] kernel_init+0x10/0x104
>> [    1.104583] [<80005878>] ret_from_kernel_thread+0x14/0x1c
>> [    1.110107] ---[ end trace f441c0d873d1fb5b ]---
>> 
>> This patch setups a "struct device" (and passes it to the bcma) which
>> allows fixing all the mentioned problems. It'll also require a tiny 
>> bcma
>> patch which will follow through the wireless tree & its maintainer.
>> 
>> Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple 
>> noncoherent platforms")
>> Cc: Christoph Hellwig <hch@lst.de>
>> Cc: stable@vger.kernel.org # v4.19+
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> 
> Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
> 
> I assume that the old ssb based devices also have such problems did
> you had a look into those?

I've ordered some device with ssb based SoC & I'm planning to test it
next week hopefully.

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

* Re: [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
  2019-01-02 12:51 [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC Rafał Miłecki
  2019-01-02 15:50 ` Hauke Mehrtens
  2019-01-03  7:34 ` [PATCH V2 " Rafał Miłecki
@ 2019-01-06 22:32 ` kbuild test robot
  2 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-01-06 22:32 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: kbuild-all, Paul Burton, Ralf Baechle, James Hogan,
	Christoph Hellwig, Linus Walleij, Hauke Mehrtens, linux-mips,
	linux-kernel, linux-wireless, Rafał Miłecki

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

Hi Rafał,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20 next-20190103]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Rafa-Mi-ecki/MIPS-BCM47XX-Setup-struct-device-for-the-SoC/20190102-210611
config: mips-bcm47xx_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   arch/mips/bcm47xx/setup.c: In function 'bcm47xx_register_bus_complete':
>> arch/mips/bcm47xx/setup.c:267:3: error: ignoring return value of 'device_register', declared with attribute warn_unused_result [-Werror=unused-result]
      device_register(bcm47xx_bus.bcma.dev);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors

vim +/device_register +267 arch/mips/bcm47xx/setup.c

   256	
   257	static int __init bcm47xx_register_bus_complete(void)
   258	{
   259		switch (bcm47xx_bus_type) {
   260	#ifdef CONFIG_BCM47XX_SSB
   261		case BCM47XX_BUS_TYPE_SSB:
   262			/* Nothing to do */
   263			break;
   264	#endif
   265	#ifdef CONFIG_BCM47XX_BCMA
   266		case BCM47XX_BUS_TYPE_BCMA:
 > 267			device_register(bcm47xx_bus.bcma.dev);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 16149 bytes --]

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

* Re: [PATCH V2 mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC
  2019-01-03  7:34 ` [PATCH V2 " Rafał Miłecki
@ 2019-01-09 22:19   ` Paul Burton
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Burton @ 2019-01-09 22:19 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Paul Burton, Ralf Baechle, James Hogan, Christoph Hellwig,
	Linus Walleij, Hauke Mehrtens, linux-mips, linux-kernel,
	linux-wireless, Rafał Miłecki, linux-mips

Hello,

Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> So far we never had any device registered for the SoC. This resulted in
> some small issues that we kept ignoring like:
> 1) Not working GPIOLIB_IRQCHIP (gpiochip_irqchip_add_key() failing)
> 2) Lack of proper tree in the /sys/devices/
> 3) mips_dma_alloc_coherent() silently handling empty coherent_dma_mask
> 
> Kernel 4.19 came with a lot of DMA changes and caused a regression on
> bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic dma
> noncoherent ops for simple noncoherent platforms") DMA coherent
> allocations just fail. Example:
> [    1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
> [    1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA
> [    1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12
> [    1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded
> 
> The bgmac driver also triggers a WARNING:
> [    0.959486] ------------[ cut here ]------------
> [    0.964387] WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 bgmac_enet_probe+0x1b4/0x5c4
> [    0.973751] Modules linked in:
> [    0.976913] CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.9 #0
> [    0.982750] Stack : 804a0000 804597c4 00000000 00000000 80458fd8 8381bc2c 838282d4 80481a47
> [    0.991367]         8042e3ec 00000001 804d38f0 00000204 83980000 00000065 8381bbe0 6f55b24f
> [    0.999975]         00000000 00000000 80520000 00002018 00000000 00000075 00000007 00000000
> [    1.008583]         00000000 80480000 000ee811 00000000 00000000 00000000 80432c00 80248db8
> [    1.017196]         00000009 00000204 83980000 803ad7b0 00000000 801feeec 00000000 804d0000
> [    1.025804]         ...
> [    1.028325] Call Trace:
> [    1.030875] [<8000aef8>] show_stack+0x58/0x100
> [    1.035513] [<8001f8b4>] __warn+0xe4/0x118
> [    1.039708] [<8001f9a4>] warn_slowpath_null+0x48/0x64
> [    1.044935] [<80248db8>] bgmac_enet_probe+0x1b4/0x5c4
> [    1.050101] [<802498e0>] bgmac_probe+0x558/0x590
> [    1.054906] [<80252fd0>] bcma_device_probe+0x38/0x70
> [    1.060017] [<8020e1e8>] really_probe+0x170/0x2e8
> [    1.064891] [<8020e714>] __driver_attach+0xa4/0xec
> [    1.069784] [<8020c1e0>] bus_for_each_dev+0x58/0xb0
> [    1.074833] [<8020d590>] bus_add_driver+0xf8/0x218
> [    1.079731] [<8020ef24>] driver_register+0xcc/0x11c
> [    1.084804] [<804b54cc>] bgmac_init+0x1c/0x44
> [    1.089258] [<8000121c>] do_one_initcall+0x7c/0x1a0
> [    1.094343] [<804a1d34>] kernel_init_freeable+0x150/0x218
> [    1.099886] [<803a082c>] kernel_init+0x10/0x104
> [    1.104583] [<80005878>] ret_from_kernel_thread+0x14/0x1c
> [    1.110107] ---[ end trace f441c0d873d1fb5b ]---
> 
> This patch setups a "struct device" (and passes it to the bcma) which
> allows fixing all the mentioned problems. It'll also require a tiny bcma
> patch which will follow through the wireless tree & its maintainer.
> 
> Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-wireless@vger.kernel.org
> Cc: stable@vger.kernel.org # v4.19+
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

Applied to mips-fixes.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

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

end of thread, other threads:[~2019-01-09 22:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 12:51 [PATCH mips-fixes] MIPS: BCM47XX: Setup struct device for the SoC Rafał Miłecki
2019-01-02 15:50 ` Hauke Mehrtens
2019-01-03  7:42   ` Rafał Miłecki
2019-01-03  7:34 ` [PATCH V2 " Rafał Miłecki
2019-01-09 22:19   ` Paul Burton
2019-01-06 22:32 ` [PATCH " kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).