Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/tests: unhandled -EDEADLK injection in drm_probe_helper_contender_fn() --
commit d28b5fe04c94cb62864f25a529c3f378922f36a4 Author: Cristian Ciocaltea <[email protected]> drm/tests: probe-helper: Add .force_ctx() callback coverage This commit adds KUnit tests for the .force_ctx() connector helper callback, including deadlock backoff handling using a contender kthread. > diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c > b/drivers/gpu/drm/tests/drm_probe_helper_test.c > index ebc0392585e72..5d7dc47255181 100644 > --- a/drivers/gpu/drm/tests/drm_probe_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c [ ... ] > @@ -212,6 +225,289 @@ static struct kunit_suite > drm_test_connector_helper_tv_get_modes_suite = { > > kunit_test_suite(drm_test_connector_helper_tv_get_modes_suite); > > +/* > + * Runs an acquire context older than the probe one, which first takes @lock, > + * then waits to be told to also request the connection_mutex held by the > + * probe context. Being older, it wounds the probe context, which will get > + * -EDEADLK as soon as it tries to take @lock. > + */ > +struct drm_probe_helper_contender { > + struct drm_device *drm; > + struct drm_modeset_lock lock; > + struct completion locked; > + struct completion go; > + struct completion done; > + int ret; > +}; > + > +static int drm_probe_helper_contender_fn(void *data) > +{ > + struct drm_probe_helper_contender *contender = data; > + struct drm_modeset_acquire_ctx ctx; > + > + drm_modeset_acquire_init(&ctx, 0); > + > + contender->ret = drm_modeset_lock(&contender->lock, &ctx); > + complete(&contender->locked); > + > + if (!contender->ret) { > + if (wait_for_completion_timeout(&contender->go, 5 * HZ)) > + contender->ret = > + > drm_modeset_lock(&contender->drm->mode_config.connection_mutex, > + &ctx); > + else > + contender->ret = -ETIMEDOUT; > + } > + > + drm_modeset_drop_locks(&ctx); [Severity: Medium] Can drm_modeset_lock(&contender->drm->mode_config.connection_mutex, &ctx) return -EDEADLK when CONFIG_DEBUG_WW_MUTEX_SLOWPATH is enabled? Acquiring connection_mutex is the second lock in ctx (ctx.ww_ctx.acquired becomes 2), so ww_mutex_lock() runs ww_mutex_deadlock_injection(). When (ctx.ww_ctx.stamp & 0xf) == 0, it injects -EDEADLK after the probe context backs off and releases connection_mutex, setting ctx.contended. Because drm_probe_helper_contender_fn() does not handle -EDEADLK, drm_modeset_drop_locks(&ctx) hits WARN_ON(ctx->contended) and drm_test_probe_helper_force_ctx_deadlock() fails KUNIT_ASSERT_EQ(test, contender->ret, 0). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=25
