Commit 3d6ce86e authored by Christoph Hellwig's avatar Christoph Hellwig

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: default avatarNipun Gupta <nipun.gupta@nxp.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>  # PCI parts
Reviewed-by: default avatarRob Herring <robh@kernel.org>
[hch: tweaked the changelog a bit]
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 07397df2
...@@ -204,7 +204,6 @@ struct bus_type amba_bustype = { ...@@ -204,7 +204,6 @@ struct bus_type amba_bustype = {
.uevent = amba_uevent, .uevent = amba_uevent,
.dma_configure = platform_dma_configure, .dma_configure = platform_dma_configure,
.pm = &amba_pm, .pm = &amba_pm,
.force_dma = true,
}; };
static int __init amba_init(void) static int __init amba_init(void)
......
...@@ -1136,7 +1136,7 @@ int platform_dma_configure(struct device *dev) ...@@ -1136,7 +1136,7 @@ int platform_dma_configure(struct device *dev)
int ret = 0; int ret = 0;
if (dev->of_node) { 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)) { } else if (has_acpi_companion(dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
if (attr != DEV_DMA_NOT_SUPPORTED) if (attr != DEV_DMA_NOT_SUPPORTED)
...@@ -1159,7 +1159,6 @@ struct bus_type platform_bus_type = { ...@@ -1159,7 +1159,6 @@ struct bus_type platform_bus_type = {
.uevent = platform_uevent, .uevent = platform_uevent,
.dma_configure = platform_dma_configure, .dma_configure = platform_dma_configure,
.pm = &platform_dev_pm_ops, .pm = &platform_dev_pm_ops,
.force_dma = true,
}; };
EXPORT_SYMBOL_GPL(platform_bus_type); EXPORT_SYMBOL_GPL(platform_bus_type);
......
...@@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent, ...@@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent,
core->irq = bcma_of_get_irq(parent, core, 0); 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) unsigned int bcma_core_irq(struct bcma_device *core, int num)
......
...@@ -398,7 +398,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) ...@@ -398,7 +398,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
} }
of_node_get(child); of_node_get(child);
new_pdev->dev.of_node = 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 * It is assumed that calling of_msi_configure is safe on
* platforms with or without MSI support. * platforms with or without MSI support.
......
...@@ -316,7 +316,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) ...@@ -316,7 +316,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
static int host1x_dma_configure(struct device *dev) 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 = { static const struct dev_pm_ops host1x_device_pm_ops = {
...@@ -333,7 +333,6 @@ struct bus_type host1x_bus_type = { ...@@ -333,7 +333,6 @@ struct bus_type host1x_bus_type = {
.match = host1x_device_match, .match = host1x_device_match,
.dma_configure = host1x_dma_configure, .dma_configure = host1x_dma_configure,
.pm = &host1x_device_pm_ops, .pm = &host1x_device_pm_ops,
.force_dma = true,
}; };
static void __host1x_device_del(struct host1x_device *device) static void __host1x_device_del(struct host1x_device *device)
...@@ -422,7 +421,7 @@ static int host1x_device_add(struct host1x *host1x, ...@@ -422,7 +421,7 @@ static int host1x_device_add(struct host1x *host1x,
device->dev.bus = &host1x_bus_type; device->dev.bus = &host1x_bus_type;
device->dev.parent = host1x->dev; 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); err = host1x_device_parse_dt(device, driver);
if (err < 0) { if (err < 0) {
......
...@@ -76,6 +76,8 @@ int of_device_add(struct platform_device *ofdev) ...@@ -76,6 +76,8 @@ int of_device_add(struct platform_device *ofdev)
* of_dma_configure - Setup DMA configuration * of_dma_configure - Setup DMA configuration
* @dev: Device to apply DMA configuration * @dev: Device to apply DMA configuration
* @np: Pointer to OF node having 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 * Try to get devices's DMA configuration from DT and update it
* accordingly. * accordingly.
...@@ -84,7 +86,7 @@ int of_device_add(struct platform_device *ofdev) ...@@ -84,7 +86,7 @@ int of_device_add(struct platform_device *ofdev)
* can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events
* to fix up DMA configuration. * 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; u64 dma_addr, paddr, size = 0;
int ret; int ret;
...@@ -100,7 +102,7 @@ int of_dma_configure(struct device *dev, struct device_node *np) ...@@ -100,7 +102,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
* DMA configuration regardless of whether "dma-ranges" is * DMA configuration regardless of whether "dma-ranges" is
* correctly specified or not. * correctly specified or not.
*/ */
if (!dev->bus->force_dma) if (!force_dma)
return ret == -ENODEV ? 0 : ret; return ret == -ENODEV ? 0 : ret;
dma_addr = offset = 0; dma_addr = offset = 0;
......
...@@ -353,7 +353,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, ...@@ -353,7 +353,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
/* ensure that dma_ops is set for virtual devices /* ensure that dma_ops is set for virtual devices
* using reserved memory * 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); dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
} else { } else {
......
...@@ -1595,7 +1595,7 @@ static int pci_dma_configure(struct device *dev) ...@@ -1595,7 +1595,7 @@ static int pci_dma_configure(struct device *dev)
if (IS_ENABLED(CONFIG_OF) && bridge->parent && if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
bridge->parent->of_node) { 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)) { } else if (has_acpi_companion(bridge)) {
struct acpi_device *adev = to_acpi_device_node(bridge->fwnode); struct acpi_device *adev = to_acpi_device_node(bridge->fwnode);
enum dev_dma_attr attr = acpi_get_dma_attr(adev); enum dev_dma_attr attr = acpi_get_dma_attr(adev);
...@@ -1621,7 +1621,6 @@ struct bus_type pci_bus_type = { ...@@ -1621,7 +1621,6 @@ struct bus_type pci_bus_type = {
.pm = PCI_PM_OPS_PTR, .pm = PCI_PM_OPS_PTR,
.num_vf = pci_bus_num_vf, .num_vf = pci_bus_num_vf,
.dma_configure = pci_dma_configure, .dma_configure = pci_dma_configure,
.force_dma = true,
}; };
EXPORT_SYMBOL(pci_bus_type); EXPORT_SYMBOL(pci_bus_type);
......
...@@ -98,8 +98,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); ...@@ -98,8 +98,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 * @p: The private data of the driver core, only the driver core can
* touch this. * touch this.
* @lock_key: Lock class key for use by the lock validator * @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 * 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 * purposes of the device model, all devices are connected via a bus, even if
...@@ -140,8 +138,6 @@ struct bus_type { ...@@ -140,8 +138,6 @@ struct bus_type {
struct subsys_private *p; struct subsys_private *p;
struct lock_class_key lock_key; struct lock_class_key lock_key;
bool force_dma;
}; };
extern int __must_check bus_register(struct bus_type *bus); extern int __must_check bus_register(struct bus_type *bus);
......
...@@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) ...@@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
return of_node_get(cpu_dev->of_node); 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); void of_dma_deconfigure(struct device *dev);
#else /* CONFIG_OF */ #else /* CONFIG_OF */
...@@ -105,7 +107,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) ...@@ -105,7 +107,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
return NULL; 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment