Hello,
There is no bug here, but it could be nice to refer to the lock in the
same way at all call sites (see line 258.
julia
---------- Forwarded message ----------
Date: Wed, 27 Dec 2023 22:34:45 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c:258:2-8: preceding lock
on line 251
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Ben Skeggs <[email protected]>
CC: Lyude Paul <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fbafc3e621c3f4ded43720fdb1d6ce1728ec664e
commit: f48dd2936138882d7755cbbc5d9984015c75980c drm/nouveau/fifo: add new engine context tracking
date: 1 year, 2 months ago
:::::: branch date: 2 days ago
:::::: commit date: 1 year, 2 months ago
config: loongarch-randconfig-r062-20231222 (https://download.01.org/0day-ci/archive/20231227/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/
cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c:258:2-8: preceding lock on line 251
vim +258 drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
f48dd293613888 Ben Skeggs 2022-06-01 240
f48dd293613888 Ben Skeggs 2022-06-01 241 int
f48dd293613888 Ben Skeggs 2022-06-01 242 nvkm_chan_cctx_get(struct nvkm_chan *chan, struct nvkm_engn *engn, struct nvkm_cctx **pcctx,
f48dd293613888 Ben Skeggs 2022-06-01 243 struct nvkm_client *client)
f48dd293613888 Ben Skeggs 2022-06-01 244 {
f48dd293613888 Ben Skeggs 2022-06-01 245 struct nvkm_cgrp *cgrp = chan->cgrp;
f48dd293613888 Ben Skeggs 2022-06-01 246 struct nvkm_vctx *vctx;
f48dd293613888 Ben Skeggs 2022-06-01 247 struct nvkm_cctx *cctx;
f48dd293613888 Ben Skeggs 2022-06-01 248 int ret;
f48dd293613888 Ben Skeggs 2022-06-01 249
f48dd293613888 Ben Skeggs 2022-06-01 250 /* Look for an existing channel context for this engine+VEID. */
f48dd293613888 Ben Skeggs 2022-06-01 @251 mutex_lock(&cgrp->mutex);
f48dd293613888 Ben Skeggs 2022-06-01 252 cctx = nvkm_list_find(cctx, &chan->cctxs, head,
f48dd293613888 Ben Skeggs 2022-06-01 253 cctx->vctx->ectx->engn == engn && cctx->vctx->vmm == chan->vmm);
f48dd293613888 Ben Skeggs 2022-06-01 254 if (cctx) {
f48dd293613888 Ben Skeggs 2022-06-01 255 refcount_inc(&cctx->refs);
f48dd293613888 Ben Skeggs 2022-06-01 256 *pcctx = cctx;
f48dd293613888 Ben Skeggs 2022-06-01 257 mutex_unlock(&chan->cgrp->mutex);
f48dd293613888 Ben Skeggs 2022-06-01 @258 return 0;
f48dd293613888 Ben Skeggs 2022-06-01 259 }
f48dd293613888 Ben Skeggs 2022-06-01 260
f48dd293613888 Ben Skeggs 2022-06-01 261 /* Nope - create a fresh one. But, sub-context first. */
f48dd293613888 Ben Skeggs 2022-06-01 262 ret = nvkm_cgrp_vctx_get(cgrp, engn, chan, &vctx, client);
f48dd293613888 Ben Skeggs 2022-06-01 263 if (ret) {
f48dd293613888 Ben Skeggs 2022-06-01 264 CHAN_ERROR(chan, "vctx %d[%s]: %d", engn->id, engn->engine->subdev.name, ret);
f48dd293613888 Ben Skeggs 2022-06-01 265 goto done;
f48dd293613888 Ben Skeggs 2022-06-01 266 }
f48dd293613888 Ben Skeggs 2022-06-01 267
f48dd293613888 Ben Skeggs 2022-06-01 268 /* Now, create the channel context - to track engine binding. */
f48dd293613888 Ben Skeggs 2022-06-01 269 CHAN_TRACE(chan, "ctor cctx %d[%s]", engn->id, engn->engine->subdev.name);
f48dd293613888 Ben Skeggs 2022-06-01 270 if (!(cctx = *pcctx = kzalloc(sizeof(*cctx), GFP_KERNEL))) {
f48dd293613888 Ben Skeggs 2022-06-01 271 nvkm_cgrp_vctx_put(cgrp, &vctx);
f48dd293613888 Ben Skeggs 2022-06-01 272 ret = -ENOMEM;
f48dd293613888 Ben Skeggs 2022-06-01 273 goto done;
f48dd293613888 Ben Skeggs 2022-06-01 274 }
f48dd293613888 Ben Skeggs 2022-06-01 275
f48dd293613888 Ben Skeggs 2022-06-01 276 cctx->vctx = vctx;
f48dd293613888 Ben Skeggs 2022-06-01 277 refcount_set(&cctx->refs, 1);
f48dd293613888 Ben Skeggs 2022-06-01 278 refcount_set(&cctx->uses, 0);
f48dd293613888 Ben Skeggs 2022-06-01 279 list_add_tail(&cctx->head, &chan->cctxs);
f48dd293613888 Ben Skeggs 2022-06-01 280 done:
f48dd293613888 Ben Skeggs 2022-06-01 281 mutex_unlock(&cgrp->mutex);
f48dd293613888 Ben Skeggs 2022-06-01 282 return ret;
f48dd293613888 Ben Skeggs 2022-06-01 283 }
f48dd293613888 Ben Skeggs 2022-06-01 284
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki