Skip to contentSkip to conversation

A couple of DMA teardown fixes for 3.19

PATCH Superseded Will Deacon 2 participants 6 messages Jan 12, 2015 – Jan 13, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover A couple of DMA teardown fixes for 3.19

Hi all,

Here are a couple of DMA teardown fixes for 3.19. The first patch adds a call to of_dma_deconfigure on device destruction and the second patch fixes a redundant "Not attached" message on the console when a device without an IOMMU is destroyed on ARM.

I guess the second patch can go independently via rmk?

Will

Will Deacon (2):
of/platform: teardown DMA mappings on device destruction
ARM: dma-mapping: don't detach devices without an IOMMU during
teardown

 arch/arm/mm/dma-mapping.c | 5 ++++-
 drivers/of/platform.c     | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/2 of/platform: teardown DMA mappings on device destruction

Now that we can create and attach to IOMMU domains via of_dma_configure, make sure we give the architecture a chance to tear them down when a platform or amba device is destroyed.

---
 drivers/of/platform.c | 1 +
 1 file changed, 1 insertion(+)
drivers/of/platform.c +1 -0
index 5b33c6a21807..3f61d668ded7 100644
@@ -526,6 +526,7 @@ static int of_platform_device_destroy(struct device *dev, void *data)
 		amba_device_unregister(to_amba_device(dev));
 #endif
 
+	of_dma_deconfigure(dev);
 	of_node_clear_flag(dev->of_node, OF_POPULATED);
 	of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
 	return 0;
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/2 ARM: dma-mapping: don't detach devices without an IOMMU during teardown

In reply to Will Deacon

When tearing down the DMA ops for a device via of_dma_deconfigure, we unconditionally detach the device from its IOMMU domain. For devices that aren't actually behind an IOMMU, this produces a "Not attached" warning message on the console.

This patch changes the teardown code so that we don't detach from the IOMMU domain when there isn't an IOMMU dma mapping to start with.

---
 arch/arm/mm/dma-mapping.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +4 -1
index 7864797609b3..711c3d2802fb 100644
@@ -2023,7 +2023,10 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
 
 static void arm_teardown_iommu_dma_ops(struct device *dev)
 {
-	struct dma_iommu_mapping *mapping = dev->archdata.mapping;
+	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+
+	if (!mapping)
+		return;
 
 	arm_iommu_detach_device(dev);
 	arm_iommu_release_mapping(mapping);
Signature · 1 line
2.1.4
#3 lore raw

PATCH 2/2 ARM: dma-mapping: don't detach devices without an IOMMU during teardown

Hi Will,

Thank you for the patch.

Quoted 9 lines · On Monday 12 January 2015 17:23:33 Will Deacon wrote:

When tearing down the DMA ops for a device via of_dma_deconfigure, we unconditionally detach the device from its IOMMU domain. For devices that aren't actually behind an IOMMU, this produces a "Not attached" warning message on the console.

This patch changes the teardown code so that we don't detach from the IOMMU domain when there isn't an IOMMU dma mapping to start with.

I might have reported the problem, but I haven't repoerted it :-)

Quoted 10 lines
---
 arch/arm/mm/dma-mapping.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +0 -0
index 7864797609b3..711c3d2802fb 100644

arch/arm/mm/dma-mapping.c static bool arm_setup_iommu_dma_ops(struct device · line 2027

Quoted 6 lines
arch/arm/mm/dma-mapping.c +1 -1
@@ -2023,7 +2023,10 @@ static bool arm_setup_iommu_dma_ops(struct device
 *dev, u64 dma_base, u64 size,
 
 static void arm_teardown_iommu_dma_ops(struct device *dev)
 {
-	struct dma_iommu_mapping *mapping = dev->archdata.mapping;
+	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);

As the function is already protected by an #ifdef CONFIG_ARM_DMA_USE_IOMMU is there a specific reason for this change ?

Quoted 6 lines
arch/arm/mm/dma-mapping.c +3 -0
+
+	if (!mapping)
+		return;
 
 	arm_iommu_detach_device(dev);

arm_iommu_release_mapping(mapping);

Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

PATCH 2/2 ARM: dma-mapping: don't detach devices without an IOMMU during teardown

Quoted 6 lines · Laurent Pinchart
Quoted 5 lines · On Monday 12 January 2015 17:23:33 Will Deacon wrote:

When tearing down the DMA ops for a device via of_dma_deconfigure, we unconditionally detach the device from its IOMMU domain. For devices that aren't actually behind an IOMMU, this produces a "Not attached" warning message on the console.

Quoted 6 lines
Quoted 4 lines

This patch changes the teardown code so that we don't detach from the IOMMU domain when there isn't an IOMMU dma mapping to start with.

I might have reported the problem, but I haven't repoerted it :-)

D'oh, fat fingers. Sorry!

Quoted 12 lines
Quoted 12 lines
---
 arch/arm/mm/dma-mapping.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +0 -0
index 7864797609b3..711c3d2802fb 100644
@@ -2023,7 +2023,10 @@ static bool arm_setup_iommu_dma_ops(struct device
 *dev, u64 dma_base, u64 size,
 
Quoted 7 lines

arch/arm/mm/dma-mapping.c static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, · line 2026

Quoted 4 lines
arch/arm/mm/dma-mapping.c +1 -1
 static void arm_teardown_iommu_dma_ops(struct device *dev)
 {
-	struct dma_iommu_mapping *mapping = dev->archdata.mapping;
+	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);

As the function is already protected by an #ifdef CONFIG_ARM_DMA_USE_IOMMU is there a specific reason for this change ?

I just wanted to hide the archdata access, since we shouldn't really care where it's stored. I could do it as a seperate patch, but I was in the area...

Will

#5 lore raw

PATCH 2/2 ARM: dma-mapping: don't detach devices without an IOMMU during teardown

Hi Will,

Quoted 38 lines · On Tuesday 13 January 2015 15:24:45 Will Deacon wrote:
Quoted 6 lines · Laurent Pinchart
Quoted 5 lines · On Monday 12 January 2015 17:23:33 Will Deacon wrote:

When tearing down the DMA ops for a device via of_dma_deconfigure, we unconditionally detach the device from its IOMMU domain. For devices that aren't actually behind an IOMMU, this produces a "Not attached" warning message on the console.

Quoted 6 lines
Quoted 4 lines

This patch changes the teardown code so that we don't detach from the IOMMU domain when there isn't an IOMMU dma mapping to start with.

I might have reported the problem, but I haven't repoerted it :-)

D'oh, fat fingers. Sorry!

Quoted 13 lines
Quoted 13 lines

---

 arch/arm/mm/dma-mapping.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +0 -0
index 7864797609b3..711c3d2802fb 100644
@@ -2023,7 +2023,10 @@ static bool arm_setup_iommu_dma_ops(struct device
 *dev, u64 dma_base, u64 size,
 
Quoted 8 lines

arch/arm/mm/dma-mapping.c static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,

Quoted 5 lines
arch/arm/mm/dma-mapping.c +1 -1
 static void arm_teardown_iommu_dma_ops(struct device *dev)
 {
 
-	struct dma_iommu_mapping *mapping = dev->archdata.mapping;
+	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);

As the function is already protected by an #ifdef CONFIG_ARM_DMA_USE_IOMMU is there a specific reason for this change ?

Quoted 3 lines

I just wanted to hide the archdata access, since we shouldn't really care where it's stored. I could do it as a seperate patch, but I was in the area...

No issue about that, but you could then send another patch to replace all direct references to dev->archdata.mapping in the file.

Signature · 3 lines
Regards,

Laurent Pinchart