drm/ttm: cleanup io_mem interface with nouveau
authorChristian König <christian.koenig@amd.com>
Mon, 13 Jul 2020 14:50:04 +0000 (16:50 +0200)
committerChristian König <christian.koenig@amd.com>
Tue, 21 Jul 2020 14:13:29 +0000 (16:13 +0200)
Nouveau is the only user of this functionality and evicting io space
on -EAGAIN is really a misuse of the return code.

Instead switch to using -ENOSPC here which makes much more sense and
simplifies the code.

This could unbreak something as we now cleanly return EAGAIN, but the
chance for this are rather low.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/378237/
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/ttm/ttm_bo_util.c

index 61355cfb7335c6a9ca02cc2937a39c1361db2d6d..a48652826f67680e7d58bb3288475de96a8ffc97 100644 (file)
@@ -1505,8 +1505,6 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
                        if (ret != 1) {
                                if (WARN_ON(ret == 0))
                                        return -EINVAL;
-                               if (ret == -ENOSPC)
-                                       return -EAGAIN;
                                return ret;
                        }
 
index 5e0f3a9caedc4ad0374666daf183755050349b7d..7d2c50fef456db29b2c33d2ef5eac667e172ef79 100644 (file)
@@ -116,7 +116,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)
        struct ttm_buffer_object *bo;
 
        if (!man->use_io_reserve_lru || list_empty(&man->io_reserve_lru))
-               return -EAGAIN;
+               return -ENOSPC;
 
        bo = list_first_entry(&man->io_reserve_lru,
                              struct ttm_buffer_object,
@@ -143,7 +143,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
            mem->bus.io_reserved_count++ == 0) {
 retry:
                ret = bdev->driver->io_mem_reserve(bdev, mem);
-               if (ret == -EAGAIN) {
+               if (ret == -ENOSPC) {
                        ret = ttm_mem_io_evict(man);
                        if (ret == 0)
                                goto retry;