Skip to contentSkip to conversation

of: amba: use of_dma_configure for AMBA devices

PATCH New Robin Murphy 5 participants 9 messages Sep 17, 2014 – Sep 25, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

---
 drivers/of/platform.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/of/platform.c +3 -4
index 0197725..3b64d0b 100644
@@ -160,11 +160,10 @@ EXPORT_SYMBOL(of_device_alloc);
  * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event
  * to fix up DMA configuration.
  */
-static void of_dma_configure(struct platform_device *pdev)
+static void of_dma_configure(struct device *dev)
 {
 	u64 dma_addr, paddr, size;
 	int ret;
-	struct device *dev = &pdev->dev;
 
 	/*
 	 * Set default dma-mask to 32 bit. Drivers are expected to setup
@@ -229,7 +228,7 @@ static struct platform_device *of_platform_device_create_pdata(
 	if (!dev)
 		goto err_clear_flag;
 
-	of_dma_configure(dev);
+	of_dma_configure(&dev->dev);
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 
@@ -291,7 +290,6 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
 	}
 
 	/* setup generic device info */
-	dev->dev.coherent_dma_mask = ~0;
 	dev->dev.of_node = of_node_get(node);
 	dev->dev.parent = parent;
 	dev->dev.platform_data = platform_data;
@@ -299,6 +297,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);
 
 	/* Allow the HW Peripheral ID to be overridden */
 	prop = of_get_property(node, "arm,primecell-periphid", NULL);
Signature · 1 line
1.9.1
maintainer
#1 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It looks fine to me (and we could get rid of the AMBA bus hook on arm64 as well).

#2 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

In reply to Robin Murphy
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It would be great if the arm-soc guys can pick this up.

Will

Quoted 49 lines
---
 drivers/of/platform.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/of/platform.c +3 -4
index 0197725..3b64d0b 100644
@@ -160,11 +160,10 @@ EXPORT_SYMBOL(of_device_alloc);
  * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event
  * to fix up DMA configuration.
  */
-static void of_dma_configure(struct platform_device *pdev)
+static void of_dma_configure(struct device *dev)
 {
 	u64 dma_addr, paddr, size;
 	int ret;
-	struct device *dev = &pdev->dev;
 
 	/*
 	 * Set default dma-mask to 32 bit. Drivers are expected to setup
@@ -229,7 +228,7 @@ static struct platform_device *of_platform_device_create_pdata(
 	if (!dev)
 		goto err_clear_flag;
 
-	of_dma_configure(dev);
+	of_dma_configure(&dev->dev);
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 
@@ -291,7 +290,6 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
 	}
 
 	/* setup generic device info */
-	dev->dev.coherent_dma_mask = ~0;
 	dev->dev.of_node = of_node_get(node);
 	dev->dev.parent = parent;
 	dev->dev.platform_data = platform_data;
@@ -299,6 +297,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);
 
 	/* Allow the HW Peripheral ID to be overridden */
 	prop = of_get_property(node, "arm,primecell-periphid", NULL);
Signature · 1 line
1.9.1
#3 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 10 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Rob

#4 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 8 lines · Rob Herring
Quoted 7 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

Quoted 7 lines
Quoted 3 lines

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices get registered with their IOMMUs.

Will

#5 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Thanks Catalin/Will/Rob,

Quoted 11 lines · Will Deacon
Quoted 10 lines · Rob Herring
Quoted 9 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices get registered with their IOMMUs.

