linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
@ 2015-03-02 21:59 Murali Karicheri
  2015-03-02 21:59 ` [PATCH - V7] of/pci: Add of_pci_dma_configure() to update DMA configuration Murali Karicheri
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Murali Karicheri @ 2015-03-02 21:59 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, iommu, devicetree, bhelgaas
  Cc: Murali Karicheri, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann

Move of_dma_configure() to device.c so it can be re-used for PCI devices to
obtain DMA configuration from DT.  Also add a second argument so that for
PCI, the DT node of root bus host bridge can be used to obtain the DMA
configuration for the slave PCI device.

Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Russell King <linux@arm.linux.org.uk>
CC: Arnd Bergmann <arnd@arndb.de>
---
 - Based on the existing patch applied to arm-pci/pci/iommu for pci next (Bjorn)
 - Fixed the build issue reported on ARCH=x86_64  
 drivers/of/device.c       |   59 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/of/platform.c     |   58 ++------------------------------------------
 include/linux/of_device.h |    2 ++
 3 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index 46d6c75c..31a7875 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -2,6 +2,9 @@
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/of_iommu.h>
+#include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
@@ -66,6 +69,62 @@ int of_device_add(struct platform_device *ofdev)
 	return device_add(&ofdev->dev);
 }
 
+/**
+ * of_dma_configure - Setup DMA configuration
+ * @dev:	Device to apply DMA configuration
+ * @np:		Pointer to OF node having DMA configuration
+ *
+ * Try to get devices's DMA configuration from DT and update it
+ * accordingly.
+ *
+ * If platform code needs to use its own special DMA configuration, it
+ * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events
+ * to fix up DMA configuration.
+ */
+void of_dma_configure(struct device *dev, struct device_node *np)
+{
+	u64 dma_addr, paddr, size;
+	int ret;
+	bool coherent;
+	unsigned long offset;
+	struct iommu_ops *iommu;
+
+	/*
+	 * Set default dma-mask to 32 bit.  Drivers are expected to setup
+	 * the correct supported dma_mask.
+	 */
+	dev->coherent_dma_mask = DMA_BIT_MASK(32);
+
+	/*
+	 * Set it to coherent_dma_mask by default if the architecture
+	 * code has not set it.
+	 */
+	if (!dev->dma_mask)
+		dev->dma_mask = &dev->coherent_dma_mask;
+
+	ret = of_dma_get_range(np, &dma_addr, &paddr, &size);
+	if (ret < 0) {
+		dma_addr = offset = 0;
+		size = dev->coherent_dma_mask;
+	} else {
+		offset = PFN_DOWN(paddr - dma_addr);
+		dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset);
+	}
+
+	dev->dma_pfn_offset = offset;
+
+	coherent = of_dma_is_coherent(np);
+	dev_dbg(dev, "device is%sdma coherent\n",
+		coherent ? " " : " not ");
+
+	iommu = of_iommu_configure(dev, np);
+	dev_dbg(dev, "device is%sbehind an iommu\n",
+		iommu ? " " : " not ");
+
+	arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
+}
+EXPORT_SYMBOL_GPL(of_dma_configure);
+
 int of_device_register(struct platform_device *pdev)
 {
 	device_initialize(&pdev->dev);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 667c6f1..a01f57c 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -19,7 +19,6 @@
 #include <linux/slab.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
-#include <linux/of_iommu.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
@@ -150,59 +149,6 @@ struct platform_device *of_device_alloc(struct device_node *np,
 }
 EXPORT_SYMBOL(of_device_alloc);
 
-/**
- * of_dma_configure - Setup DMA configuration
- * @dev:	Device to apply DMA configuration
- *
- * Try to get devices's DMA configuration from DT and update it
- * accordingly.
- *
- * In case if platform code need to use own special DMA configuration,it
- * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event
- * to fix up DMA configuration.
- */
-static void of_dma_configure(struct device *dev)
-{
-	u64 dma_addr, paddr, size;
-	int ret;
-	bool coherent;
-	unsigned long offset;
-	struct iommu_ops *iommu;
-
-	/*
-	 * Set default dma-mask to 32 bit. Drivers are expected to setup
-	 * the correct supported dma_mask.
-	 */
-	dev->coherent_dma_mask = DMA_BIT_MASK(32);
-
-	/*
-	 * Set it to coherent_dma_mask by default if the architecture
-	 * code has not set it.
-	 */
-	if (!dev->dma_mask)
-		dev->dma_mask = &dev->coherent_dma_mask;
-
-	ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size);
-	if (ret < 0) {
-		dma_addr = offset = 0;
-		size = dev->coherent_dma_mask;
-	} else {
-		offset = PFN_DOWN(paddr - dma_addr);
-		dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset);
-	}
-	dev->dma_pfn_offset = offset;
-
-	coherent = of_dma_is_coherent(dev->of_node);
-	dev_dbg(dev, "device is%sdma coherent\n",
-		coherent ? " " : " not ");
-
-	iommu = of_iommu_configure(dev, dev->of_node);
-	dev_dbg(dev, "device is%sbehind an iommu\n",
-		iommu ? " " : " not ");
-
-	arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
-}
-
 static void of_dma_deconfigure(struct device *dev)
 {
 	arch_teardown_dma_ops(dev);
@@ -236,7 +182,7 @@ static struct platform_device *of_platform_device_create_pdata(
 
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
-	of_dma_configure(&dev->dev);
+	of_dma_configure(&dev->dev, dev->dev.of_node);
 
 	if (of_device_add(dev) != 0) {
 		of_dma_deconfigure(&dev->dev);
@@ -299,7 +245,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
 		dev_set_name(&dev->dev, "%s", bus_id);
 	else
 		of_device_make_bus_id(&dev->dev);
-	of_dma_configure(&dev->dev);
+	of_dma_configure(&dev->dev, dev->dev.of_node);
 
 	/* Allow the HW Peripheral ID to be overridden */
 	prop = of_get_property(node, "arm,primecell-periphid", NULL);
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ef37021..be70cb4 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -53,6 +53,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
 	return of_node_get(cpu_dev->of_node);
 }
 
+void of_dma_configure(struct device *dev, struct device_node *np);
 #else /* CONFIG_OF */
 
 static inline int of_driver_match_device(struct device *dev,
@@ -90,6 +91,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
 {
 	return NULL;
 }
+static inline void of_dma_configure(struct device *dev, struct device_node *np) { }
 #endif /* CONFIG_OF */
 
 #endif /* _LINUX_OF_DEVICE_H */
-- 
1.7.9.5


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

* [PATCH - V7] of/pci: Add of_pci_dma_configure() to update DMA configuration
  2015-03-02 21:59 [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Murali Karicheri
@ 2015-03-02 21:59 ` Murali Karicheri
  2015-03-03  3:43 ` [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Bjorn Helgaas
  2015-03-03 16:16 ` Rob Herring
  2 siblings, 0 replies; 9+ messages in thread
