All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-22  8:19 ` Christoph Hellwig
  (?)
  (?)
@ 2018-03-22 15:13 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-22 15:13 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: robin.murphy, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@lst.de]
> Sent: Thursday, March 22, 2018 13:49
> To: Nipun Gupta <nipun.gupta@nxp.com>
> 
> > --- a/drivers/dma/qcom/hidma_mgmt.c
> > +++ b/drivers/dma/qcom/hidma_mgmt.c
> > @@ -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.
> 
> Where did we mark this bus as force_dma before?

I thought these devices to be on the platform bus as the device is of type
'struct platform_device', though I am not sure then why 'of_dma_configure()'
is called here. Is this not on platform bus?

> 
> > diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> > index 9a4f4246..895c83e 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -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);
> 
> Did all the callers of this one really force dma?  I have a hard time
> untangling the call stacks unfortunately.

I see this API being called indirectly from NXP DPAA device driver which
is for platform bus devices. So I marked 'true' out here. There are more places
from where it is being called.

Thanks,
Nipun
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,2/2] drivers: remove force dma flag from buses
  2018-04-28  2:51 ` Nipun Gupta
  (?)
@ 2018-05-03 16:36 ` Vinod Koul
  -1 siblings, 0 replies; 141+ messages in thread
From: Vinod Koul @ 2018-05-03 16:36 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, thierry.reding, robh+dt,
	frowand.list, jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov,
	johan, msuchanek, linux-kernel, iommu, linux-wireless,
	linux-arm-msm, linux-soc, dmaengine, dri-devel, linux-tegra,
	devicetree, linux-pci, bharat.bhushan, leoyang.li

On Sat, Apr 28, 2018 at 08:21:59AM +0530, Nipun Gupta wrote:
> With each bus implementing its own DMA configuration callback,
> there is no need for bus to explicitly have force_dma in its
> global structure. This patch modifies of_dma_configure API to
> accept an input parameter which specifies if implicit DMA
> configuration is required even 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
> ---
> Changes in v2:
>   - This is a new change suggested by Robin and Christoph
>     and is added to the series.
> 
> Changes in v3:
>   - Rebase and changes corresponding to the changes in patch 1/2
> 
> Changes in v4:
>   - Rebased on top of 4.17-rc2
> 
>  drivers/amba/bus.c            | 1 -
>  drivers/base/platform.c       | 3 +--
>  drivers/bcma/main.c           | 2 +-
>  drivers/dma/qcom/hidma_mgmt.c | 2 +-

This one:
Acked-by: Vinod Koul <vkoul@kernel.org>

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-04-30 10:41 ` Thierry Reding
  (?)
@ 2018-05-03 12:21 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-05-03 12:21 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Nipun Gupta, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

On Mon, Apr 30, 2018 at 12:41:24PM +0200, Thierry Reding wrote:
> On Sat, Apr 28, 2018 at 08:21:58AM +0530, Nipun Gupta wrote:
> [...]
> > diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> > index 88a3558..a9ec99d 100644
> > --- a/drivers/gpu/host1x/bus.c
> > +++ b/drivers/gpu/host1x/bus.c
> > @@ -314,6 +314,13 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
> >  	return strcmp(dev_name(dev), drv->name) == 0;
> >  }
> >  
> > +static int host1x_dma_configure(struct device *dev)
> > +{
> > +	if (dev->of_node)
> > +		return of_dma_configure(dev, dev->of_node);
> 
> The conditional here is somewhat pointless since the of_node should
> always be set. If it weren't it should be considered a bug and this
> function welcome to crash to make that very obvious.

Agreed.  Please remove the check for the resend.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-04-28  2:51 ` Nipun Gupta
  (?)
@ 2018-05-03 12:21 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-05-03 12:21 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

This still fails to apply against either 4.17-rc3 or current Linus
master for me.  Please resend against it, and mention the tree it
is against.

Also please resend it in a separate email thread (all your patches
were replies to the previous ones) and include a cover letter.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,2/2] drivers: remove force dma flag from buses
  2018-04-28  2:51 ` Nipun Gupta
  (?)
@ 2018-05-01 12:34 ` Rob Herring
  -1 siblings, 0 replies; 141+ messages in thread
From: Rob Herring @ 2018-05-01 12:34 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, frowand.list, jarkko.sakkinen, rafael.j.wysocki,
	dmitry.torokhov, johan, msuchanek, linux-kernel, iommu,
	linux-wireless, linux-arm-msm, linux-soc, dmaengine, dri-devel,
	linux-tegra, devicetree, linux-pci, bharat.bhushan, leoyang.li

On Sat, Apr 28, 2018 at 08:21:59AM +0530, Nipun Gupta wrote:
> With each bus implementing its own DMA configuration callback,
> there is no need for bus to explicitly have force_dma in its
> global structure. This patch modifies of_dma_configure API to
> accept an input parameter which specifies if implicit DMA
> configuration is required even 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
> ---
> Changes in v2:
>   - This is a new change suggested by Robin and Christoph
>     and is added to the series.
> 
> Changes in v3:
>   - Rebase and changes corresponding to the changes in patch 1/2
> 
> Changes in v4:
>   - Rebased on top of 4.17-rc2
> 
>  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/pci-driver.c      | 3 +--
>  include/linux/device.h        | 4 ----
>  include/linux/of_device.h     | 8 ++++++--
>  10 files changed, 17 insertions(+), 19 deletions(-)

Reviewed-by: Rob Herring <robh@kernel.org>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-04-28  2:51 ` Nipun Gupta
  (?)
@ 2018-04-30 10:41 ` Thierry Reding
  -1 siblings, 0 replies; 141+ messages in thread
From: Thierry Reding @ 2018-04-30 10:41 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul, robh+dt,
	frowand.list, jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov,
	johan, msuchanek, linux-kernel, iommu, linux-wireless,
	linux-arm-msm, linux-soc, dmaengine, dri-devel, linux-tegra,
	devicetree, linux-pci, bharat.bhushan, leoyang.li

On Sat, Apr 28, 2018 at 08:21:58AM +0530, Nipun Gupta wrote:
[...]
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 88a3558..a9ec99d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,13 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  	return strcmp(dev_name(dev), drv->name) == 0;
>  }
>  
> +static int host1x_dma_configure(struct device *dev)
> +{
> +	if (dev->of_node)
> +		return of_dma_configure(dev, dev->of_node);

The conditional here is somewhat pointless since the of_node should
always be set. If it weren't it should be considered a bug and this
function welcome to crash to make that very obvious.

Either way:

Acked-by: Thierry Reding <treding@nvidia.com>

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v4,2/2] drivers: remove force dma flag from buses
  2018-04-28  2:51 ` Nipun Gupta
  (?)
@ 2018-04-28  2:51 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-04-28  2:51 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

With each bus implementing its own DMA configuration callback,
there is no need for bus to explicitly have force_dma in its
global structure. This patch modifies of_dma_configure API to
accept an input parameter which specifies if implicit DMA
configuration is required even 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
---
Changes in v2:
  - This is a new change suggested by Robin and Christoph
    and is added to the series.

Changes in v3:
  - Rebase and changes corresponding to the changes in patch 1/2

Changes in v4:
  - Rebased on top of 4.17-rc2

 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/pci-driver.c      | 3 +--
 include/linux/device.h        | 4 ----
 include/linux/of_device.h     | 8 ++++++--
 10 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 867dc2b..abe73c4 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -199,7 +199,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 638d42e..c0ff1e7 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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)
@@ -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);
 
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 000c7019..d64edeb 100644
--- a/drivers/dma/qcom/hidma_mgmt.c
+++ b/drivers/dma/qcom/hidma_mgmt.c
@@ -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.
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index a9ec99d..b39c1e9 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -317,7 +317,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 static int host1x_dma_configure(struct device *dev)
 {
 	if (dev->of_node)
-		return of_dma_configure(dev, dev->of_node);
+		return of_dma_configure(dev, dev->of_node, true);
 	return 0;
 }
 
@@ -335,7 +335,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)
@@ -424,7 +423,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 064c818..33d8551 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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.
@@ -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;
@@ -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;
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 9a4f4246..895c83e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -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 {
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ba8c6b4..f8269a7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -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);
@@ -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);
 
diff --git a/include/linux/device.h b/include/linux/device.h
index 607c7eb..31dcb29 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -98,8 +98,6 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @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
@@ -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);
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;
 }

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [v4,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-12 15:24 ` Nipun Gupta
  (?)
@ 2018-04-28  2:51 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-04-28  2:51 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

It is bus specific aspect to map a given device on the bus and
relevant firmware description of its DMA configuration.
So, this change introduces 'dma_configure' as bus callback
giving flexibility to busses for implementing its own dma
configuration function.

The change eases the addition of new busses w.r.t. adding the dma
configuration functionality.

This patch also updates the PCI, Platform, ACPI and host1x bus to
use new introduced callbacks.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>  # PCI parts
---
 - The patches are based on the comments on:
   https://patchwork.kernel.org/patch/10259087/

Changes in v2:
  - Do not have dma_deconfigure callback
  - Have '/dma_common_configure/' API to provide a common DMA
    configuration which can be used by busses if it suits them.
  - Platform and ACPI bus to use '/dma_common_configure/' in
    '/dma_configure/' callback.
  - Updated commit message
  - Updated pci_dma_configure API with changes suggested by Robin

Changes in v3:
  - Move dma_common_configure() within platform_dma_configure() and
    reuse platofrm_dma_configure() for AMBA bus too
  - Declare 'attr' in pci_dma_configure() inside the else statement
    where it is used.

Changes in v4:
  - Rebased on top of 4.17-rc2

 drivers/amba/bus.c              |  4 ++++
 drivers/base/dma-mapping.c      | 31 ++++---------------------------
 drivers/base/platform.c         | 17 +++++++++++++++++
 drivers/gpu/host1x/bus.c        |  8 ++++++++
 drivers/pci/pci-driver.c        | 32 ++++++++++++++++++++++++++++++++
 include/linux/device.h          |  4 ++++
 include/linux/platform_device.h |  2 ++
 7 files changed, 71 insertions(+), 27 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 594c228..867dc2b 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -20,6 +20,7 @@
 #include <linux/sizes.h>
 #include <linux/limits.h>
 #include <linux/clk/clk-conf.h>
+#include <linux/platform_device.h>
 
 #include <asm/irq.h>
 
@@ -188,12 +189,15 @@ static int amba_pm_runtime_resume(struct device *dev)
 /*
  * Primecells are part of the Advanced Microcontroller Bus Architecture,
  * so we call the bus "amba".
+ * DMA configuration for platform and AMBA bus is same. So here we reuse
+ * platform's DMA config routine.
  */
 struct bus_type amba_bustype = {
 	.name		= "amba",
 	.dev_groups	= amba_dev_groups,
 	.match		= amba_match,
 	.uevent		= amba_uevent,
+	.dma_configure	= platform_dma_configure,
 	.pm		= &amba_pm,
 	.force_dma	= true,
 };
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index d82566d..f831a58 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -329,36 +329,13 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
 #endif
 
 /*
- * Common configuration to enable DMA API use for a device
+ * enables DMA API use for a device
  */
-#include <linux/pci.h>
-
 int dma_configure(struct device *dev)
 {
-	struct device *bridge = NULL, *dma_dev = dev;
-	enum dev_dma_attr attr;
-	int ret = 0;
-
-	if (dev_is_pci(dev)) {
-		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
-		dma_dev = bridge;
-		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
-		    dma_dev->parent->of_node)
-			dma_dev = dma_dev->parent;
-	}
-
-	if (dma_dev->of_node) {
-		ret = of_dma_configure(dev, dma_dev->of_node);
-	} else if (has_acpi_companion(dma_dev)) {
-		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
-		if (attr != DEV_DMA_NOT_SUPPORTED)
-			ret = acpi_dma_configure(dev, attr);
-	}
-
-	if (bridge)
-		pci_put_host_bridge_device(bridge);
-
-	return ret;
+	if (dev->bus->dma_configure)
+		return dev->bus->dma_configure(dev);
+	return 0;
 }
 
 void dma_deconfigure(struct device *dev)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8075ddc..638d42e 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1130,6 +1130,22 @@ int platform_pm_restore(struct device *dev)
 
 #endif /* CONFIG_HIBERNATE_CALLBACKS */
 
+int platform_dma_configure(struct device *dev)
+{
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	if (dev->of_node) {
+		ret = of_dma_configure(dev, dev->of_node);
+	} else if (has_acpi_companion(dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	return ret;
+}
+
 static const struct dev_pm_ops platform_dev_pm_ops = {
 	.runtime_suspend = pm_generic_runtime_suspend,
 	.runtime_resume = pm_generic_runtime_resume,
@@ -1141,6 +1157,7 @@ struct bus_type platform_bus_type = {
 	.dev_groups	= platform_dev_groups,
 	.match		= platform_match,
 	.uevent		= platform_uevent,
+	.dma_configure	= platform_dma_configure,
 	.pm		= &platform_dev_pm_ops,
 	.force_dma	= true,
 };
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 88a3558..a9ec99d 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -314,6 +314,13 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 	return strcmp(dev_name(dev), drv->name) == 0;
 }
 
+static int host1x_dma_configure(struct device *dev)
+{
+	if (dev->of_node)
+		return of_dma_configure(dev, dev->of_node);
+	return 0;
+}
+
 static const struct dev_pm_ops host1x_device_pm_ops = {
 	.suspend = pm_generic_suspend,
 	.resume = pm_generic_resume,
@@ -326,6 +333,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 struct bus_type host1x_bus_type = {
 	.name = "host1x",
 	.match = host1x_device_match,
+	.dma_configure	= host1x_dma_configure,
 	.pm = &host1x_device_pm_ops,
 	.force_dma = true,
 };
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b9a1311..ba8c6b4 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -16,6 +16,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
 #include <linux/kexec.h>
+#include <linux/of_device.h>
+#include <linux/acpi.h>
 #include "pci.h"
 #include "pcie/portdrv.h"
 
@@ -1577,6 +1579,35 @@ static int pci_bus_num_vf(struct device *dev)
 	return pci_num_vf(to_pci_dev(dev));
 }
 
+/**
+ * pci_dma_configure - Setup DMA configuration
+ * @dev: ptr to dev structure
+ *
+ * Function to update PCI devices's DMA configuration using the same
+ * info from the OF node or ACPI node of host bridge's parent (if any).
+ */
+static int pci_dma_configure(struct device *dev)
+{
+	struct device *bridge;
+	int ret = 0;
+
+	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
+
+	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
+	    bridge->parent->of_node) {
+		ret = of_dma_configure(dev, bridge->parent->of_node);
+	} 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);
+
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	pci_put_host_bridge_device(bridge);
+	return ret;
+}
+
 struct bus_type pci_bus_type = {
 	.name		= "pci",
 	.match		= pci_bus_match,
@@ -1589,6 +1620,7 @@ struct bus_type pci_bus_type = {
 	.drv_groups	= pci_drv_groups,
 	.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 0059b99..607c7eb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @resume:	Called to bring a device on this bus out of sleep mode.
  * @num_vf:	Called to find out how many virtual functions a device on this
  *		bus supports.
+ * @dma_configure:	Called to setup DMA configuration on a device on
+			this bus.
  * @pm:		Power management operations of this bus, callback the specific
  *		device driver's pm-ops.
  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
@@ -130,6 +132,8 @@ struct bus_type {
 
 	int (*num_vf)(struct device *dev);
 
+	int (*dma_configure)(struct device *dev);
+
 	const struct dev_pm_ops *pm;
 
 	const struct iommu_ops *iommu_ops;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 49f634d..3097c94 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -356,6 +356,8 @@ static inline char *early_platform_driver_setup_func(void)		\
 #define platform_pm_restore		NULL
 #endif
 
+extern int platform_dma_configure(struct device *dev);
+
 #ifdef CONFIG_PM_SLEEP
 #define USE_PLATFORM_PM_SLEEP_OPS \
 	.suspend = platform_pm_suspend, \

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [v3,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-04-23 12:56 ` Christoph Hellwig
  (?)
  (?)
@ 2018-04-27 17:10 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-04-27 17:10 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: robin.murphy, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@lst.de]
> Sent: Monday, April 23, 2018 6:27 PM
> To: Nipun Gupta <nipun.gupta@nxp.com>
> Cc: robin.murphy@arm.com; hch@lst.de; linux@armlinux.org.uk;
> gregkh@linuxfoundation.org; m.szyprowski@samsung.com;
> bhelgaas@google.com; zajec5@gmail.com; andy.gross@linaro.org;
> david.brown@linaro.org; dan.j.williams@intel.com; vinod.koul@intel.com;
> thierry.reding@gmail.com; robh+dt@kernel.org; frowand.list@gmail.com;
> jarkko.sakkinen@linux.intel.com; rafael.j.wysocki@intel.com;
> dmitry.torokhov@gmail.com; johan@kernel.org; msuchanek@suse.de; linux-
> kernel@vger.kernel.org; iommu@lists.linux-foundation.org; linux-
> wireless@vger.kernel.org; linux-arm-msm@vger.kernel.org; linux-
> soc@vger.kernel.org; dmaengine@vger.kernel.org; dri-
> devel@lists.freedesktop.org; linux-tegra@vger.kernel.org;
> devicetree@vger.kernel.org; linux-pci@vger.kernel.org; Bharat Bhushan
> <bharat.bhushan@nxp.com>; Leo Li <leoyang.li@nxp.com>
> Subject: Re: [PATCH v3 1/2] dma-mapping: move dma configuration to bus
> infrastructure
> 
> Can you resend your changes against Linux 4.17-rc2?  There are a lot
> of conflicts as-is.

