From: Jérôme Glisse <jgli...@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/nouveau/nouveau_bo.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 6edcce1..f601049 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -28,7 +28,6 @@
  */

 #include <linux/dma-mapping.h>
-#include <linux/swiotlb.h>

 #include "nouveau_drm.h"
 #include "nouveau_dma.h"
@@ -1504,11 +1503,9 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
        }
 #endif

-#ifdef CONFIG_SWIOTLB
-       if (swiotlb_nr_tbl()) {
+       if (swiotlb_in_use(pdev)) {
                return ttm_dma_populate((void *)ttm, dev->dev);
        }
-#endif

        r = ttm_pool_populate(ttm);
        if (r) {
@@ -1572,12 +1569,10 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
        }
 #endif

-#ifdef CONFIG_SWIOTLB
-       if (swiotlb_nr_tbl()) {
+       if (swiotlb_in_use(pdev)) {
                ttm_dma_unpopulate((void *)ttm, dev->dev);
                return;
        }
-#endif

        for (i = 0; i < ttm->num_pages; i++) {
                if (ttm_dma->dma_address[i]) {
-- 
2.1.0

Reply via email to