drivers/gpu/drm/i915/gvt/scheduler.c:646 prepare_shadow_wa_ctx() warn: inconsistent returns 'wa_ctx->indirect_ctx.obj->base.resv'.
From: Dan Carpenter
Date: Tue Sep 28 2021 - 02:24:42 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 92477dd1faa650e50bd3bb35a6c0b8d09198cc35
commit: 67f1120381df022a7016f4acc8d4880da9a66c03 drm/i915/gvt: Introduce per object locking in GVT scheduler.
config: x86_64-randconfig-m001-20210927 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
drivers/gpu/drm/i915/gvt/scheduler.c:646 prepare_shadow_wa_ctx() warn: inconsistent returns 'wa_ctx->indirect_ctx.obj->base.resv'.
vim +646 drivers/gpu/drm/i915/gvt/scheduler.c
d8235b5e55845d Zhi Wang 2017-09-12 605 static int prepare_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
d8235b5e55845d Zhi Wang 2017-09-12 606 {
d8235b5e55845d Zhi Wang 2017-09-12 607 struct i915_vma *vma;
d8235b5e55845d Zhi Wang 2017-09-12 608 unsigned char *per_ctx_va =
d8235b5e55845d Zhi Wang 2017-09-12 609 (unsigned char *)wa_ctx->indirect_ctx.shadow_va +
d8235b5e55845d Zhi Wang 2017-09-12 610 wa_ctx->indirect_ctx.size;
67f1120381df02 Zhi Wang 2021-01-10 611 struct i915_gem_ww_ctx ww;
67f1120381df02 Zhi Wang 2021-01-10 612 int ret;
d8235b5e55845d Zhi Wang 2017-09-12 613
d8235b5e55845d Zhi Wang 2017-09-12 614 if (wa_ctx->indirect_ctx.size == 0)
d8235b5e55845d Zhi Wang 2017-09-12 615 return 0;
d8235b5e55845d Zhi Wang 2017-09-12 616
67f1120381df02 Zhi Wang 2021-01-10 617 i915_gem_ww_ctx_init(&ww, false);
67f1120381df02 Zhi Wang 2021-01-10 618 retry:
67f1120381df02 Zhi Wang 2021-01-10 619 i915_gem_object_lock(wa_ctx->indirect_ctx.obj, &ww);
67f1120381df02 Zhi Wang 2021-01-10 620
67f1120381df02 Zhi Wang 2021-01-10 621 vma = i915_gem_object_ggtt_pin_ww(wa_ctx->indirect_ctx.obj, &ww, NULL,
d8235b5e55845d Zhi Wang 2017-09-12 622 0, CACHELINE_BYTES, 0);
67f1120381df02 Zhi Wang 2021-01-10 623 if (IS_ERR(vma)) {
67f1120381df02 Zhi Wang 2021-01-10 624 ret = PTR_ERR(vma);
67f1120381df02 Zhi Wang 2021-01-10 625 if (ret == -EDEADLK) {
67f1120381df02 Zhi Wang 2021-01-10 626 ret = i915_gem_ww_ctx_backoff(&ww);
67f1120381df02 Zhi Wang 2021-01-10 627 if (!ret)
67f1120381df02 Zhi Wang 2021-01-10 628 goto retry;
Does this path result in a double lock? (I haven't looked carefully).
67f1120381df02 Zhi Wang 2021-01-10 629 }
67f1120381df02 Zhi Wang 2021-01-10 630 return ret;
Call i915_gem_object_unlock() before returning.
67f1120381df02 Zhi Wang 2021-01-10 631 }
67f1120381df02 Zhi Wang 2021-01-10 632
67f1120381df02 Zhi Wang 2021-01-10 633 i915_gem_object_unlock(wa_ctx->indirect_ctx.obj);
d8235b5e55845d Zhi Wang 2017-09-12 634
d8235b5e55845d Zhi Wang 2017-09-12 635 /* FIXME: we are not tracking our pinned VMA leaving it
d8235b5e55845d Zhi Wang 2017-09-12 636 * up to the core to fix up the stray pin_count upon
d8235b5e55845d Zhi Wang 2017-09-12 637 * free.
d8235b5e55845d Zhi Wang 2017-09-12 638 */
d8235b5e55845d Zhi Wang 2017-09-12 639
d8235b5e55845d Zhi Wang 2017-09-12 640 wa_ctx->indirect_ctx.shadow_gma = i915_ggtt_offset(vma);
d8235b5e55845d Zhi Wang 2017-09-12 641
d8235b5e55845d Zhi Wang 2017-09-12 642 wa_ctx->per_ctx.shadow_gma = *((unsigned int *)per_ctx_va + 1);
d8235b5e55845d Zhi Wang 2017-09-12 643 memset(per_ctx_va, 0, CACHELINE_BYTES);
d8235b5e55845d Zhi Wang 2017-09-12 644
d8235b5e55845d Zhi Wang 2017-09-12 645 update_wa_ctx_2_shadow_ctx(wa_ctx);
d8235b5e55845d Zhi Wang 2017-09-12 @646 return 0;
d8235b5e55845d Zhi Wang 2017-09-12 647 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx