Re: [RFC PATCH v3 4/6] swiotlb: Add restricted DMA alloc/free support.

From
Florian Fainelli <f.fainelli@gmail.com>
Date
2021-01-13 00:43:09
Also in
linux-iommu, linuxppc-dev, lkml, xen-devel
Reply to
Claire Chang, 2021-01-06
On 1/5/21 7:41 PM, Claire Chang wrote:
Add the functions, swiotlb_alloc and swiotlb_free to support the
memory allocation from restricted DMA pool.

Signed-off-by: Claire Chang <redacted>
---
[snip]
quoted hunk ↗ jump to hunk
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 30ccbc08e229..126e9b3354d6 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -137,6 +137,11 @@ void *dma_direct_alloc(struct device *dev, size_t size,
 	void *ret;
 	int err;
 
+#ifdef CONFIG_SWIOTLB
+	if (unlikely(dev->dma_io_tlb_mem))
+		return swiotlb_alloc(dev, size, dma_handle, attrs);
+#endif
While this is potentially a hot path, I am not sure of the unkikely is
warranted, maybe best left as a plain conditional.
-- 
Florian
Thread (58 messages) 58 messages, 10 authors, last reply 2021-02-09
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help