800-bcma-get-SoC-device-struct-copy-its-DMA-params-to-th.patch 2.7 KB

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