[PATCH 6/6] drm/amdgpu: Use swiotlb_in_use() to know if swiotlb is enabled.

jglisse at redhat.com jglisse at redhat.com
Wed Aug 26 11:52:07 PDT 2015


From: Jérôme Glisse <jglisse at redhat.com>

We can not rely on swiotlb_nr_tbl() to know if swiotlb is in use or
not for our device. Use the new helper to determine that.

Signed-off-by: Jérôme Glisse <jglisse at redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Ben Skeggs <bskeggs at redhat.com>
Cc: Dave Airlie <airlied at redhat.com>
Cc: lkml at vger.kernel.org
Cc: Daniel Vetter <daniel.vetter at intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index dd3415d..bb48fc5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -38,7 +38,6 @@
 #include <drm/amdgpu_drm.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
-#include <linux/swiotlb.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
 #include <linux/debugfs.h>
@@ -692,11 +691,9 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
 
 	adev = amdgpu_get_adev(ttm->bdev);
 
-#ifdef CONFIG_SWIOTLB
-	if (swiotlb_nr_tbl()) {
+	if (swiotlb_in_use(adev->dev)) {
 		return ttm_dma_populate(&gtt->ttm, adev->dev);
 	}
-#endif
 
 	r = ttm_pool_populate(ttm);
 	if (r) {
@@ -738,12 +735,10 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
 
 	adev = amdgpu_get_adev(ttm->bdev);
 
-#ifdef CONFIG_SWIOTLB
-	if (swiotlb_nr_tbl()) {
+	if (swiotlb_in_use(adev->dev)) {
 		ttm_dma_unpopulate(&gtt->ttm, adev->dev);
 		return;
 	}
-#endif
 
 	for (i = 0; i < ttm->num_pages; i++) {
 		if (gtt->ttm.dma_address[i]) {
@@ -1190,10 +1185,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
 
 	count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
 
-#ifdef CONFIG_SWIOTLB
-	if (!swiotlb_nr_tbl())
+	if (!swiotlb_in_use(adev->dev))
 		--count;
-#endif
 
 	return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
 #else
-- 
2.1.0



More information about the dri-devel mailing list