Hi Thomas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-xe/drm-xe-next]
[also build test WARNING on linus/master v6.16-rc1 next-20250613]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
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-buildonly-randconfig-005-20250613 
(https://download.01.org/0day-ci/archive/20250614/202506140238.kcnsvmru-...@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 
58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20250614/202506140238.kcnsvmru-...@intel.com/reproduce)

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 <l...@intel.com>
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202506140238.kcnsvmru-...@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/ttm/ttm_bo_util.c:965:7: warning: variable 'ret' is used 
>> uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     965 |                 if (!bo_locked)
         |                     ^~~~~~~~~~
   drivers/gpu/drm/ttm/ttm_bo_util.c:975:8: note: uninitialized use occurs here
     975 |                 if (!ret && bo->resource && bo->resource->mem_type 
== mem_type)
         |                      ^~~
   drivers/gpu/drm/ttm/ttm_bo_util.c:965:3: note: remove the 'if' if its 
condition is always true
     965 |                 if (!bo_locked)
         |                 ^~~~~~~~~~~~~~~
     966 |                         ret = ttm_lru_walk_ticketlock(arg, bo, 
&curs->needs_unlock);
   drivers/gpu/drm/ttm/ttm_bo_util.c:939:20: note: initialize the variable 
'ret' to silence this warning
     939 |                 int mem_type, ret;
         |                                  ^
         |                                   = 0
   1 warning generated.


vim +965 drivers/gpu/drm/ttm/ttm_bo_util.c

   926  
   927  static struct ttm_buffer_object *
   928  __ttm_bo_lru_cursor_next(struct ttm_bo_lru_cursor *curs, bool first)
   929  {
   930          spinlock_t *lru_lock = &curs->res_curs.man->bdev->lru_lock;
   931          struct ttm_resource *res = NULL;
   932          struct ttm_buffer_object *bo;
   933          struct ttm_lru_walk_arg *arg = curs->arg;
   934  
   935          ttm_bo_lru_cursor_cleanup_bo(curs);
   936  
   937          spin_lock(lru_lock);
   938          for (;;) {
   939                  int mem_type, ret;
   940                  bool bo_locked = false;
   941  
   942                  if (first) {
   943                          res = 
ttm_resource_manager_first(&curs->res_curs);
   944                          first = false;
   945                  } else {
   946                          res = 
ttm_resource_manager_next(&curs->res_curs);
   947                  }
   948                  if (!res)
   949                          break;
   950  
   951                  bo = res->bo;
   952                  if (ttm_lru_walk_trylock(arg, bo, &curs->needs_unlock))
   953                          bo_locked = true;
   954                  else if (!arg->ticket || arg->ctx->no_wait_gpu || 
arg->trylock_only)
   955                          continue;
   956  
   957                  if (!ttm_bo_get_unless_zero(bo)) {
   958                          if (curs->needs_unlock)
   959                                  dma_resv_unlock(bo->base.resv);
   960                          continue;
   961                  }
   962  
   963                  mem_type = res->mem_type;
   964                  spin_unlock(lru_lock);
 > 965                  if (!bo_locked)
   966                          ret = ttm_lru_walk_ticketlock(arg, bo, 
&curs->needs_unlock);
   967                  /*
   968                   * Note that in between the release of the lru lock and 
the
   969                   * ticketlock, the bo may have switched resource,
   970                   * and also memory type, since the resource may have 
been
   971                   * freed and allocated again with a different memory 
type.
   972                   * In that case, just skip it.
   973                   */
   974                  curs->bo = bo;
   975                  if (!ret && bo->resource && bo->resource->mem_type == 
mem_type)
   976                          return bo;
   977  
   978                  ttm_bo_lru_cursor_cleanup_bo(curs);
   979                  if (ret)
   980                          return ERR_PTR(ret);
   981  
   982                  spin_lock(lru_lock);
   983          }
   984  
   985          spin_unlock(lru_lock);
   986          return res ? bo : NULL;
   987  }
   988  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Reply via email to