Skip to contentSkip to conversation

Fix dma_mapping_error for 32bit x86

PATCH Applied Thomas Bogendoerfer 4 participants 11 messages Nov 29, 2008 – Dec 1, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Fix dma_mapping_error for 32bit x86

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

---

include/asm-x86/dma-mapping.h renamed from linux-2.6.27.4/include/asm-x86/dma-mapping.h +2 -4
diff -ru orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h linux-2.6.27.4/include/asm-x86/dma-mapping.h
@@ -74,15 +74,13 @@
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#1 lore raw
Quoted 18 lines · On Sat, 29 Nov 2008 13:46:27 +0100 (CET) Thomas Bogendoerfer…

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

---

diff -ru orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h linux-2.6.27.4/include/asm-x86/dma-mapping.h

include/asm-x86/dma-mapping.h renamed from linux-2.6.27.4/include/asm-x86/dma-mapping.h +0 -2
@@ -74,15 +74,13 @@
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;

include/asm-x86/dma-mapping.h line 84

Quoted 10 lines
include/asm-x86/dma-mapping.h renamed from linux-2.6.27.4/include/asm-x86/dma-mapping.h +2 -2
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }

Surely, 2.6.27.4 needs this fix (and all the stable trees need this too, I think).

This can't be cleanly applied to the current git (dma-mapping.h was moved). How about just removing the ifdef? I think that it's clean a bit.

arch/x86/include/asm/dma-mapping.h +0 -4
index 7f225a4..dc22c07 100644
@@ -71,15 +71,11 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
 	return (dma_addr == bad_dma_address);
-#endif
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
Acked-by on v3 1/1
#2 lore raw
In reply to Thomas Bogendoerfer
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

Quoted 1 line
Quoted 27 lines

diff -ru orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h linux-2.6.27.4/include/asm-x86/dma-mapping.h

include/asm-x86/dma-mapping.h renamed from linux-2.6.27.4/include/asm-x86/dma-mapping.h +2 -5
@@ -74,15 +74,13 @@
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

Quoted 36 lines
Quoted 1 line
Quoted 23 lines

diff -ru orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h linux-2.6.27.4/include/asm-x86/dma-mapping.h

include/asm-x86/dma-mapping.h renamed from linux-2.6.27.4/include/asm-x86/dma-mapping.h +2 -5
@@ -74,15 +74,13 @@
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Acked-by FUJITA Tomonori
#4 lore raw
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 6 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

i have i queued up in x86/urgent, see below.

Ingo

-------------->

Quoted 1 line

From 7b1dedca42ac0d0d0be01e39d8461bb53a2389b3 Mon Sep 17 00:00:00 2001

From: Thomas Bogendoerfer <[email protected]>
Date: Sat, 29 Nov 2008 13:46:27 +0100
Subject: [PATCH] x86: fix dma_mapping_error for 32bit x86

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

---
 arch/x86/include/asm/dma-mapping.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/include/asm/dma-mapping.h +2 -4
index 7f225a4..097794f 100644
@@ -71,15 +71,13 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#5 lore raw
Quoted 28 lines · On Mon, 1 Dec 2008 13:55:01 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 8 lines
Quoted 6 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

i have i queued up in x86/urgent, see below.

As I wrote, just removing #ifdef is better since:

1) Xen people want swiotlb on X86_32. swiotlb uses ops->mapping_error so X86_32 also needs to check ops->mapping_error.

2) Removing #ifdef hack is always good.

But this patch fixes the bug and it works for now. And I think that Thomas tested it. So it's fine to commit this patch by me.

I'll send a patch to remove the ifdef on the top of this patch after this patch goes into mainline.

Quoted 46 lines

-------------->
From 7b1dedca42ac0d0d0be01e39d8461bb53a2389b3 Mon Sep 17 00:00:00 2001
From: Thomas Bogendoerfer <[email protected]>
Date: Sat, 29 Nov 2008 13:46:27 +0100
Subject: [PATCH] x86: fix dma_mapping_error for 32bit x86

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

---
 arch/x86/include/asm/dma-mapping.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/include/asm/dma-mapping.h +2 -5
index 7f225a4..097794f 100644
@@ -71,15 +71,13 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_32
-	return 0;
-#else
+#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
 #endif
+	return (dma_addr == bad_dma_address);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#6 lore raw
Quoted 42 lines · FUJITA Tomonori
Quoted 28 lines · On Mon, 1 Dec 2008 13:55:01 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 8 lines
Quoted 6 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

i have i queued up in x86/urgent, see below.

As I wrote, just removing #ifdef is better since:

Quoted 8 lines