Sure.. I will send it soon..

Regards,
Nipun
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-04-10 19:20 ` Bjorn Helgaas
  (?)
@ 2018-04-23 12:56 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-04-23 12:56 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Nipun Gupta, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li

On Tue, Apr 10, 2018 at 02:20:41PM -0500, Bjorn Helgaas wrote:
> I assume you'll merge this via some non-PCI tree.  Let me know if you
> need anything else from me.

I'll take it through the dma-mapping tree, so you should be fine.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-30  7:54 ` Nipun Gupta
  (?)
@ 2018-04-23 12:56 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-04-23 12:56 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

Can you resend your changes against Linux 4.17-rc2?  There are a lot
of conflicts as-is.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,2/2] drivers: remove force dma flag from buses
  2018-03-30  7:54 ` Nipun Gupta
  (?)
@ 2018-04-10 19:21 ` Bjorn Helgaas
  -1 siblings, 0 replies; 141+ messages in thread
From: Bjorn Helgaas @ 2018-04-10 19:21 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

On Fri, Mar 30, 2018 at 01:24:45PM +0530, Nipun Gupta wrote:
> With each bus implementing its own DMA configuration callback,
> there is no need for bus to explicitly have force_dma in its
> global structure. This patch modifies of_dma_configure API to
> accept an input parameter which specifies if implicit DMA
> configuration is required even 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

> ---
> Changes in v2:
>   - This is a new change suggested by Robin and Christoph
>     and is added to the series.
> 
> Changes in v3:
>   - Rebase and changes corresponding to the changes in patch 1/2
> 
>  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/pci-driver.c      | 3 +--
>  include/linux/device.h        | 4 ----
>  include/linux/of_device.h     | 8 ++++++--
>  10 files changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 867dc2b..abe73c4 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -199,7 +199,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 72fdbf6..cfbc569 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -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)
> @@ -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);
>  
> 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 000c7019..d64edeb 100644
> --- a/drivers/dma/qcom/hidma_mgmt.c
> +++ b/drivers/dma/qcom/hidma_mgmt.c
> @@ -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.
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index a9ec99d..b39c1e9 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -317,7 +317,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  static int host1x_dma_configure(struct device *dev)
>  {
>  	if (dev->of_node)
> -		return of_dma_configure(dev, dev->of_node);
> +		return of_dma_configure(dev, dev->of_node, true);
>  	return 0;
>  }
>  
> @@ -335,7 +335,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)
> @@ -424,7 +423,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 064c818..33d8551 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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.
> @@ -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;
> @@ -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;
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 9a4f4246..895c83e 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -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 {
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 78e507f..27c832f 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -1540,7 +1540,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);
> @@ -1566,7 +1566,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 1832d90..92c530e 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -98,8 +98,6 @@ extern int __must_check bus_create_file(struct bus_type *,
>   * @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
> @@ -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);
> 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;
>  }
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-30  7:54 ` Nipun Gupta
  (?)
@ 2018-04-10 19:20 ` Bjorn Helgaas
  -1 siblings, 0 replies; 141+ messages in thread
From: Bjorn Helgaas @ 2018-04-10 19:20 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

On Fri, Mar 30, 2018 at 01:24:44PM +0530, Nipun Gupta wrote:
> It is bus specific aspect to map a given device on the bus and
> relevant firmware description of its DMA configuration.
> So, this change introduces 'dma_configure' as bus callback
> giving flexibility to busses for implementing its own dma
> configuration function.
> 
> The change eases the addition of new busses w.r.t. adding the dma
> configuration functionality.
> 
> This patch also updates the PCI, Platform, ACPI and host1x bus to
> use new introduced callbacks.

s/dma/DMA/ consistently above.

> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>  # PCI parts

I assume you'll merge this via some non-PCI tree.  Let me know if you
need anything else from me.

