Add is_dev_swiotlb_force() which returns true if the device has restricted DMA pool (e.g. dev->dev_swiotlb is set). Signed-off-by: Claire Chang <tientzu@xxxxxxxxxxxx> --- include/linux/swiotlb.h | 9 +++++++++ kernel/dma/swiotlb.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 76f86c684524..b9f2a250c8da 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -73,11 +73,16 @@ extern enum swiotlb_force swiotlb_force; #ifdef CONFIG_DMA_RESTRICTED_POOL bool is_swiotlb_force(struct device *dev); +bool is_dev_swiotlb_force(struct device *dev); #else static inline bool is_swiotlb_force(struct device *dev) { return unlikely(swiotlb_force == SWIOTLB_FORCE); } +static inline bool is_dev_swiotlb_force(struct device *dev) +{ + return false; +} #endif /* CONFIG_DMA_RESTRICTED_POOL */ bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr); @@ -93,6 +98,10 @@ static inline bool is_swiotlb_force(struct device *dev) { return false; } +static inline bool is_dev_swiotlb_force(struct device *dev) +{ + return false; +} static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) { return false; diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index f64cbe6e84cc..fd9c1bd183ac 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -841,6 +841,11 @@ bool is_swiotlb_force(struct device *dev) return unlikely(swiotlb_force == SWIOTLB_FORCE) || dev->dev_swiotlb; } +bool is_dev_swiotlb_force(struct device *dev) +{ + return dev->dev_swiotlb; +} + static int rmem_swiotlb_device_init(struct reserved_mem *rmem, struct device *dev) { -- 2.30.0.478.g8a0d178c01-goog