diff options
author | Christoph Hellwig <hch@lst.de> | 2020-06-29 16:03:56 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-06-30 16:44:03 +0300 |
commit | 3aa91625007807bfca4155df1867a5c924a08662 (patch) | |
tree | 200b5d80ea2b377dcdc560056f1fc247dc18024f /kernel/dma/direct.c | |
parent | 2bdeb3ed547d8822b2566797afa6c2584abdb119 (diff) | |
download | linux-3aa91625007807bfca4155df1867a5c924a08662.tar.xz |
dma-mapping: Add a new dma_need_sync API
Add a new API to check if calls to dma_sync_single_for_{device,cpu} are
required for a given DMA streaming mapping.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200629130359.2690853-2-hch@lst.de
Diffstat (limited to 'kernel/dma/direct.c')
-rw-r--r-- | kernel/dma/direct.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 0a4881e59aa7..ecb922a0bfa0 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -530,3 +530,9 @@ size_t dma_direct_max_mapping_size(struct device *dev) return swiotlb_max_mapping_size(dev); return SIZE_MAX; } + +bool dma_direct_need_sync(struct device *dev, dma_addr_t dma_addr) +{ + return !dev_is_dma_coherent(dev) || + is_swiotlb_buffer(dma_to_phys(dev, dma_addr)); +} |