> ---
>  - The patches are based on the comments on:
>    https://patchwork.kernel.org/patch/10259087/
> 
> Changes in v2:
>   - Do not have dma_deconfigure callback
>   - Have '/dma_common_configure/' API to provide a common DMA
>     configuration which can be used by busses if it suits them.
>   - Platform and ACPI bus to use '/dma_common_configure/' in
>     '/dma_configure/' callback.
>   - Updated commit message
>   - Updated pci_dma_configure API with changes suggested by Robin
> 
> Changes in v3
>   - Move dma_common_configure() within platform_dma_configure() and
>     reuse platofrm_dma_configure() for AMBA bus too
>   - Declare 'attr' in pci_dma_configure() inside the else statement
>     where it is used.
> 
>  drivers/amba/bus.c              |  4 ++++
>  drivers/base/dma-mapping.c      | 31 ++++---------------------------
>  drivers/base/platform.c         | 17 +++++++++++++++++
>  drivers/gpu/host1x/bus.c        |  8 ++++++++
>  drivers/pci/pci-driver.c        | 32 ++++++++++++++++++++++++++++++++
>  include/linux/device.h          |  4 ++++
>  include/linux/platform_device.h |  2 ++
>  7 files changed, 71 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 594c228..867dc2b 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -20,6 +20,7 @@
>  #include <linux/sizes.h>
>  #include <linux/limits.h>
>  #include <linux/clk/clk-conf.h>
> +#include <linux/platform_device.h>
>  
>  #include <asm/irq.h>
>  
> @@ -188,12 +189,15 @@ static int amba_pm_runtime_resume(struct device *dev)
>  /*
>   * Primecells are part of the Advanced Microcontroller Bus Architecture,
>   * so we call the bus "amba".
> + * DMA configuration for platform and AMBA bus is same. So here we reuse
> + * platform's DMA config routine.
>   */
>  struct bus_type amba_bustype = {
>  	.name		= "amba",
>  	.dev_groups	= amba_dev_groups,
>  	.match		= amba_match,
>  	.uevent		= amba_uevent,
> +	.dma_configure	= platform_dma_configure,
>  	.pm		= &amba_pm,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index 3b11835..fdc1502 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -331,36 +331,13 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
>  #endif
>  
>  /*
> - * Common configuration to enable DMA API use for a device
> + * enables DMA API use for a device
>   */
> -#include <linux/pci.h>
> -
>  int dma_configure(struct device *dev)
>  {
> -	struct device *bridge = NULL, *dma_dev = dev;
> -	enum dev_dma_attr attr;
> -	int ret = 0;
> -
> -	if (dev_is_pci(dev)) {
> -		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> -		dma_dev = bridge;
> -		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
> -		    dma_dev->parent->of_node)
> -			dma_dev = dma_dev->parent;
> -	}
> -
> -	if (dma_dev->of_node) {
> -		ret = of_dma_configure(dev, dma_dev->of_node);
> -	} else if (has_acpi_companion(dma_dev)) {
> -		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
> -		if (attr != DEV_DMA_NOT_SUPPORTED)
> -			ret = acpi_dma_configure(dev, attr);
> -	}
> -
> -	if (bridge)
> -		pci_put_host_bridge_device(bridge);
> -
> -	return ret;
> +	if (dev->bus->dma_configure)
> +		return dev->bus->dma_configure(dev);
> +	return 0;
>  }
>  
>  void dma_deconfigure(struct device *dev)
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index f1bf7b3..72fdbf6 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -1130,6 +1130,22 @@ int platform_pm_restore(struct device *dev)
>  
>  #endif /* CONFIG_HIBERNATE_CALLBACKS */
>  
> +int platform_dma_configure(struct device *dev)
> +{
> +	enum dev_dma_attr attr;
> +	int ret = 0;
> +
> +	if (dev->of_node) {
> +		ret = of_dma_configure(dev, dev->of_node);
> +	} else if (has_acpi_companion(dev)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			ret = acpi_dma_configure(dev, attr);
> +	}
> +
> +	return ret;
> +}
> +
>  static const struct dev_pm_ops platform_dev_pm_ops = {
>  	.runtime_suspend = pm_generic_runtime_suspend,
>  	.runtime_resume = pm_generic_runtime_resume,
> @@ -1141,6 +1157,7 @@ struct bus_type platform_bus_type = {
>  	.dev_groups	= platform_dev_groups,
>  	.match		= platform_match,
>  	.uevent		= platform_uevent,
> +	.dma_configure	= platform_dma_configure,
>  	.pm		= &platform_dev_pm_ops,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 88a3558..a9ec99d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,13 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  	return strcmp(dev_name(dev), drv->name) == 0;
>  }
>  
> +static int host1x_dma_configure(struct device *dev)
> +{
> +	if (dev->of_node)
> +		return of_dma_configure(dev, dev->of_node);
> +	return 0;
> +}
> +
>  static const struct dev_pm_ops host1x_device_pm_ops = {
>  	.suspend = pm_generic_suspend,
>  	.resume = pm_generic_resume,
> @@ -326,6 +333,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  struct bus_type host1x_bus_type = {
>  	.name = "host1x",
>  	.match = host1x_device_match,
> +	.dma_configure	= host1x_dma_configure,
>  	.pm = &host1x_device_pm_ops,
>  	.force_dma = true,
>  };
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 3bed6be..78e507f 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -18,6 +18,8 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/suspend.h>
>  #include <linux/kexec.h>
> +#include <linux/of_device.h>
> +#include <linux/acpi.h>
>  #include "pci.h"
>  
>  struct pci_dynid {
> @@ -1522,6 +1524,35 @@ static int pci_bus_num_vf(struct device *dev)
>  	return pci_num_vf(to_pci_dev(dev));
>  }
>  
> +/**
> + * pci_dma_configure - Setup DMA configuration
> + * @dev: ptr to dev structure
> + *
> + * Function to update PCI devices's DMA configuration using the same
> + * info from the OF node or ACPI node of host bridge's parent (if any).
> + */
> +static int pci_dma_configure(struct device *dev)
> +{
> +	struct device *bridge;
> +	int ret = 0;
> +
> +	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> +
> +	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
> +	    bridge->parent->of_node) {
> +		ret = of_dma_configure(dev, bridge->parent->of_node);
> +	} 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);
> +
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			ret = acpi_dma_configure(dev, attr);
> +	}
> +
> +	pci_put_host_bridge_device(bridge);
> +	return ret;
> +}
> +
>  struct bus_type pci_bus_type = {
>  	.name		= "pci",
>  	.match		= pci_bus_match,
> @@ -1534,6 +1565,7 @@ struct bus_type pci_bus_type = {
>  	.drv_groups	= pci_drv_groups,
>  	.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 b093405..1832d90 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type *,
>   * @resume:	Called to bring a device on this bus out of sleep mode.
>   * @num_vf:	Called to find out how many virtual functions a device on this
>   *		bus supports.
> + * @dma_configure:	Called to setup DMA configuration on a device on
> +			this bus.
>   * @pm:		Power management operations of this bus, callback the specific
>   *		device driver's pm-ops.
>   * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
> @@ -130,6 +132,8 @@ struct bus_type {
>  
>  	int (*num_vf)(struct device *dev);
>  
> +	int (*dma_configure)(struct device *dev);
> +
>  	const struct dev_pm_ops *pm;
>  
>  	const struct iommu_ops *iommu_ops;
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 49f634d..3097c94 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -356,6 +356,8 @@ static inline char *early_platform_driver_setup_func(void)		\
>  #define platform_pm_restore		NULL
>  #endif
>  
> +extern int platform_dma_configure(struct device *dev);
> +
>  #ifdef CONFIG_PM_SLEEP
>  #define USE_PLATFORM_PM_SLEEP_OPS \
>  	.suspend = platform_pm_suspend, \
> -- 
> 1.9.1
>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,2/2] drivers: remove force dma flag from buses
  2018-03-30  7:54 ` Nipun Gupta
  (?)
@ 2018-04-09 20:27 ` Rob Herring
  -1 siblings, 0 replies; 141+ messages in thread
From: Rob Herring @ 2018-04-09 20:27 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, frowand.list, jarkko.sakkinen, rafael.j.wysocki,
	dmitry.torokhov, johan, msuchanek, linux-kernel, iommu,
	linux-wireless, linux-arm-msm, linux-soc, dmaengine, dri-devel,
	linux-tegra, devicetree, linux-pci, bharat.bhushan, leoyang.li

On Fri, Mar 30, 2018 at 01:24:45PM +0530, Nipun Gupta wrote:
> With each bus implementing its own DMA configuration callback,
> there is no need for bus to explicitly have force_dma in its
> global structure. This patch modifies of_dma_configure API to
> accept an input parameter which specifies if implicit DMA
> configuration is required even when it is not described by the
> firmware.
> 
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> ---
> Changes in v2:
>   - This is a new change suggested by Robin and Christoph
>     and is added to the series.
> 
> Changes in v3:
>   - Rebase and changes corresponding to the changes in patch 1/2
> 
>  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/pci-driver.c      | 3 +--
>  include/linux/device.h        | 4 ----
>  include/linux/of_device.h     | 8 ++++++--
>  10 files changed, 17 insertions(+), 19 deletions(-)

Reviewed-by: Rob Herring <robh@kernel.org>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v3,2/2] drivers: remove force dma flag from buses
  2018-03-30  7:54 ` Nipun Gupta
  (?)
  (?)
@ 2018-03-30  7:54 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-30  7:54 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

With each bus implementing its own DMA configuration callback,
there is no need for bus to explicitly have force_dma in its
global structure. This patch modifies of_dma_configure API to
accept an input parameter which specifies if implicit DMA
configuration is required even when it is not described by the
firmware.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
Changes in v2:
  - This is a new change suggested by Robin and Christoph
    and is added to the series.

Changes in v3:
  - Rebase and changes corresponding to the changes in patch 1/2

 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/pci-driver.c      | 3 +--
 include/linux/device.h        | 4 ----
 include/linux/of_device.h     | 8 ++++++--
 10 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 867dc2b..abe73c4 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -199,7 +199,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 72fdbf6..cfbc569 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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)
@@ -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);
 
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 000c7019..d64edeb 100644
--- a/drivers/dma/qcom/hidma_mgmt.c
+++ b/drivers/dma/qcom/hidma_mgmt.c
@@ -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.
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index a9ec99d..b39c1e9 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -317,7 +317,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 static int host1x_dma_configure(struct device *dev)
 {
 	if (dev->of_node)
-		return of_dma_configure(dev, dev->of_node);
+		return of_dma_configure(dev, dev->of_node, true);
 	return 0;
 }
 
@@ -335,7 +335,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)
@@ -424,7 +423,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 064c818..33d8551 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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.
@@ -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;
@@ -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;
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 9a4f4246..895c83e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -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 {
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 78e507f..27c832f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1540,7 +1540,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);
@@ -1566,7 +1566,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 1832d90..92c530e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -98,8 +98,6 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @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
@@ -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);
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;
 }

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [v3,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-12 15:24 ` Nipun Gupta
  (?)
  (?)
@ 2018-03-30  7:54 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-30  7:54 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

It is bus specific aspect to map a given device on the bus and
relevant firmware description of its DMA configuration.
So, this change introduces 'dma_configure' as bus callback
giving flexibility to busses for implementing its own dma
configuration function.

The change eases the addition of new busses w.r.t. adding the dma
configuration functionality.

This patch also updates the PCI, Platform, ACPI and host1x bus to
use new introduced callbacks.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 - The patches are based on the comments on:
   https://patchwork.kernel.org/patch/10259087/

Changes in v2:
  - Do not have dma_deconfigure callback
  - Have '/dma_common_configure/' API to provide a common DMA
    configuration which can be used by busses if it suits them.
  - Platform and ACPI bus to use '/dma_common_configure/' in
    '/dma_configure/' callback.
  - Updated commit message
  - Updated pci_dma_configure API with changes suggested by Robin

Changes in v3
  - Move dma_common_configure() within platform_dma_configure() and
    reuse platofrm_dma_configure() for AMBA bus too
  - Declare 'attr' in pci_dma_configure() inside the else statement
    where it is used.

 drivers/amba/bus.c              |  4 ++++
 drivers/base/dma-mapping.c      | 31 ++++---------------------------
 drivers/base/platform.c         | 17 +++++++++++++++++
 drivers/gpu/host1x/bus.c        |  8 ++++++++
 drivers/pci/pci-driver.c        | 32 ++++++++++++++++++++++++++++++++
 include/linux/device.h          |  4 ++++
 include/linux/platform_device.h |  2 ++
 7 files changed, 71 insertions(+), 27 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 594c228..867dc2b 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -20,6 +20,7 @@
 #include <linux/sizes.h>
 #include <linux/limits.h>
 #include <linux/clk/clk-conf.h>
+#include <linux/platform_device.h>
 
 #include <asm/irq.h>
 
@@ -188,12 +189,15 @@ static int amba_pm_runtime_resume(struct device *dev)
 /*
  * Primecells are part of the Advanced Microcontroller Bus Architecture,
  * so we call the bus "amba".
+ * DMA configuration for platform and AMBA bus is same. So here we reuse
+ * platform's DMA config routine.
  */
 struct bus_type amba_bustype = {
 	.name		= "amba",
 	.dev_groups	= amba_dev_groups,
 	.match		= amba_match,
 	.uevent		= amba_uevent,
+	.dma_configure	= platform_dma_configure,
 	.pm		= &amba_pm,
 	.force_dma	= true,
 };
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 3b11835..fdc1502 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -331,36 +331,13 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
 #endif
 
 /*
- * Common configuration to enable DMA API use for a device
+ * enables DMA API use for a device
  */
-#include <linux/pci.h>
-
 int dma_configure(struct device *dev)
 {
-	struct device *bridge = NULL, *dma_dev = dev;
-	enum dev_dma_attr attr;
-	int ret = 0;
-
-	if (dev_is_pci(dev)) {
-		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
-		dma_dev = bridge;
-		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
-		    dma_dev->parent->of_node)
-			dma_dev = dma_dev->parent;
-	}
-
-	if (dma_dev->of_node) {
-		ret = of_dma_configure(dev, dma_dev->of_node);
-	} else if (has_acpi_companion(dma_dev)) {
-		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
-		if (attr != DEV_DMA_NOT_SUPPORTED)
-			ret = acpi_dma_configure(dev, attr);
-	}
-
-	if (bridge)
-		pci_put_host_bridge_device(bridge);
-
-	return ret;
+	if (dev->bus->dma_configure)
+		return dev->bus->dma_configure(dev);
+	return 0;
 }
 
 void dma_deconfigure(struct device *dev)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b3..72fdbf6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1130,6 +1130,22 @@ int platform_pm_restore(struct device *dev)
 
 #endif /* CONFIG_HIBERNATE_CALLBACKS */
 