1) Xen people want swiotlb on X86_32. swiotlb uses ops->mapping_error so X86_32 also needs to check ops->mapping_error.

2) Removing #ifdef hack is always good.

But this patch fixes the bug and it works for now. And I think that Thomas tested it. So it's fine to commit this patch by me.

yeah, i included the tested patch.

Quoted 2 lines

I'll send a patch to remove the ifdef on the top of this patch after this patch goes into mainline.

sure - or you can send it against tip/master straight away.

Ingo

#7 lore raw
Quoted 54 lines · On Mon, 1 Dec 2008 15:35:34 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 42 lines · FUJITA Tomonori
Quoted 28 lines · On Mon, 1 Dec 2008 13:55:01 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 8 lines
Quoted 6 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

i have i queued up in x86/urgent, see below.

As I wrote, just removing #ifdef is better since:

Quoted 8 lines

1) Xen people want swiotlb on X86_32. swiotlb uses ops->mapping_error so X86_32 also needs to check ops->mapping_error.

2) Removing #ifdef hack is always good.

But this patch fixes the bug and it works for now. And I think that Thomas tested it. So it's fine to commit this patch by me.

Quoted 6 lines

yeah, i included the tested patch.

Quoted 2 lines

I'll send a patch to remove the ifdef on the top of this patch after this patch goes into mainline.

sure - or you can send it against tip/master straight away.

Ok, here you are.

Note that this is for 2.6.29 (not 2.6.28).

=
From: FUJITA Tomonori <[email protected]>
Subject: [PATCH] x86: remove ifdef CONFIG_X86_64 in dma_mapping_error

This removes ifdef CONFIG_X86_64 in dma_mapping_error():

1) Xen people plan to use swiotlb on X86_32 for Dom0 support. swiotlb uses ops->mapping_error so X86_32 also needs to check ops->mapping_error.

2) Removing #ifdef hack is almost always a good thing.

---
 arch/x86/include/asm/dma-mapping.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/x86/include/asm/dma-mapping.h +0 -2
index ecf8eaf..40d155d 100644
@@ -72,12 +72,10 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
 /* Make sure we keep the same behaviour */
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-#ifdef CONFIG_X86_64
 	struct dma_mapping_ops *ops = get_dma_ops(dev);
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-#endif
 	return (dma_addr == bad_dma_address);
 }
 
Signature · 1 line
1.5.5.GIT
Applied
#8 lore raw
Quoted 59 lines · FUJITA Tomonori
Quoted 56 lines · On Mon, 1 Dec 2008 15:35:34 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 42 lines · FUJITA Tomonori
Quoted 28 lines · On Mon, 1 Dec 2008 13:55:01 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 8 lines
Quoted 6 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

As I already wrote, the current git needs a patch modified slightly:

http://marc.info/?l=linux-kernel&m=122797163405377&w=2

i have i queued up in x86/urgent, see below.

As I wrote, just removing #ifdef is better since:

Quoted 8 lines

1) Xen people want swiotlb on X86_32. swiotlb uses ops->mapping_error so X86_32 also needs to check ops->mapping_error.

2) Removing #ifdef hack is always good.

But this patch fixes the bug and it works for now. And I think that Thomas tested it. So it's fine to commit this patch by me.

yeah, i included the tested patch.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I'll send a patch to remove the ifdef on the top of this patch after this patch goes into mainline.

sure - or you can send it against tip/master straight away.

Ok, here you are.

Note that this is for 2.6.29 (not 2.6.28).

thanks, applied to tip/x86/iommu.

Ingo

#9 lore raw
In reply to FUJITA Tomonori
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 2 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

Ah true, thanks. Anyway, the patch also solved the problem with swiotlb on 64bit.

Joerg

#10 lore raw
Quoted 26 lines · On Mon, 1 Dec 2008 13:58:52 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 25 lines · FUJITA Tomonori
Quoted 9 lines · On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel <[email protected]> wrote:
Quoted 4 lines · Thomas Bogendoerfer

Devices like b44 ethernet can't dma from addresses above 1GB. The driver handles this cases by falling back to GFP_DMA allocation. But for detecting the problem it needs to get an indication from dma_mapping_error. The bug is triggered by using a VMSPLIT option of 2G/2G.

Looks like your system uses swiotlb as the dma_ops backend. Its the only implementation providing the ops->mapping_error callback and does not use bad_dma_address as the error value.

I think that you misunderstand the problem.

He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now).

b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB.

Quoted 5 lines
Quoted 2 lines

This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address).

Ah true, thanks. Anyway, the patch also solved the problem with swiotlb on 64bit.

Can you be specific?

swiotlb's dma_mapping_error on X86_64 doesn't have any problem as far as I know.