[Intel-gfx] [bug report] drm/i915/selftests: Exercise context switching in parallel

Dan Carpenter dan.carpenter at oracle.com
Fri Oct 11 11:42:09 UTC 2019


Hello Chris Wilson,

This is a semi-automatic email about new static checker warnings.

The patch 50d16d44cce4: "drm/i915/selftests: Exercise context 
switching in parallel" from Sep 30, 2019, leads to the following 
Smatch complaint:

    drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:349 live_parallel_switch()
    error: we previously assumed 'data' could be null (see line 263)

drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
   257          }
   258  
   259          engines = i915_gem_context_lock_engines(ctx);
   260          count = engines->num_engines;
   261  
   262		data = kcalloc(count, sizeof(*data), GFP_KERNEL);
   263		if (!data) {
   264			i915_gem_context_unlock_engines(ctx);
   265			err = -ENOMEM;
   266			goto out;
                        ^^^^^^^^
goto out is always a sign of troubled times ahead...

   267		}
   268	
   269		m = 0; /* Use the first context as our template for the engines */
   270		for_each_gem_engine(ce, engines, it) {
   271			err = intel_context_pin(ce);
   272			if (err) {
   273				i915_gem_context_unlock_engines(ctx);
   274				goto out;
   275			}
   276			data[m++].ce[0] = intel_context_get(ce);
   277		}
   278		i915_gem_context_unlock_engines(ctx);
   279	
   280		/* Clone the same set of engines into the other contexts */
   281		for (n = 1; n < ARRAY_SIZE(data->ce); n++) {
   282			ctx = live_context(i915, file);
   283			if (IS_ERR(ctx)) {
   284				err = PTR_ERR(ctx);
   285				goto out;
   286			}
   287	
   288			for (m = 0; m < count; m++) {
   289				if (!data[m].ce[0])
   290					continue;
   291	
   292				ce = intel_context_create(ctx, data[m].ce[0]->engine);
   293				if (IS_ERR(ce))
   294					goto out;
   295	
   296				err = intel_context_pin(ce);
   297				if (err) {
   298					intel_context_put(ce);
   299					goto out;
   300				}
   301	
   302				data[m].ce[n] = ce;
   303			}
   304		}
   305	
   306		for (fn = func; !err && *fn; fn++) {
   307			struct igt_live_test t;
   308			int n;
   309	
   310			err = igt_live_test_begin(&t, i915, __func__, "");
   311			if (err)
   312				break;
   313	
   314			for (n = 0; n < count; n++) {
   315				if (!data[n].ce[0])
   316					continue;
   317	
   318				data[n].tsk = kthread_run(*fn, &data[n],
   319							  "igt/parallel:%s",
   320							  data[n].ce[0]->engine->name);
   321				if (IS_ERR(data[n].tsk)) {
   322					err = PTR_ERR(data[n].tsk);
   323					break;
   324				}
   325				get_task_struct(data[n].tsk);
   326			}
   327	
   328			for (n = 0; n < count; n++) {
   329				int status;
   330	
   331				if (IS_ERR_OR_NULL(data[n].tsk))
   332					continue;
   333	
   334				status = kthread_stop(data[n].tsk);
   335				if (status && !err)
   336					err = status;
   337	
   338				put_task_struct(data[n].tsk);
   339				data[n].tsk = NULL;
   340			}
   341	
   342			if (igt_live_test_end(&t))
   343				err = -EIO;
   344		}
   345	
   346	out:
   347		for (n = 0; n < count; n++) {
   348			for (m = 0; m < ARRAY_SIZE(data->ce); m++) {
   349				if (!data[n].ce[m])
                                    ^^^^^^^^
Toasted.

   350					continue;
   351	

regards,
dan carpenter


More information about the Intel-gfx mailing list