+int platform_dma_configure(struct device *dev)
+{
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	if (dev->of_node) {
+		ret = of_dma_configure(dev, dev->of_node);
+	} else if (has_acpi_companion(dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	return ret;
+}
+
 static const struct dev_pm_ops platform_dev_pm_ops = {
 	.runtime_suspend = pm_generic_runtime_suspend,
 	.runtime_resume = pm_generic_runtime_resume,
@@ -1141,6 +1157,7 @@ struct bus_type platform_bus_type = {
 	.dev_groups	= platform_dev_groups,
 	.match		= platform_match,
 	.uevent		= platform_uevent,
+	.dma_configure	= platform_dma_configure,
 	.pm		= &platform_dev_pm_ops,
 	.force_dma	= true,
 };
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 88a3558..a9ec99d 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -314,6 +314,13 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 	return strcmp(dev_name(dev), drv->name) == 0;
 }
 
+static int host1x_dma_configure(struct device *dev)
+{
+	if (dev->of_node)
+		return of_dma_configure(dev, dev->of_node);
+	return 0;
+}
+
 static const struct dev_pm_ops host1x_device_pm_ops = {
 	.suspend = pm_generic_suspend,
 	.resume = pm_generic_resume,
@@ -326,6 +333,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 struct bus_type host1x_bus_type = {
 	.name = "host1x",
 	.match = host1x_device_match,
+	.dma_configure	= host1x_dma_configure,
 	.pm = &host1x_device_pm_ops,
 	.force_dma = true,
 };
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 3bed6be..78e507f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -18,6 +18,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
 #include <linux/kexec.h>
+#include <linux/of_device.h>
+#include <linux/acpi.h>
 #include "pci.h"
 
 struct pci_dynid {
@@ -1522,6 +1524,35 @@ static int pci_bus_num_vf(struct device *dev)
 	return pci_num_vf(to_pci_dev(dev));
 }
 
+/**
+ * pci_dma_configure - Setup DMA configuration
+ * @dev: ptr to dev structure
+ *
+ * Function to update PCI devices's DMA configuration using the same
+ * info from the OF node or ACPI node of host bridge's parent (if any).
+ */
+static int pci_dma_configure(struct device *dev)
+{
+	struct device *bridge;
+	int ret = 0;
+
+	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
+
+	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
+	    bridge->parent->of_node) {
+		ret = of_dma_configure(dev, bridge->parent->of_node);
+	} 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);
+
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	pci_put_host_bridge_device(bridge);
+	return ret;
+}
+
 struct bus_type pci_bus_type = {
 	.name		= "pci",
 	.match		= pci_bus_match,
@@ -1534,6 +1565,7 @@ struct bus_type pci_bus_type = {
 	.drv_groups	= pci_drv_groups,
 	.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 b093405..1832d90 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @resume:	Called to bring a device on this bus out of sleep mode.
  * @num_vf:	Called to find out how many virtual functions a device on this
  *		bus supports.
+ * @dma_configure:	Called to setup DMA configuration on a device on
+			this bus.
  * @pm:		Power management operations of this bus, callback the specific
  *		device driver's pm-ops.
  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
@@ -130,6 +132,8 @@ struct bus_type {
 
 	int (*num_vf)(struct device *dev);
 
+	int (*dma_configure)(struct device *dev);
+
 	const struct dev_pm_ops *pm;
 
 	const struct iommu_ops *iommu_ops;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 49f634d..3097c94 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -356,6 +356,8 @@ static inline char *early_platform_driver_setup_func(void)		\
 #define platform_pm_restore		NULL
 #endif
 
+extern int platform_dma_configure(struct device *dev);
+
 #ifdef CONFIG_PM_SLEEP
 #define USE_PLATFORM_PM_SLEEP_OPS \
 	.suspend = platform_pm_suspend, \

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-24  9:25 ` kbuild test robot
  -1 siblings, 0 replies; 141+ messages in thread
From: kbuild test robot @ 2018-03-24  9:25 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: kbuild-all, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li

Hi Nipun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Nipun-Gupta/dma-mapping-move-dma-configuration-to-bus-infrastructure/20180323-232307
config: score-spct6600_defconfig (attached as .config)
compiler: score-elf-gcc (GCC) 4.9.4
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=score 

All errors (new ones prefixed by >>):

   init/main.o: In function `try_to_run_init_process':
   main.c:(.text+0x40): relocation truncated to fit: R_SCORE_24 against `run_init_process'
   main.c:(.text+0x78): relocation truncated to fit: R_SCORE_24 against `.L36'
   init/main.o: In function `.L132':
   main.c:(.text+0x190): relocation truncated to fit: R_SCORE_24 against `.L129'
   main.c:(.text+0x200): relocation truncated to fit: R_SCORE_24 against `.L132'
   init/main.o: In function `loglevel':
   main.c:(.init.text+0xa4): relocation truncated to fit: R_SCORE_24 against `get_option'
   init/main.o: In function `.L15':
   main.c:(.init.text+0x110): relocation truncated to fit: R_SCORE_24 against `strcmp'
   main.c:(.init.text+0x124): relocation truncated to fit: R_SCORE_24 against `parameq'
   main.c:(.init.text+0x14c): relocation truncated to fit: R_SCORE_24 against `printk'
   init/main.o: In function `.L31':
   main.c:(.init.text+0x160): relocation truncated to fit: R_SCORE_24 against `strcmp'
   init/main.o: In function `.L21':
   main.c:(.init.text+0x170): relocation truncated to fit: R_SCORE_24 against `.L15'
   init/main.o: In function `initcall_blacklist':
   main.c:(.init.text+0x198): additional relocation overflows omitted from the output
   drivers/base/platform.o: In function `platform_dma_configure':
>> platform.c:(.text.platform_dma_configure+0x0): undefined reference to `dma_common_configure'
---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-23 17:41 ` kbuild test robot
  -1 siblings, 0 replies; 141+ messages in thread
From: kbuild test robot @ 2018-03-23 17:41 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: kbuild-all, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li

Hi Nipun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Nipun-Gupta/dma-mapping-move-dma-configuration-to-bus-infrastructure/20180323-232307
config: i386-randconfig-x014-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers//bcma/main.c: In function 'bcma_of_fill_device':
>> drivers//bcma/main.c:210:2: error: too many arguments to function 'of_dma_configure'
     of_dma_configure(&core->dev, node, false);
     ^~~~~~~~~~~~~~~~
   In file included from include/linux/of_platform.h:12:0,
                    from drivers//bcma/main.c:17:
   include/linux/of_device.h:110:19: note: declared here
    static inline int of_dma_configure(struct device *dev, struct device_node *np)
                      ^~~~~~~~~~~~~~~~

vim +/of_dma_configure +210 drivers//bcma/main.c

   198	
   199	static void bcma_of_fill_device(struct device *parent,
   200					struct bcma_device *core)
   201	{
   202		struct device_node *node;
   203	
   204		node = bcma_of_find_child_device(parent, core);
   205		if (node)
   206			core->dev.of_node = node;
   207	
   208		core->irq = bcma_of_get_irq(parent, core, 0);
   209	
 > 210		of_dma_configure(&core->dev, node, false);
   211	}
   212
---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-23 16:09 ` kbuild test robot
  -1 siblings, 0 replies; 141+ messages in thread
From: kbuild test robot @ 2018-03-23 16:09 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: kbuild-all, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li

Hi Nipun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Nipun-Gupta/dma-mapping-move-dma-configuration-to-bus-infrastructure/20180323-232307
config: i386-randconfig-x013-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/base/dma-mapping.c: In function 'dma_common_configure':
>> drivers/base/dma-mapping.c:344:9: error: too many arguments to function 'of_dma_configure'
      ret = of_dma_configure(dev, dev->of_node, force_dma);
            ^~~~~~~~~~~~~~~~
   In file included from drivers/base/dma-mapping.c:13:0:
   include/linux/of_device.h:110:19: note: declared here
    static inline int of_dma_configure(struct device *dev, struct device_node *np)
                      ^~~~~~~~~~~~~~~~
---
   drivers/pci/pci-driver.c: In function 'pci_dma_configure':
>> drivers/pci/pci-driver.c:1544:9: error: too many arguments to function 'of_dma_configure'
      ret = of_dma_configure(dev, bridge->parent->of_node, true);
            ^~~~~~~~~~~~~~~~
   In file included from drivers/pci/pci-driver.c:21:0:
   include/linux/of_device.h:110:19: note: declared here
    static inline int of_dma_configure(struct device *dev, struct device_node *np)
                      ^~~~~~~~~~~~~~~~

vim +/of_dma_configure +344 drivers/base/dma-mapping.c

   332	
   333	/*
   334	 * Common configuration to enable DMA API use for a device.
   335	 * A bus can use this function in its 'dma_configure' callback, if
   336	 * suitable for the bus.
   337	 */
   338	int dma_common_configure(struct device *dev, bool force_dma)
   339	{
   340		enum dev_dma_attr attr;
   341		int ret = 0;
   342	
   343		if (dev->of_node) {
 > 344			ret = of_dma_configure(dev, dev->of_node, force_dma);
   345		} else if (has_acpi_companion(dev)) {
   346			attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
   347			if (attr != DEV_DMA_NOT_SUPPORTED)
   348				ret = acpi_dma_configure(dev, attr);
   349		}
   350	
   351		return ret;
   352	}
   353	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-22  8:15 ` Christoph Hellwig
  (?)
  (?)
@ 2018-03-22 15:05 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-22 15:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: robin.murphy, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@lst.de]
> Sent: Thursday, March 22, 2018 13:46
> To: Nipun Gupta <nipun.gupta@nxp.com>
> 
> > +static int amba_dma_configure(struct device *dev)
> > +{
> > +	return dma_common_configure(dev);
> > +}
> 
> So it turns out we only end with two callers of dma_common_configure
> after this series.  Based ont hat I'm tempted with the suggestion
> from Robin to just have amba call platform_dma_configure, and move
> the code from dma_common_configure to platform_dma_configure.

okay, that would be fine, trivial query - will it be okay to include
'linux/platform_device.h' in the AMBA bus? I am reluctant for this change
because of including platform file.

Thanks,
Nipun
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-22  8:19 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-03-22  8:19 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

> --- a/drivers/dma/qcom/hidma_mgmt.c
> +++ b/drivers/dma/qcom/hidma_mgmt.c
> @@ -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.

Where did we mark this bus as force_dma before?

> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 9a4f4246..895c83e 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -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);

Did all the callers of this one really force dma?  I have a hard time
untangling the call stacks unfortunately.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  7:19 ` Bharat Bhushan
  (?)
@ 2018-03-22  8:17 ` hch
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-03-22  8:17 UTC (permalink / raw)
  To: Bharat Bhushan
  Cc: Nipun Gupta, robin.murphy, hch, linux, gregkh, m.szyprowski,
	bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, Leo Li

> > +int dma_configure(struct device *dev)
> > +{
> > +	if (dev->bus->dma_configure)
> > +		return dev->bus->dma_configure(dev);
> 
> What if dma_common_configure() is called in case "bus->dma_configure" is not defined?

Then we'd still have a dependency of common code on OF and ACPI.

On the other hand we'd get free OF and ACPI dma ranges parsing for
everyone, which might be handy.  And which would really help mitigating
the risk that we missed some bus that gets dma configuration from OF,
so maybe it actually is a good idea.  I'd just rename it to
dma_default_configure or similar in that case.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-22  8:15 ` Christoph Hellwig
  -1 siblings, 0 replies; 141+ messages in thread
From: Christoph Hellwig @ 2018-03-22  8:15 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, gregkh, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

> +static int amba_dma_configure(struct device *dev)
> +{
> +	return dma_common_configure(dev);
> +}

So it turns out we only end with two callers of dma_common_configure
after this series.  Based ont hat I'm tempted with the suggestion
from Robin to just have amba call platform_dma_configure, and move
the code from dma_common_configure to platform_dma_configure.

> +int dma_configure(struct device *dev)
> +{
> +	if (dev->bus->dma_configure)
> +		return dev->bus->dma_configure(dev);
> +
> +	return 0;
> +}
>  void dma_deconfigure(struct device *dev)

As grep pointed out this wants a blank line after the function, and while
in nitpicking mode I'd suggest to remove the blank line above the return
statement while at it.

> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 88a3558..fa9896d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  	return strcmp(dev_name(dev), drv->name) == 0;
>  }
>  
> +static int host1x_dma_configure(struct device *dev)
> +{
> +	if (dev->of_node)
> +		return of_dma_configure(dev, dev->of_node);
> +
> +	return 0;

Same here.

> + */
> +static int pci_dma_configure(struct device *dev)
> +{
> +	struct device *bridge;
> +	enum dev_dma_attr attr;
> +	int ret = 0;
> +
> +	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> +
> +	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
> +	    bridge->parent->of_node) {
> +		ret = of_dma_configure(dev, bridge->parent->of_node);
> +	} else if (has_acpi_companion(bridge)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode));
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			ret = acpi_dma_configure(dev, attr);
> +	}

The attr declaration can be moved into the inner scope here.

> +	pci_put_host_bridge_device(bridge);
> +
> +	return ret;

Drop the blank line after the return, please.
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21 16:28 ` Nipun Gupta
  (?)
@ 2018-03-21 17:49 ` Greg KH
  -1 siblings, 0 replies; 141+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-21 17:49 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

On Wed, Mar 21, 2018 at 04:28:46PM +0000, Nipun Gupta wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > Sent: Wednesday, March 21, 2018 15:05
> > To: Nipun Gupta <nipun.gupta@nxp.com>
> > Cc: robin.murphy@arm.com; hch@lst.de; linux@armlinux.org.uk;
> > m.szyprowski@samsung.com; bhelgaas@google.com; zajec5@gmail.com;
> > andy.gross@linaro.org; david.brown@linaro.org; dan.j.williams@intel.com;
> > vinod.koul@intel.com; thierry.reding@gmail.com; robh+dt@kernel.org;
> > frowand.list@gmail.com; jarkko.sakkinen@linux.intel.com;
> > rafael.j.wysocki@intel.com; dmitry.torokhov@gmail.com; johan@kernel.org;
> > msuchanek@suse.de; linux-kernel@vger.kernel.org; iommu@lists.linux-
> > foundation.org; linux-wireless@vger.kernel.org; linux-arm-
> > msm@vger.kernel.org; linux-soc@vger.kernel.org; dmaengine@vger.kernel.org;
> > dri-devel@lists.freedesktop.org; linux-tegra@vger.kernel.org;
> > devicetree@vger.kernel.org; linux-pci@vger.kernel.org; Bharat Bhushan
> > <bharat.bhushan@nxp.com>; Leo Li <leoyang.li@nxp.com>
> > Subject: Re: [PATCH v2 2/2] drivers: remove force dma flag from buses
> > 
> > On Wed, Mar 21, 2018 at 12:25:23PM +0530, Nipun Gupta wrote:
> > > With each bus implementing its own DMA configuration callback,
> > > there is no need for bus to explicitly have force_dma in its
> > > global structure. This patch modifies of_dma_configure API to
> > > accept an input parameter which specifies if implicit DMA
> > > configuration is required even when it is not described by the
> > > firmware.
> > 
> > Having to "remember" what that bool variable means on the end of the
> > function call is a royal pain over time, right?
> > 
> > Why not just create a new function:
> > 	dma_common_configure_force(dma)
> > that always does this?  Leave "dma_common_configure()" alone, and then
> > wrap the old code with these two helper functions that call the 'core'
> > code with the bool set properly?
> > 
> > That way you do not have to "know" what that parameter is, the function
> > name just documents it automatically, so when you see it in the
> > bus-specific code, no need to go and have to hunt for anything.  And if
> > you are reading the dma core code, it's obvious what is happening as the
> > functions are all right there.
> 
> How about we do not pass any flag in 'dma_common_configure()', and inside this
> API we pass "true" to 'of_dma_configure()'? I am saying this because currently
> both the busses (platform and AMBA) which uses 'dma_common_configure()' passes
> "true" value. If we create additional 'dma_common_configure_force()', then
> 'dma_common_configure()' will not be used anytime and will become redundant.
> 
> If someday new busses come and they needs to use similar functionality which
> 'dma_common_configure()' provides, but with passing "false" to 'of_dma_configure()',
> then what you suggests of having two separate such API's will be more reasonable
> and can be implemented?

If that makes things "simple", yes, sounds good.

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  9:35 ` Greg KH
  (?)
  (?)
@ 2018-03-21 16:28 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-21 16:28 UTC (permalink / raw)
  To: Greg KH
  Cc: robin.murphy, hch, linux, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Wednesday, March 21, 2018 15:05
> To: Nipun Gupta <nipun.gupta@nxp.com>
> Cc: robin.murphy@arm.com; hch@lst.de; linux@armlinux.org.uk;
> m.szyprowski@samsung.com; bhelgaas@google.com; zajec5@gmail.com;
> andy.gross@linaro.org; david.brown@linaro.org; dan.j.williams@intel.com;
> vinod.koul@intel.com; thierry.reding@gmail.com; robh+dt@kernel.org;
> frowand.list@gmail.com; jarkko.sakkinen@linux.intel.com;
> rafael.j.wysocki@intel.com; dmitry.torokhov@gmail.com; johan@kernel.org;
> msuchanek@suse.de; linux-kernel@vger.kernel.org; iommu@lists.linux-
> foundation.org; linux-wireless@vger.kernel.org; linux-arm-
> msm@vger.kernel.org; linux-soc@vger.kernel.org; dmaengine@vger.kernel.org;
> dri-devel@lists.freedesktop.org; linux-tegra@vger.kernel.org;
> devicetree@vger.kernel.org; linux-pci@vger.kernel.org; Bharat Bhushan
> <bharat.bhushan@nxp.com>; Leo Li <leoyang.li@nxp.com>
> Subject: Re: [PATCH v2 2/2] drivers: remove force dma flag from buses
> 
> On Wed, Mar 21, 2018 at 12:25:23PM +0530, Nipun Gupta wrote:
> > With each bus implementing its own DMA configuration callback,
> > there is no need for bus to explicitly have force_dma in its
> > global structure. This patch modifies of_dma_configure API to
> > accept an input parameter which specifies if implicit DMA
> > configuration is required even when it is not described by the
> > firmware.
> 
> Having to "remember" what that bool variable means on the end of the
> function call is a royal pain over time, right?
> 
> Why not just create a new function:
> 	dma_common_configure_force(dma)
> that always does this?  Leave "dma_common_configure()" alone, and then
> wrap the old code with these two helper functions that call the 'core'
> code with the bool set properly?
> 
> That way you do not have to "know" what that parameter is, the function
> name just documents it automatically, so when you see it in the
> bus-specific code, no need to go and have to hunt for anything.  And if
> you are reading the dma core code, it's obvious what is happening as the
> functions are all right there.

How about we do not pass any flag in 'dma_common_configure()', and inside this
API we pass "true" to 'of_dma_configure()'? I am saying this because currently
both the busses (platform and AMBA) which uses 'dma_common_configure()' passes
"true" value. If we create additional 'dma_common_configure_force()', then
'dma_common_configure()' will not be used anytime and will become redundant.

If someday new busses come and they needs to use similar functionality which
'dma_common_configure()' provides, but with passing "false" to 'of_dma_configure()',
then what you suggests of having two separate such API's will be more reasonable
and can be implemented?

Thanks,
Nipun

> 
> thanks,
> 
> greg k-h
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  9:29 ` Greg KH
  (?)
  (?)
@ 2018-03-21 16:13 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-21 16:13 UTC (permalink / raw)
  To: Greg KH
  Cc: robin.murphy, hch, linux, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	Bharat Bhushan, Leo Li

> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Wednesday, March 21, 2018 15:00

<snip>

> > +int dma_configure(struct device *dev)
> > +{
> > +	if (dev->bus->dma_configure)
> > +		return dev->bus->dma_configure(dev);
> > +
> > +	return 0;
> > +}
> >  void dma_deconfigure(struct device *dev)
> 
> Empty line after this new function?  Sorry, couldn't help it :)
> 
> >  {
> >  	of_dma_deconfigure(dev);
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index f1bf7b3..d2d5891 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -1130,6 +1130,11 @@ int platform_pm_restore(struct device *dev)
> >
> >  #endif /* CONFIG_HIBERNATE_CALLBACKS */
> >

<snip>

> > +
> >  	const struct dev_pm_ops *pm;
> >
> >  	const struct iommu_ops *iommu_ops;
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index eb9eab4..c15986b 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -761,6 +761,7 @@ void *dma_mark_declared_memory_occupied(struct
> device *dev,
> >  }
> >  #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
> >
> > +int dma_common_configure(struct device *dev);
> >  #ifdef CONFIG_HAS_DMA
> 
> Blank line after the new function declaration?
> 
> Other than those very minor things, nice job, this looks good:
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thank you for the review :). I will fix your comments in next version.

Regards,
Nipun
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-21  9:35 ` Greg KH
  -1 siblings, 0 replies; 141+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-21  9:35 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

On Wed, Mar 21, 2018 at 12:25:23PM +0530, Nipun Gupta wrote:
> With each bus implementing its own DMA configuration callback,
> there is no need for bus to explicitly have force_dma in its
> global structure. This patch modifies of_dma_configure API to
> accept an input parameter which specifies if implicit DMA
> configuration is required even when it is not described by the
> firmware.

Having to "remember" what that bool variable means on the end of the
function call is a royal pain over time, right?

Why not just create a new function:
	dma_common_configure_force(dma)
that always does this?  Leave "dma_common_configure()" alone, and then
wrap the old code with these two helper functions that call the 'core'
code with the bool set properly?

That way you do not have to "know" what that parameter is, the function
name just documents it automatically, so when you see it in the
bus-specific code, no need to go and have to hunt for anything.  And if
you are reading the dma core code, it's obvious what is happening as the
functions are all right there.

thanks,

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-21  9:29 ` Greg KH
  -1 siblings, 0 replies; 141+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-21  9:29 UTC (permalink / raw)
  To: Nipun Gupta
  Cc: robin.murphy, hch, linux, m.szyprowski, bhelgaas, zajec5,
	andy.gross, david.brown, dan.j.williams, vinod.koul,
	thierry.reding, robh+dt, frowand.list, jarkko.sakkinen,
	rafael.j.wysocki, dmitry.torokhov, johan, msuchanek,
	linux-kernel, iommu, linux-wireless, linux-arm-msm, linux-soc,
	dmaengine, dri-devel, linux-tegra, devicetree, linux-pci,
	bharat.bhushan, leoyang.li

On Wed, Mar 21, 2018 at 12:25:22PM +0530, Nipun Gupta wrote:
> It's bus specific aspect to map a given device on the bus and
> relevant firmware description of its DMA configuration.
> So, this change introduces '/dma_configure/' as bus callback
> giving flexibility to busses for implementing its own dma
> configuration function.
> 
> The change eases the addition of new busses w.r.t. adding the dma
> configuration functionality.
> 
> This patch also updates the PCI, Platform, ACPI and host1x bus to
> use new introduced callbacks.
> 
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> ---
>  - The patches are based on the comments on:
>    https://patchwork.kernel.org/patch/10259087/
> 
> Changes in v2:
>   - Do not have dma_deconfigure callback
>   - Have '/dma_common_configure/' API to provide a common DMA
>     configuration which can be used by busses if it suits them.
>   - Platform and ACPI bus to use '/dma_common_configure/' in
>     '/dma_configure/' callback.
>   - Updated commit message
>   - Updated pci_dma_configure API with changes suggested by Robin
> 
>  drivers/amba/bus.c          |  7 +++++++
>  drivers/base/dma-mapping.c  | 35 +++++++++++++++--------------------
>  drivers/base/platform.c     |  6 ++++++
>  drivers/gpu/host1x/bus.c    |  9 +++++++++
>  drivers/pci/pci-driver.c    | 32 ++++++++++++++++++++++++++++++++
>  include/linux/device.h      |  4 ++++
>  include/linux/dma-mapping.h |  1 +
>  7 files changed, 74 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 594c228..2fa1e8b 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -20,6 +20,7 @@
>  #include <linux/sizes.h>
>  #include <linux/limits.h>
>  #include <linux/clk/clk-conf.h>
> +#include <linux/dma-mapping.h>
>  
>  #include <asm/irq.h>
>  
> @@ -171,6 +172,11 @@ static int amba_pm_runtime_resume(struct device *dev)
>  }
>  #endif /* CONFIG_PM */
>  
> +static int amba_dma_configure(struct device *dev)
> +{
> +	return dma_common_configure(dev);
> +}
> +
>  static const struct dev_pm_ops amba_pm = {
>  	.suspend	= pm_generic_suspend,
>  	.resume		= pm_generic_resume,
> @@ -194,6 +200,7 @@ struct bus_type amba_bustype = {
>  	.dev_groups	= amba_dev_groups,
>  	.match		= amba_match,
>  	.uevent		= amba_uevent,
> +	.dma_configure	= amba_dma_configure,
>  	.pm		= &amba_pm,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index 3b11835..48f9af0 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -331,38 +331,33 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
>  #endif
>  
>  /*
> - * Common configuration to enable DMA API use for a device
> + * Common configuration to enable DMA API use for a device.
> + * A bus can use this function in its 'dma_configure' callback, if
> + * suitable for the bus.
>   */
> -#include <linux/pci.h>
> -
> -int dma_configure(struct device *dev)
> +int dma_common_configure(struct device *dev)
>  {
> -	struct device *bridge = NULL, *dma_dev = dev;
>  	enum dev_dma_attr attr;
>  	int ret = 0;
>  
> -	if (dev_is_pci(dev)) {
> -		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> -		dma_dev = bridge;
> -		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
> -		    dma_dev->parent->of_node)
> -			dma_dev = dma_dev->parent;
> -	}
> -
> -	if (dma_dev->of_node) {
> -		ret = of_dma_configure(dev, dma_dev->of_node);
> -	} else if (has_acpi_companion(dma_dev)) {
> -		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
> +	if (dev->of_node) {
> +		ret = of_dma_configure(dev, dev->of_node);
> +	} else if (has_acpi_companion(dev)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
>  		if (attr != DEV_DMA_NOT_SUPPORTED)
>  			ret = acpi_dma_configure(dev, attr);
>  	}
>  
> -	if (bridge)
> -		pci_put_host_bridge_device(bridge);
> -
>  	return ret;
>  }
>  
> +int dma_configure(struct device *dev)
> +{
> +	if (dev->bus->dma_configure)
> +		return dev->bus->dma_configure(dev);
> +
> +	return 0;
> +}
>  void dma_deconfigure(struct device *dev)

Empty line after this new function?  Sorry, couldn't help it :)

>  {
>  	of_dma_deconfigure(dev);
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index f1bf7b3..d2d5891 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -1130,6 +1130,11 @@ int platform_pm_restore(struct device *dev)
>  
>  #endif /* CONFIG_HIBERNATE_CALLBACKS */
>  
> +static int platform_dma_configure(struct device *dev)
> +{
> +	return dma_common_configure(dev);
> +}
> +
>  static const struct dev_pm_ops platform_dev_pm_ops = {
>  	.runtime_suspend = pm_generic_runtime_suspend,
>  	.runtime_resume = pm_generic_runtime_resume,
> @@ -1141,6 +1146,7 @@ struct bus_type platform_bus_type = {
>  	.dev_groups	= platform_dev_groups,
>  	.match		= platform_match,
>  	.uevent		= platform_uevent,
> +	.dma_configure	= platform_dma_configure,
>  	.pm		= &platform_dev_pm_ops,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 88a3558..fa9896d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  	return strcmp(dev_name(dev), drv->name) == 0;
>  }
>  
> +static int host1x_dma_configure(struct device *dev)
> +{
> +	if (dev->of_node)
> +		return of_dma_configure(dev, dev->of_node);
> +
> +	return 0;
> +}
> +
>  static const struct dev_pm_ops host1x_device_pm_ops = {
>  	.suspend = pm_generic_suspend,
>  	.resume = pm_generic_resume,
> @@ -326,6 +334,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
>  struct bus_type host1x_bus_type = {
>  	.name = "host1x",
>  	.match = host1x_device_match,
> +	.dma_configure	= host1x_dma_configure,
>  	.pm = &host1x_device_pm_ops,
>  	.force_dma = true,
>  };
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 3bed6be..b473a4c 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -18,6 +18,8 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/suspend.h>
>  #include <linux/kexec.h>
> +#include <linux/of_device.h>
> +#include <linux/acpi.h>
>  #include "pci.h"
>  
>  struct pci_dynid {
> @@ -1522,6 +1524,35 @@ static int pci_bus_num_vf(struct device *dev)
>  	return pci_num_vf(to_pci_dev(dev));
>  }
>  
> +/**
> + * pci_dma_configure - Setup DMA configuration
> + * @dev: ptr to dev structure
> + *
> + * Function to update PCI devices's DMA configuration using the same
> + * info from the OF node or ACPI node of host bridge's parent (if any).
> + */
> +static int pci_dma_configure(struct device *dev)
> +{
> +	struct device *bridge;
> +	enum dev_dma_attr attr;
> +	int ret = 0;
> +
> +	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> +
> +	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
> +	    bridge->parent->of_node) {
> +		ret = of_dma_configure(dev, bridge->parent->of_node);
> +	} else if (has_acpi_companion(bridge)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode));
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			ret = acpi_dma_configure(dev, attr);
> +	}
> +
> +	pci_put_host_bridge_device(bridge);
> +
> +	return ret;
> +}
> +
>  struct bus_type pci_bus_type = {
>  	.name		= "pci",
>  	.match		= pci_bus_match,
> @@ -1534,6 +1565,7 @@ struct bus_type pci_bus_type = {
>  	.drv_groups	= pci_drv_groups,
>  	.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 b093405..1832d90 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type *,
>   * @resume:	Called to bring a device on this bus out of sleep mode.
>   * @num_vf:	Called to find out how many virtual functions a device on this
>   *		bus supports.
> + * @dma_configure:	Called to setup DMA configuration on a device on
> +			this bus.
>   * @pm:		Power management operations of this bus, callback the specific
>   *		device driver's pm-ops.
>   * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
> @@ -130,6 +132,8 @@ struct bus_type {
>  
>  	int (*num_vf)(struct device *dev);
>  
> +	int (*dma_configure)(struct device *dev);
> +
>  	const struct dev_pm_ops *pm;
>  
>  	const struct iommu_ops *iommu_ops;
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index eb9eab4..c15986b 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -761,6 +761,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
>  }
>  #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
>  
> +int dma_common_configure(struct device *dev);
>  #ifdef CONFIG_HAS_DMA

Blank line after the new function declaration?

Other than those very minor things, nice job, this looks good:

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  7:19 ` Bharat Bhushan
  (?)
  (?)
@ 2018-03-21  7:29 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-21  7:29 UTC (permalink / raw)
  To: Bharat Bhushan, robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, Leo Li

> -----Original Message-----
> From: Bharat Bhushan
> Sent: Wednesday, March 21, 2018 12:49

> >
> > +int dma_configure(struct device *dev)
> > +{
> > +	if (dev->bus->dma_configure)
> > +		return dev->bus->dma_configure(dev);
> 
> What if dma_common_configure() is called in case "bus->dma_configure" is
> not defined?
> 
> Thanks
> -Bharat

I think it is cleaner for bus to call '/dma_common_configure/' rather
than this been called implicitly, but Robin/Christoph can comment
better on this.

Thanks,
Nipun
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-21  6:55 ` Nipun Gupta
  (?)
  (?)
@ 2018-03-21  7:19 ` Bharat Bhushan
  -1 siblings, 0 replies; 141+ messages in thread
From: Bharat Bhushan @ 2018-03-21  7:19 UTC (permalink / raw)
  To: Nipun Gupta, robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, Leo Li

> -----Original Message-----
> From: Nipun Gupta
> Sent: Wednesday, March 21, 2018 12:25 PM
> To: robin.murphy@arm.com; hch@lst.de; linux@armlinux.org.uk;
> gregkh@linuxfoundation.org; m.szyprowski@samsung.com
> Cc: bhelgaas@google.com; zajec5@gmail.com; andy.gross@linaro.org;
> david.brown@linaro.org; dan.j.williams@intel.com; vinod.koul@intel.com;
> thierry.reding@gmail.com; robh+dt@kernel.org; frowand.list@gmail.com;
> jarkko.sakkinen@linux.intel.com; rafael.j.wysocki@intel.com;
> dmitry.torokhov@gmail.com; johan@kernel.org; msuchanek@suse.de; linux-
> kernel@vger.kernel.org; iommu@lists.linux-foundation.org; linux-
> wireless@vger.kernel.org; linux-arm-msm@vger.kernel.org; linux-
> soc@vger.kernel.org; dmaengine@vger.kernel.org; dri-
> devel@lists.freedesktop.org; linux-tegra@vger.kernel.org;
> devicetree@vger.kernel.org; linux-pci@vger.kernel.org; Bharat Bhushan
> <bharat.bhushan@nxp.com>; Leo Li <leoyang.li@nxp.com>; Nipun Gupta
> <nipun.gupta@nxp.com>
> Subject: [PATCH v2 1/2] dma-mapping: move dma configuration to bus
> infrastructure
> 
> It's bus specific aspect to map a given device on the bus and relevant firmware
> description of its DMA configuration.
> So, this change introduces '/dma_configure/' as bus callback giving flexibility to
> busses for implementing its own dma configuration function.
> 
> The change eases the addition of new busses w.r.t. adding the dma
> configuration functionality.
> 
> This patch also updates the PCI, Platform, ACPI and host1x bus to use new
> introduced callbacks.
> 
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> ---
>  - The patches are based on the comments on:
>    https://patchwork.kernel.org/patch/10259087/
> 
> Changes in v2:
>   - Do not have dma_deconfigure callback
>   - Have '/dma_common_configure/' API to provide a common DMA
>     configuration which can be used by busses if it suits them.
>   - Platform and ACPI bus to use '/dma_common_configure/' in
>     '/dma_configure/' callback.
>   - Updated commit message
>   - Updated pci_dma_configure API with changes suggested by Robin
> 
>  drivers/amba/bus.c          |  7 +++++++
>  drivers/base/dma-mapping.c  | 35 +++++++++++++++--------------------
>  drivers/base/platform.c     |  6 ++++++
>  drivers/gpu/host1x/bus.c    |  9 +++++++++
>  drivers/pci/pci-driver.c    | 32 ++++++++++++++++++++++++++++++++
>  include/linux/device.h      |  4 ++++
>  include/linux/dma-mapping.h |  1 +
>  7 files changed, 74 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 594c228..2fa1e8b
> 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -20,6 +20,7 @@
>  #include <linux/sizes.h>
>  #include <linux/limits.h>
>  #include <linux/clk/clk-conf.h>
> +#include <linux/dma-mapping.h>
> 
>  #include <asm/irq.h>
> 
> @@ -171,6 +172,11 @@ static int amba_pm_runtime_resume(struct device
> *dev)  }  #endif /* CONFIG_PM */
> 
> +static int amba_dma_configure(struct device *dev) {
> +	return dma_common_configure(dev);
> +}
> +
>  static const struct dev_pm_ops amba_pm = {
>  	.suspend	= pm_generic_suspend,
>  	.resume		= pm_generic_resume,
> @@ -194,6 +200,7 @@ struct bus_type amba_bustype = {
>  	.dev_groups	= amba_dev_groups,
>  	.match		= amba_match,
>  	.uevent		= amba_uevent,
> +	.dma_configure	= amba_dma_configure,
>  	.pm		= &amba_pm,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index
> 3b11835..48f9af0 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -331,38 +331,33 @@ void dma_common_free_remap(void *cpu_addr,
> size_t size, unsigned long vm_flags)  #endif
> 
>  /*
> - * Common configuration to enable DMA API use for a device
> + * Common configuration to enable DMA API use for a device.
> + * A bus can use this function in its 'dma_configure' callback, if
> + * suitable for the bus.
>   */
> -#include <linux/pci.h>
> -
> -int dma_configure(struct device *dev)
> +int dma_common_configure(struct device *dev)
>  {
> -	struct device *bridge = NULL, *dma_dev = dev;
>  	enum dev_dma_attr attr;
>  	int ret = 0;
> 
> -	if (dev_is_pci(dev)) {
> -		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> -		dma_dev = bridge;
> -		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
> -		    dma_dev->parent->of_node)
> -			dma_dev = dma_dev->parent;
> -	}
> -
> -	if (dma_dev->of_node) {
> -		ret = of_dma_configure(dev, dma_dev->of_node);
> -	} else if (has_acpi_companion(dma_dev)) {
> -		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev-
> >fwnode));
> +	if (dev->of_node) {
> +		ret = of_dma_configure(dev, dev->of_node);
> +	} else if (has_acpi_companion(dev)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
>  		if (attr != DEV_DMA_NOT_SUPPORTED)
>  			ret = acpi_dma_configure(dev, attr);
>  	}
> 
> -	if (bridge)
> -		pci_put_host_bridge_device(bridge);
> -
>  	return ret;
>  }
> 
> +int dma_configure(struct device *dev)
> +{
> +	if (dev->bus->dma_configure)
> +		return dev->bus->dma_configure(dev);

What if dma_common_configure() is called in case "bus->dma_configure" is not defined?

Thanks
-Bharat

> +
> +	return 0;
> +}
>  void dma_deconfigure(struct device *dev)  {
>  	of_dma_deconfigure(dev);
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c index
> f1bf7b3..d2d5891 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -1130,6 +1130,11 @@ int platform_pm_restore(struct device *dev)
> 
>  #endif /* CONFIG_HIBERNATE_CALLBACKS */
> 
> +static int platform_dma_configure(struct device *dev) {
> +	return dma_common_configure(dev);
> +}
> +
>  static const struct dev_pm_ops platform_dev_pm_ops = {
>  	.runtime_suspend = pm_generic_runtime_suspend,
>  	.runtime_resume = pm_generic_runtime_resume, @@ -1141,6 +1146,7
> @@ struct bus_type platform_bus_type = {
>  	.dev_groups	= platform_dev_groups,
>  	.match		= platform_match,
>  	.uevent		= platform_uevent,
> +	.dma_configure	= platform_dma_configure,
>  	.pm		= &platform_dev_pm_ops,
>  	.force_dma	= true,
>  };
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index
> 88a3558..fa9896d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev,
> struct device_driver *drv)
>  	return strcmp(dev_name(dev), drv->name) == 0;  }
> 
> +static int host1x_dma_configure(struct device *dev) {
> +	if (dev->of_node)
> +		return of_dma_configure(dev, dev->of_node);
> +
> +	return 0;
> +}
> +
>  static const struct dev_pm_ops host1x_device_pm_ops = {
>  	.suspend = pm_generic_suspend,
>  	.resume = pm_generic_resume,
> @@ -326,6 +334,7 @@ static int host1x_device_match(struct device *dev,
> struct device_driver *drv)  struct bus_type host1x_bus_type = {
>  	.name = "host1x",
>  	.match = host1x_device_match,
> +	.dma_configure	= host1x_dma_configure,
>  	.pm = &host1x_device_pm_ops,
>  	.force_dma = true,
>  };
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index
> 3bed6be..b473a4c 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -18,6 +18,8 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/suspend.h>
>  #include <linux/kexec.h>
> +#include <linux/of_device.h>
> +#include <linux/acpi.h>
>  #include "pci.h"
> 
>  struct pci_dynid {
> @@ -1522,6 +1524,35 @@ static int pci_bus_num_vf(struct device *dev)
>  	return pci_num_vf(to_pci_dev(dev));
>  }
> 
> +/**
> + * pci_dma_configure - Setup DMA configuration
> + * @dev: ptr to dev structure
> + *
> + * Function to update PCI devices's DMA configuration using the same
> + * info from the OF node or ACPI node of host bridge's parent (if any).
> + */
> +static int pci_dma_configure(struct device *dev) {
> +	struct device *bridge;
> +	enum dev_dma_attr attr;
> +	int ret = 0;
> +
> +	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> +
> +	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
> +	    bridge->parent->of_node) {
> +		ret = of_dma_configure(dev, bridge->parent->of_node);
> +	} else if (has_acpi_companion(bridge)) {
> +		attr = acpi_get_dma_attr(to_acpi_device_node(bridge-
> >fwnode));
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			ret = acpi_dma_configure(dev, attr);
> +	}
> +
> +	pci_put_host_bridge_device(bridge);
> +
> +	return ret;
> +}
> +
>  struct bus_type pci_bus_type = {
>  	.name		= "pci",
>  	.match		= pci_bus_match,
> @@ -1534,6 +1565,7 @@ struct bus_type pci_bus_type = {
>  	.drv_groups	= pci_drv_groups,
>  	.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
> b093405..1832d90 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type
> *,
>   * @resume:	Called to bring a device on this bus out of sleep mode.
>   * @num_vf:	Called to find out how many virtual functions a device on this
>   *		bus supports.
> + * @dma_configure:	Called to setup DMA configuration on a device on
> +			this bus.
>   * @pm:		Power management operations of this bus, callback the
> specific
>   *		device driver's pm-ops.
>   * @iommu_ops:  IOMMU specific operations for this bus, used to attach
> IOMMU @@ -130,6 +132,8 @@ struct bus_type {
> 
>  	int (*num_vf)(struct device *dev);
> 
> +	int (*dma_configure)(struct device *dev);
> +
>  	const struct dev_pm_ops *pm;
> 
>  	const struct iommu_ops *iommu_ops;
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index
> eb9eab4..c15986b 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -761,6 +761,7 @@ void *dma_mark_declared_memory_occupied(struct
> device *dev,  }  #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
> 
> +int dma_common_configure(struct device *dev);
>  #ifdef CONFIG_HAS_DMA
>  int dma_configure(struct device *dev);
>  void dma_deconfigure(struct device *dev);
> --
> 1.9.1
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 141+ messages in thread
* [v2,2/2] drivers: remove force dma flag from buses
  2018-03-21  6:55 ` Nipun Gupta
  (?)
@ 2018-03-21  6:55 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-21  6:55 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

With each bus implementing its own DMA configuration callback,
there is no need for bus to explicitly have force_dma in its
global structure. This patch modifies of_dma_configure API to
accept an input parameter which specifies if implicit DMA
configuration is required even when it is not described by the
firmware.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---

Changes in v2:
  - This is a new change suggested by Robin and Christoph
    and is added to the series.

 drivers/amba/bus.c            | 3 +--
 drivers/base/dma-mapping.c    | 4 ++--
 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/pci-driver.c      | 3 +--
 include/linux/device.h        | 4 ----
 include/linux/dma-mapping.h   | 2 +-
 include/linux/of_device.h     | 4 +++-
 12 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 2fa1e8b..1d58348 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -174,7 +174,7 @@ static int amba_pm_runtime_resume(struct device *dev)
 
 static int amba_dma_configure(struct device *dev)
 {
-	return dma_common_configure(dev);
+	return dma_common_configure(dev, true);
 }
 
 static const struct dev_pm_ops amba_pm = {
@@ -202,7 +202,6 @@ struct bus_type amba_bustype = {
 	.uevent		= amba_uevent,
 	.dma_configure	= amba_dma_configure,
 	.pm		= &amba_pm,
-	.force_dma	= true,
 };
 
 static int __init amba_init(void)
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 48f9af0..03f8584 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -335,13 +335,13 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
  * A bus can use this function in its 'dma_configure' callback, if
  * suitable for the bus.
  */
-int dma_common_configure(struct device *dev)
+int dma_common_configure(struct device *dev, bool force_dma)
 {
 	enum dev_dma_attr attr;
 	int ret = 0;
 
 	if (dev->of_node) {
-		ret = of_dma_configure(dev, dev->of_node);
+		ret = of_dma_configure(dev, dev->of_node, force_dma);
 	} else if (has_acpi_companion(dev)) {
 		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
 		if (attr != DEV_DMA_NOT_SUPPORTED)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index d2d5891..154707c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1132,7 +1132,7 @@ int platform_pm_restore(struct device *dev)
 
 static int platform_dma_configure(struct device *dev)
 {
-	return dma_common_configure(dev);
+	return dma_common_configure(dev, true);
 }
 
 static const struct dev_pm_ops platform_dev_pm_ops = {
@@ -1148,7 +1148,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 000c7019..d64edeb 100644
--- a/drivers/dma/qcom/hidma_mgmt.c
+++ b/drivers/dma/qcom/hidma_mgmt.c
@@ -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.
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index fa9896d..211eb6b 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -317,7 +317,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 static int host1x_dma_configure(struct device *dev)
 {
 	if (dev->of_node)
-		return of_dma_configure(dev, dev->of_node);
+		return of_dma_configure(dev, dev->of_node, true);
 
 	return 0;
 }
@@ -336,7 +336,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)
@@ -425,7 +424,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 064c818..33d8551 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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.
@@ -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;
@@ -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;
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 9a4f4246..895c83e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -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 {
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b473a4c..b15637a 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1541,7 +1541,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)) {
 		attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode));
 		if (attr != DEV_DMA_NOT_SUPPORTED)
@@ -1566,7 +1566,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 1832d90..92c530e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -98,8 +98,6 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @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
@@ -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);
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index c15986b..3dba3e6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -761,7 +761,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
 }
 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
 
-int dma_common_configure(struct device *dev);
+int dma_common_configure(struct device *dev, bool force_dma);
 #ifdef CONFIG_HAS_DMA
 int dma_configure(struct device *dev);
 void dma_deconfigure(struct device *dev);
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 8da5a1b..b0be3a5 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 */
 

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [v2,1/2] dma-mapping: move dma configuration to bus infrastructure
  2018-03-12 15:24 ` Nipun Gupta
  (?)
@ 2018-03-21  6:55 ` Nipun Gupta
  -1 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-21  6:55 UTC (permalink / raw)
  To: robin.murphy, hch, linux, gregkh, m.szyprowski
  Cc: bhelgaas, zajec5, andy.gross, david.brown, dan.j.williams,
	vinod.koul, thierry.reding, robh+dt, frowand.list,
	jarkko.sakkinen, rafael.j.wysocki, dmitry.torokhov, johan,
	msuchanek, linux-kernel, iommu, linux-wireless, linux-arm-msm,
	linux-soc, dmaengine, dri-devel, linux-tegra, devicetree,
	linux-pci, bharat.bhushan, leoyang.li, Nipun Gupta

It's bus specific aspect to map a given device on the bus and
relevant firmware description of its DMA configuration.
So, this change introduces '/dma_configure/' as bus callback
giving flexibility to busses for implementing its own dma
configuration function.

The change eases the addition of new busses w.r.t. adding the dma
configuration functionality.

This patch also updates the PCI, Platform, ACPI and host1x bus to
use new introduced callbacks.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 - The patches are based on the comments on:
   https://patchwork.kernel.org/patch/10259087/

Changes in v2:
  - Do not have dma_deconfigure callback
  - Have '/dma_common_configure/' API to provide a common DMA
    configuration which can be used by busses if it suits them.
  - Platform and ACPI bus to use '/dma_common_configure/' in
    '/dma_configure/' callback.
  - Updated commit message
  - Updated pci_dma_configure API with changes suggested by Robin

 drivers/amba/bus.c          |  7 +++++++
 drivers/base/dma-mapping.c  | 35 +++++++++++++++--------------------
 drivers/base/platform.c     |  6 ++++++
 drivers/gpu/host1x/bus.c    |  9 +++++++++
 drivers/pci/pci-driver.c    | 32 ++++++++++++++++++++++++++++++++
 include/linux/device.h      |  4 ++++
 include/linux/dma-mapping.h |  1 +
 7 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 594c228..2fa1e8b 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -20,6 +20,7 @@
 #include <linux/sizes.h>
 #include <linux/limits.h>
 #include <linux/clk/clk-conf.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/irq.h>
 
@@ -171,6 +172,11 @@ static int amba_pm_runtime_resume(struct device *dev)
 }
 #endif /* CONFIG_PM */
 
+static int amba_dma_configure(struct device *dev)
+{
+	return dma_common_configure(dev);
+}
+
 static const struct dev_pm_ops amba_pm = {
 	.suspend	= pm_generic_suspend,
 	.resume		= pm_generic_resume,
@@ -194,6 +200,7 @@ struct bus_type amba_bustype = {
 	.dev_groups	= amba_dev_groups,
 	.match		= amba_match,
 	.uevent		= amba_uevent,
+	.dma_configure	= amba_dma_configure,
 	.pm		= &amba_pm,
 	.force_dma	= true,
 };
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 3b11835..48f9af0 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -331,38 +331,33 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
 #endif
 
 /*
- * Common configuration to enable DMA API use for a device
+ * Common configuration to enable DMA API use for a device.
+ * A bus can use this function in its 'dma_configure' callback, if
+ * suitable for the bus.
  */
-#include <linux/pci.h>
-
-int dma_configure(struct device *dev)
+int dma_common_configure(struct device *dev)
 {
-	struct device *bridge = NULL, *dma_dev = dev;
 	enum dev_dma_attr attr;
 	int ret = 0;
 
-	if (dev_is_pci(dev)) {
-		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
-		dma_dev = bridge;
-		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
-		    dma_dev->parent->of_node)
-			dma_dev = dma_dev->parent;
-	}
-
-	if (dma_dev->of_node) {
-		ret = of_dma_configure(dev, dma_dev->of_node);
-	} else if (has_acpi_companion(dma_dev)) {
-		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
+	if (dev->of_node) {
+		ret = of_dma_configure(dev, dev->of_node);
+	} else if (has_acpi_companion(dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
 		if (attr != DEV_DMA_NOT_SUPPORTED)
 			ret = acpi_dma_configure(dev, attr);
 	}
 
-	if (bridge)
-		pci_put_host_bridge_device(bridge);
-
 	return ret;
 }
 
+int dma_configure(struct device *dev)
+{
+	if (dev->bus->dma_configure)
+		return dev->bus->dma_configure(dev);
+
+	return 0;
+}
 void dma_deconfigure(struct device *dev)
 {
 	of_dma_deconfigure(dev);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b3..d2d5891 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1130,6 +1130,11 @@ int platform_pm_restore(struct device *dev)
 
 #endif /* CONFIG_HIBERNATE_CALLBACKS */
 
+static int platform_dma_configure(struct device *dev)
+{
+	return dma_common_configure(dev);
+}
+
 static const struct dev_pm_ops platform_dev_pm_ops = {
 	.runtime_suspend = pm_generic_runtime_suspend,
 	.runtime_resume = pm_generic_runtime_resume,
@@ -1141,6 +1146,7 @@ struct bus_type platform_bus_type = {
 	.dev_groups	= platform_dev_groups,
 	.match		= platform_match,
 	.uevent		= platform_uevent,
+	.dma_configure	= platform_dma_configure,
 	.pm		= &platform_dev_pm_ops,
 	.force_dma	= true,
 };
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 88a3558..fa9896d 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 	return strcmp(dev_name(dev), drv->name) == 0;
 }
 
+static int host1x_dma_configure(struct device *dev)
+{
+	if (dev->of_node)
+		return of_dma_configure(dev, dev->of_node);
+
+	return 0;
+}
+
 static const struct dev_pm_ops host1x_device_pm_ops = {
 	.suspend = pm_generic_suspend,
 	.resume = pm_generic_resume,
@@ -326,6 +334,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
 struct bus_type host1x_bus_type = {
 	.name = "host1x",
 	.match = host1x_device_match,
+	.dma_configure	= host1x_dma_configure,
 	.pm = &host1x_device_pm_ops,
 	.force_dma = true,
 };
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 3bed6be..b473a4c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -18,6 +18,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
 #include <linux/kexec.h>
+#include <linux/of_device.h>
+#include <linux/acpi.h>
 #include "pci.h"
 
 struct pci_dynid {
@@ -1522,6 +1524,35 @@ static int pci_bus_num_vf(struct device *dev)
 	return pci_num_vf(to_pci_dev(dev));
 }
 
+/**
+ * pci_dma_configure - Setup DMA configuration
+ * @dev: ptr to dev structure
+ *
+ * Function to update PCI devices's DMA configuration using the same
+ * info from the OF node or ACPI node of host bridge's parent (if any).
+ */
+static int pci_dma_configure(struct device *dev)
+{
+	struct device *bridge;
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
+
+	if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
+	    bridge->parent->of_node) {
+		ret = of_dma_configure(dev, bridge->parent->of_node);
+	} else if (has_acpi_companion(bridge)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	pci_put_host_bridge_device(bridge);
+
+	return ret;
+}
+
 struct bus_type pci_bus_type = {
 	.name		= "pci",
 	.match		= pci_bus_match,
@@ -1534,6 +1565,7 @@ struct bus_type pci_bus_type = {
 	.drv_groups	= pci_drv_groups,
 	.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 b093405..1832d90 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -88,6 +88,8 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @resume:	Called to bring a device on this bus out of sleep mode.
  * @num_vf:	Called to find out how many virtual functions a device on this
  *		bus supports.
+ * @dma_configure:	Called to setup DMA configuration on a device on
+			this bus.
  * @pm:		Power management operations of this bus, callback the specific
  *		device driver's pm-ops.
  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
@@ -130,6 +132,8 @@ struct bus_type {
 
 	int (*num_vf)(struct device *dev);
 
+	int (*dma_configure)(struct device *dev);
+
 	const struct dev_pm_ops *pm;
 
 	const struct iommu_ops *iommu_ops;
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4..c15986b 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -761,6 +761,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
 }
 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
 
+int dma_common_configure(struct device *dev);
 #ifdef CONFIG_HAS_DMA
 int dma_configure(struct device *dev);
 void dma_deconfigure(struct device *dev);

^ permalink raw reply related	[flat|nested] 141+ messages in thread
* [PATCH] dma-mapping: move dma configuration to bus infrastructure
@ 2018-03-12 15:24 ` Nipun Gupta
  0 siblings, 0 replies; 141+ messages in thread
From: Nipun Gupta @ 2018-03-12 15:24 UTC (permalink / raw)
  To: hch, robin.murphy, linux, gregkh, m.szyprowski, bhelgaas
  Cc: dmitry.torokhov, rafael.j.wysocki, jarkko.sakkinen,
	linus.walleij, johan, msuchanek, linux-kernel, iommu, linux-pci,
	Nipun Gupta

The change introduces 'dma_configure' & 'dma_deconfigure'as
bus callback functions so each bus can choose to implement
its own dma configuration function.
This eases the addition of new busses w.r.t. adding the dma
configuration functionality.

The change also updates the PCI, Platform and ACPI bus to use
new introduced callbacks.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 - This patch is based on the comments on:
   https://patchwork.kernel.org/patch/10259087/
 - I have validated for PCI and platform, but not for AMBA as I
   do not have infrastructure to validate it.
   Can anyone please validate them on AMBA?

 drivers/amba/bus.c          | 38 ++++++++++++++++++++++++-----
 drivers/base/dd.c           | 14 +++++++----
 drivers/base/dma-mapping.c  | 41 -------------------------------
 drivers/base/platform.c     | 36 ++++++++++++++++++++++-----
 drivers/pci/pci-driver.c    | 59 ++++++++++++++++++++++++++++++++++++---------
 include/linux/device.h      |  6 +++++
 include/linux/dma-mapping.h | 12 ---------
 7 files changed, 124 insertions(+), 82 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 594c228..58241d2 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -20,6 +20,8 @@
 #include <linux/sizes.h>
 #include <linux/limits.h>
 #include <linux/clk/clk-conf.h>
+#include <linux/acpi.h>
+#include <linux/of_device.h>
 
 #include <asm/irq.h>
 
@@ -171,6 +173,28 @@ static int amba_pm_runtime_resume(struct device *dev)
 }
 #endif /* CONFIG_PM */
 
+int amba_dma_configure(struct device *dev)
+{
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	if (dev->of_node) {
+		ret = of_dma_configure(dev, dev->of_node);
+	} else if (has_acpi_companion(dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	return ret;
+}
+
+void amba_dma_deconfigure(struct device *dev)
+{
+	of_dma_deconfigure(dev);
+	acpi_dma_deconfigure(dev);
+}
+
 static const struct dev_pm_ops amba_pm = {
 	.suspend	= pm_generic_suspend,
 	.resume		= pm_generic_resume,
@@ -190,12 +214,14 @@ static int amba_pm_runtime_resume(struct device *dev)
  * so we call the bus "amba".
  */
 struct bus_type amba_bustype = {
-	.name		= "amba",
-	.dev_groups	= amba_dev_groups,
-	.match		= amba_match,
-	.uevent		= amba_uevent,
-	.pm		= &amba_pm,
-	.force_dma	= true,
+	.name			= "amba",
+	.dev_groups		= amba_dev_groups,
+	.match			= amba_match,
+	.uevent			= amba_uevent,
+	.pm			= &amba_pm,
+	.dma_configure		= amba_dma_configure,
+	.dma_deconfigure	= amba_dma_deconfigure,
+	.force_dma		= true,
 };
 
 static int __init amba_init(void)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index de6fd09..f124f3f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -421,9 +421,11 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 	if (ret)
 		goto pinctrl_bind_failed;
 
-	ret = dma_configure(dev);
-	if (ret)
-		goto dma_failed;
+	if (dev->bus->dma_configure) {
+		ret = dev->bus->dma_configure(dev);
+		if (ret)
+			goto dma_failed;
+	}
 
 	if (driver_sysfs_add(dev)) {
 		printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
@@ -486,7 +488,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 	goto done;
 
 probe_failed:
-	dma_deconfigure(dev);
+	if (dev->bus->dma_deconfigure)
+		dev->bus->dma_deconfigure(dev);
 dma_failed:
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -895,7 +898,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
 			drv->remove(dev);
 
 		device_links_driver_cleanup(dev);
-		dma_deconfigure(dev);
+		if (dev->bus->dma_deconfigure)
+			dev->bus->dma_deconfigure(dev);
 
 		devres_release_all(dev);
 		dev->driver = NULL;
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 3b11835..f16bd49 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -6,11 +6,9 @@
  * Copyright (c) 2006  Tejun Heo <teheo@suse.de>
  */
 
-#include <linux/acpi.h>
 #include <linux/dma-mapping.h>
 #include <linux/export.h>
 #include <linux/gfp.h>
-#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 
@@ -329,42 +327,3 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
 	vunmap(cpu_addr);
 }
 #endif
-
-/*
- * Common configuration to enable DMA API use for a device
- */
-#include <linux/pci.h>
-
-int dma_configure(struct device *dev)
-{
-	struct device *bridge = NULL, *dma_dev = dev;
-	enum dev_dma_attr attr;
-	int ret = 0;
-
-	if (dev_is_pci(dev)) {
-		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
-		dma_dev = bridge;
-		if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
-		    dma_dev->parent->of_node)
-			dma_dev = dma_dev->parent;
-	}
-
-	if (dma_dev->of_node) {
-		ret = of_dma_configure(dev, dma_dev->of_node);
-	} else if (has_acpi_companion(dma_dev)) {
-		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
-		if (attr != DEV_DMA_NOT_SUPPORTED)
-			ret = acpi_dma_configure(dev, attr);
-	}
-
-	if (bridge)
-		pci_put_host_bridge_device(bridge);
-
-	return ret;
-}
-
-void dma_deconfigure(struct device *dev)
-{
-	of_dma_deconfigure(dev);
-	acpi_dma_deconfigure(dev);
-}
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b3..adf94eb 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1130,6 +1130,28 @@ int platform_pm_restore(struct device *dev)
 
 #endif /* CONFIG_HIBERNATE_CALLBACKS */
 
+int platform_dma_configure(struct device *dev)
+{
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	if (dev->of_node) {
+		ret = of_dma_configure(dev, dev->of_node);
+	} else if (has_acpi_companion(dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	return ret;
+}
+
+void platform_dma_deconfigure(struct device *dev)
+{
+	of_dma_deconfigure(dev);
+	acpi_dma_deconfigure(dev);
+}
+
 static const struct dev_pm_ops platform_dev_pm_ops = {
 	.runtime_suspend = pm_generic_runtime_suspend,
 	.runtime_resume = pm_generic_runtime_resume,
@@ -1137,12 +1159,14 @@ int platform_pm_restore(struct device *dev)
 };
 
 struct bus_type platform_bus_type = {
-	.name		= "platform",
-	.dev_groups	= platform_dev_groups,
-	.match		= platform_match,
-	.uevent		= platform_uevent,
-	.pm		= &platform_dev_pm_ops,
-	.force_dma	= true,
+	.name			= "platform",
+	.dev_groups		= platform_dev_groups,
+	.match			= platform_match,
+	.uevent			= platform_uevent,
+	.pm			= &platform_dev_pm_ops,
+	.dma_configure		= platform_dma_configure,
+	.dma_deconfigure	= platform_dma_deconfigure,
+	.force_dma		= true,
 };
 EXPORT_SYMBOL_GPL(platform_bus_type);
 
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 3bed6be..4a77814 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -18,6 +18,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
 #include <linux/kexec.h>
+#include <linux/acpi.h>
+#include <linux/of_device.h>
 #include "pci.h"
 
 struct pci_dynid {
@@ -1522,19 +1524,52 @@ static int pci_bus_num_vf(struct device *dev)
 	return pci_num_vf(to_pci_dev(dev));
 }
 
+int pci_dma_configure(struct device *dev)
+{
+	struct device *bridge, *dma_dev;
+	enum dev_dma_attr attr;
+	int ret = 0;
+
+	bridge = pci_get_host_bridge_device(to_pci_dev(dev));
+	dma_dev = bridge;
+	if (IS_ENABLED(CONFIG_OF) && dma_dev->parent &&
+	    dma_dev->parent->of_node)
+		dma_dev = dma_dev->parent;
+
+	if (dma_dev->of_node) {
+		ret = of_dma_configure(dev, dma_dev->of_node);
+	} else if (has_acpi_companion(dma_dev)) {
+		attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			ret = acpi_dma_configure(dev, attr);
+	}
+
+	pci_put_host_bridge_device(bridge);
+
+	return ret;
+}
+
+void pci_dma_deconfigure(struct device *dev)
+{
+	of_dma_deconfigure(dev);
+	acpi_dma_deconfigure(dev);
+}
+
 struct bus_type pci_bus_type = {
-	.name		= "pci",
-	.match		= pci_bus_match,
-	.uevent		= pci_uevent,
-	.probe		= pci_device_probe,
-	.remove		= pci_device_remove,
-	.shutdown	= pci_device_shutdown,
-	.dev_groups	= pci_dev_groups,
-	.bus_groups	= pci_bus_groups,
-	.drv_groups	= pci_drv_groups,
-	.pm		= PCI_PM_OPS_PTR,
-	.num_vf		= pci_bus_num_vf,
-	.force_dma	= true,
+	.name			= "pci",
+	.match			= pci_bus_match,
+	.uevent			= pci_uevent,
+	.probe			= pci_device_probe,
+	.remove			= pci_device_remove,
+	.shutdown		= pci_device_shutdown,
+	.dev_groups		= pci_dev_groups,
+	.bus_groups		= pci_bus_groups,
+	.drv_groups		= pci_drv_groups,
+	.pm			= PCI_PM_OPS_PTR,
+	.num_vf			= pci_bus_num_vf,
+	.dma_configure		= pci_dma_configure,
+	.dma_deconfigure	= pci_dma_deconfigure,
+	.force_dma		= true,
 };
 EXPORT_SYMBOL(pci_bus_type);
 
diff --git a/include/linux/device.h b/include/linux/device.h
index b093405..9b2dcf6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -88,6 +88,9 @@ extern int __must_check bus_create_file(struct bus_type *,
  * @resume:	Called to bring a device on this bus out of sleep mode.
  * @num_vf:	Called to find out how many virtual functions a device on this
  *		bus supports.
+ * @dma_configure:	Called to setup DMA configuration on a device on
+			this bus.
+ * @dma_deconfigure:	Called to tear down the DMA configuration.
  * @pm:		Power management operations of this bus, callback the specific
  *		device driver's pm-ops.
  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
@@ -130,6 +133,9 @@ struct bus_type {
 
 	int (*num_vf)(struct device *dev);
 
+	int (*dma_configure)(struct device *dev);
+	void (*dma_deconfigure)(struct device *dev);
+
 	const struct dev_pm_ops *pm;
 
 	const struct iommu_ops *iommu_ops;
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4..039224b 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -761,18 +761,6 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
 }
 #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */
 
-#ifdef CONFIG_HAS_DMA
-int dma_configure(struct device *dev);
-void dma_deconfigure(struct device *dev);
-#else
-static inline int dma_configure(struct device *dev)
-{
-	return 0;
-}
-
-static inline void dma_deconfigure(struct device *dev) {}
-#endif
-
 /*
  * Managed DMA API
  */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 141+ messages in thread

end of thread, other threads:[~2018-05-03 16:36 UTC | newest]

Thread overview: 141+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 15:13 [v2,2/2] drivers: remove force dma flag from buses Nipun Gupta
2018-03-22 15:13 ` [PATCH v2 2/2] " Nipun Gupta
2018-03-22 15:13 ` Nipun Gupta
2018-03-22 15:13 ` Nipun Gupta
  -- strict thread matches above, loose matches on Subject: below --
2018-05-03 16:36 [v4,2/2] " Vinod Koul
2018-05-03 16:36 ` [PATCH v4 2/2] " Vinod Koul
2018-05-03 16:36 ` Vinod Koul
2018-05-03 12:21 [v4,1/2] dma-mapping: move dma configuration to bus infrastructure Christoph Hellwig
2018-05-03 12:21 ` [PATCH v4 1/2] " Christoph Hellwig
2018-05-03 12:21 ` Christoph Hellwig
2018-05-03 12:21 [v4,1/2] " Christoph Hellwig
2018-05-03 12:21 ` [PATCH v4 1/2] " Christoph Hellwig
2018-05-03 12:21 ` Christoph Hellwig
2018-05-01 12:34 [v4,2/2] drivers: remove force dma flag from buses Rob Herring
2018-05-01 12:34 ` [PATCH v4 2/2] " Rob Herring
2018-05-01 12:34 ` Rob Herring
2018-04-30 10:41 [v4,1/2] dma-mapping: move dma configuration to bus infrastructure Thierry Reding
2018-04-30 10:41 ` [PATCH v4 1/2] " Thierry Reding
2018-04-30 10:41 ` Thierry Reding
2018-04-28  2:51 [v4,2/2] drivers: remove force dma flag from buses Nipun Gupta
2018-04-28  2:51 ` [PATCH v4 2/2] " Nipun Gupta
2018-04-28  2:51 ` Nipun Gupta
2018-04-28  2:51 [v4,1/2] dma-mapping: move dma configuration to bus infrastructure Nipun Gupta
2018-04-28  2:51 ` [PATCH v4 1/2] " Nipun Gupta
2018-04-28  2:51 ` Nipun Gupta
2018-04-27 17:10 [v3,1/2] " Nipun Gupta
2018-04-27 17:10 ` [PATCH v3 1/2] " Nipun Gupta
2018-04-27 17:10 ` Nipun Gupta
2018-04-27 17:10 ` Nipun Gupta
2018-04-23 12:56 [v3,1/2] " Christoph Hellwig
2018-04-23 12:56 ` [PATCH v3 1/2] " Christoph Hellwig
2018-04-23 12:56 ` Christoph Hellwig
2018-04-23 12:56 [v3,1/2] " Christoph Hellwig
2018-04-23 12:56 ` [PATCH v3 1/2] " Christoph Hellwig
2018-04-23 12:56 ` Christoph Hellwig
2018-04-10 19:21 [v3,2/2] drivers: remove force dma flag from buses Bjorn Helgaas
2018-04-10 19:21 ` [PATCH v3 2/2] " Bjorn Helgaas
2018-04-10 19:21 ` Bjorn Helgaas
2018-04-10 19:20 [v3,1/2] dma-mapping: move dma configuration to bus infrastructure Bjorn Helgaas
2018-04-10 19:20 ` [PATCH v3 1/2] " Bjorn Helgaas
2018-04-10 19:20 ` Bjorn Helgaas
2018-04-09 20:27 [v3,2/2] drivers: remove force dma flag from buses Rob Herring
2018-04-09 20:27 ` [PATCH v3 2/2] " Rob Herring
2018-04-09 20:27 ` Rob Herring
2018-03-30  7:54 [v3,2/2] " Nipun Gupta
2018-03-30  7:54 ` [PATCH v3 2/2] " Nipun Gupta
2018-03-30  7:54 ` Nipun Gupta
2018-03-30  7:54 ` Nipun Gupta
2018-03-30  7:54 [v3,1/2] dma-mapping: move dma configuration to bus infrastructure Nipun Gupta
2018-03-30  7:54 ` [PATCH v3 1/2] " Nipun Gupta
2018-03-30  7:54 ` Nipun Gupta
2018-03-30  7:54 ` Nipun Gupta
2018-03-24  9:25 [v2,1/2] " kbuild test robot
2018-03-24  9:25 ` [PATCH v2 1/2] " kbuild test robot
2018-03-24  9:25 ` kbuild test robot
2018-03-23 17:41 [v2,2/2] drivers: remove force dma flag from buses kbuild test robot
2018-03-23 17:41 ` [PATCH v2 2/2] " kbuild test robot
2018-03-23 17:41 ` kbuild test robot
2018-03-23 16:09 [v2,2/2] " kbuild test robot
2018-03-23 16:09 ` [PATCH v2 2/2] " kbuild test robot
2018-03-23 16:09 ` kbuild test robot
2018-03-22 15:05 [v2,1/2] dma-mapping: move dma configuration to bus infrastructure Nipun Gupta
2018-03-22 15:05 ` [PATCH v2 1/2] " Nipun Gupta
2018-03-22 15:05 ` Nipun Gupta
2018-03-22 15:05 ` Nipun Gupta
2018-03-22  8:19 [v2,2/2] drivers: remove force dma flag from buses Christoph Hellwig
2018-03-22  8:19 ` [PATCH v2 2/2] " Christoph Hellwig
2018-03-22  8:19 ` Christoph Hellwig
2018-03-22  8:17 [v2,1/2] dma-mapping: move dma configuration to bus infrastructure Christoph Hellwig
2018-03-22  8:17 ` [PATCH v2 1/2] " hch-jcswGhMUV9g
2018-03-22  8:17 ` hch
2018-03-22  8:15 [v2,1/2] " Christoph Hellwig
2018-03-22  8:15 ` [PATCH v2 1/2] " Christoph Hellwig
2018-03-22  8:15 ` Christoph Hellwig
2018-03-21 17:49 [v2,2/2] drivers: remove force dma flag from buses Greg Kroah-Hartman
2018-03-21 17:49 ` [PATCH v2 2/2] " Greg KH
2018-03-21 17:49 ` Greg KH
2018-03-21 16:28 [v2,2/2] " Nipun Gupta
2018-03-21 16:28 ` [PATCH v2 2/2] " Nipun Gupta
2018-03-21 16:28 ` Nipun Gupta
2018-03-21 16:28 ` Nipun Gupta
2018-03-21 16:13 [v2,1/2] dma-mapping: move dma configuration to bus infrastructure Nipun Gupta
2018-03-21 16:13 ` [PATCH v2 1/2] " Nipun Gupta
2018-03-21 16:13 ` Nipun Gupta
2018-03-21 16:13 ` Nipun Gupta
2018-03-21  9:35 [v2,2/2] drivers: remove force dma flag from buses Greg Kroah-Hartman
2018-03-21  9:35 ` [PATCH v2 2/2] " Greg KH
2018-03-21  9:35 ` Greg KH
2018-03-21  9:29 [v2,1/2] dma-mapping: move dma configuration to bus infrastructure Greg Kroah-Hartman
2018-03-21  9:29 ` [PATCH v2 1/2] " Greg KH
2018-03-21  9:29 ` Greg KH
2018-03-21  7:29 [v2,1/2] " Nipun Gupta
2018-03-21  7:29 ` [PATCH v2 1/2] " Nipun Gupta
2018-03-21  7:29 ` Nipun Gupta
2018-03-21  7:29 ` Nipun Gupta
2018-03-21  7:19 [v2,1/2] " Bharat Bhushan
2018-03-21  7:19 ` [PATCH v2 1/2] " Bharat Bhushan
2018-03-21  7:19 ` Bharat Bhushan
2018-03-21  7:19 ` Bharat Bhushan
2018-03-21  6:55 [v2,2/2] drivers: remove force dma flag from buses Nipun Gupta
2018-03-21  6:55 ` [PATCH v2 2/2] " Nipun Gupta
2018-03-21  6:55 ` Nipun Gupta
2018-03-21  6:55 [v2,1/2] dma-mapping: move dma configuration to bus infrastructure Nipun Gupta
2018-03-21  6:55 ` [PATCH v2 1/2] " Nipun Gupta
2018-03-21  6:55 ` Nipun Gupta
2018-03-12 15:24 [PATCH] " Nipun Gupta
2018-03-12 15:24 ` Nipun Gupta
2018-03-12 16:44 ` Sinan Kaya
2018-03-12 16:44   ` Sinan Kaya
2018-03-13  4:22   ` Nipun Gupta
2018-03-13  4:22     ` Nipun Gupta
2018-03-13  4:22     ` Nipun Gupta
2018-03-13  7:27     ` hch
2018-03-13  7:27       ` hch-jcswGhMUV9g
2018-03-13  7:34 ` Christoph Hellwig
2018-03-13  7:34   ` Christoph Hellwig
2018-03-13 15:59   ` Nipun Gupta
2018-03-13 15:59     ` Nipun Gupta
2018-03-13 15:59     ` Nipun Gupta
2018-03-14  9:03     ` Christoph Hellwig
2018-03-14  9:03       ` Christoph Hellwig
2018-03-13 11:35 ` Robin Murphy
2018-03-13 11:35   ` Robin Murphy
2018-03-13 16:11   ` Nipun Gupta
2018-03-13 16:11     ` Nipun Gupta
2018-03-13 16:11     ` Nipun Gupta
2018-03-14  9:02   ` Christoph Hellwig
2018-03-14  9:02     ` Christoph Hellwig
2018-03-13 21:53 ` kbuild test robot
2018-03-13 21:53   ` kbuild test robot
2018-03-13 21:53 ` [RFC PATCH] dma-mapping: platform_dma_configure() can be static kbuild test robot
2018-03-13 21:53   ` kbuild test robot
2018-03-14  5:48 ` [dma] 9a019f4251: BUG:unable_to_handle_kernel kernel test robot
2018-03-14  5:48   ` kernel test robot
2018-03-14  5:48   ` kernel test robot
2018-03-30  7:15 ` [PATCH] dma-mapping: move dma configuration to bus infrastructure Christoph Hellwig
2018-03-30  7:17   ` Nipun Gupta
2018-03-30  7:17     ` Nipun Gupta
2018-03-30  7:17     ` Nipun Gupta
2018-03-30  9:05   ` Greg KH
2018-03-30  9:05     ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.