drm/ttm: add default implementations for ttm_tt_(un)populate
authorChristian König <christian.koenig@amd.com>
Thu, 22 Feb 2018 11:00:05 +0000 (12:00 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 27 Feb 2018 04:09:41 +0000 (23:09 -0500)
Use ttm_pool_populate/ttm_pool_unpopulate if the driver doesn't provide
a function.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/ttm/ttm_tt.c

index 9fd7115a013aa04f8b8c9f89474fd66de8149e19..65bf4eac184b765b8aeb11534258c0561943ab63 100644 (file)
@@ -410,7 +410,10 @@ int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
        if (ttm->state != tt_unpopulated)
                return 0;
 
-       ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+       if (ttm->bdev->driver->ttm_tt_populate)
+               ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
+       else
+               ret = ttm_pool_populate(ttm, ctx);
        if (!ret)
                ttm_tt_add_mapping(ttm);
        return ret;
@@ -436,5 +439,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
                return;
 
        ttm_tt_clear_mapping(ttm);
-       ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+       if (ttm->bdev->driver->ttm_tt_unpopulate)
+               ttm->bdev->driver->ttm_tt_unpopulate(ttm);
+       else
+               ttm_pool_unpopulate(ttm);
 }