From: Murali Karicheri @ 2015-03-02 21:59 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, iommu, devicetree, bhelgaas
  Cc: Murali Karicheri, Joerg Roedel, Grant Likely, Russell King,
	Arnd Bergmann

Add of_pci_dma_configure() to allow updating the DMA configuration of the
PCI device using the configuration from DT of the parent of the root bridge
device.  Use the newly added APIs pci_get/put_host_bridge_device() for
implementing this.

Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Rob Herring <robh+dt@kernel.org>
Acked-by: Will Deacon <will.deacon@arm.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: Grant Likely <grant.likely@linaro.org>
CC: Russell King <linux@arm.linux.org.uk>
CC: Arnd Bergmann <arnd@arndb.de>
---
 - Based on the existing patch on arm-pci/pci/iommu for pci next (Bjorn)
 - Fixed build issue seen on ARCH=sparc
 drivers/of/of_pci.c    |   18 ++++++++++++++++++
 include/linux/of_pci.h |    3 +++
 2 files changed, 21 insertions(+)

diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 62426d8..86d3c38 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -2,6 +2,7 @@
 #include <linux/export.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_pci.h>
 #include <linux/slab.h>
 
@@ -116,6 +117,23 @@ int of_get_pci_domain_nr(struct device_node *node)
 }
 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr);
 
