Skip to content

Commit 3d6ce86

Browse files
author
Christoph Hellwig
committed
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>
1 parent 07397df commit 3d6ce86

10 files changed

Lines changed: 17 additions & 19 deletions

File tree

‎drivers/amba/bus.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ struct bus_type amba_bustype = {
204204
.uevent = amba_uevent,
205205
.dma_configure = platform_dma_configure,
206206
.pm = &amba_pm,
207-
.force_dma = true,
208207
};
209208

210209
static int __init amba_init(void)

‎drivers/base/platform.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ int platform_dma_configure(struct device *dev)
11361136
int ret = 0;
11371137

11381138
if (dev->of_node) {
1139-
ret = of_dma_configure(dev, dev->of_node);
1139+
ret = of_dma_configure(dev, dev->of_node, true);
11401140
} else if (has_acpi_companion(dev)) {
11411141
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
11421142
if (attr != DEV_DMA_NOT_SUPPORTED)
@@ -1159,7 +1159,6 @@ struct bus_type platform_bus_type = {
11591159
.uevent = platform_uevent,
11601160
.dma_configure = platform_dma_configure,
11611161
.pm = &platform_dev_pm_ops,
1162-
.force_dma = true,
11631162
};
11641163
EXPORT_SYMBOL_GPL(platform_bus_type);
11651164

‎drivers/bcma/main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent,
207207

208208
core->irq = bcma_of_get_irq(parent, core, 0);
209209

210-
of_dma_configure(&core->dev, node);
210+
of_dma_configure(&core->dev, node, false);
211211
}
212212

213213
unsigned int bcma_core_irq(struct bcma_device *core, int num)

‎drivers/dma/qcom/hidma_mgmt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
398398
}
399399
of_node_get(child);
400400
new_pdev->dev.of_node = child;
401-
of_dma_configure(&new_pdev->dev, child);
401+
of_dma_configure(&new_pdev->dev, child, true);
402402
/*
403403
* It is assumed that calling of_msi_configure is safe on
404404
* platforms with or without MSI support.

‎drivers/gpu/host1x/bus.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
316316

317317
static int host1x_dma_configure(struct device *dev)
318318
{
319-
return of_dma_configure(dev, dev->of_node);
319+
return of_dma_configure(dev, dev->of_node, true);
320320
}
321321

322322
static const struct dev_pm_ops host1x_device_pm_ops = {
@@ -333,7 +333,6 @@ struct bus_type host1x_bus_type = {
333333
.match = host1x_device_match,
334334
.dma_configure = host1x_dma_configure,
335335
.pm = &host1x_device_pm_ops,
336-
.force_dma = true,
337336
};
338337

339338
static void __host1x_device_del(struct host1x_device *device)
@@ -422,7 +421,7 @@ static int host1x_device_add(struct host1x *host1x,
422421
device->dev.bus = &host1x_bus_type;
423422
device->dev.parent = host1x->dev;
424423

425-
of_dma_configure(&device->dev, host1x->dev->of_node);
424+
of_dma_configure(&device->dev, host1x->dev->of_node, true);
426425

427426
err = host1x_device_parse_dt(device, driver);
428427
if (err < 0) {

‎drivers/of/device.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ int of_device_add(struct platform_device *ofdev)
7676
* of_dma_configure - Setup DMA configuration
7777
* @dev: Device to apply DMA configuration
7878
* @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.
7981
*
8082
* Try to get devices's DMA configuration from DT and update it
8183
* accordingly.
@@ -84,7 +86,7 @@ int of_device_add(struct platform_device *ofdev)
8486
* can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events
8587
* to fix up DMA configuration.
8688
*/
87-
int of_dma_configure(struct device *dev, struct device_node *np)
89+
int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
8890
{
8991
u64 dma_addr, paddr, size = 0;
9092
int ret;
@@ -100,7 +102,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
100102
* DMA configuration regardless of whether "dma-ranges" is
101103
* correctly specified or not.
102104
*/
103-
if (!dev->bus->force_dma)
105+
if (!force_dma)
104106
return ret == -ENODEV ? 0 : ret;
105107

106108
dma_addr = offset = 0;

‎drivers/of/of_reserved_mem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
353353
/* ensure that dma_ops is set for virtual devices
354354
* using reserved memory
355355
*/
356-
of_dma_configure(dev, np);
356+
of_dma_configure(dev, np, true);
357357

358358
dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
359359
} else {

‎drivers/pci/pci-driver.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ static int pci_dma_configure(struct device *dev)
15951595

15961596
if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
15971597
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);
15991599
} else if (has_acpi_companion(bridge)) {
16001600
struct acpi_device *adev = to_acpi_device_node(bridge->fwnode);
16011601
enum dev_dma_attr attr = acpi_get_dma_attr(adev);
@@ -1621,7 +1621,6 @@ struct bus_type pci_bus_type = {
16211621
.pm = PCI_PM_OPS_PTR,
16221622
.num_vf = pci_bus_num_vf,
16231623
.dma_configure = pci_dma_configure,
1624-
.force_dma = true,
16251624
};
16261625
EXPORT_SYMBOL(pci_bus_type);
16271626

‎include/linux/device.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
9898
* @p: The private data of the driver core, only the driver core can
9999
* touch this.
100100
* @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.
103101
*
104102
* A bus is a channel between the processor and one or more devices. For the
105103
* purposes of the device model, all devices are connected via a bus, even if
@@ -140,8 +138,6 @@ struct bus_type {
140138

141139
struct subsys_private *p;
142140
struct lock_class_key lock_key;
143-
144-
bool force_dma;
145141
};
146142

147143
extern int __must_check bus_register(struct bus_type *bus);

‎include/linux/of_device.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
5555
return of_node_get(cpu_dev->of_node);
5656
}
5757

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);
5961
void of_dma_deconfigure(struct device *dev);
6062
#else /* CONFIG_OF */
6163

@@ -105,7 +107,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
105107
return NULL;
106108
}
107109

108-
static inline int of_dma_configure(struct device *dev, struct device_node *np)
110+
static inline int of_dma_configure(struct device *dev,
111+
struct device_node *np,
112+
bool force_dma)
109113
{
110114
return 0;
111115
}

0 commit comments

Comments
 (0)