summaryrefslogtreecommitdiffstats
path: root/kernel/dma
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-10-21 09:20:39 +0200
committerChristoph Hellwig <hch@lst.de>2021-12-07 12:47:06 +0100
commit5570449b6876f215d49ac4db9ccce6ff7aa1e20a (patch)
tree5823410573206e2a9d1968cec3f0e53be11af4af /kernel/dma
parentdma-direct: factor out dma_set_{de,en}crypted helpers (diff)
downloadlinux-5570449b6876f215d49ac4db9ccce6ff7aa1e20a.tar.xz
linux-5570449b6876f215d49ac4db9ccce6ff7aa1e20a.zip
dma-direct: don't call dma_set_decrypted for remapped allocations
Remapped allocations handle the encrypted bit through the pgprot passed to vmap, so there is no call dma_set_decrypted. Note that this case is currently entirely theoretical as no valid kernel configuration supports remapped allocations and memory encryption currently. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/dma')
-rw-r--r--kernel/dma/direct.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index d4d54af31a34..996ba4edb2fa 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -229,8 +229,6 @@ void *dma_direct_alloc(struct device *dev, size_t size,
__builtin_return_address(0));
if (!ret)
goto out_free_pages;
- if (dma_set_decrypted(dev, ret, size))
- goto out_free_pages;
memset(ret, 0, size);
goto done;
}
@@ -304,12 +302,13 @@ void dma_direct_free(struct device *dev, size_t size,
dma_free_from_pool(dev, cpu_addr, PAGE_ALIGN(size)))
return;
- dma_set_encrypted(dev, cpu_addr, 1 << page_order);
-
- if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr))
+ if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) {
vunmap(cpu_addr);
- else if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED))
- arch_dma_clear_uncached(cpu_addr, size);
+ } else {
+ if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED))
+ arch_dma_clear_uncached(cpu_addr, size);
+ dma_set_encrypted(dev, cpu_addr, 1 << page_order);
+ }
__dma_direct_free_pages(dev, dma_direct_to_page(dev, dma_addr), size);
}