From 90ea8f9afa19363f0bb98e9fd243079159cb4ca4 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 3 May 2018 16:25:08 +0200 Subject: [PATCH 054/211] 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 Acked-by: Bjorn Helgaas # PCI parts Reviewed-by: Rob Herring [hch: tweaked the changelog a bit] Signed-off-by: Christoph Hellwig (cherry picked from commit 3d6ce86ee79465e1b1b6e287f8ea26b553fc768e) [valentine.barshak: changed drivers/pci/endpoint/pci-epc-core.c as well] Signed-off-by: Valentine Barshak --- drivers/amba/bus.c | 1 - drivers/base/platform.c | 3 +-- drivers/bcma/main.c | 2 +- drivers/dma/qcom/hidma_mgmt.c | 2 +- drivers/gpu/host1x/bus.c | 5 ++--- drivers/of/device.c | 6 ++++-- drivers/of/of_reserved_mem.c | 2 +- drivers/pci/endpoint/pci-epc-core.c | 2 +- drivers/pci/pci-driver.c | 3 +-- include/linux/device.h | 4 ---- include/linux/of_device.h | 8 ++++++-- 11 files changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index b1f41f7..3b01187 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -204,7 +204,6 @@ struct bus_type amba_bustype = { .uevent = amba_uevent, .dma_configure = platform_dma_configure, .pm = &amba_pm, - .force_dma = true, }; static int __init amba_init(void) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 5b43ace..55e9456 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1137,7 +1137,7 @@ int platform_dma_configure(struct device *dev) int ret = 0; if (dev->of_node) { - ret = of_dma_configure(dev, dev->of_node); + ret = of_dma_configure(dev, dev->of_node, true); } else if (has_acpi_companion(dev)) { attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); if (attr != DEV_DMA_NOT_SUPPORTED) @@ -1160,7 +1160,6 @@ struct bus_type platform_bus_type = { .uevent = platform_uevent, .dma_configure = platform_dma_configure, .pm = &platform_dev_pm_ops, - .force_dma = true, }; EXPORT_SYMBOL_GPL(platform_bus_type); diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index e6986c7..fc1f4ac 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent, core->irq = bcma_of_get_irq(parent, core, 0); - of_dma_configure(&core->dev, node); + of_dma_configure(&core->dev, node, false); } unsigned int bcma_core_irq(struct bcma_device *core, int num) diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c index 7335e2e..3a0e363 100644 --- a/drivers/dma/qcom/hidma_mgmt.c +++ b/drivers/dma/qcom/hidma_mgmt.c @@ -427,7 +427,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) } of_node_get(child); new_pdev->dev.of_node = child; - of_dma_configure(&new_pdev->dev, child); + of_dma_configure(&new_pdev->dev, child, true); /* * It is assumed that calling of_msi_configure is safe on * platforms with or without MSI support. diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 0c79baf..815bdb4 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -316,7 +316,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) static int host1x_dma_configure(struct device *dev) { - return of_dma_configure(dev, dev->of_node); + return of_dma_configure(dev, dev->of_node, true); } static const struct dev_pm_ops host1x_device_pm_ops = { @@ -333,7 +333,6 @@ struct bus_type host1x_bus_type = { .match = host1x_device_match, .dma_configure = host1x_dma_configure, .pm = &host1x_device_pm_ops, - .force_dma = true, }; static void __host1x_device_del(struct host1x_device *device) @@ -422,7 +421,7 @@ static int host1x_device_add(struct host1x *host1x, device->dev.bus = &host1x_bus_type; device->dev.parent = host1x->dev; - of_dma_configure(&device->dev, host1x->dev->of_node); + of_dma_configure(&device->dev, host1x->dev->of_node, true); err = host1x_device_parse_dt(device, driver); if (err < 0) { diff --git a/drivers/of/device.c b/drivers/of/device.c index 25bddf9..4404903 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -75,6 +75,8 @@ int of_device_add(struct platform_device *ofdev) * of_dma_configure - Setup DMA configuration * @dev: Device to apply DMA configuration * @np: Pointer to OF node having DMA configuration + * @force_dma: Whether device is to be set up by of_dma_configure() even if + * DMA capability is not explicitly described by firmware. * * Try to get devices's DMA configuration from DT and update it * accordingly. @@ -83,7 +85,7 @@ int of_device_add(struct platform_device *ofdev) * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events * to fix up DMA configuration. */ -int of_dma_configure(struct device *dev, struct device_node *np) +int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma) { u64 dma_addr, paddr, size = 0; int ret; @@ -99,7 +101,7 @@ int of_dma_configure(struct device *dev, struct device_node *np) * DMA configuration regardless of whether "dma-ranges" is * correctly specified or not. */ - if (!dev->bus->force_dma) + if (!force_dma) return ret == -ENODEV ? 0 : ret; dma_addr = offset = 0; diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 32771c2..e36c119 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -357,7 +357,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, /* ensure that dma_ops is set for virtual devices * using reserved memory */ - of_dma_configure(dev, np); + of_dma_configure(dev, np, true); dev_info(dev, "assigned reserved memory node %s\n", rmem->name); } else { diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 42c2a11..c09e08c 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -384,7 +384,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) epf->epc = epc; if (dev->of_node) { - of_dma_configure(&epf->dev, dev->of_node); + of_dma_configure(&epf->dev, dev->of_node, true); } else { dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); epf->dev.dma_mask = epc->dev.dma_mask; diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index fddbb24..2d67f5f 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1482,7 +1482,7 @@ static int pci_dma_configure(struct device *dev) if (IS_ENABLED(CONFIG_OF) && bridge->parent && bridge->parent->of_node) { - ret = of_dma_configure(dev, bridge->parent->of_node); + ret = of_dma_configure(dev, bridge->parent->of_node, true); } else if (has_acpi_companion(bridge)) { struct acpi_device *adev = to_acpi_device_node(bridge->fwnode); enum dev_dma_attr attr = acpi_get_dma_attr(adev); @@ -1508,7 +1508,6 @@ struct bus_type pci_bus_type = { .pm = PCI_PM_OPS_PTR, .num_vf = pci_bus_num_vf, .dma_configure = pci_dma_configure, - .force_dma = true, }; EXPORT_SYMBOL(pci_bus_type); diff --git a/include/linux/device.h b/include/linux/device.h index 012c4377..d57443b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -99,8 +99,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); * @p: The private data of the driver core, only the driver core can * touch this. * @lock_key: Lock class key for use by the lock validator - * @force_dma: Assume devices on this bus should be set up by dma_configure() - * even if DMA capability is not explicitly described by firmware. * * A bus is a channel between the processor and one or more devices. For the * purposes of the device model, all devices are connected via a bus, even if @@ -141,8 +139,6 @@ struct bus_type { struct subsys_private *p; struct lock_class_key lock_key; - - bool force_dma; }; extern int __must_check bus_register(struct bus_type *bus); diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 8da5a1b..165fd30 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) return of_node_get(cpu_dev->of_node); } -int of_dma_configure(struct device *dev, struct device_node *np); +int of_dma_configure(struct device *dev, + struct device_node *np, + bool force_dma); void of_dma_deconfigure(struct device *dev); #else /* CONFIG_OF */ @@ -105,7 +107,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) return NULL; } -static inline int of_dma_configure(struct device *dev, struct device_node *np) +static inline int of_dma_configure(struct device *dev, + struct device_node *np, + bool force_dma) { return 0; } -- 2.7.4