[Intel-gfx] [bug report] drm/i915/selftests: Add a cancel request selftest that triggers a reset

Dan Carpenter dan.carpenter at linaro.org
Fri May 26 12:00:31 UTC 2023


Hello Matthew Brost,

The patch 4e6835466771: "drm/i915/selftests: Add a cancel request
selftest that triggers a reset" from Jan 13, 2022, leads to the
following Smatch static checker warning:

	drivers/gpu/drm/i915/selftests/i915_request.c:863 __cancel_reset()
	warn: NEW missing error code 'err'

drivers/gpu/drm/i915/selftests/i915_request.c
    817 static int __cancel_reset(struct drm_i915_private *i915,
    818                           struct intel_engine_cs *engine)
    819 {
    820         struct intel_context *ce;
    821         struct igt_spinner spin;
    822         struct i915_request *rq, *nop;
    823         unsigned long preempt_timeout_ms;
    824         int err = 0;
    825 
    826         if (!CONFIG_DRM_I915_PREEMPT_TIMEOUT ||
    827             !intel_has_reset_engine(engine->gt))
    828                 return 0;
    829 
    830         preempt_timeout_ms = engine->props.preempt_timeout_ms;
    831         engine->props.preempt_timeout_ms = 100;
    832 
    833         if (igt_spinner_init(&spin, engine->gt))
    834                 goto out_restore;

Propagate error code from igt_spinner_init()?

    835 
    836         ce = intel_context_create(engine);
    837         if (IS_ERR(ce)) {
    838                 err = PTR_ERR(ce);
    839                 goto out_spin;
    840         }
    841 
    842         rq = igt_spinner_create_request(&spin, ce, MI_NOOP);
    843         if (IS_ERR(rq)) {
    844                 err = PTR_ERR(rq);
    845                 goto out_ce;
    846         }
    847 
    848         pr_debug("%s: Cancelling active non-preemptable request\n",
    849                  engine->name);
    850         i915_request_get(rq);
    851         i915_request_add(rq);
    852         if (!igt_wait_for_spinner(&spin, rq)) {
    853                 struct drm_printer p = drm_info_printer(engine->i915->drm.dev);
    854 
    855                 pr_err("Failed to start spinner on %s\n", engine->name);
    856                 intel_engine_dump(engine, &p, "%s\n", engine->name);
    857                 err = -ETIME;
    858                 goto out_rq;
    859         }
    860 
    861         nop = intel_context_create_request(ce);
    862         if (IS_ERR(nop))
--> 863                 goto out_rq;

err = PTR_ERR(nop);?

    864         i915_request_get(nop);
    865         i915_request_add(nop);
    866 
    867         i915_request_cancel(rq, -EINTR);
    868 
    869         if (i915_request_wait(rq, 0, HZ) < 0) {
    870                 struct drm_printer p = drm_info_printer(engine->i915->drm.dev);
    871 
    872                 pr_err("%s: Failed to cancel hung request\n", engine->name);
    873                 intel_engine_dump(engine, &p, "%s\n", engine->name);
    874                 err = -ETIME;
    875                 goto out_nop;
    876         }
    877 
    878         if (rq->fence.error != -EINTR) {
    879                 pr_err("%s: fence not cancelled (%u)\n",
    880                        engine->name, rq->fence.error);
    881                 err = -EINVAL;
    882                 goto out_nop;
    883         }
    884 
    885         if (i915_request_wait(nop, 0, HZ) < 0) {
    886                 struct drm_printer p = drm_info_printer(engine->i915->drm.dev);
    887 
    888                 pr_err("%s: Failed to complete nop request\n", engine->name);
    889                 intel_engine_dump(engine, &p, "%s\n", engine->name);
    890                 err = -ETIME;
    891                 goto out_nop;
    892         }
    893 
    894         if (nop->fence.error != 0) {
    895                 pr_err("%s: Nop request errored (%u)\n",
    896                        engine->name, nop->fence.error);
    897                 err = -EINVAL;
    898         }
    899 
    900 out_nop:
    901         i915_request_put(nop);
    902 out_rq:
    903         i915_request_put(rq);
    904 out_ce:
    905         intel_context_put(ce);
    906 out_spin:
    907         igt_spinner_fini(&spin);
    908 out_restore:
    909         engine->props.preempt_timeout_ms = preempt_timeout_ms;
    910         if (err)
    911                 pr_err("%s: %s error %d\n", __func__, engine->name, err);
    912         return err;
    913 }

regards,
dan carpenter


More information about the Intel-gfx mailing list