All of lore.kernel.org
 help / color / mirror / Atom feed
* [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02  8:44 ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: kernel test robot @ 2021-07-01 23:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 8176 bytes --]

CC: kbuild-all(a)lists.01.org
CC: intel-gfx(a)lists.freedesktop.org
CC: dri-devel(a)lists.freedesktop.org
TO: Chris Wilson <chris@chris-wilson.co.uk>
CC: Matthew Auld <matthew.auld@intel.com>
CC: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>

tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
:::::: branch date: 2 weeks ago
:::::: commit date: 2 weeks ago
config: x86_64-randconfig-m001-20210630 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.

Old smatch warnings:
drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)

vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c

cf586021642d80 Chris Wilson 2021-06-17   31  
cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   33  		int (*fn)(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   34  			  struct i915_gem_ww_ctx *ww,
cf586021642d80 Chris Wilson 2021-06-17   35  			  struct drm_i915_gem_object *src,
cf586021642d80 Chris Wilson 2021-06-17   36  			  struct drm_i915_gem_object *dst,
cf586021642d80 Chris Wilson 2021-06-17   37  			  struct i915_request **out),
cf586021642d80 Chris Wilson 2021-06-17   38  		u32 sz, struct rnd_state *prng)
cf586021642d80 Chris Wilson 2021-06-17   39  {
cf586021642d80 Chris Wilson 2021-06-17   40  	struct drm_i915_private *i915 = migrate->context->engine->i915;
cf586021642d80 Chris Wilson 2021-06-17   41  	struct drm_i915_gem_object *src, *dst;
cf586021642d80 Chris Wilson 2021-06-17   42  	struct i915_request *rq;
cf586021642d80 Chris Wilson 2021-06-17   43  	struct i915_gem_ww_ctx ww;
cf586021642d80 Chris Wilson 2021-06-17   44  	u32 *vaddr;
cf586021642d80 Chris Wilson 2021-06-17   45  	int err = 0;
cf586021642d80 Chris Wilson 2021-06-17   46  	int i;
cf586021642d80 Chris Wilson 2021-06-17   47  
cf586021642d80 Chris Wilson 2021-06-17   48  	src = create_lmem_or_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   49  	if (IS_ERR(src))
cf586021642d80 Chris Wilson 2021-06-17   50  		return 0;
cf586021642d80 Chris Wilson 2021-06-17   51  
cf586021642d80 Chris Wilson 2021-06-17   52  	dst = i915_gem_object_create_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   53  	if (IS_ERR(dst))
cf586021642d80 Chris Wilson 2021-06-17   54  		goto err_free_src;
cf586021642d80 Chris Wilson 2021-06-17   55  
cf586021642d80 Chris Wilson 2021-06-17   56  	for_i915_gem_ww(&ww, err, true) {
cf586021642d80 Chris Wilson 2021-06-17   57  		err = i915_gem_object_lock(src, &ww);
cf586021642d80 Chris Wilson 2021-06-17   58  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   59  			continue;
cf586021642d80 Chris Wilson 2021-06-17   60  
cf586021642d80 Chris Wilson 2021-06-17   61  		err = i915_gem_object_lock(dst, &ww);
cf586021642d80 Chris Wilson 2021-06-17   62  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   63  			continue;
cf586021642d80 Chris Wilson 2021-06-17   64  
cf586021642d80 Chris Wilson 2021-06-17   65  		vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   66  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   67  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   68  			continue;
cf586021642d80 Chris Wilson 2021-06-17   69  		}
cf586021642d80 Chris Wilson 2021-06-17   70  
cf586021642d80 Chris Wilson 2021-06-17   71  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   72  			vaddr[i] = i;
cf586021642d80 Chris Wilson 2021-06-17   73  		i915_gem_object_flush_map(src);
cf586021642d80 Chris Wilson 2021-06-17   74  
cf586021642d80 Chris Wilson 2021-06-17   75  		vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   76  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   77  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   78  			goto unpin_src;
cf586021642d80 Chris Wilson 2021-06-17   79  		}
cf586021642d80 Chris Wilson 2021-06-17   80  
cf586021642d80 Chris Wilson 2021-06-17   81  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   82  			vaddr[i] = ~i;
cf586021642d80 Chris Wilson 2021-06-17   83  		i915_gem_object_flush_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   84  
cf586021642d80 Chris Wilson 2021-06-17   85  		err = fn(migrate, &ww, src, dst, &rq);
cf586021642d80 Chris Wilson 2021-06-17   86  		if (!err)
cf586021642d80 Chris Wilson 2021-06-17   87  			continue;
cf586021642d80 Chris Wilson 2021-06-17   88  
cf586021642d80 Chris Wilson 2021-06-17   89  		if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
cf586021642d80 Chris Wilson 2021-06-17   90  			pr_err("%ps failed, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17   91  		if (rq) {
cf586021642d80 Chris Wilson 2021-06-17   92  			i915_request_wait(rq, 0, HZ);
cf586021642d80 Chris Wilson 2021-06-17   93  			i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17   94  		}
cf586021642d80 Chris Wilson 2021-06-17   95  		i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
cf586021642d80 Chris Wilson 2021-06-17   97  		i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17   98  	}
cf586021642d80 Chris Wilson 2021-06-17   99  	if (err)
cf586021642d80 Chris Wilson 2021-06-17  100  		goto err_out;
cf586021642d80 Chris Wilson 2021-06-17  101  
cf586021642d80 Chris Wilson 2021-06-17 @102  	if (rq) {
cf586021642d80 Chris Wilson 2021-06-17  103  		if (i915_request_wait(rq, 0, HZ) < 0) {
cf586021642d80 Chris Wilson 2021-06-17  104  			pr_err("%ps timed out, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17  105  			err = -ETIME;
cf586021642d80 Chris Wilson 2021-06-17  106  		}
cf586021642d80 Chris Wilson 2021-06-17  107  		i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17  108  	}
cf586021642d80 Chris Wilson 2021-06-17  109  
cf586021642d80 Chris Wilson 2021-06-17  110  	for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
cf586021642d80 Chris Wilson 2021-06-17  111  		int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
cf586021642d80 Chris Wilson 2021-06-17  112  
cf586021642d80 Chris Wilson 2021-06-17 @113  		if (vaddr[x] != x) {
cf586021642d80 Chris Wilson 2021-06-17  114  			pr_err("%ps failed, size: %u, offset: %zu\n",
cf586021642d80 Chris Wilson 2021-06-17  115  			       fn, sz, x * sizeof(u32));
cf586021642d80 Chris Wilson 2021-06-17  116  			igt_hexdump(vaddr + i * 1024, 4096);
cf586021642d80 Chris Wilson 2021-06-17  117  			err = -EINVAL;
cf586021642d80 Chris Wilson 2021-06-17  118  		}
cf586021642d80 Chris Wilson 2021-06-17  119  	}
cf586021642d80 Chris Wilson 2021-06-17  120  
cf586021642d80 Chris Wilson 2021-06-17  121  	i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17  122  	i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17  123  
cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
cf586021642d80 Chris Wilson 2021-06-17  125  	i915_gem_object_put(dst);
cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
cf586021642d80 Chris Wilson 2021-06-17  127  	i915_gem_object_put(src);
cf586021642d80 Chris Wilson 2021-06-17  128  
cf586021642d80 Chris Wilson 2021-06-17  129  	return err;
cf586021642d80 Chris Wilson 2021-06-17  130  }
cf586021642d80 Chris Wilson 2021-06-17  131  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 48632 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02  8:44 ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02  8:44 UTC (permalink / raw)
  To: kbuild, Chris Wilson
  Cc: Thomas Hellström, kbuild-all, lkp, intel-gfx, dri-devel,
	Matthew Auld

tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
config: x86_64-randconfig-m001-20210630 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.

Old smatch warnings:
drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)

vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c

cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   33  		int (*fn)(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   34  			  struct i915_gem_ww_ctx *ww,
cf586021642d80 Chris Wilson 2021-06-17   35  			  struct drm_i915_gem_object *src,
cf586021642d80 Chris Wilson 2021-06-17   36  			  struct drm_i915_gem_object *dst,
cf586021642d80 Chris Wilson 2021-06-17   37  			  struct i915_request **out),
cf586021642d80 Chris Wilson 2021-06-17   38  		u32 sz, struct rnd_state *prng)
cf586021642d80 Chris Wilson 2021-06-17   39  {
cf586021642d80 Chris Wilson 2021-06-17   40  	struct drm_i915_private *i915 = migrate->context->engine->i915;
cf586021642d80 Chris Wilson 2021-06-17   41  	struct drm_i915_gem_object *src, *dst;
cf586021642d80 Chris Wilson 2021-06-17   42  	struct i915_request *rq;
cf586021642d80 Chris Wilson 2021-06-17   43  	struct i915_gem_ww_ctx ww;
cf586021642d80 Chris Wilson 2021-06-17   44  	u32 *vaddr;
cf586021642d80 Chris Wilson 2021-06-17   45  	int err = 0;

One way to silence these warnings would be to initialize err = -EINVAL.
Then Smatch would know that we goto err_out for an empty list.

cf586021642d80 Chris Wilson 2021-06-17   46  	int i;
cf586021642d80 Chris Wilson 2021-06-17   47  
cf586021642d80 Chris Wilson 2021-06-17   48  	src = create_lmem_or_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   49  	if (IS_ERR(src))
cf586021642d80 Chris Wilson 2021-06-17   50  		return 0;
cf586021642d80 Chris Wilson 2021-06-17   51  
cf586021642d80 Chris Wilson 2021-06-17   52  	dst = i915_gem_object_create_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   53  	if (IS_ERR(dst))
cf586021642d80 Chris Wilson 2021-06-17   54  		goto err_free_src;
cf586021642d80 Chris Wilson 2021-06-17   55  
cf586021642d80 Chris Wilson 2021-06-17   56  	for_i915_gem_ww(&ww, err, true) {
cf586021642d80 Chris Wilson 2021-06-17   57  		err = i915_gem_object_lock(src, &ww);
cf586021642d80 Chris Wilson 2021-06-17   58  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   59  			continue;
cf586021642d80 Chris Wilson 2021-06-17   60  
cf586021642d80 Chris Wilson 2021-06-17   61  		err = i915_gem_object_lock(dst, &ww);
cf586021642d80 Chris Wilson 2021-06-17   62  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   63  			continue;
cf586021642d80 Chris Wilson 2021-06-17   64  
cf586021642d80 Chris Wilson 2021-06-17   65  		vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   66  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   67  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   68  			continue;
cf586021642d80 Chris Wilson 2021-06-17   69  		}
cf586021642d80 Chris Wilson 2021-06-17   70  
cf586021642d80 Chris Wilson 2021-06-17   71  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   72  			vaddr[i] = i;
cf586021642d80 Chris Wilson 2021-06-17   73  		i915_gem_object_flush_map(src);
cf586021642d80 Chris Wilson 2021-06-17   74  
cf586021642d80 Chris Wilson 2021-06-17   75  		vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   76  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   77  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   78  			goto unpin_src;
cf586021642d80 Chris Wilson 2021-06-17   79  		}
cf586021642d80 Chris Wilson 2021-06-17   80  
cf586021642d80 Chris Wilson 2021-06-17   81  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   82  			vaddr[i] = ~i;
cf586021642d80 Chris Wilson 2021-06-17   83  		i915_gem_object_flush_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   84  
cf586021642d80 Chris Wilson 2021-06-17   85  		err = fn(migrate, &ww, src, dst, &rq);
cf586021642d80 Chris Wilson 2021-06-17   86  		if (!err)
cf586021642d80 Chris Wilson 2021-06-17   87  			continue;

Does fn() initialize "rq" on the success path?  Anyway Smatch would
complain anyway because it thinks the list could be empty or that we
might hit and early continue for everything.

cf586021642d80 Chris Wilson 2021-06-17   88  
cf586021642d80 Chris Wilson 2021-06-17   89  		if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
cf586021642d80 Chris Wilson 2021-06-17   90  			pr_err("%ps failed, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17   91  		if (rq) {
cf586021642d80 Chris Wilson 2021-06-17   92  			i915_request_wait(rq, 0, HZ);
cf586021642d80 Chris Wilson 2021-06-17   93  			i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17   94  		}
cf586021642d80 Chris Wilson 2021-06-17   95  		i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
cf586021642d80 Chris Wilson 2021-06-17   97  		i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17   98  	}
cf586021642d80 Chris Wilson 2021-06-17   99  	if (err)
cf586021642d80 Chris Wilson 2021-06-17  100  		goto err_out;
cf586021642d80 Chris Wilson 2021-06-17  101  
cf586021642d80 Chris Wilson 2021-06-17 @102  	if (rq) {
cf586021642d80 Chris Wilson 2021-06-17  103  		if (i915_request_wait(rq, 0, HZ) < 0) {
cf586021642d80 Chris Wilson 2021-06-17  104  			pr_err("%ps timed out, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17  105  			err = -ETIME;
cf586021642d80 Chris Wilson 2021-06-17  106  		}
cf586021642d80 Chris Wilson 2021-06-17  107  		i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17  108  	}
cf586021642d80 Chris Wilson 2021-06-17  109  
cf586021642d80 Chris Wilson 2021-06-17  110  	for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
cf586021642d80 Chris Wilson 2021-06-17  111  		int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
cf586021642d80 Chris Wilson 2021-06-17  112  
cf586021642d80 Chris Wilson 2021-06-17 @113  		if (vaddr[x] != x) {
cf586021642d80 Chris Wilson 2021-06-17  114  			pr_err("%ps failed, size: %u, offset: %zu\n",
cf586021642d80 Chris Wilson 2021-06-17  115  			       fn, sz, x * sizeof(u32));
cf586021642d80 Chris Wilson 2021-06-17  116  			igt_hexdump(vaddr + i * 1024, 4096);
cf586021642d80 Chris Wilson 2021-06-17  117  			err = -EINVAL;
cf586021642d80 Chris Wilson 2021-06-17  118  		}
cf586021642d80 Chris Wilson 2021-06-17  119  	}
cf586021642d80 Chris Wilson 2021-06-17  120  
cf586021642d80 Chris Wilson 2021-06-17  121  	i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17  122  	i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17  123  
cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
cf586021642d80 Chris Wilson 2021-06-17  125  	i915_gem_object_put(dst);
cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
cf586021642d80 Chris Wilson 2021-06-17  127  	i915_gem_object_put(src);
cf586021642d80 Chris Wilson 2021-06-17  128  
cf586021642d80 Chris Wilson 2021-06-17  129  	return err;
cf586021642d80 Chris Wilson 2021-06-17  130  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02  8:44 ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02  8:44 UTC (permalink / raw)
  To: kbuild, Chris Wilson
  Cc: Thomas Hellström, kbuild-all, intel-gfx, dri-devel, Matthew Auld

tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
config: x86_64-randconfig-m001-20210630 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.

Old smatch warnings:
drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)

vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c

cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   33  		int (*fn)(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   34  			  struct i915_gem_ww_ctx *ww,
cf586021642d80 Chris Wilson 2021-06-17   35  			  struct drm_i915_gem_object *src,
cf586021642d80 Chris Wilson 2021-06-17   36  			  struct drm_i915_gem_object *dst,
cf586021642d80 Chris Wilson 2021-06-17   37  			  struct i915_request **out),
cf586021642d80 Chris Wilson 2021-06-17   38  		u32 sz, struct rnd_state *prng)
cf586021642d80 Chris Wilson 2021-06-17   39  {
cf586021642d80 Chris Wilson 2021-06-17   40  	struct drm_i915_private *i915 = migrate->context->engine->i915;
cf586021642d80 Chris Wilson 2021-06-17   41  	struct drm_i915_gem_object *src, *dst;
cf586021642d80 Chris Wilson 2021-06-17   42  	struct i915_request *rq;
cf586021642d80 Chris Wilson 2021-06-17   43  	struct i915_gem_ww_ctx ww;
cf586021642d80 Chris Wilson 2021-06-17   44  	u32 *vaddr;
cf586021642d80 Chris Wilson 2021-06-17   45  	int err = 0;

One way to silence these warnings would be to initialize err = -EINVAL.
Then Smatch would know that we goto err_out for an empty list.

cf586021642d80 Chris Wilson 2021-06-17   46  	int i;
cf586021642d80 Chris Wilson 2021-06-17   47  
cf586021642d80 Chris Wilson 2021-06-17   48  	src = create_lmem_or_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   49  	if (IS_ERR(src))
cf586021642d80 Chris Wilson 2021-06-17   50  		return 0;
cf586021642d80 Chris Wilson 2021-06-17   51  
cf586021642d80 Chris Wilson 2021-06-17   52  	dst = i915_gem_object_create_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   53  	if (IS_ERR(dst))
cf586021642d80 Chris Wilson 2021-06-17   54  		goto err_free_src;
cf586021642d80 Chris Wilson 2021-06-17   55  
cf586021642d80 Chris Wilson 2021-06-17   56  	for_i915_gem_ww(&ww, err, true) {
cf586021642d80 Chris Wilson 2021-06-17   57  		err = i915_gem_object_lock(src, &ww);
cf586021642d80 Chris Wilson 2021-06-17   58  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   59  			continue;
cf586021642d80 Chris Wilson 2021-06-17   60  
cf586021642d80 Chris Wilson 2021-06-17   61  		err = i915_gem_object_lock(dst, &ww);
cf586021642d80 Chris Wilson 2021-06-17   62  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   63  			continue;
cf586021642d80 Chris Wilson 2021-06-17   64  
cf586021642d80 Chris Wilson 2021-06-17   65  		vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   66  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   67  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   68  			continue;
cf586021642d80 Chris Wilson 2021-06-17   69  		}
cf586021642d80 Chris Wilson 2021-06-17   70  
cf586021642d80 Chris Wilson 2021-06-17   71  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   72  			vaddr[i] = i;
cf586021642d80 Chris Wilson 2021-06-17   73  		i915_gem_object_flush_map(src);
cf586021642d80 Chris Wilson 2021-06-17   74  
cf586021642d80 Chris Wilson 2021-06-17   75  		vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   76  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   77  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   78  			goto unpin_src;
cf586021642d80 Chris Wilson 2021-06-17   79  		}
cf586021642d80 Chris Wilson 2021-06-17   80  
cf586021642d80 Chris Wilson 2021-06-17   81  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   82  			vaddr[i] = ~i;
cf586021642d80 Chris Wilson 2021-06-17   83  		i915_gem_object_flush_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   84  
cf586021642d80 Chris Wilson 2021-06-17   85  		err = fn(migrate, &ww, src, dst, &rq);
cf586021642d80 Chris Wilson 2021-06-17   86  		if (!err)
cf586021642d80 Chris Wilson 2021-06-17   87  			continue;

Does fn() initialize "rq" on the success path?  Anyway Smatch would
complain anyway because it thinks the list could be empty or that we
might hit and early continue for everything.

cf586021642d80 Chris Wilson 2021-06-17   88  
cf586021642d80 Chris Wilson 2021-06-17   89  		if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
cf586021642d80 Chris Wilson 2021-06-17   90  			pr_err("%ps failed, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17   91  		if (rq) {
cf586021642d80 Chris Wilson 2021-06-17   92  			i915_request_wait(rq, 0, HZ);
cf586021642d80 Chris Wilson 2021-06-17   93  			i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17   94  		}
cf586021642d80 Chris Wilson 2021-06-17   95  		i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
cf586021642d80 Chris Wilson 2021-06-17   97  		i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17   98  	}
cf586021642d80 Chris Wilson 2021-06-17   99  	if (err)
cf586021642d80 Chris Wilson 2021-06-17  100  		goto err_out;
cf586021642d80 Chris Wilson 2021-06-17  101  
cf586021642d80 Chris Wilson 2021-06-17 @102  	if (rq) {
cf586021642d80 Chris Wilson 2021-06-17  103  		if (i915_request_wait(rq, 0, HZ) < 0) {
cf586021642d80 Chris Wilson 2021-06-17  104  			pr_err("%ps timed out, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17  105  			err = -ETIME;
cf586021642d80 Chris Wilson 2021-06-17  106  		}
cf586021642d80 Chris Wilson 2021-06-17  107  		i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17  108  	}
cf586021642d80 Chris Wilson 2021-06-17  109  
cf586021642d80 Chris Wilson 2021-06-17  110  	for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
cf586021642d80 Chris Wilson 2021-06-17  111  		int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
cf586021642d80 Chris Wilson 2021-06-17  112  
cf586021642d80 Chris Wilson 2021-06-17 @113  		if (vaddr[x] != x) {
cf586021642d80 Chris Wilson 2021-06-17  114  			pr_err("%ps failed, size: %u, offset: %zu\n",
cf586021642d80 Chris Wilson 2021-06-17  115  			       fn, sz, x * sizeof(u32));
cf586021642d80 Chris Wilson 2021-06-17  116  			igt_hexdump(vaddr + i * 1024, 4096);
cf586021642d80 Chris Wilson 2021-06-17  117  			err = -EINVAL;
cf586021642d80 Chris Wilson 2021-06-17  118  		}
cf586021642d80 Chris Wilson 2021-06-17  119  	}
cf586021642d80 Chris Wilson 2021-06-17  120  
cf586021642d80 Chris Wilson 2021-06-17  121  	i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17  122  	i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17  123  
cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
cf586021642d80 Chris Wilson 2021-06-17  125  	i915_gem_object_put(dst);
cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
cf586021642d80 Chris Wilson 2021-06-17  127  	i915_gem_object_put(src);
cf586021642d80 Chris Wilson 2021-06-17  128  
cf586021642d80 Chris Wilson 2021-06-17  129  	return err;
cf586021642d80 Chris Wilson 2021-06-17  130  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02  8:44 ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02  8:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 8087 bytes --]

tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
config: x86_64-randconfig-m001-20210630 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.

Old smatch warnings:
drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)

vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c

cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   33  		int (*fn)(struct intel_migrate *migrate,
cf586021642d80 Chris Wilson 2021-06-17   34  			  struct i915_gem_ww_ctx *ww,
cf586021642d80 Chris Wilson 2021-06-17   35  			  struct drm_i915_gem_object *src,
cf586021642d80 Chris Wilson 2021-06-17   36  			  struct drm_i915_gem_object *dst,
cf586021642d80 Chris Wilson 2021-06-17   37  			  struct i915_request **out),
cf586021642d80 Chris Wilson 2021-06-17   38  		u32 sz, struct rnd_state *prng)
cf586021642d80 Chris Wilson 2021-06-17   39  {
cf586021642d80 Chris Wilson 2021-06-17   40  	struct drm_i915_private *i915 = migrate->context->engine->i915;
cf586021642d80 Chris Wilson 2021-06-17   41  	struct drm_i915_gem_object *src, *dst;
cf586021642d80 Chris Wilson 2021-06-17   42  	struct i915_request *rq;
cf586021642d80 Chris Wilson 2021-06-17   43  	struct i915_gem_ww_ctx ww;
cf586021642d80 Chris Wilson 2021-06-17   44  	u32 *vaddr;
cf586021642d80 Chris Wilson 2021-06-17   45  	int err = 0;

One way to silence these warnings would be to initialize err = -EINVAL.
Then Smatch would know that we goto err_out for an empty list.

cf586021642d80 Chris Wilson 2021-06-17   46  	int i;
cf586021642d80 Chris Wilson 2021-06-17   47  
cf586021642d80 Chris Wilson 2021-06-17   48  	src = create_lmem_or_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   49  	if (IS_ERR(src))
cf586021642d80 Chris Wilson 2021-06-17   50  		return 0;
cf586021642d80 Chris Wilson 2021-06-17   51  
cf586021642d80 Chris Wilson 2021-06-17   52  	dst = i915_gem_object_create_internal(i915, sz);
cf586021642d80 Chris Wilson 2021-06-17   53  	if (IS_ERR(dst))
cf586021642d80 Chris Wilson 2021-06-17   54  		goto err_free_src;
cf586021642d80 Chris Wilson 2021-06-17   55  
cf586021642d80 Chris Wilson 2021-06-17   56  	for_i915_gem_ww(&ww, err, true) {
cf586021642d80 Chris Wilson 2021-06-17   57  		err = i915_gem_object_lock(src, &ww);
cf586021642d80 Chris Wilson 2021-06-17   58  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   59  			continue;
cf586021642d80 Chris Wilson 2021-06-17   60  
cf586021642d80 Chris Wilson 2021-06-17   61  		err = i915_gem_object_lock(dst, &ww);
cf586021642d80 Chris Wilson 2021-06-17   62  		if (err)
cf586021642d80 Chris Wilson 2021-06-17   63  			continue;
cf586021642d80 Chris Wilson 2021-06-17   64  
cf586021642d80 Chris Wilson 2021-06-17   65  		vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   66  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   67  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   68  			continue;
cf586021642d80 Chris Wilson 2021-06-17   69  		}
cf586021642d80 Chris Wilson 2021-06-17   70  
cf586021642d80 Chris Wilson 2021-06-17   71  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   72  			vaddr[i] = i;
cf586021642d80 Chris Wilson 2021-06-17   73  		i915_gem_object_flush_map(src);
cf586021642d80 Chris Wilson 2021-06-17   74  
cf586021642d80 Chris Wilson 2021-06-17   75  		vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
cf586021642d80 Chris Wilson 2021-06-17   76  		if (IS_ERR(vaddr)) {
cf586021642d80 Chris Wilson 2021-06-17   77  			err = PTR_ERR(vaddr);
cf586021642d80 Chris Wilson 2021-06-17   78  			goto unpin_src;
cf586021642d80 Chris Wilson 2021-06-17   79  		}
cf586021642d80 Chris Wilson 2021-06-17   80  
cf586021642d80 Chris Wilson 2021-06-17   81  		for (i = 0; i < sz / sizeof(u32); i++)
cf586021642d80 Chris Wilson 2021-06-17   82  			vaddr[i] = ~i;
cf586021642d80 Chris Wilson 2021-06-17   83  		i915_gem_object_flush_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   84  
cf586021642d80 Chris Wilson 2021-06-17   85  		err = fn(migrate, &ww, src, dst, &rq);
cf586021642d80 Chris Wilson 2021-06-17   86  		if (!err)
cf586021642d80 Chris Wilson 2021-06-17   87  			continue;

Does fn() initialize "rq" on the success path?  Anyway Smatch would
complain anyway because it thinks the list could be empty or that we
might hit and early continue for everything.

cf586021642d80 Chris Wilson 2021-06-17   88  
cf586021642d80 Chris Wilson 2021-06-17   89  		if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
cf586021642d80 Chris Wilson 2021-06-17   90  			pr_err("%ps failed, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17   91  		if (rq) {
cf586021642d80 Chris Wilson 2021-06-17   92  			i915_request_wait(rq, 0, HZ);
cf586021642d80 Chris Wilson 2021-06-17   93  			i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17   94  		}
cf586021642d80 Chris Wilson 2021-06-17   95  		i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
cf586021642d80 Chris Wilson 2021-06-17   97  		i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17   98  	}
cf586021642d80 Chris Wilson 2021-06-17   99  	if (err)
cf586021642d80 Chris Wilson 2021-06-17  100  		goto err_out;
cf586021642d80 Chris Wilson 2021-06-17  101  
cf586021642d80 Chris Wilson 2021-06-17 @102  	if (rq) {
cf586021642d80 Chris Wilson 2021-06-17  103  		if (i915_request_wait(rq, 0, HZ) < 0) {
cf586021642d80 Chris Wilson 2021-06-17  104  			pr_err("%ps timed out, size: %u\n", fn, sz);
cf586021642d80 Chris Wilson 2021-06-17  105  			err = -ETIME;
cf586021642d80 Chris Wilson 2021-06-17  106  		}
cf586021642d80 Chris Wilson 2021-06-17  107  		i915_request_put(rq);
cf586021642d80 Chris Wilson 2021-06-17  108  	}
cf586021642d80 Chris Wilson 2021-06-17  109  
cf586021642d80 Chris Wilson 2021-06-17  110  	for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
cf586021642d80 Chris Wilson 2021-06-17  111  		int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
cf586021642d80 Chris Wilson 2021-06-17  112  
cf586021642d80 Chris Wilson 2021-06-17 @113  		if (vaddr[x] != x) {
cf586021642d80 Chris Wilson 2021-06-17  114  			pr_err("%ps failed, size: %u, offset: %zu\n",
cf586021642d80 Chris Wilson 2021-06-17  115  			       fn, sz, x * sizeof(u32));
cf586021642d80 Chris Wilson 2021-06-17  116  			igt_hexdump(vaddr + i * 1024, 4096);
cf586021642d80 Chris Wilson 2021-06-17  117  			err = -EINVAL;
cf586021642d80 Chris Wilson 2021-06-17  118  		}
cf586021642d80 Chris Wilson 2021-06-17  119  	}
cf586021642d80 Chris Wilson 2021-06-17  120  
cf586021642d80 Chris Wilson 2021-06-17  121  	i915_gem_object_unpin_map(dst);
cf586021642d80 Chris Wilson 2021-06-17  122  	i915_gem_object_unpin_map(src);
cf586021642d80 Chris Wilson 2021-06-17  123  
cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
cf586021642d80 Chris Wilson 2021-06-17  125  	i915_gem_object_put(dst);
cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
cf586021642d80 Chris Wilson 2021-06-17  127  	i915_gem_object_put(src);
cf586021642d80 Chris Wilson 2021-06-17  128  
cf586021642d80 Chris Wilson 2021-06-17  129  	return err;
cf586021642d80 Chris Wilson 2021-06-17  130  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02  8:44 ` Dan Carpenter
  (?)
@ 2021-07-02 10:32   ` Matthew Auld
  -1 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 10:32 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> config: x86_64-randconfig-m001-20210630 (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@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New smatch warnings:
> drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
>
> Old smatch warnings:
> drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
>
> vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
>
> cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> cf586021642d80 Chris Wilson 2021-06-17   39  {
> cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
>
> One way to silence these warnings would be to initialize err = -EINVAL.
> Then Smatch would know that we goto err_out for an empty list.
>
> cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> cf586021642d80 Chris Wilson 2021-06-17   47
> cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> cf586021642d80 Chris Wilson 2021-06-17   51
> cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> cf586021642d80 Chris Wilson 2021-06-17   55
> cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   60
> cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   64
> cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   69             }
> cf586021642d80 Chris Wilson 2021-06-17   70
> cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   74
> cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> cf586021642d80 Chris Wilson 2021-06-17   79             }
> cf586021642d80 Chris Wilson 2021-06-17   80
> cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   84
> cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
>
> Does fn() initialize "rq" on the success path?  Anyway Smatch would
> complain anyway because it thinks the list could be empty or that we
> might hit and early continue for everything.

The fn() will always first initialize the rq to NULL. If it returns
success then rq will always be a valid rq. If it returns an err then
the rq might be NULL, or a valid rq depending on how far the copy/fn
got.

And for_i915_gem_ww() will always run at least once, since ww->loop =
true, so this looks like a false positive?

>
> cf586021642d80 Chris Wilson 2021-06-17   88
> cf586021642d80 Chris Wilson 2021-06-17   89             if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
> cf586021642d80 Chris Wilson 2021-06-17   90                     pr_err("%ps failed, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17   91             if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17   92                     i915_request_wait(rq, 0, HZ);
> cf586021642d80 Chris Wilson 2021-06-17   93                     i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17   94             }
> cf586021642d80 Chris Wilson 2021-06-17   95             i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
> cf586021642d80 Chris Wilson 2021-06-17   97             i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   98     }
> cf586021642d80 Chris Wilson 2021-06-17   99     if (err)
> cf586021642d80 Chris Wilson 2021-06-17  100             goto err_out;
> cf586021642d80 Chris Wilson 2021-06-17  101
> cf586021642d80 Chris Wilson 2021-06-17 @102     if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17  103             if (i915_request_wait(rq, 0, HZ) < 0) {
> cf586021642d80 Chris Wilson 2021-06-17  104                     pr_err("%ps timed out, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17  105                     err = -ETIME;
> cf586021642d80 Chris Wilson 2021-06-17  106             }
> cf586021642d80 Chris Wilson 2021-06-17  107             i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17  108     }
> cf586021642d80 Chris Wilson 2021-06-17  109
> cf586021642d80 Chris Wilson 2021-06-17  110     for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
> cf586021642d80 Chris Wilson 2021-06-17  111             int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
> cf586021642d80 Chris Wilson 2021-06-17  112
> cf586021642d80 Chris Wilson 2021-06-17 @113             if (vaddr[x] != x) {
> cf586021642d80 Chris Wilson 2021-06-17  114                     pr_err("%ps failed, size: %u, offset: %zu\n",
> cf586021642d80 Chris Wilson 2021-06-17  115                            fn, sz, x * sizeof(u32));
> cf586021642d80 Chris Wilson 2021-06-17  116                     igt_hexdump(vaddr + i * 1024, 4096);
> cf586021642d80 Chris Wilson 2021-06-17  117                     err = -EINVAL;
> cf586021642d80 Chris Wilson 2021-06-17  118             }
> cf586021642d80 Chris Wilson 2021-06-17  119     }
> cf586021642d80 Chris Wilson 2021-06-17  120
> cf586021642d80 Chris Wilson 2021-06-17  121     i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17  122     i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17  123
> cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
> cf586021642d80 Chris Wilson 2021-06-17  125     i915_gem_object_put(dst);
> cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
> cf586021642d80 Chris Wilson 2021-06-17  127     i915_gem_object_put(src);
> cf586021642d80 Chris Wilson 2021-06-17  128
> cf586021642d80 Chris Wilson 2021-06-17  129     return err;
> cf586021642d80 Chris Wilson 2021-06-17  130  }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 10:32   ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 10:32 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> config: x86_64-randconfig-m001-20210630 (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@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New smatch warnings:
> drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
>
> Old smatch warnings:
> drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
>
> vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
>
> cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> cf586021642d80 Chris Wilson 2021-06-17   39  {
> cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
>
> One way to silence these warnings would be to initialize err = -EINVAL.
> Then Smatch would know that we goto err_out for an empty list.
>
> cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> cf586021642d80 Chris Wilson 2021-06-17   47
> cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> cf586021642d80 Chris Wilson 2021-06-17   51
> cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> cf586021642d80 Chris Wilson 2021-06-17   55
> cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   60
> cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   64
> cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   69             }
> cf586021642d80 Chris Wilson 2021-06-17   70
> cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   74
> cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> cf586021642d80 Chris Wilson 2021-06-17   79             }
> cf586021642d80 Chris Wilson 2021-06-17   80
> cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   84
> cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
>
> Does fn() initialize "rq" on the success path?  Anyway Smatch would
> complain anyway because it thinks the list could be empty or that we
> might hit and early continue for everything.

The fn() will always first initialize the rq to NULL. If it returns
success then rq will always be a valid rq. If it returns an err then
the rq might be NULL, or a valid rq depending on how far the copy/fn
got.

And for_i915_gem_ww() will always run at least once, since ww->loop =
true, so this looks like a false positive?

>
> cf586021642d80 Chris Wilson 2021-06-17   88
> cf586021642d80 Chris Wilson 2021-06-17   89             if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
> cf586021642d80 Chris Wilson 2021-06-17   90                     pr_err("%ps failed, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17   91             if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17   92                     i915_request_wait(rq, 0, HZ);
> cf586021642d80 Chris Wilson 2021-06-17   93                     i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17   94             }
> cf586021642d80 Chris Wilson 2021-06-17   95             i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
> cf586021642d80 Chris Wilson 2021-06-17   97             i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   98     }
> cf586021642d80 Chris Wilson 2021-06-17   99     if (err)
> cf586021642d80 Chris Wilson 2021-06-17  100             goto err_out;
> cf586021642d80 Chris Wilson 2021-06-17  101
> cf586021642d80 Chris Wilson 2021-06-17 @102     if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17  103             if (i915_request_wait(rq, 0, HZ) < 0) {
> cf586021642d80 Chris Wilson 2021-06-17  104                     pr_err("%ps timed out, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17  105                     err = -ETIME;
> cf586021642d80 Chris Wilson 2021-06-17  106             }
> cf586021642d80 Chris Wilson 2021-06-17  107             i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17  108     }
> cf586021642d80 Chris Wilson 2021-06-17  109
> cf586021642d80 Chris Wilson 2021-06-17  110     for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
> cf586021642d80 Chris Wilson 2021-06-17  111             int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
> cf586021642d80 Chris Wilson 2021-06-17  112
> cf586021642d80 Chris Wilson 2021-06-17 @113             if (vaddr[x] != x) {
> cf586021642d80 Chris Wilson 2021-06-17  114                     pr_err("%ps failed, size: %u, offset: %zu\n",
> cf586021642d80 Chris Wilson 2021-06-17  115                            fn, sz, x * sizeof(u32));
> cf586021642d80 Chris Wilson 2021-06-17  116                     igt_hexdump(vaddr + i * 1024, 4096);
> cf586021642d80 Chris Wilson 2021-06-17  117                     err = -EINVAL;
> cf586021642d80 Chris Wilson 2021-06-17  118             }
> cf586021642d80 Chris Wilson 2021-06-17  119     }
> cf586021642d80 Chris Wilson 2021-06-17  120
> cf586021642d80 Chris Wilson 2021-06-17  121     i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17  122     i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17  123
> cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
> cf586021642d80 Chris Wilson 2021-06-17  125     i915_gem_object_put(dst);
> cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
> cf586021642d80 Chris Wilson 2021-06-17  127     i915_gem_object_put(src);
> cf586021642d80 Chris Wilson 2021-06-17  128
> cf586021642d80 Chris Wilson 2021-06-17  129     return err;
> cf586021642d80 Chris Wilson 2021-06-17  130  }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 10:32   ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 10:32 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9587 bytes --]

On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> config: x86_64-randconfig-m001-20210630 (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@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> New smatch warnings:
> drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
>
> Old smatch warnings:
> drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
>
> vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
>
> cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> cf586021642d80 Chris Wilson 2021-06-17   39  {
> cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
>
> One way to silence these warnings would be to initialize err = -EINVAL.
> Then Smatch would know that we goto err_out for an empty list.
>
> cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> cf586021642d80 Chris Wilson 2021-06-17   47
> cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> cf586021642d80 Chris Wilson 2021-06-17   51
> cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> cf586021642d80 Chris Wilson 2021-06-17   55
> cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   60
> cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   64
> cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> cf586021642d80 Chris Wilson 2021-06-17   69             }
> cf586021642d80 Chris Wilson 2021-06-17   70
> cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   74
> cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> cf586021642d80 Chris Wilson 2021-06-17   79             }
> cf586021642d80 Chris Wilson 2021-06-17   80
> cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   84
> cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
>
> Does fn() initialize "rq" on the success path?  Anyway Smatch would
> complain anyway because it thinks the list could be empty or that we
> might hit and early continue for everything.

The fn() will always first initialize the rq to NULL. If it returns
success then rq will always be a valid rq. If it returns an err then
the rq might be NULL, or a valid rq depending on how far the copy/fn
got.

And for_i915_gem_ww() will always run at least once, since ww->loop =
true, so this looks like a false positive?