Noob question: Does that mean I should resend (with ACKs) to arm at kernel.org? (I wasn't entirely sure where this should go, hence just throwing at the list with CCs)

Robin.

Quoted 2 lines

Will

maintainer
#6 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 16 lines · Robin Murphy
Quoted 15 lines · Will Deacon
Quoted 14 lines · Rob Herring
Quoted 10 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices get registered with their IOMMUs.

Noob question: Does that mean I should resend (with ACKs) to arm at kernel.org? (I wasn't entirely sure where this should go, hence just throwing at the list with CCs)

If it is not part of a larger series you want to merge, Rob could pick it up (he could add the acks as well).

Alternatively, I can get it via the arm64 tree together with an additional patch removing the bus hooks in dma-mapping.c (maybe that's a better option if no-one objects).

Signature · 1 line
Catalin
maintainer
#7 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 26 lines · Catalin Marinas
Quoted 16 lines · Robin Murphy
Quoted 15 lines · Will Deacon
Quoted 14 lines · Rob Herring
Quoted 10 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices get registered with their IOMMUs.

Noob question: Does that mean I should resend (with ACKs) to arm at kernel.org? (I wasn't entirely sure where this should go, hence just throwing at the list with CCs)

Quoted 6 lines

If it is not part of a larger series you want to merge, Rob could pick it up (he could add the acks as well).

Alternatively, I can get it via the arm64 tree together with an additional patch removing the bus hooks in dma-mapping.c (maybe that's a better option if no-one objects).

So I plan to take this patch via the arm64 tree together with the patch below (after some more testing):

----8<----------------------------

Quoted 1 line

From 2189064795dc3fb4101e5c34d28c6b62b8a3bfd9 Mon Sep 17 00:00:00 2001

From: Catalin Marinas <[email protected]>
Date: Mon, 22 Sep 2014 11:48:31 +0100
Subject: [PATCH] arm64: Implement set_arch_dma_coherent_ops() to replace bus
notifiers

Commit 6ecba8eb51b7 (arm64: Use bus notifiers to set per-device coherent DMA ops) introduced bus notifiers to set the coherent dma ops based on the 'dma-coherent' DT property. Since the generic of_dma_configure() handles this property for platform and AMBA devices, replace the notifiers with set_arch_dma_coherent_ops().

---
 arch/arm64/include/asm/dma-mapping.h |  7 +++++++
 arch/arm64/mm/dma-mapping.c          | 31 -------------------------------
 2 files changed, 7 insertions(+), 31 deletions(-)
arch/arm64/include/asm/dma-mapping.h +7 -0
index dc82e52acdb3..adeae3f6f0fc 100644
@@ -52,6 +52,13 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
 	dev->archdata.dma_ops = ops;
 }
 
+static inline int set_arch_dma_coherent_ops(struct device *dev)
+{
+	set_dma_ops(dev, &coherent_swiotlb_dma_ops);
+	return 0;
+}
+#define set_arch_dma_coherent_ops	set_arch_dma_coherent_ops
+
 #include <asm-generic/dma-mapping-common.h>
 
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
arch/arm64/mm/dma-mapping.c +0 -31
index 4164c5ace9f8..d6ceb3df0047 100644
@@ -22,11 +22,8 @@
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/dma-contiguous.h>
-#include <linux/of.h>
-#include <linux/platform_device.h>
 #include <linux/vmalloc.h>
 #include <linux/swiotlb.h>
-#include <linux/amba/bus.h>
 
 #include <asm/cacheflush.h>
 
@@ -308,40 +305,12 @@ struct dma_map_ops coherent_swiotlb_dma_ops = {
 };
 EXPORT_SYMBOL(coherent_swiotlb_dma_ops);
 
-static int dma_bus_notifier(struct notifier_block *nb,
-			    unsigned long event, void *_dev)
-{
-	struct device *dev = _dev;
-
-	if (event != BUS_NOTIFY_ADD_DEVICE)
-		return NOTIFY_DONE;
-
-	if (of_property_read_bool(dev->of_node, "dma-coherent"))
-		set_dma_ops(dev, &coherent_swiotlb_dma_ops);
-
-	return NOTIFY_OK;
-}
-
-static struct notifier_block platform_bus_nb = {
-	.notifier_call = dma_bus_notifier,
-};
-
-static struct notifier_block amba_bus_nb = {
-	.notifier_call = dma_bus_notifier,
-};
-
 extern int swiotlb_late_init_with_default_size(size_t default_size);
 
 static int __init swiotlb_late_init(void)
 {
 	size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT);
 
-	/*
-	 * These must be registered before of_platform_populate().
-	 */
-	bus_register_notifier(&platform_bus_type, &platform_bus_nb);
-	bus_register_notifier(&amba_bustype, &amba_bus_nb);
-
 	dma_ops = &noncoherent_swiotlb_dma_ops;
 
 	return swiotlb_late_init_with_default_size(swiotlb_size);
#8 lore raw

PATCH 1/1 of: amba: use of_dma_configure for AMBA devices

Quoted 30 lines · Catalin Marinas
Quoted 29 lines · Catalin Marinas
Quoted 16 lines · Robin Murphy
Quoted 15 lines · Will Deacon
Quoted 14 lines · Rob Herring
Quoted 10 lines · Will Deacon
Quoted 5 lines · Robin Murphy

Commit 591c1e ("of: configure the platform device dma parameters) introduced a common mechanism to configure DMA from DT properties. AMBA devices created from DT can take advantage of this, too.

It would be great if the arm-soc guys can pick this up.

Is this a dependency for something else? If so,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices get registered with their IOMMUs.

Noob question: Does that mean I should resend (with ACKs) to arm at kernel.org? (I wasn't entirely sure where this should go, hence just throwing at the list with CCs)

If it is not part of a larger series you want to merge, Rob could pick it up (he could add the acks as well).

Quoted 6 lines
Quoted 3 lines

Alternatively, I can get it via the arm64 tree together with an additional patch removing the bus hooks in dma-mapping.c (maybe that's a better option if no-one objects).

So I plan to take this patch via the arm64 tree together with the patch below (after some more testing):

Sounds good to me. If you haven't already done so, please add

Arnd