From: Jérôme Glisse <jglisse@xxxxxxxxxx> Some device like GPU do things differently if swiotlb is in use. We use to rely on swiotlb_nr_tbl() to know if swiotlb was enabled or not but this is unreliable. Patch add a simple helpers to check if any of the dma_ops associated with a device points to the swiotlb functions, making swiotlb check reliable for a device. Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Alex Deucher <alexander.deucher@xxxxxxx> Cc: Ben Skeggs <bskeggs@xxxxxxxxxx> Cc: Dave Airlie <airlied@xxxxxxxxxx> Cc: lkml@xxxxxxxxxxxxxxx Cc: Daniel Vetter <daniel.vetter@xxxxxxxxx> --- include/linux/dma-mapping.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index ac07ff0..eac911e 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -314,4 +314,22 @@ static inline int dma_mmap_writecombine(struct device *dev, #define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) #endif + +#ifdef CONFIG_SWIOTLB +static inline bool swiotlb_in_use(struct device *dev) +{ + struct dma_map_ops *ops = get_dma_ops(dev); + + return (ops->map_sg == swiotlb_map_sg_attrs || + ops->unmap_sg == swiotlb_unmap_sg_attrs || + ops->map_page == swiotlb_map_page); +} +#else +static inline bool swiotlb_in_use(struct device *dev) +{ + return false; +} +#endif + + #endif -- 2.1.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel