Skip to content

Commit

Permalink
drivers: remove force dma flag from buses
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Bjorn Helgaas <[email protected]>  # PCI parts
Reviewed-by: Rob Herring <[email protected]>
[hch: tweaked the changelog a bit]
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 3, 2018
1 parent 07397df commit 3d6ce86
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion drivers/amba/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,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)
Expand All @@ -1159,7 +1159,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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/bcma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/qcom/hidma_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,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.
Expand Down
5 changes: 2 additions & 3 deletions drivers/gpu/host1x/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions drivers/of/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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.
Expand All @@ -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
* 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;
Expand All @@ -100,7 +102,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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/of/of_reserved_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,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 {
Expand Down
3 changes: 1 addition & 2 deletions drivers/pci/pci-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,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);
Expand All @@ -1621,7 +1621,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);

Expand Down
4 changes: 0 additions & 4 deletions include/linux/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
* 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
Expand Down Expand Up @@ -140,8 +138,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);
Expand Down
8 changes: 6 additions & 2 deletions include/linux/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 3d6ce86

Please sign in to comment.