Skip to contentSkip to conversation

swiotlb: swiotlb_{alloc,free}_buffer should depend on CONFIG_DMA_DIRECT_OPS

PATCH In review Christoph Hellwig 4 participants 7 messages Mar 23, 2018 – Mar 26, 2018 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swiotlb: swiotlb_{alloc,free}_buffer should depend on CONFIG_DMA_DIRECT_OPS

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")
---
 lib/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
lib/swiotlb.c +2 -0
index 15954b86f09e..47aeb04c1997 100644
@@ -692,6 +692,7 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr,
 	}
 }
 
+#ifdef CONFIG_DMA_DIRECT_OPS
 static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr,
 		size_t size)
 {
@@ -763,6 +764,7 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size,
 				 DMA_ATTR_SKIP_CPU_SYNC);
 	return true;
 }
+#endif
 
 static void
 swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
Signature · 1 line
2.14.2
#1 lore raw
Quoted 7 lines · Christoph Hellwig

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")

Alternatively could we set the Kconfig to slect DMA_DIRECT_OPS?

Quoted 27 lines
---
 lib/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
lib/swiotlb.c +2 -0
index 15954b86f09e..47aeb04c1997 100644
@@ -692,6 +692,7 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr,
 	}
 }
 
+#ifdef CONFIG_DMA_DIRECT_OPS
 static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr,
 		size_t size)
 {
@@ -763,6 +764,7 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size,
 				 DMA_ATTR_SKIP_CPU_SYNC);
 	return true;
 }
+#endif
 
 static void
 swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
Signature · 1 line
2.14.2
#2 lore raw
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 7 lines · Christoph Hellwig

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")

Alternatively could we set the Kconfig to slect DMA_DIRECT_OPS?

You only want to do that when you actually need the code. If not it's a pointless exercise.

But Christoph change makes sense independent of that because the next oddball Kconfig will come along sooner than later and run into the very same problem.

Thanks,

tglx

#3 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 7 lines · Christoph Hellwig

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")

Alternatively could we set the Kconfig to slect DMA_DIRECT_OPS?

IFF we build swiotlb.c only for xen-swiotlb we don't need DMA_DIRECT_OPS. IF you are fine with just requring it as well that would be doable nicely only if we consolidate to a single defintion of CONFIG_SWIOTLB instead of one per architecture. Which is something we should do anyway, so I'll look into it once I get some time.

#4 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 7 lines · Christoph Hellwig

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")
Quoted 4 lines
Quoted 1 line

Alternatively could we set the Kconfig to slect DMA_DIRECT_OPS?

IFF we build swiotlb.c only for xen-swiotlb we don't need DMA_DIRECT_OPS.

I don't think there is ever an case where you want a Xen specific build.

Quoted 4 lines

IF you are fine with just requring it as well that would be doable nicely only if we consolidate to a single defintion of CONFIG_SWIOTLB instead of one per architecture. Which is something we should do anyway, so I'll look into it once I get some time.

Sounds good. Thank you.

#5 lore raw
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

Otherwise we might get unused symbol warnings for configs that built swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

Fixes 16e73adbca76 ("dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()")
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Alternatively could we set the Kconfig to slect DMA_DIRECT_OPS?

IFF we build swiotlb.c only for xen-swiotlb we don't need DMA_DIRECT_OPS.

I don't think there is ever an case where you want a Xen specific build.

arm never uses swiotlb directly, so any swiotlb.c build on arm is purely for xen-swiotlb.c

#6 lore raw

[tip:x86/dma] swiotlb: Make swiotlb_{alloc,free}_buffer depend on CONFIG_DMA_DIRECT_OPS

In reply to Christoph Hellwig
swiotlb: Make swiotlb_{alloc,free}_buffer depend on CONFIG_DMA_DIRECT_OPS
Commit-ID:  0803e6051c1562e1525c3e044313390bf8b35c2b
Gitweb:     https://git.kernel.org/tip/0803e6051c1562e1525c3e044313390bf8b35c2b
Author:     Christoph Hellwig <[email protected]>
AuthorDate: Fri, 23 Mar 2018 18:49:30 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 23 Mar 2018 20:15:38 +0100

swiotlb: Make swiotlb_{alloc,free}_buffer depend on CONFIG_DMA_DIRECT_OPS

Otherwise this causes unused symbol warnings for configs that build swiotlb.c only for use by xen-swiotlb.c and that don't otherwise select CONFIG_DMA_DIRECT_OPS, which is possible on arm.

---
 lib/swiotlb.c | 2 ++
 1 file changed, 2 insertions(+)
lib/swiotlb.c +2 -0
index 15954b86f09e..47aeb04c1997 100644
@@ -692,6 +692,7 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr,
 	}
 }
 
+#ifdef CONFIG_DMA_DIRECT_OPS
 static inline bool dma_coherent_ok(struct device *dev, dma_addr_t addr,
 		size_t size)
 {
@@ -763,6 +764,7 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size,
 				 DMA_ATTR_SKIP_CPU_SYNC);
 	return true;
 }
+#endif
 
 static void
 swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,