>
> cf586021642d80 Chris Wilson 2021-06-17   88
> cf586021642d80 Chris Wilson 2021-06-17   89             if (err != -EDEADLK && err != -EINTR && err != -ERESTARTSYS)
> cf586021642d80 Chris Wilson 2021-06-17   90                     pr_err("%ps failed, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17   91             if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17   92                     i915_request_wait(rq, 0, HZ);
> cf586021642d80 Chris Wilson 2021-06-17   93                     i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17   94             }
> cf586021642d80 Chris Wilson 2021-06-17   95             i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17   96  unpin_src:
> cf586021642d80 Chris Wilson 2021-06-17   97             i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17   98     }
> cf586021642d80 Chris Wilson 2021-06-17   99     if (err)
> cf586021642d80 Chris Wilson 2021-06-17  100             goto err_out;
> cf586021642d80 Chris Wilson 2021-06-17  101
> cf586021642d80 Chris Wilson 2021-06-17 @102     if (rq) {
> cf586021642d80 Chris Wilson 2021-06-17  103             if (i915_request_wait(rq, 0, HZ) < 0) {
> cf586021642d80 Chris Wilson 2021-06-17  104                     pr_err("%ps timed out, size: %u\n", fn, sz);
> cf586021642d80 Chris Wilson 2021-06-17  105                     err = -ETIME;
> cf586021642d80 Chris Wilson 2021-06-17  106             }
> cf586021642d80 Chris Wilson 2021-06-17  107             i915_request_put(rq);
> cf586021642d80 Chris Wilson 2021-06-17  108     }
> cf586021642d80 Chris Wilson 2021-06-17  109
> cf586021642d80 Chris Wilson 2021-06-17  110     for (i = 0; !err && i < sz / PAGE_SIZE; i++) {
> cf586021642d80 Chris Wilson 2021-06-17  111             int x = i * 1024 + i915_prandom_u32_max_state(1024, prng);
> cf586021642d80 Chris Wilson 2021-06-17  112
> cf586021642d80 Chris Wilson 2021-06-17 @113             if (vaddr[x] != x) {
> cf586021642d80 Chris Wilson 2021-06-17  114                     pr_err("%ps failed, size: %u, offset: %zu\n",
> cf586021642d80 Chris Wilson 2021-06-17  115                            fn, sz, x * sizeof(u32));
> cf586021642d80 Chris Wilson 2021-06-17  116                     igt_hexdump(vaddr + i * 1024, 4096);
> cf586021642d80 Chris Wilson 2021-06-17  117                     err = -EINVAL;
> cf586021642d80 Chris Wilson 2021-06-17  118             }
> cf586021642d80 Chris Wilson 2021-06-17  119     }
> cf586021642d80 Chris Wilson 2021-06-17  120
> cf586021642d80 Chris Wilson 2021-06-17  121     i915_gem_object_unpin_map(dst);
> cf586021642d80 Chris Wilson 2021-06-17  122     i915_gem_object_unpin_map(src);
> cf586021642d80 Chris Wilson 2021-06-17  123
> cf586021642d80 Chris Wilson 2021-06-17  124  err_out:
> cf586021642d80 Chris Wilson 2021-06-17  125     i915_gem_object_put(dst);
> cf586021642d80 Chris Wilson 2021-06-17  126  err_free_src:
> cf586021642d80 Chris Wilson 2021-06-17  127     i915_gem_object_put(src);
> cf586021642d80 Chris Wilson 2021-06-17  128
> cf586021642d80 Chris Wilson 2021-06-17  129     return err;
> cf586021642d80 Chris Wilson 2021-06-17  130  }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx(a)lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02 10:32   ` Matthew Auld
  (?)
  (?)
@ 2021-07-02 11:07     ` Dan Carpenter
  -1 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:07 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > New smatch warnings:
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> >
> > Old smatch warnings:
> > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> >
> > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> >
> > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> >
> > One way to silence these warnings would be to initialize err = -EINVAL.
> > Then Smatch would know that we goto err_out for an empty list.
> >
> > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > cf586021642d80 Chris Wilson 2021-06-17   47
> > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > cf586021642d80 Chris Wilson 2021-06-17   51
> > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > cf586021642d80 Chris Wilson 2021-06-17   55
> > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   60
> > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   64
> > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > cf586021642d80 Chris Wilson 2021-06-17   70
> > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > cf586021642d80 Chris Wilson 2021-06-17   74
> > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > cf586021642d80 Chris Wilson 2021-06-17   80
> > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > cf586021642d80 Chris Wilson 2021-06-17   84
> > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> >
> > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > complain anyway because it thinks the list could be empty or that we
> > might hit and early continue for everything.
> 
> The fn() will always first initialize the rq to NULL. If it returns
> success then rq will always be a valid rq. If it returns an err then
> the rq might be NULL, or a valid rq depending on how far the copy/fn
> got.
> 
> And for_i915_gem_ww() will always run at least once, since ww->loop =
> true, so this looks like a false positive?

You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
i915_gem_object_pin_map() can fail?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:07     ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:07 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > New smatch warnings:
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> >
> > Old smatch warnings:
> > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> >
> > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> >
> > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> >
> > One way to silence these warnings would be to initialize err = -EINVAL.
> > Then Smatch would know that we goto err_out for an empty list.
> >
> > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > cf586021642d80 Chris Wilson 2021-06-17   47
> > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > cf586021642d80 Chris Wilson 2021-06-17   51
> > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > cf586021642d80 Chris Wilson 2021-06-17   55
> > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   60
> > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   64
> > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > cf586021642d80 Chris Wilson 2021-06-17   70
> > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > cf586021642d80 Chris Wilson 2021-06-17   74
> > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > cf586021642d80 Chris Wilson 2021-06-17   80
> > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > cf586021642d80 Chris Wilson 2021-06-17   84
> > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> >
> > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > complain anyway because it thinks the list could be empty or that we
> > might hit and early continue for everything.
> 
> The fn() will always first initialize the rq to NULL. If it returns
> success then rq will always be a valid rq. If it returns an err then
> the rq might be NULL, or a valid rq depending on how far the copy/fn
> got.
> 
> And for_i915_gem_ww() will always run at least once, since ww->loop =
> true, so this looks like a false positive?

You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
i915_gem_object_pin_map() can fail?

regards,
dan carpenter

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:07     ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:07 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6455 bytes --]

On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > New smatch warnings:
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> >
> > Old smatch warnings:
> > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> >
> > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> >
> > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> >
> > One way to silence these warnings would be to initialize err = -EINVAL.
> > Then Smatch would know that we goto err_out for an empty list.
> >
> > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > cf586021642d80 Chris Wilson 2021-06-17   47
> > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > cf586021642d80 Chris Wilson 2021-06-17   51
> > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > cf586021642d80 Chris Wilson 2021-06-17   55
> > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   60
> > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   64
> > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > cf586021642d80 Chris Wilson 2021-06-17   70
> > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > cf586021642d80 Chris Wilson 2021-06-17   74
> > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > cf586021642d80 Chris Wilson 2021-06-17   80
> > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > cf586021642d80 Chris Wilson 2021-06-17   84
> > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> >
> > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > complain anyway because it thinks the list could be empty or that we
> > might hit and early continue for everything.
> 
> The fn() will always first initialize the rq to NULL. If it returns
> success then rq will always be a valid rq. If it returns an err then
> the rq might be NULL, or a valid rq depending on how far the copy/fn
> got.
> 
> And for_i915_gem_ww() will always run at least once, since ww->loop =
> true, so this looks like a false positive?

You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
i915_gem_object_pin_map() can fail?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:07     ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6455 bytes --]

On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > New smatch warnings:
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> >
> > Old smatch warnings:
> > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> >
> > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> >
> > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> >
> > One way to silence these warnings would be to initialize err = -EINVAL.
> > Then Smatch would know that we goto err_out for an empty list.
> >
> > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > cf586021642d80 Chris Wilson 2021-06-17   47
> > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > cf586021642d80 Chris Wilson 2021-06-17   51
> > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > cf586021642d80 Chris Wilson 2021-06-17   55
> > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   60
> > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   64
> > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > cf586021642d80 Chris Wilson 2021-06-17   70
> > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > cf586021642d80 Chris Wilson 2021-06-17   74
> > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > cf586021642d80 Chris Wilson 2021-06-17   80
> > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > cf586021642d80 Chris Wilson 2021-06-17   84
> > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> >
> > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > complain anyway because it thinks the list could be empty or that we
> > might hit and early continue for everything.
> 
> The fn() will always first initialize the rq to NULL. If it returns
> success then rq will always be a valid rq. If it returns an err then
> the rq might be NULL, or a valid rq depending on how far the copy/fn
> got.
> 
> And for_i915_gem_ww() will always run at least once, since ww->loop =
> true, so this looks like a false positive?

You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
i915_gem_object_pin_map() can fail?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02 11:07     ` Dan Carpenter
  (?)
  (?)
@ 2021-07-02 11:13       ` Dan Carpenter
  -1 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:13 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> > 
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> > 
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
> 
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Btw, I sincerely hope that we will re-enable GCC's uninitialized
variable checks.  Will GCC be able to verify that this is initialized?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:13       ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:13 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> > 
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> > 
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
> 
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Btw, I sincerely hope that we will re-enable GCC's uninitialized
variable checks.  Will GCC be able to verify that this is initialized?

