[PATCH 8/8] drm/vram-helper: Simplify vmap implementation
Thomas Zimmermann
tzimmermann at suse.de
Mon Nov 30 12:04:33 UTC 2020
After removing the pinning operations, the vmap/vunmap code as been
reduced to what used to be an internal helper. Inline the helper to
simplify the implementation.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
drivers/gpu/drm/drm_gem_vram_helper.c | 57 +++++++++++----------------
1 file changed, 23 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index a44718dd66cb..10d89c01990f 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -378,36 +378,6 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo)
}
EXPORT_SYMBOL(drm_gem_vram_unpin);
-static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
- struct dma_buf_map *map)
-{
- int ret;
-
- ret = ttm_bo_vmap(&gbo->bo, &gbo->map);
- if (ret)
- return ret;
-
- *map = gbo->map;
-
- return 0;
-}
-
-static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,
- struct dma_buf_map *map)
-{
- struct drm_device *dev = gbo->bo.base.dev;
-
- if (drm_WARN_ON_ONCE(dev, !dma_buf_map_is_equal(&gbo->map, map)))
- return; /* BUG: map not mapped from this BO */
-
- /*
- * Permanently mapping and unmapping buffers adds overhead from
- * updating the page tables and creates debugging output. Therefore,
- * we delay the actual unmap operation until the BO gets evicted
- * from memory. See drm_gem_vram_bo_driver_move_notify().
- */
-}
-
/**
* drm_gem_vram_vmap() - Pins and maps a GEM VRAM object into kernel address
* space
@@ -426,9 +396,17 @@ static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,
*/
int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)
{
+ int ret;
+
dma_resv_assert_held(gbo->bo.base.resv);
- return drm_gem_vram_kmap_locked(gbo, map);
+ ret = ttm_bo_vmap(&gbo->bo, &gbo->map);
+ if (ret)
+ return ret;
+
+ *map = gbo->map;
+
+ return 0;
}
EXPORT_SYMBOL(drm_gem_vram_vmap);
@@ -442,8 +420,19 @@ EXPORT_SYMBOL(drm_gem_vram_vmap);
*/
void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)
{
+ struct drm_device *dev = gbo->bo.base.dev;
+
dma_resv_assert_held(gbo->bo.base.resv);
- drm_gem_vram_kunmap_locked(gbo, map);
+
+ if (drm_WARN_ON_ONCE(dev, !dma_buf_map_is_equal(&gbo->map, map)))
+ return; /* BUG: map not mapped from this BO */
+
+ /*
+ * Permanently mapping and unmapping buffers adds overhead from
+ * updating the page tables and creates debugging output. Therefore,
+ * we delay the actual unmap operation until the BO gets evicted
+ * from memory. See drm_gem_vram_bo_driver_move_notify().
+ */
}
EXPORT_SYMBOL(drm_gem_vram_vunmap);
@@ -471,7 +460,7 @@ int drm_gem_vram_vmap_unlocked(struct drm_gem_vram_object *gbo, struct dma_buf_m
if (ret)
return ret;
- ret = drm_gem_vram_kmap_locked(gbo, map);
+ ret = drm_gem_vram_vmap(gbo, map);
if (ret)
goto err_ttm_bo_unreserve;
@@ -494,7 +483,7 @@ EXPORT_SYMBOL(drm_gem_vram_vmap_unlocked);
*/
void drm_gem_vram_vunmap_unlocked(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)
{
- drm_gem_vram_kunmap_locked(gbo, map);
+ drm_gem_vram_vunmap(gbo, map);
ttm_bo_unreserve(&gbo->bo);
}
EXPORT_SYMBOL(drm_gem_vram_vunmap_unlocked);
--
2.29.2
More information about the dri-devel
mailing list