+/**
+ * of_pci_dma_configure - Setup DMA configuration
+ * @dev: ptr to pci_dev struct of the pci device
+ *
+ * Function to update PCI devices's DMA configuration using the same
+ * info from the OF node of root host bridge's parent.
+ */
+void of_pci_dma_configure(struct pci_dev *pci_dev)
+{
+	struct device *dev = &pci_dev->dev;
+	struct device *bridge = pci_get_host_bridge_device(pci_dev);
+
+	of_dma_configure(dev, bridge->parent->of_node);
+	pci_put_host_bridge_device(bridge);
+}
+EXPORT_SYMBOL_GPL(of_pci_dma_configure);
+
 #if defined(CONFIG_OF_ADDRESS)
 /**
  * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h
index ce0e5ab..29fd3fe 100644
--- a/include/linux/of_pci.h
+++ b/include/linux/of_pci.h
@@ -16,6 +16,7 @@ int of_pci_get_devfn(struct device_node *np);
 int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
 int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
 int of_get_pci_domain_nr(struct device_node *node);
+void of_pci_dma_configure(struct pci_dev *pci_dev);
 #else
 static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
 {
@@ -50,6 +51,8 @@ of_get_pci_domain_nr(struct device_node *node)
 {
 	return -1;
 }
+
+static inline void of_pci_dma_configure(struct pci_dev *pci_dev) { }
 #endif
 
 #if defined(CONFIG_OF_ADDRESS)
-- 
1.7.9.5


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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-02 21:59 [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Murali Karicheri
  2015-03-02 21:59 ` [PATCH - V7] of/pci: Add of_pci_dma_configure() to update DMA configuration Murali Karicheri
@ 2015-03-03  3:43 ` Bjorn Helgaas
  2015-03-03 14:58   ` Murali Karicheri
  2015-03-03 17:55   ` Murali Karicheri
  2015-03-03 16:16 ` Rob Herring
  2 siblings, 2 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2015-03-03  3:43 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann

On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri <m-karicheri2@ti.com> wrote:
> Move of_dma_configure() to device.c so it can be re-used for PCI devices to
> obtain DMA configuration from DT.  Also add a second argument so that for
> PCI, the DT node of root bus host bridge can be used to obtain the DMA
> configuration for the slave PCI device.
>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> Acked-by: Will Deacon <will.deacon@arm.com>
> CC: Joerg Roedel <joro@8bytes.org>
> CC: Grant Likely <grant.likely@linaro.org>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Russell King <linux@arm.linux.org.uk>
> CC: Arnd Bergmann <arnd@arndb.de>
> ---
>  - Based on the existing patch applied to arm-pci/pci/iommu for pci next (Bjorn)
>  - Fixed the build issue reported on ARCH=x86_64

Hi Murali,

Can you please repost the entire series with fixed patches?  It's
easier for me to reapply the whole thing at once than it is to keep
track of and fiddle with individual patches.

Bjorn

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-03  3:43 ` [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Bjorn Helgaas
@ 2015-03-03 14:58   ` Murali Karicheri
  2015-03-03 17:55   ` Murali Karicheri
  1 sibling, 0 replies; 9+ messages in thread
From: Murali Karicheri @ 2015-03-03 14:58 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann

On 03/02/2015 10:43 PM, Bjorn Helgaas wrote:
> On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri<m-karicheri2@ti.com>  wrote:
>> Move of_dma_configure() to device.c so it can be re-used for PCI devices to
>> obtain DMA configuration from DT.  Also add a second argument so that for
>> PCI, the DT node of root bus host bridge can be used to obtain the DMA
>> configuration for the slave PCI device.
>>
>> Tested-by: Suravee Suthikulpanit<Suravee.Suthikulpanit@amd.com>  (AMD Seattle)
>> Signed-off-by: Murali Karicheri<m-karicheri2@ti.com>
>> Signed-off-by: Bjorn Helgaas<bhelgaas@google.com>
>> Reviewed-by: Catalin Marinas<catalin.marinas@arm.com>
>> Acked-by: Will Deacon<will.deacon@arm.com>
>> CC: Joerg Roedel<joro@8bytes.org>
>> CC: Grant Likely<grant.likely@linaro.org>
>> CC: Rob Herring<robh+dt@kernel.org>
>> CC: Russell King<linux@arm.linux.org.uk>
>> CC: Arnd Bergmann<arnd@arndb.de>
>> ---
>>   - Based on the existing patch applied to arm-pci/pci/iommu for pci next (Bjorn)
>>   - Fixed the build issue reported on ARCH=x86_64
>
> Hi Murali,
>
> Can you please repost the entire series with fixed patches?  It's
> easier for me to reapply the whole thing at once than it is to keep
> track of and fiddle with individual patches.
>
> Bjorn
Ok Fine. Will post now.

Murali

-- 
Murali Karicheri
Linux Kernel, Texas Instruments

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-02 21:59 [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Murali Karicheri
  2015-03-02 21:59 ` [PATCH - V7] of/pci: Add of_pci_dma_configure() to update DMA configuration Murali Karicheri
  2015-03-03  3:43 ` [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Bjorn Helgaas
@ 2015-03-03 16:16 ` Rob Herring
  2 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2015-03-03 16:16 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: linux-arm-kernel, linux-kernel, Linux IOMMU, devicetree,
	Bjorn Helgaas, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann

On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri <m-karicheri2@ti.com> wrote:
> Move of_dma_configure() to device.c so it can be re-used for PCI devices to
> obtain DMA configuration from DT.  Also add a second argument so that for
> PCI, the DT node of root bus host bridge can be used to obtain the DMA
> configuration for the slave PCI device.
>
> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> Acked-by: Will Deacon <will.deacon@arm.com>
> CC: Joerg Roedel <joro@8bytes.org>
> CC: Grant Likely <grant.likely@linaro.org>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Russell King <linux@arm.linux.org.uk>
> CC: Arnd Bergmann <arnd@arndb.de>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  - Based on the existing patch applied to arm-pci/pci/iommu for pci next (Bjorn)
>  - Fixed the build issue reported on ARCH=x86_64
>  drivers/of/device.c       |   59 +++++++++++++++++++++++++++++++++++++++++++++
>  drivers/of/platform.c     |   58 ++------------------------------------------
>  include/linux/of_device.h |    2 ++
>  3 files changed, 63 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 46d6c75c..31a7875 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -2,6 +2,9 @@
>  #include <linux/kernel.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/of_address.h>
> +#include <linux/of_iommu.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> @@ -66,6 +69,62 @@ int of_device_add(struct platform_device *ofdev)
>         return device_add(&ofdev->dev);
>  }
>
> +/**
> + * of_dma_configure - Setup DMA configuration
> + * @dev:       Device to apply DMA configuration
> + * @np:                Pointer to OF node having DMA configuration
> + *
> + * Try to get devices's DMA configuration from DT and update it
> + * accordingly.
> + *
> + * If platform code needs to use its own special DMA configuration, it
> + * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events
> + * to fix up DMA configuration.
> + */
> +void of_dma_configure(struct device *dev, struct device_node *np)
> +{
> +       u64 dma_addr, paddr, size;
> +       int ret;
> +       bool coherent;
> +       unsigned long offset;
> +       struct iommu_ops *iommu;
> +
> +       /*
> +        * Set default dma-mask to 32 bit.  Drivers are expected to setup
> +        * the correct supported dma_mask.
> +        */
> +       dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +
> +       /*
> +        * Set it to coherent_dma_mask by default if the architecture
> +        * code has not set it.
> +        */
> +       if (!dev->dma_mask)
> +               dev->dma_mask = &dev->coherent_dma_mask;
> +
> +       ret = of_dma_get_range(np, &dma_addr, &paddr, &size);
> +       if (ret < 0) {
> +               dma_addr = offset = 0;
> +               size = dev->coherent_dma_mask;
> +       } else {
> +               offset = PFN_DOWN(paddr - dma_addr);
> +               dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset);
> +       }
> +
> +       dev->dma_pfn_offset = offset;
> +
> +       coherent = of_dma_is_coherent(np);
> +       dev_dbg(dev, "device is%sdma coherent\n",
> +               coherent ? " " : " not ");
> +
> +       iommu = of_iommu_configure(dev, np);
> +       dev_dbg(dev, "device is%sbehind an iommu\n",
> +               iommu ? " " : " not ");
> +
> +       arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
> +}
> +EXPORT_SYMBOL_GPL(of_dma_configure);
> +
>  int of_device_register(struct platform_device *pdev)
>  {
>         device_initialize(&pdev->dev);
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 667c6f1..a01f57c 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -19,7 +19,6 @@
>  #include <linux/slab.h>
>  #include <linux/of_address.h>
>  #include <linux/of_device.h>
> -#include <linux/of_iommu.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
> @@ -150,59 +149,6 @@ struct platform_device *of_device_alloc(struct device_node *np,
>  }
>  EXPORT_SYMBOL(of_device_alloc);
>
> -/**
> - * of_dma_configure - Setup DMA configuration
> - * @dev:       Device to apply DMA configuration
> - *
> - * Try to get devices's DMA configuration from DT and update it
> - * accordingly.
> - *
> - * In case if platform code need to use own special DMA configuration,it
> - * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event
> - * to fix up DMA configuration.
> - */
> -static void of_dma_configure(struct device *dev)
> -{
> -       u64 dma_addr, paddr, size;
> -       int ret;
> -       bool coherent;
> -       unsigned long offset;
> -       struct iommu_ops *iommu;
> -
> -       /*
> -        * Set default dma-mask to 32 bit. Drivers are expected to setup
> -        * the correct supported dma_mask.
> -        */
> -       dev->coherent_dma_mask = DMA_BIT_MASK(32);
> -
> -       /*
> -        * Set it to coherent_dma_mask by default if the architecture
> -        * code has not set it.
> -        */
> -       if (!dev->dma_mask)
> -               dev->dma_mask = &dev->coherent_dma_mask;
> -
> -       ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size);
> -       if (ret < 0) {
> -               dma_addr = offset = 0;
> -               size = dev->coherent_dma_mask;
> -       } else {
> -               offset = PFN_DOWN(paddr - dma_addr);
> -               dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset);
> -       }
> -       dev->dma_pfn_offset = offset;
> -
> -       coherent = of_dma_is_coherent(dev->of_node);
> -       dev_dbg(dev, "device is%sdma coherent\n",
> -               coherent ? " " : " not ");
> -
> -       iommu = of_iommu_configure(dev, dev->of_node);
> -       dev_dbg(dev, "device is%sbehind an iommu\n",
> -               iommu ? " " : " not ");
> -
> -       arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent);
> -}
> -
>  static void of_dma_deconfigure(struct device *dev)
>  {
>         arch_teardown_dma_ops(dev);
> @@ -236,7 +182,7 @@ static struct platform_device *of_platform_device_create_pdata(
>
>         dev->dev.bus = &platform_bus_type;
>         dev->dev.platform_data = platform_data;
> -       of_dma_configure(&dev->dev);
> +       of_dma_configure(&dev->dev, dev->dev.of_node);
>
>         if (of_device_add(dev) != 0) {
>                 of_dma_deconfigure(&dev->dev);
> @@ -299,7 +245,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
>                 dev_set_name(&dev->dev, "%s", bus_id);
>         else
>                 of_device_make_bus_id(&dev->dev);
> -       of_dma_configure(&dev->dev);
> +       of_dma_configure(&dev->dev, dev->dev.of_node);
>
>         /* Allow the HW Peripheral ID to be overridden */
>         prop = of_get_property(node, "arm,primecell-periphid", NULL);
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ef37021..be70cb4 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -53,6 +53,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
>         return of_node_get(cpu_dev->of_node);
>  }
>
> +void of_dma_configure(struct device *dev, struct device_node *np);
>  #else /* CONFIG_OF */
>
>  static inline int of_driver_match_device(struct device *dev,
> @@ -90,6 +91,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
>  {
>         return NULL;
>  }
> +static inline void of_dma_configure(struct device *dev, struct device_node *np) { }
>  #endif /* CONFIG_OF */
>
>  #endif /* _LINUX_OF_DEVICE_H */
> --
> 1.7.9.5
>

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-03  3:43 ` [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Bjorn Helgaas
  2015-03-03 14:58   ` Murali Karicheri
@ 2015-03-03 17:55   ` Murali Karicheri
  2015-03-03 20:53     ` Bjorn Helgaas
  1 sibling, 1 reply; 9+ messages in thread
From: Murali Karicheri @ 2015-03-03 17:55 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann

On 03/02/2015 10:43 PM, Bjorn Helgaas wrote:
> On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri<m-karicheri2@ti.com>  wrote:
>> Move of_dma_configure() to device.c so it can be re-used for PCI devices to
>> obtain DMA configuration from DT.  Also add a second argument so that for
>> PCI, the DT node of root bus host bridge can be used to obtain the DMA
>> configuration for the slave PCI device.
>>
>> Tested-by: Suravee Suthikulpanit<Suravee.Suthikulpanit@amd.com>  (AMD Seattle)
>> Signed-off-by: Murali Karicheri<m-karicheri2@ti.com>
>> Signed-off-by: Bjorn Helgaas<bhelgaas@google.com>
>> Reviewed-by: Catalin Marinas<catalin.marinas@arm.com>
>> Acked-by: Will Deacon<will.deacon@arm.com>
>> CC: Joerg Roedel<joro@8bytes.org>
>> CC: Grant Likely<grant.likely@linaro.org>
>> CC: Rob Herring<robh+dt@kernel.org>
>> CC: Russell King<linux@arm.linux.org.uk>
>> CC: Arnd Bergmann<arnd@arndb.de>
>> ---
>>   - Based on the existing patch applied to arm-pci/pci/iommu for pci next (Bjorn)
>>   - Fixed the build issue reported on ARCH=x86_64
>
> Hi Murali,
>
> Can you please repost the entire series with fixed patches?  It's
> easier for me to reapply the whole thing at once than it is to keep
> track of and fiddle with individual patches.
>
> Bjorn
Bjorn,

Ok. I have just posted v8 of the series including all patches.

FYI.
-- 
Murali Karicheri
Linux Kernel, Texas Instruments

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-03 17:55   ` Murali Karicheri
@ 2015-03-03 20:53     ` Bjorn Helgaas
  2015-03-03 22:54       ` Murali Karicheri
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2015-03-03 20:53 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann, linux-pci

[+cc linux-pci]

On Tue, Mar 3, 2015 at 11:55 AM, Murali Karicheri <m-karicheri2@ti.com> wrote:
> On 03/02/2015 10:43 PM, Bjorn Helgaas wrote:
>>
>> On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri<m-karicheri2@ti.com>
>> wrote:
>>>
>>> Move of_dma_configure() to device.c so it can be re-used for PCI devices
>>> to
>>> obtain DMA configuration from DT.  Also add a second argument so that for
>>> PCI, the DT node of root bus host bridge can be used to obtain the DMA
>>> configuration for the slave PCI device.
>>>
>>> Tested-by: Suravee Suthikulpanit<Suravee.Suthikulpanit@amd.com>  (AMD
>>> Seattle)
>>> Signed-off-by: Murali Karicheri<m-karicheri2@ti.com>
>>> Signed-off-by: Bjorn Helgaas<bhelgaas@google.com>
>>> Reviewed-by: Catalin Marinas<catalin.marinas@arm.com>
>>> Acked-by: Will Deacon<will.deacon@arm.com>
>>> CC: Joerg Roedel<joro@8bytes.org>
>>> CC: Grant Likely<grant.likely@linaro.org>
>>> CC: Rob Herring<robh+dt@kernel.org>
>>> CC: Russell King<linux@arm.linux.org.uk>
>>> CC: Arnd Bergmann<arnd@arndb.de>
>>> ---
>>>   - Based on the existing patch applied to arm-pci/pci/iommu for pci next
>>> (Bjorn)
>>>   - Fixed the build issue reported on ARCH=x86_64
>>
>>
>> Hi Murali,
>>
>> Can you please repost the entire series with fixed patches?  It's
>> easier for me to reapply the whole thing at once than it is to keep
>> track of and fiddle with individual patches.
>>
>> Bjorn
>
> Bjorn,
>
> Ok. I have just posted v8 of the series including all patches.

Thanks, I put them on a pci/murali-v8 branch for now.  I'm assuming
you want them to go through my tree.  In the cover letter, you
mentioned the "arm-pci iommu branch", so if that means you want them
via an ARM tree instead of mine, just let me know.  I assume the build
will be clean and I'll rename it back to pci/iommu.

Bjorn

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-03 20:53     ` Bjorn Helgaas
@ 2015-03-03 22:54       ` Murali Karicheri
  2015-03-19 15:02         ` Bjorn Helgaas
  0 siblings, 1 reply; 9+ messages in thread
From: Murali Karicheri @ 2015-03-03 22:54 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann, linux-pci

On 03/03/2015 03:53 PM, Bjorn Helgaas wrote:
> [+cc linux-pci]
>
> On Tue, Mar 3, 2015 at 11:55 AM, Murali Karicheri<m-karicheri2@ti.com>  wrote:
>> On 03/02/2015 10:43 PM, Bjorn Helgaas wrote:
>>>
>>> On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri<m-karicheri2@ti.com>
>>> wrote:
>>>>
>>>> Move of_dma_configure() to device.c so it can be re-used for PCI devices
>>>> to
>>>> obtain DMA configuration from DT.  Also add a second argument so that for
>>>> PCI, the DT node of root bus host bridge can be used to obtain the DMA
>>>> configuration for the slave PCI device.
>>>>
>>>> Tested-by: Suravee Suthikulpanit<Suravee.Suthikulpanit@amd.com>   (AMD
>>>> Seattle)
>>>> Signed-off-by: Murali Karicheri<m-karicheri2@ti.com>
>>>> Signed-off-by: Bjorn Helgaas<bhelgaas@google.com>
>>>> Reviewed-by: Catalin Marinas<catalin.marinas@arm.com>
>>>> Acked-by: Will Deacon<will.deacon@arm.com>
>>>> CC: Joerg Roedel<joro@8bytes.org>
>>>> CC: Grant Likely<grant.likely@linaro.org>
>>>> CC: Rob Herring<robh+dt@kernel.org>
>>>> CC: Russell King<linux@arm.linux.org.uk>
>>>> CC: Arnd Bergmann<arnd@arndb.de>
>>>> ---
>>>>    - Based on the existing patch applied to arm-pci/pci/iommu for pci next
>>>> (Bjorn)
>>>>    - Fixed the build issue reported on ARCH=x86_64
>>>
>>>
>>> Hi Murali,
>>>
>>> Can you please repost the entire series with fixed patches?  It's
>>> easier for me to reapply the whole thing at once than it is to keep
>>> track of and fiddle with individual patches.
>>>
>>> Bjorn
>>
>> Bjorn,
>>
>> Ok. I have just posted v8 of the series including all patches.
>
> Thanks, I put them on a pci/murali-v8 branch for now.  I'm assuming
> you want them to go through my tree.  In the cover letter, you
> mentioned the "arm-pci iommu branch", so if that means you want them
> via an ARM tree instead of mine, just let me know.  I assume the build
> will be clean and I'll rename it back to pci/iommu.

My bad. It should have beem pci/iommu. My remote was named arm-pci and 
hence the confusion. Please apply it to the pci/iommu branch.

Thanks

Murali
>
> Bjorn


-- 
Murali Karicheri
Linux Kernel, Texas Instruments

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

* Re: [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use
  2015-03-03 22:54       ` Murali Karicheri
@ 2015-03-19 15:02         ` Bjorn Helgaas
  0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2015-03-19 15:02 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: linux-arm, linux-kernel, open list:INTEL IOMMU (VT-d),
	devicetree, Joerg Roedel, Grant Likely, Rob Herring,
	Russell King, Arnd Bergmann, linux-pci

On Tue, Mar 03, 2015 at 05:54:25PM -0500, Murali Karicheri wrote:
> On 03/03/2015 03:53 PM, Bjorn Helgaas wrote:
> >[+cc linux-pci]
> >
> >On Tue, Mar 3, 2015 at 11:55 AM, Murali Karicheri<m-karicheri2@ti.com>  wrote:
> >>On 03/02/2015 10:43 PM, Bjorn Helgaas wrote:
> >>>
> >>>On Mon, Mar 2, 2015 at 3:59 PM, Murali Karicheri<m-karicheri2@ti.com>
> >>>wrote:
> >>>>
> >>>>Move of_dma_configure() to device.c so it can be re-used for PCI devices
> >>>>to
> >>>>obtain DMA configuration from DT.  Also add a second argument so that for
> >>>>PCI, the DT node of root bus host bridge can be used to obtain the DMA
> >>>>configuration for the slave PCI device.
> >>>>
> >>>>Tested-by: Suravee Suthikulpanit<Suravee.Suthikulpanit@amd.com>   (AMD
> >>>>Seattle)
> >>>>Signed-off-by: Murali Karicheri<m-karicheri2@ti.com>
> >>>>Signed-off-by: Bjorn Helgaas<bhelgaas@google.com>
> >>>>Reviewed-by: Catalin Marinas<catalin.marinas@arm.com>
> >>>>Acked-by: Will Deacon<will.deacon@arm.com>
> >>>>CC: Joerg Roedel<joro@8bytes.org>
> >>>>CC: Grant Likely<grant.likely@linaro.org>
> >>>>CC: Rob Herring<robh+dt@kernel.org>
> >>>>CC: Russell King<linux@arm.linux.org.uk>
> >>>>CC: Arnd Bergmann<arnd@arndb.de>
> >>>>---
> >>>>   - Based on the existing patch applied to arm-pci/pci/iommu for pci next
> >>>>(Bjorn)
> >>>>   - Fixed the build issue reported on ARCH=x86_64
> >>>
> >>>
> >>>Hi Murali,
> >>>
> >>>Can you please repost the entire series with fixed patches?  It's
> >>>easier for me to reapply the whole thing at once than it is to keep
> >>>track of and fiddle with individual patches.
> >>>
> >>>Bjorn
> >>
> >>Bjorn,
> >>
> >>Ok. I have just posted v8 of the series including all patches.
> >
> >Thanks, I put them on a pci/murali-v8 branch for now.  I'm assuming
> >you want them to go through my tree.  In the cover letter, you
> >mentioned the "arm-pci iommu branch", so if that means you want them
> >via an ARM tree instead of mine, just let me know.  I assume the build
> >will be clean and I'll rename it back to pci/iommu.
> 
> My bad. It should have beem pci/iommu. My remote was named arm-pci
> and hence the confusion. Please apply it to the pci/iommu branch.

Applied to pci/iommu for v4.1, thanks!

Bjorn

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

end of thread, other threads:[~2015-03-19 15:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 21:59 [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Murali Karicheri
2015-03-02 21:59 ` [PATCH - V7] of/pci: Add of_pci_dma_configure() to update DMA configuration Murali Karicheri
2015-03-03  3:43 ` [PATCH - v7] of: Move of_dma_configure() to device.c to help re-use Bjorn Helgaas
2015-03-03 14:58   ` Murali Karicheri
2015-03-03 17:55   ` Murali Karicheri
2015-03-03 20:53     ` Bjorn Helgaas
2015-03-03 22:54       ` Murali Karicheri
2015-03-19 15:02         ` Bjorn Helgaas
2015-03-03 16:16 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).