b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl> |
| 2 | Subject: [PATCH] bcma: get SoC device struct & copy its DMA params to the |
| 3 | subdevices |
| 4 | MIME-Version: 1.0 |
| 5 | Content-Type: text/plain; charset=UTF-8 |
| 6 | Content-Transfer-Encoding: 8bit |
| 7 | |
| 8 | For bus devices to be fully usable it's required to set their DMA |
| 9 | parameters. |
| 10 | |
| 11 | For years it has been missing and remained unnoticed because of |
| 12 | mips_dma_alloc_coherent() silently handling the empty coherent_dma_mask. |
| 13 | Kernel 4.19 came with a lot of DMA changes and caused a regression on |
| 14 | the bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic |
| 15 | dma noncoherent ops for simple noncoherent platforms") DMA coherent |
| 16 | allocations just fail. Example: |
| 17 | [ 1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed |
| 18 | [ 1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA |
| 19 | [ 1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12 |
| 20 | [ 1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded |
| 21 | |
| 22 | This change fixes above regression in addition to the MIPS bcm47xx |
| 23 | commit 321c46b91550 ("MIPS: BCM47XX: Setup struct device for the SoC"). |
| 24 | |
| 25 | It also fixes another *old* GPIO regression caused by a parent pointing |
| 26 | to the NULL: |
| 27 | [ 0.157054] missing gpiochip .dev parent pointer |
| 28 | [ 0.157287] bcma: bus0: Error registering GPIO driver: -22 |
| 29 | introduced by the commit 74f4e0cc6108 ("bcma: switch GPIO portions to |
| 30 | use GPIOLIB_IRQCHIP"). |
| 31 | |
| 32 | Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms") |
| 33 | Fixes: 74f4e0cc6108 ("bcma: switch GPIO portions to use GPIOLIB_IRQCHIP") |
| 34 | Cc: linux-mips@linux-mips.org |
| 35 | Cc: Christoph Hellwig <hch@lst.de> |
| 36 | Cc: Linus Walleij <linus.walleij@linaro.org> |
| 37 | Signed-off-by: Rafał Miłecki <rafal@milecki.pl> |
| 38 | --- |
| 39 | |
| 40 | --- a/drivers/bcma/host_soc.c |
| 41 | +++ b/drivers/bcma/host_soc.c |
| 42 | @@ -191,6 +191,8 @@ int __init bcma_host_soc_init(struct bcm |
| 43 | struct bcma_bus *bus = &soc->bus; |
| 44 | int err; |
| 45 | |
| 46 | + bus->dev = soc->dev; |
| 47 | + |
| 48 | /* Scan bus and initialize it */ |
| 49 | err = bcma_bus_early_register(bus); |
| 50 | if (err) |
| 51 | --- a/drivers/bcma/main.c |
| 52 | +++ b/drivers/bcma/main.c |
| 53 | @@ -241,8 +241,10 @@ void bcma_prepare_core(struct bcma_bus * |
| 54 | core->dev.bus = &bcma_bus_type; |
| 55 | dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); |
| 56 | core->dev.parent = bus->dev; |
| 57 | - if (bus->dev) |
| 58 | + if (bus->dev) { |
| 59 | bcma_of_fill_device(bus->dev, core); |
| 60 | + dma_coerce_mask_and_coherent(&core->dev, bus->dev->coherent_dma_mask); |
| 61 | + } |
| 62 | |
| 63 | switch (bus->hosttype) { |
| 64 | case BCMA_HOSTTYPE_PCI: |