regards,
dan carpenter

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:13       ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:13 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> > 
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> > 
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
> 
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Btw, I sincerely hope that we will re-enable GCC's uninitialized
variable checks.  Will GCC be able to verify that this is initialized?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:13       ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 11:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> > 
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> > 
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
> 
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Btw, I sincerely hope that we will re-enable GCC's uninitialized
variable checks.  Will GCC be able to verify that this is initialized?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02 11:07     ` Dan Carpenter
  (?)
@ 2021-07-02 11:34       ` Matthew Auld
  -1 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 12:07, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > >
> > > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > >
> > > New smatch warnings:
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> > >
> > > Old smatch warnings:
> > > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> > >
> > > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> > >
> > > One way to silence these warnings would be to initialize err = -EINVAL.
> > > Then Smatch would know that we goto err_out for an empty list.
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > > cf586021642d80 Chris Wilson 2021-06-17   47
> > > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > > cf586021642d80 Chris Wilson 2021-06-17   51
> > > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   55
> > > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   60
> > > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   64
> > > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > > cf586021642d80 Chris Wilson 2021-06-17   70
> > > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > > cf586021642d80 Chris Wilson 2021-06-17   74
> > > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > > cf586021642d80 Chris Wilson 2021-06-17   80
> > > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> >
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> >
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
>
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Yeah, they can totally fail but then we mostly likely just hit the
err_out. The for_i915_gem_ww() is a little strange since it's not
really looping over anything, it's just about retrying the block if we
see -EDEADLK(which involves dropping some locks), if we see any other
error then the loop is terminated with ww->loop = false, which then
hits the goto err_out.

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:34       ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 12:07, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > >
> > > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > >
> > > New smatch warnings:
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> > >
> > > Old smatch warnings:
> > > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> > >
> > > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> > >
> > > One way to silence these warnings would be to initialize err = -EINVAL.
> > > Then Smatch would know that we goto err_out for an empty list.
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > > cf586021642d80 Chris Wilson 2021-06-17   47
> > > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > > cf586021642d80 Chris Wilson 2021-06-17   51
> > > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   55
> > > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   60
> > > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   64
> > > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > > cf586021642d80 Chris Wilson 2021-06-17   70
> > > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > > cf586021642d80 Chris Wilson 2021-06-17   74
> > > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > > cf586021642d80 Chris Wilson 2021-06-17   80
> > > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> >
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> >
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
>
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Yeah, they can totally fail but then we mostly likely just hit the
err_out. The for_i915_gem_ww() is a little strange since it's not
really looping over anything, it's just about retrying the block if we
see -EDEADLK(which involves dropping some locks), if we see any other
error then the loop is terminated with ww->loop = false, which then
hits the goto err_out.

>
> regards,
> dan carpenter
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:34       ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:34 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7108 bytes --]

