Thread (25 messages) flat view 25 messages, 3 authors, 2021-06-16

Re: [PATCH v10 10/12] swiotlb: Add restricted DMA alloc/free support

From: Christoph Hellwig <hch@lst.de>
Date: 2021-06-15 13:43:05
Also in: intel-gfx, linux-iommu, linux-pci, linuxppc-dev, lkml, xen-devel

On Tue, Jun 15, 2021 at 09:27:09PM +0800, Claire Chang wrote:
Add the functions, swiotlb_{alloc,free} to support the memory allocation
from restricted DMA pool.

The restricted DMA pool is preferred if available.

Note that since coherent allocation needs remapping, one must set up
another device coherent pool by shared-dma-pool and use
dma_alloc_from_dev_coherent instead for atomic coherent allocation.
Note: when applied this should go before the next patch to make sure
bisection works fine.
 #ifdef CONFIG_DMA_RESTRICTED_POOL
+struct page *swiotlb_alloc(struct device *dev, size_t size)
+{
+	struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
+	phys_addr_t tlb_addr;
+	int index;
+
+	/*
+	 * Skip io_tlb_default_mem since swiotlb_alloc doesn't support atomic
+	 * coherent allocation. Otherwise might break existing devices.
+	 * One must set up another device coherent pool by shared-dma-pool and
+	 * use dma_alloc_from_dev_coherent instead for atomic coherent
+	 * allocation to avoid mempry remapping.
s/mempry/memory/g

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help