[PATCH 3/3] drm/ttm, drm_xe, Implement ttm_lru_walk_for_evict() using the guarded LRU iteration
Dan Carpenter
dan.carpenter at linaro.org
Wed Jun 18 17:43:25 UTC 2025
Hi Thomas,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Hellstr-m/drm-ttm-Use-a-struct-for-the-common-part-of-struct-ttm_lru_walk-and-struct-ttm_bo_lru_cursor/20250613-232106
base: https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link: https://lore.kernel.org/r/20250613151824.178650-4-thomas.hellstrom%40linux.intel.com
patch subject: [PATCH 3/3] drm/ttm, drm_xe, Implement ttm_lru_walk_for_evict() using the guarded LRU iteration
config: i386-randconfig-141-20250614 (https://download.01.org/0day-ci/archive/20250614/202506141727.FtEuY8xN-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp at intel.com>
| Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
| Closes: https://lore.kernel.org/r/202506141727.FtEuY8xN-lkp@intel.com/
smatch warnings:
drivers/gpu/drm/ttm/ttm_bo_util.c:975 __ttm_bo_lru_cursor_next() error: uninitialized symbol 'ret'.
vim +/ret +975 drivers/gpu/drm/ttm/ttm_bo_util.c
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 927 static struct ttm_buffer_object *
a9654c8f32d9f4 Thomas Hellström 2025-06-13 928 __ttm_bo_lru_cursor_next(struct ttm_bo_lru_cursor *curs, bool first)
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 929 {
a9654c8f32d9f4 Thomas Hellström 2025-06-13 930 spinlock_t *lru_lock = &curs->res_curs.man->bdev->lru_lock;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 931 struct ttm_resource *res = NULL;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 932 struct ttm_buffer_object *bo;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 933 struct ttm_lru_walk_arg *arg = curs->arg;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 934
a9654c8f32d9f4 Thomas Hellström 2025-06-13 935 ttm_bo_lru_cursor_cleanup_bo(curs);
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 936
a9654c8f32d9f4 Thomas Hellström 2025-06-13 937 spin_lock(lru_lock);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 938 for (;;) {
a9654c8f32d9f4 Thomas Hellström 2025-06-13 939 int mem_type, ret;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 940 bool bo_locked = false;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 941
a9654c8f32d9f4 Thomas Hellström 2025-06-13 942 if (first) {
a9654c8f32d9f4 Thomas Hellström 2025-06-13 943 res = ttm_resource_manager_first(&curs->res_curs);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 944 first = false;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 945 } else {
a9654c8f32d9f4 Thomas Hellström 2025-06-13 946 res = ttm_resource_manager_next(&curs->res_curs);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 947 }
a9654c8f32d9f4 Thomas Hellström 2025-06-13 948 if (!res)
a9654c8f32d9f4 Thomas Hellström 2025-06-13 949 break;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 950
a9654c8f32d9f4 Thomas Hellström 2025-06-13 951 bo = res->bo;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 952 if (ttm_lru_walk_trylock(arg, bo, &curs->needs_unlock))
a9654c8f32d9f4 Thomas Hellström 2025-06-13 953 bo_locked = true;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 954 else if (!arg->ticket || arg->ctx->no_wait_gpu || arg->trylock_only)
a9654c8f32d9f4 Thomas Hellström 2025-06-13 955 continue;
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 956
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 957 if (!ttm_bo_get_unless_zero(bo)) {
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 958 if (curs->needs_unlock)
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 959 dma_resv_unlock(bo->base.resv);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 960 continue;
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 961 }
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 962
a9654c8f32d9f4 Thomas Hellström 2025-06-13 963 mem_type = res->mem_type;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 964 spin_unlock(lru_lock);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 965 if (!bo_locked)
a9654c8f32d9f4 Thomas Hellström 2025-06-13 966 ret = ttm_lru_walk_ticketlock(arg, bo, &curs->needs_unlock);
ret is uninitialized on else path
a9654c8f32d9f4 Thomas Hellström 2025-06-13 967 /*
a9654c8f32d9f4 Thomas Hellström 2025-06-13 968 * Note that in between the release of the lru lock and the
a9654c8f32d9f4 Thomas Hellström 2025-06-13 969 * ticketlock, the bo may have switched resource,
a9654c8f32d9f4 Thomas Hellström 2025-06-13 970 * and also memory type, since the resource may have been
a9654c8f32d9f4 Thomas Hellström 2025-06-13 971 * freed and allocated again with a different memory type.
a9654c8f32d9f4 Thomas Hellström 2025-06-13 972 * In that case, just skip it.
a9654c8f32d9f4 Thomas Hellström 2025-06-13 973 */
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 974 curs->bo = bo;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 @975 if (!ret && bo->resource && bo->resource->mem_type == mem_type)
^^^^
warning
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 976 return bo;
a9654c8f32d9f4 Thomas Hellström 2025-06-13 977
a9654c8f32d9f4 Thomas Hellström 2025-06-13 978 ttm_bo_lru_cursor_cleanup_bo(curs);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 979 if (ret)
a9654c8f32d9f4 Thomas Hellström 2025-06-13 980 return ERR_PTR(ret);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 981
a9654c8f32d9f4 Thomas Hellström 2025-06-13 982 spin_lock(lru_lock);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 983 }
a9654c8f32d9f4 Thomas Hellström 2025-06-13 984
a9654c8f32d9f4 Thomas Hellström 2025-06-13 985 spin_unlock(lru_lock);
a9654c8f32d9f4 Thomas Hellström 2025-06-13 986 return res ? bo : NULL;
f3bcfd04a52fb1 Thomas Hellström 2025-03-05 987 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
More information about the Intel-xe
mailing list