Commit 1d61261b authored by Fabio M. De Francesco's avatar Fabio M. De Francesco Committed by Christoph Hellwig

swiotlb: replace kmap_atomic() with memcpy_{from,to}_page()

The use of kmap_atomic() is being deprecated in favor of
kmap_local_page(), which can also be used in atomic context (including
interrupts).

Replace kmap_atomic() with kmap_local_page(). Instead of open coding
mapping, memcpy(), and un-mapping, use the memcpy_{from,to}_page() helper.
Suggested-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarFabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 521a547c
...@@ -545,9 +545,8 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size ...@@ -545,9 +545,8 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size
} }
if (PageHighMem(pfn_to_page(pfn))) { if (PageHighMem(pfn_to_page(pfn))) {
/* The buffer does not have a mapping. Map it in and copy */
unsigned int offset = orig_addr & ~PAGE_MASK; unsigned int offset = orig_addr & ~PAGE_MASK;
char *buffer; struct page *page;
unsigned int sz = 0; unsigned int sz = 0;
unsigned long flags; unsigned long flags;
...@@ -555,12 +554,11 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size ...@@ -555,12 +554,11 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size
sz = min_t(size_t, PAGE_SIZE - offset, size); sz = min_t(size_t, PAGE_SIZE - offset, size);
local_irq_save(flags); local_irq_save(flags);
buffer = kmap_atomic(pfn_to_page(pfn)); page = pfn_to_page(pfn);
if (dir == DMA_TO_DEVICE) if (dir == DMA_TO_DEVICE)
memcpy(vaddr, buffer + offset, sz); memcpy_from_page(vaddr, page, offset, sz);
else else
memcpy(buffer + offset, vaddr, sz); memcpy_to_page(page, offset, vaddr, sz);
kunmap_atomic(buffer);
local_irq_restore(flags); local_irq_restore(flags);
size -= sz; size -= sz;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment