mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bcma: use the SoC device for DMA on MIPS
@ 2026-10-09 21:31 Rosen Penev
  2026-10-13 12:30 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-10-09 21:31 UTC (permalink / raw)
  To: linux-kernel, f.fainelli, Christoph Hellwig, Linus Walleij
  Cc: Rafał Miłecki, Paul Burton,
	open list:BROADCOM SPECIFIC AMBA DRIVER (BCMA)

The MIPS BCM47xx code allocates a struct device for the SoC, sets a
32-bit DMA mask on it and passes it to bcma in struct bcma_soc. bcma
never uses it: bus->dev stays NULL for the MIPS SoC host, so cores fall
back to doing DMA through their own struct device, whose
coherent_dma_mask is 0. Since
commit f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
coherent allocations then fail:

  bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
  bgmac_bcma bcma0:2: Unable to alloc memory for DMA
  bgmac_bcma: probe of bcma0:2 failed with error -12

Set bus->dev from the SoC device and do DMA through it, as the ARM SoC
host already does. Every SoC host now has a bus device, so drop the
fallback that pointed a core's dma_mask at its coherent_dma_mask.

This addresses the review of the earlier postings: the cores' DMA masks
are no longer touched at all.

Tested on an ASUS RT-N16 (BCM4718): bgmac probes and passes traffic.

Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
Link: https://patchwork.kernel.org/project/linux-wireless/patch/20190121101121.24555-1-zajec5@gmail.com/
Link: https://lore.kernel.org/linux-mips/20220107041744.2388470-1-f.fainelli@gmail.com/
Suggested-by: Rafał Miłecki <rafal@milecki.pl>
Assisted-by: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/bcma/host_soc.c | 2 ++
 drivers/bcma/main.c     | 7 +------
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/bcma/host_soc.c b/drivers/bcma/host_soc.c
index 411cfbf53f7b..6150e1588af5 100644
--- a/drivers/bcma/host_soc.c
+++ b/drivers/bcma/host_soc.c
@@ -188,6 +188,8 @@ int __init bcma_host_soc_register(struct bcma_soc *soc)
 
 int __init bcma_host_soc_init(struct bcma_soc *soc)
 {
+	soc->bus.dev = soc->dev;
+
 	return bcma_bus_early_register(&soc->bus);
 }
 
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 72f045e6ed51..3498d5419c19 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -251,12 +251,7 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
 		core->irq = bus->host_pci->irq;
 		break;
 	case BCMA_HOSTTYPE_SOC:
-		if (IS_ENABLED(CONFIG_OF) && bus->dev) {
-			core->dma_dev = bus->dev;
-		} else {
-			core->dev.dma_mask = &core->dev.coherent_dma_mask;
-			core->dma_dev = &core->dev;
-		}
+		core->dma_dev = bus->dev;
 		break;
 	case BCMA_HOSTTYPE_SDIO:
 		break;
-- 
2.56.0


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

* Re: [PATCH] bcma: use the SoC device for DMA on MIPS
  2026-10-09 21:31 [PATCH] bcma: use the SoC device for DMA on MIPS Rosen Penev
@ 2026-10-13 12:30 ` Johannes Berg
  2026-10-13 22:57   ` Rosen Penev
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2026-10-13 12:30 UTC (permalink / raw)
  To: Rosen Penev, linux-kernel, f.fainelli, Christoph Hellwig, Linus Walleij
  Cc: Rafał Miłecki, Paul Burton,
	open list:BROADCOM SPECIFIC AMBA DRIVER (BCMA)

On Fri, 2026-10-09 at 14:31 -0700, Rosen Penev wrote:
> The MIPS BCM47xx code allocates a struct device for the SoC, sets a
> 32-bit DMA mask on it and passes it to bcma in struct bcma_soc. bcma
> never uses it: bus->dev stays NULL for the MIPS SoC host, so cores fall
> back to doing DMA through their own struct device, whose
> coherent_dma_mask is 0. Since
> commit f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> coherent allocations then fail:
> 
>   bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
>   bgmac_bcma bcma0:2: Unable to alloc memory for DMA
>   bgmac_bcma: probe of bcma0:2 failed with error -12
> 
> Set bus->dev from the SoC device and do DMA through it, as the ARM SoC
> host already does. Every SoC host now has a bus device, so drop the
> fallback that pointed a core's dma_mask at its coherent_dma_mask.
> 
> This addresses the review of the earlier postings: the cores' DMA masks
> are no longer touched at all.
> 
> Tested on an ASUS RT-N16 (BCM4718): bgmac probes and passes traffic.
> 
> Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> 

That was in a MIPS tree, so perhaps this fix should be too? I don't
really know what to do with it.

johannes

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

* Re: [PATCH] bcma: use the SoC device for DMA on MIPS
  2026-10-13 12:30 ` Johannes Berg
@ 2026-10-13 22:57   ` Rosen Penev
  0 siblings, 0 replies; 3+ messages in thread
From: Rosen Penev @ 2026-10-13 22:57 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-kernel, f.fainelli, Christoph Hellwig, Linus Walleij,
	Rafał Miłecki, Paul Burton,
	open list:BROADCOM SPECIFIC AMBA DRIVER (BCMA)

On Tue, Oct 13, 2026 at 5:30 AM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> On Fri, 2026-10-09 at 14:31 -0700, Rosen Penev wrote:
> > The MIPS BCM47xx code allocates a struct device for the SoC, sets a
> > 32-bit DMA mask on it and passes it to bcma in struct bcma_soc. bcma
> > never uses it: bus->dev stays NULL for the MIPS SoC host, so cores fall
> > back to doing DMA through their own struct device, whose
> > coherent_dma_mask is 0. Since
> > commit f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> > coherent allocations then fail:
> >
> >   bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed
> >   bgmac_bcma bcma0:2: Unable to alloc memory for DMA
> >   bgmac_bcma: probe of bcma0:2 failed with error -12
> >
> > Set bus->dev from the SoC device and do DMA through it, as the ARM SoC
> > host already does. Every SoC host now has a bus device, so drop the
> > fallback that pointed a core's dma_mask at its coherent_dma_mask.
> >
> > This addresses the review of the earlier postings: the cores' DMA masks
> > are no longer touched at all.
> >
> > Tested on an ASUS RT-N16 (BCM4718): bgmac probes and passes traffic.
> >
> > Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms")
> >
>
> That was in a MIPS tree, so perhaps this fix should be too? I don't
> really know what to do with it.
I thought it was weird as well. The last submission was sent to
wireless-next as well. FWIW I ran get_maintainers.pl
>
> johannes

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

end of thread, other threads:[~2026-10-13 22:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09 21:31 [PATCH] bcma: use the SoC device for DMA on MIPS Rosen Penev
2026-10-13 12:30 ` Johannes Berg
2026-10-13 22:57   ` Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®