Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: remove force dma flag from buses

With each bus implementing its own DMA configuration callback, there is no
need for bus to explicitly set the force_dma flag. Modify the
of_dma_configure function to accept an input parameter which specifies if
implicit DMA configuration is required when it is not described by the
firmware.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # PCI parts
Reviewed-by: Rob Herring <robh@kernel.org>
[hch: tweaked the changelog a bit]
Signed-off-by: Christoph Hellwig <hch@lst.de>

+17 -19
-1
drivers/amba/bus.c
··· 204 204 .uevent = amba_uevent, 205 205 .dma_configure = platform_dma_configure, 206 206 .pm = &amba_pm, 207 - .force_dma = true, 208 207 }; 209 208 210 209 static int __init amba_init(void)
+1 -2
drivers/base/platform.c
··· 1136 1136 int ret = 0; 1137 1137 1138 1138 if (dev->of_node) { 1139 - ret = of_dma_configure(dev, dev->of_node); 1139 + ret = of_dma_configure(dev, dev->of_node, true); 1140 1140 } else if (has_acpi_companion(dev)) { 1141 1141 attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); 1142 1142 if (attr != DEV_DMA_NOT_SUPPORTED) ··· 1159 1159 .uevent = platform_uevent, 1160 1160 .dma_configure = platform_dma_configure, 1161 1161 .pm = &platform_dev_pm_ops, 1162 - .force_dma = true, 1163 1162 }; 1164 1163 EXPORT_SYMBOL_GPL(platform_bus_type); 1165 1164
+1 -1
drivers/bcma/main.c
··· 207 207 208 208 core->irq = bcma_of_get_irq(parent, core, 0); 209 209 210 - of_dma_configure(&core->dev, node); 210 + of_dma_configure(&core->dev, node, false); 211 211 } 212 212 213 213 unsigned int bcma_core_irq(struct bcma_device *core, int num)
+1 -1
drivers/dma/qcom/hidma_mgmt.c
··· 398 398 } 399 399 of_node_get(child); 400 400 new_pdev->dev.of_node = child; 401 - of_dma_configure(&new_pdev->dev, child); 401 + of_dma_configure(&new_pdev->dev, child, true); 402 402 /* 403 403 * It is assumed that calling of_msi_configure is safe on 404 404 * platforms with or without MSI support.
+2 -3
drivers/gpu/host1x/bus.c
··· 316 316 317 317 static int host1x_dma_configure(struct device *dev) 318 318 { 319 - return of_dma_configure(dev, dev->of_node); 319 + return of_dma_configure(dev, dev->of_node, true); 320 320 } 321 321 322 322 static const struct dev_pm_ops host1x_device_pm_ops = { ··· 333 333 .match = host1x_device_match, 334 334 .dma_configure = host1x_dma_configure, 335 335 .pm = &host1x_device_pm_ops, 336 - .force_dma = true, 337 336 }; 338 337 339 338 static void __host1x_device_del(struct host1x_device *device) ··· 421 422 device->dev.bus = &host1x_bus_type; 422 423 device->dev.parent = host1x->dev; 423 424 424 - of_dma_configure(&device->dev, host1x->dev->of_node); 425 + of_dma_configure(&device->dev, host1x->dev->of_node, true); 425 426 426 427 err = host1x_device_parse_dt(device, driver); 427 428 if (err < 0) {
+4 -2
drivers/of/device.c
··· 76 76 * of_dma_configure - Setup DMA configuration 77 77 * @dev: Device to apply DMA configuration 78 78 * @np: Pointer to OF node having DMA configuration 79 + * @force_dma: Whether device is to be set up by of_dma_configure() even if 80 + * DMA capability is not explicitly described by firmware. 79 81 * 80 82 * Try to get devices's DMA configuration from DT and update it 81 83 * accordingly. ··· 86 84 * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events 87 85 * to fix up DMA configuration. 88 86 */ 89 - int of_dma_configure(struct device *dev, struct device_node *np) 87 + int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) 90 88 { 91 89 u64 dma_addr, paddr, size = 0; 92 90 int ret; ··· 102 100 * DMA configuration regardless of whether "dma-ranges" is 103 101 * correctly specified or not. 104 102 */ 105 - if (!dev->bus->force_dma) 103 + if (!force_dma) 106 104 return ret == -ENODEV ? 0 : ret; 107 105 108 106 dma_addr = offset = 0;
+1 -1
drivers/of/of_reserved_mem.c
··· 353 353 /* ensure that dma_ops is set for virtual devices 354 354 * using reserved memory 355 355 */ 356 - of_dma_configure(dev, np); 356 + of_dma_configure(dev, np, true); 357 357 358 358 dev_info(dev, "assigned reserved memory node %s\n", rmem->name); 359 359 } else {
+1 -2
drivers/pci/pci-driver.c
··· 1595 1595 1596 1596 if (IS_ENABLED(CONFIG_OF) && bridge->parent && 1597 1597 bridge->parent->of_node) { 1598 - ret = of_dma_configure(dev, bridge->parent->of_node); 1598 + ret = of_dma_configure(dev, bridge->parent->of_node, true); 1599 1599 } else if (has_acpi_companion(bridge)) { 1600 1600 struct acpi_device *adev = to_acpi_device_node(bridge->fwnode); 1601 1601 enum dev_dma_attr attr = acpi_get_dma_attr(adev); ··· 1621 1621 .pm = PCI_PM_OPS_PTR, 1622 1622 .num_vf = pci_bus_num_vf, 1623 1623 .dma_configure = pci_dma_configure, 1624 - .force_dma = true, 1625 1624 }; 1626 1625 EXPORT_SYMBOL(pci_bus_type); 1627 1626
-4
include/linux/device.h
··· 98 98 * @p: The private data of the driver core, only the driver core can 99 99 * touch this. 100 100 * @lock_key: Lock class key for use by the lock validator 101 - * @force_dma: Assume devices on this bus should be set up by dma_configure() 102 - * even if DMA capability is not explicitly described by firmware. 103 101 * 104 102 * A bus is a channel between the processor and one or more devices. For the 105 103 * purposes of the device model, all devices are connected via a bus, even if ··· 138 140 139 141 struct subsys_private *p; 140 142 struct lock_class_key lock_key; 141 - 142 - bool force_dma; 143 143 }; 144 144 145 145 extern int __must_check bus_register(struct bus_type *bus);
+6 -2
include/linux/of_device.h
··· 55 55 return of_node_get(cpu_dev->of_node); 56 56 } 57 57 58 - int of_dma_configure(struct device *dev, struct device_node *np); 58 + int of_dma_configure(struct device *dev, 59 + struct device_node *np, 60 + bool force_dma); 59 61 void of_dma_deconfigure(struct device *dev); 60 62 #else /* CONFIG_OF */ 61 63 ··· 107 105 return NULL; 108 106 } 109 107 110 - static inline int of_dma_configure(struct device *dev, struct device_node *np) 108 + static inline int of_dma_configure(struct device *dev, 109 + struct device_node *np, 110 + bool force_dma) 111 111 { 112 112 return 0; 113 113 }