On Fri, 2 Jul 2021 at 12:07, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > >
> > > tree:   git://anongit.freedesktop.org/drm-intel drm-intel-gt-next
> > > head:   5cd57f676bb946a00275408f0dd0d75dbc466d25
> > > commit: cf586021642d8017cde111b7dd1ba86224e9da51 [8/14] drm/i915/gt: Pipelined page migration
> > > config: x86_64-randconfig-m001-20210630 (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@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > >
> > > New smatch warnings:
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
> > > drivers/gpu/drm/i915/gt/selftest_migrate.c:113 copy() error: uninitialized symbol 'vaddr'.
> > >
> > > Old smatch warnings:
> > > drivers/gpu/drm/i915/gem/i915_gem_object.h:182 __i915_gem_object_lock() error: we previously assumed 'ww' could be null (see line 171)
> > >
> > > vim +/rq +102 drivers/gpu/drm/i915/gt/selftest_migrate.c
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   32  static int copy(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   33             int (*fn)(struct intel_migrate *migrate,
> > > cf586021642d80 Chris Wilson 2021-06-17   34                       struct i915_gem_ww_ctx *ww,
> > > cf586021642d80 Chris Wilson 2021-06-17   35                       struct drm_i915_gem_object *src,
> > > cf586021642d80 Chris Wilson 2021-06-17   36                       struct drm_i915_gem_object *dst,
> > > cf586021642d80 Chris Wilson 2021-06-17   37                       struct i915_request **out),
> > > cf586021642d80 Chris Wilson 2021-06-17   38             u32 sz, struct rnd_state *prng)
> > > cf586021642d80 Chris Wilson 2021-06-17   39  {
> > > cf586021642d80 Chris Wilson 2021-06-17   40     struct drm_i915_private *i915 = migrate->context->engine->i915;
> > > cf586021642d80 Chris Wilson 2021-06-17   41     struct drm_i915_gem_object *src, *dst;
> > > cf586021642d80 Chris Wilson 2021-06-17   42     struct i915_request *rq;
> > > cf586021642d80 Chris Wilson 2021-06-17   43     struct i915_gem_ww_ctx ww;
> > > cf586021642d80 Chris Wilson 2021-06-17   44     u32 *vaddr;
> > > cf586021642d80 Chris Wilson 2021-06-17   45     int err = 0;
> > >
> > > One way to silence these warnings would be to initialize err = -EINVAL.
> > > Then Smatch would know that we goto err_out for an empty list.
> > >
> > > cf586021642d80 Chris Wilson 2021-06-17   46     int i;
> > > cf586021642d80 Chris Wilson 2021-06-17   47
> > > cf586021642d80 Chris Wilson 2021-06-17   48     src = create_lmem_or_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   49     if (IS_ERR(src))
> > > cf586021642d80 Chris Wilson 2021-06-17   50             return 0;
> > > cf586021642d80 Chris Wilson 2021-06-17   51
> > > cf586021642d80 Chris Wilson 2021-06-17   52     dst = i915_gem_object_create_internal(i915, sz);
> > > cf586021642d80 Chris Wilson 2021-06-17   53     if (IS_ERR(dst))
> > > cf586021642d80 Chris Wilson 2021-06-17   54             goto err_free_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   55
> > > cf586021642d80 Chris Wilson 2021-06-17   56     for_i915_gem_ww(&ww, err, true) {
> > > cf586021642d80 Chris Wilson 2021-06-17   57             err = i915_gem_object_lock(src, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   58             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   59                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   60
> > > cf586021642d80 Chris Wilson 2021-06-17   61             err = i915_gem_object_lock(dst, &ww);
> > > cf586021642d80 Chris Wilson 2021-06-17   62             if (err)
> > > cf586021642d80 Chris Wilson 2021-06-17   63                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   64
> > > cf586021642d80 Chris Wilson 2021-06-17   65             vaddr = i915_gem_object_pin_map(src, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   66             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   67                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   68                     continue;
> > > cf586021642d80 Chris Wilson 2021-06-17   69             }
> > > cf586021642d80 Chris Wilson 2021-06-17   70
> > > cf586021642d80 Chris Wilson 2021-06-17   71             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   72                     vaddr[i] = i;
> > > cf586021642d80 Chris Wilson 2021-06-17   73             i915_gem_object_flush_map(src);
> > > cf586021642d80 Chris Wilson 2021-06-17   74
> > > cf586021642d80 Chris Wilson 2021-06-17   75             vaddr = i915_gem_object_pin_map(dst, I915_MAP_WC);
> > > cf586021642d80 Chris Wilson 2021-06-17   76             if (IS_ERR(vaddr)) {
> > > cf586021642d80 Chris Wilson 2021-06-17   77                     err = PTR_ERR(vaddr);
> > > cf586021642d80 Chris Wilson 2021-06-17   78                     goto unpin_src;
> > > cf586021642d80 Chris Wilson 2021-06-17   79             }
> > > cf586021642d80 Chris Wilson 2021-06-17   80
> > > cf586021642d80 Chris Wilson 2021-06-17   81             for (i = 0; i < sz / sizeof(u32); i++)
> > > cf586021642d80 Chris Wilson 2021-06-17   82                     vaddr[i] = ~i;
> > > cf586021642d80 Chris Wilson 2021-06-17   83             i915_gem_object_flush_map(dst);
> > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > >
> > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > complain anyway because it thinks the list could be empty or that we
> > > might hit and early continue for everything.
> >
> > The fn() will always first initialize the rq to NULL. If it returns
> > success then rq will always be a valid rq. If it returns an err then
> > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > got.
> >
> > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > true, so this looks like a false positive?
>
> You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> i915_gem_object_pin_map() can fail?

Yeah, they can totally fail but then we mostly likely just hit the
err_out. The for_i915_gem_ww() is a little strange since it's not
really looping over anything, it's just about retrying the block if we
see -EDEADLK(which involves dropping some locks), if we see any other
error then the loop is terminated with ww->loop = false, which then
hits the goto err_out.

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02 11:13       ` Dan Carpenter
  (?)
@ 2021-07-02 11:57         ` Matthew Auld
  -1 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 12:14, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> > On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
>
> Btw, I sincerely hope that we will re-enable GCC's uninitialized
> variable checks.  Will GCC be able to verify that this is initialized?

34b07d47dd00 ("drm/i915: Enable -Wuninitialized")

GCC doesn't complain AFAIK.

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:57         ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, 2 Jul 2021 at 12:14, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> > On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
>
> Btw, I sincerely hope that we will re-enable GCC's uninitialized
> variable checks.  Will GCC be able to verify that this is initialized?

34b07d47dd00 ("drm/i915: Enable -Wuninitialized")

GCC doesn't complain AFAIK.

>
> regards,
> dan carpenter
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 11:57         ` Matthew Auld
  0 siblings, 0 replies; 25+ messages in thread
From: Matthew Auld @ 2021-07-02 11:57 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]

On Fri, 2 Jul 2021 at 12:14, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 02, 2021 at 02:07:27PM +0300, Dan Carpenter wrote:
> > On Fri, Jul 02, 2021 at 11:32:45AM +0100, Matthew Auld wrote:
> > > On Fri, 2 Jul 2021 at 09:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   84
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
>
> Btw, I sincerely hope that we will re-enable GCC's uninitialized
> variable checks.  Will GCC be able to verify that this is initialized?

34b07d47dd00 ("drm/i915: Enable -Wuninitialized")

GCC doesn't complain AFAIK.

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
  2021-07-02 11:34       ` Matthew Auld
  (?)
  (?)
@ 2021-07-02 12:19         ` Dan Carpenter
  -1 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 12:19 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 12:34:33PM +0100, Matthew Auld wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
> 
> Yeah, they can totally fail but then we mostly likely just hit the
> err_out. The for_i915_gem_ww() is a little strange since it's not
> really looping over anything, it's just about retrying the block if we
> see -EDEADLK(which involves dropping some locks), if we see any other
> error then the loop is terminated with ww->loop = false, which then
> hits the goto err_out.
> 

Ah, yeah, you're right.  False positive.

I hadn't looked at this code in context (I only had reviewed the email).
Now that I've pulled the tree and looked at the code, then I'm sort of
surprised that Smatch generates a warning...  I will investigate some
more.  Thanks!

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 12:19         ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 12:19 UTC (permalink / raw)
  To: Matthew Auld
  Cc: Thomas Hellström, kbuild-all, kbuild, ML dri-devel,
	Chris Wilson, Matthew Auld, Intel Graphics Development

On Fri, Jul 02, 2021 at 12:34:33PM +0100, Matthew Auld wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
> 
> Yeah, they can totally fail but then we mostly likely just hit the
> err_out. The for_i915_gem_ww() is a little strange since it's not
> really looping over anything, it's just about retrying the block if we
> see -EDEADLK(which involves dropping some locks), if we see any other
> error then the loop is terminated with ww->loop = false, which then
> hits the goto err_out.
> 

Ah, yeah, you're right.  False positive.

I hadn't looked at this code in context (I only had reviewed the email).
Now that I've pulled the tree and looked at the code, then I'm sort of
surprised that Smatch generates a warning...  I will investigate some
more.  Thanks!

regards,
dan carpenter

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 12:19         ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 12:19 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1740 bytes --]

On Fri, Jul 02, 2021 at 12:34:33PM +0100, Matthew Auld wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
> 
> Yeah, they can totally fail but then we mostly likely just hit the
> err_out. The for_i915_gem_ww() is a little strange since it's not
> really looping over anything, it's just about retrying the block if we
> see -EDEADLK(which involves dropping some locks), if we see any other
> error then the loop is terminated with ww->loop = false, which then
> hits the goto err_out.
> 

Ah, yeah, you're right.  False positive.

I hadn't looked at this code in context (I only had reviewed the email).
Now that I've pulled the tree and looked at the code, then I'm sort of
surprised that Smatch generates a warning...  I will investigate some
more.  Thanks!

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Intel-gfx] [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq'.
@ 2021-07-02 12:19         ` Dan Carpenter
  0 siblings, 0 replies; 25+ messages in thread
From: Dan Carpenter @ 2021-07-02 12:19 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1740 bytes --]

On Fri, Jul 02, 2021 at 12:34:33PM +0100, Matthew Auld wrote:
> > > > cf586021642d80 Chris Wilson 2021-06-17   85             err = fn(migrate, &ww, src, dst, &rq);
> > > > cf586021642d80 Chris Wilson 2021-06-17   86             if (!err)
> > > > cf586021642d80 Chris Wilson 2021-06-17   87                     continue;
> > > >
> > > > Does fn() initialize "rq" on the success path?  Anyway Smatch would
> > > > complain anyway because it thinks the list could be empty or that we
> > > > might hit and early continue for everything.
> > >
> > > The fn() will always first initialize the rq to NULL. If it returns
> > > success then rq will always be a valid rq. If it returns an err then
> > > the rq might be NULL, or a valid rq depending on how far the copy/fn
> > > got.
> > >
> > > And for_i915_gem_ww() will always run at least once, since ww->loop =
> > > true, so this looks like a false positive?
> >
> > You don't think i915_gem_object_lock(), i915_gem_object_pin_map() or
> > i915_gem_object_pin_map() can fail?
> 
> Yeah, they can totally fail but then we mostly likely just hit the
> err_out. The for_i915_gem_ww() is a little strange since it's not
> really looping over anything, it's just about retrying the block if we
> see -EDEADLK(which involves dropping some locks), if we see any other
> error then the loop is terminated with ww->loop = false, which then
> hits the goto err_out.
> 

Ah, yeah, you're right.  False positive.

I hadn't looked at this code in context (I only had reviewed the email).
Now that I've pulled the tree and looked at the code, then I'm sort of
surprised that Smatch generates a warning...  I will investigate some
more.  Thanks!

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-07-02 12:19 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 23:14 [drm-intel:drm-intel-gt-next 8/14] drivers/gpu/drm/i915/gt/selftest_migrate.c:102 copy() error: uninitialized symbol 'rq' kernel test robot
2021-07-02  8:44 ` Dan Carpenter
2021-07-02  8:44 ` [Intel-gfx] " Dan Carpenter
2021-07-02  8:44 ` Dan Carpenter
2021-07-02 10:32 ` [Intel-gfx] " Matthew Auld
2021-07-02 10:32   ` Matthew Auld
2021-07-02 10:32   ` Matthew Auld
2021-07-02 11:07   ` Dan Carpenter
2021-07-02 11:07     ` Dan Carpenter
2021-07-02 11:07     ` Dan Carpenter
2021-07-02 11:07     ` Dan Carpenter
2021-07-02 11:13     ` Dan Carpenter
2021-07-02 11:13       ` Dan Carpenter
2021-07-02 11:13       ` Dan Carpenter
2021-07-02 11:13       ` Dan Carpenter
2021-07-02 11:57       ` Matthew Auld
2021-07-02 11:57         ` Matthew Auld
2021-07-02 11:57         ` Matthew Auld
2021-07-02 11:34     ` Matthew Auld
2021-07-02 11:34       ` Matthew Auld
2021-07-02 11:34       ` Matthew Auld
2021-07-02 12:19       ` Dan Carpenter
2021-07-02 12:19         ` Dan Carpenter
2021-07-02 12:19         ` Dan Carpenter
2021-07-02 12:19         ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.