From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795953611; b=S9vpE3TLrSXvnYm5Z1TsU1BkniVMvAj96nXenecenQvBk3hDLSVhjcRU83Zzu+g/3Feb FL7mcPMXS2u6A8eJN2odN9ezdxkCtpt7yR6/oHSaMKHqz45A0gfEJTSv2MwsERbarG+y1 45X2UnrHaPaHtzbxMfiHLqO5C8lGtyzKGg1Lx/S89aMpG9ZSLFMtvi7iq1zVgBE3nOC3F N2VHxNDJB5T3ywg2FZlgz9wnJVcgmMQZurtS7w5m+G4tOVv0N84v9UX+A1pIwDzyTEq4W 5YtLpD90RjBCAJGi6hyybJS2qOXizzp4YtSnKjnDTzJg5uHAxLH/u6CZMGi1woRW+Rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795953611; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=RT8848ZlwI3wZRINNRrI47VObbVeT/p+ECqayrJQRYQ=; b=FOKtOZXuvd0XXn4xtIV4gPEtCj1LSnfHHI/sKZNG5e6okUW+pQOOf3LT5uRGBgsqxqIf xEyquux4cZssKCVlEoS4cnVWZVZxjAb56CUVgrOSiz5Sm1hoFD6R3yPzzld3dbr6YLp4L nBIFrDNj92H1r8C9JEmDE/+pw2SnHdzGwsxprAS7Jc1J5FvnK7WcG4p8Am7VhxdfkIPxw 1QAaG1GC55slbsNagCozvJKQdWs0ML7BdEr8HtwswKu5qHA5v079PVRN0WbLAU/nDRzY9 8/rCuUk3ZMzcC43NcDJfjKZV6ZxvnJ9w8x9xVHXwbkWLiWo70ZoOXa/aSNMonFN6N0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kYBaRHkV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6774606A331 for ; Sun, 29 Nov 2026 12:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kYBaRHkV Received: by smtp.kernel.org (Postfix) with ESMTPSA id B582B1F00897; Sun, 29 Nov 2026 12:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795953611; bh=RT8848ZlwI3wZRINNRrI47VObbVeT/p+ECqayrJQRYQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kYBaRHkVV/zPEnjyMgnnlYEv4y+hVaV7RSR5ju1eSVkG7JpLJokM5/a/LgE4z5zkH WSxi7TwqiEvmpm0yFhIpqhh+JtHTX4o7ekRIZptJ6uVPhZK2vgYS9V2xPmxUve+zTA Mvqj7KC3DaLBLxJdNi9sp2uD6llrjunmW4dffeJT4wV1ngiuCgL2S3hpdW26dIJkpw H8qC/8VavpjKCeEVWR3l5jbLEzkH5AKb4N0vTm0DQMQKJZm7FYsdbYPG9Q2RQ7JyY7 W8oDL0dFigmejkz30JiKwIyJHxg0NIFjaLMYzsbFzHSEuPqMqBA9K/1oo81HzigYaH YXV7aomor+d4A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 09/14] accel/thames: Recover from faults and timeouts Reply-To: sashiko-reviews@lists.linux.dev To: "Tomeu Vizoso" Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org In-Reply-To: <20261129-thames-v4-9-003b1e3365bf@tomeuvizoso.net> References: <20261129-thames-v4-0-003b1e3365bf@tomeuvizoso.net> <20261129-thames-v4-9-003b1e3365bf@tomeuvizoso.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 12:00:10 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 10 potential issues to consider: - [High] accel/thames: stale fault_records read in thames_core_idles() and timeout - [High] accel/thames: race between thames_core_subdev_stop() and timeout recovery - [High] accel/thames: race between thames_job_run() and thames_core_subdev_stop() - [High] accel/thames: false completion_stuck on seqno 0 in thames_job_timedout() - [High] accel/thames: race in thames_job_complete() re-arming TDR during suspend/drain - [Medium] accel/thames: missing ring check and table rewrites in thames_core_reset() - [Medium] accel/thames: lost immediate fault recovery in thames_job_timedout() - [Medium] accel/thames: premature release of bad job before reset in thames_job_recover() - [Medium] accel/thames: missing completion_stuck check in thames_job_cancel()/complete() - [Low] accel/thames: lost error code on resubmission failure in thames_job_recover() -- commit 868a9169441152079b6e90fccf0327d93f948e02 Author: Tomeu Vizoso accel/thames: Recover from faults and timeouts This commit adds fault record queries, context banning after repeated job faults, and timeout and firmware fault recovery via remoteproc reset. > diff --git a/drivers/accel/thames/thames_core.c b/drivers/accel/thames/th= ames_core.c > index 73350784979ec..512de3d880d01 100644 > --- a/drivers/accel/thames/thames_core.c > +++ b/drivers/accel/thames/thames_core.c [ ... ] > @@ -430,6 +433,19 @@ static void thames_core_subdev_stop(struct rproc_sub= dev *subdev, bool crashed) > dev_warn(core->dev, THAMES_CORE_FMT > " is stopped through remoteproc; it is offline until remoteproc star= ts it again\n", > THAMES_CORE_ARG(core)); > + > + /* Its fence lock may be held by a thread that never returns. */ > + if (core->completion_stuck) > + return; > + > + if (!crashed && > + read_poll_timeout(thames_core_idles, idle, idle, USEC_PER_MSEC, > + THAMES_IDLE_TIMEOUT_MS * USEC_PER_MSEC, false, core)) > + dev_crit(core->dev, THAMES_CORE_FMT " is not known to idle; remoteproc= stops it all the same\n", > + THAMES_CORE_ARG(core)); > + > + thames_job_complete(core); > + thames_job_fail_submitted(core); > } [Severity: High] Can thames_core_subdev_stop() race with thames_job_timedout() and thames_job_recover() on tdev->reset_wq? Unlike thames_job_suspend() and thames_job_drain(), thames_core_subdev_stop() does not stop the scheduler workqueues or cancel core->sched.work_tdr. In thames_job_timedout(), core->job_lock is released after looking up oldest and before calling thames_job_recover(core, sched_job, oldest, &record): CPU0 (remoteproc stop) CPU1 (reset_wq) thames_core_subdev_stop() thames_job_timedout() lock(&core->job_lock) oldest =3D list_first_entry_or_null(...) unlock(&core->job_lock) thames_job_fail_submitted() lock(&core->job_lock) list_splice_init(&core->submitted, &lost) unlock(&core->job_lock) list_for_each_entry(job, &lost, node) thames_job_recover(..., oldest, ...) lock(&core->job_lock) list_del_init(&bad->node) <-- corrupts CPU0's unlocked lost list traversal unlock(&core->job_lock) thames_job_fail_done_fence() dma_fence_set_error(bad->done_fence, -EIO) <-- WARN_ON on already-signaled fence thames_sched_job_put(bad) <-- double put / use-after-free Even without a concurrent remoteproc stop, if thames_mbox_rx() -> thames_job_complete() completes the job after thames_job_timedout() drops core->job_lock, thames_job_timedout() still takes the healthy core offline. [ ... ] > @@ -649,11 +675,50 @@ bool thames_core_idles(struct thames_core *core) > return READ_ONCE(record->kind) =3D=3D DRM_THAMES_FAULT_FIRMWARE; > } > =20 > +/* Runs on reset_wq, the ordered queue the timeout handler runs on. */ > +int thames_core_reset(struct thames_core *core) > +{ > + struct thames_caps caps =3D {}; > + struct rproc *rproc =3D core->rproc; > + bool idle; > + int err; > + > + err =3D read_poll_timeout(thames_core_idles, idle, idle, USEC_PER_MSEC, > + THAMES_IDLE_TIMEOUT_MS * USEC_PER_MSEC, false, core); > + if (err) { > + dev_crit(core->dev, THAMES_CORE_FMT " is not known to idle; not stoppi= ng it\n", > + THAMES_CORE_ARG(core)); > + return -EBUSY; > + } > + > + dev_warn(core->dev, "Resetting " THAMES_CORE_FMT "\n", THAMES_CORE_ARG(= core)); > + > + err =3D thames_core_rproc_shutdown(core); > + if (!err && rproc->state !=3D RPROC_OFFLINE) { > + dev_err(core->dev, THAMES_CORE_FMT " is kept running by another power = count; not resetting it\n", > + THAMES_CORE_ARG(core)); > + thames_core_rproc_boot(core); > + return -EBUSY; > + } > + if (err) > + return err; > + > + err =3D thames_core_rproc_boot(core); > + if (err) > + return err; > + > + err =3D thames_core_wait_handshake(core); > + if (err) > + return err; > + > + return thames_core_read_handshake(core, &caps); > +} [Severity: Medium] Should thames_core_reset() verify that the ring is empty, update core->ring_tail, and rewrite the context and transfer tables after reading the handshake? Because thames_core_rproc_boot() sets core->rproc_caller =3D current, thames_core_subdev_start() returns early without calling thames_core_attach(). Unlike thames_core_attach() and thames_core_resume(), thames_core_reset() does not check that head =3D=3D tail, does not set core->ring_tail =3D head, does not call thames_context_rewrite_entries(core) (which bumps mapping_generation so the restarted firmware invalidates its TLB) or thames_transfers_rewrite(core), and does not reset core->unfinished_seqno =3D 0. > diff --git a/drivers/accel/thames/thames_job.c b/drivers/accel/thames/tha= mes_job.c > index ee0a883065f97..33c9063782acd 100644 > --- a/drivers/accel/thames/thames_job.c > +++ b/drivers/accel/thames/thames_job.c [ ... ] > +/* > + * The firmware faulted with its Ring empty: it writes the record at its= head's > + * slot under that slot's stale seqno and takes no doorbell after. > + */ > +static bool thames_job_read_empty_ring_fault(struct thames_core *core, s= truct thames_sched_job *job, > + struct thames_fault_record *record) > +{ > + u32 head =3D READ_ONCE(core->ipc->ring.head); > + > + if (head % THAMES_RING_DEPTH !=3D job->ring_index) > + return false; > + > + /* Read the fault record after the head that says it is there. */ > + rmb(); > + memcpy(record, &core->ipc->fault_records[job->ring_index], sizeof(*reco= rd)); > + > + return record->kind =3D=3D DRM_THAMES_FAULT_FIRMWARE; > +} [Severity: High] Can stale DRM_THAMES_FAULT_FIRMWARE records in core->ipc->fault_records[] cause thames_core_idles() and thames_job_read_empty_ring_fault() to misclassify later jobs when the ring wraps around? Nothing clears core->ipc->fault_records[slot].kind after a fault record is consumed or before a new job is written to that slot, and neither thames_core_idles() nor thames_job_read_empty_ring_fault() checks record->seqno: drivers/accel/thames/thames_core.c:thames_core_idles() { u32 head =3D READ_ONCE(core->ipc->ring.head); u32 slot =3D head % THAMES_RING_DEPTH; struct thames_fault_record *record =3D &core->ipc->fault_records[slot]; if (head =3D=3D core->ring_tail) return true; /* Read the fault record after the head that says it is there. */ rmb(); return READ_ONCE(record->kind) =3D=3D DRM_THAMES_FAULT_FIRMWARE; } Once a slot holds a DRM_THAMES_FAULT_FIRMWARE record, when the 64-entry ring wraps back to that slot, thames_core_idles() returns true while the core is actively executing the new job (causing thames_core_subdev_stop() to stop waiting early or thames_job_suspend() to fail system suspend with -EBUSY). If a later job at that slot hangs without writing a fault record, thames_job_read_fault() rejects the stale seqno and thames_job_timedout() falls through to thames_job_read_empty_ring_fault(), which matches the old DRM_THAMES_FAULT_FIRMWARE record and calls thames_job_recover(core, sched_job, NULL, &record), resetting the core and re-running the hung job without blaming it or counting it towards the context ban. Clearing core->ipc->fault_records[index].kind in thames_job_hw_submit() and after consuming an empty-ring fault in thames_job_recover() would prevent stale matches. [ ... ] > @@ -183,6 +314,19 @@ void thames_job_complete(struct thames_core *core) > trace_thames_job_done(core, job, signalled); > thames_sched_job_put(job); > } > + > + /* > + * The firmware's own fault moves neither the Fence nor the head: it > + * rings the doorbell and parks in IDLE. > + */ > + scoped_guard(mutex, &core->job_lock) { > + job =3D list_first_entry_or_null(&core->submitted, struct thames_sched= _job, node); > + if (job && !thames_core_is_dead(core) && thames_job_read_fault(core, j= ob, &record)) > + firmware_fault =3D record.kind =3D=3D DRM_THAMES_FAULT_FIRMWARE; > + } > + > + if (firmware_fault) > + drm_sched_fault(&core->sched); > } [Severity: High] Can thames_job_complete() re-arm sched->work_tdr via drm_sched_fault() after thames_job_suspend() or thames_job_drain() has already cancelled it? Both thames_job_suspend() and thames_job_drain() stop the scheduler workqueues and call cancel_delayed_work_sync(&sched->work_tdr) before waiting for pending jobs on core->submitted. During that wait, thames_job_complete() runs (from thames_mbox_rx(), at the end of thames_job_suspend(), or in every poll of thames_job_ring_drained()) and calls drm_sched_fault(&core->sched) if the head job faulted with DRM_THAMES_FAULT_FIRMWARE: CPU0 (unbind / thames_core_fini) CPU1 (reset_wq) thames_job_drain() drm_sched_wqueue_stop(sched) cancel_delayed_work_sync(&work_tdr) read_poll_timeout(thames_job_ring_drained, ...) thames_job_complete() drm_sched_fault() thames_job_timedout() thames_job_recover() list_del_init(&bad->node) list_splice_init(&core->submitted, &lost) list_empty(&core->submitted) --> true, poll exits cancel_delayed_work_sync(&work_tdr) thames_core_reset() thames_job_run() <-- resubmits pending jobs back onto core->submitted drm_sched_wqueue_stop(sched) returns to thames_core_fini() <-- resubmitted jobs still active on the hardware Ring In thames_job_suspend(), the newly queued work_tdr is never cancelled at all, so thames_job_recover() can run concurrently with thames_core_rproc_shutdown() or with thames_job_resume() restarting submit_wq while thames_job_recover() walks sched->pending_list unlocked. [ ... ] > @@ -272,6 +422,12 @@ static struct dma_fence *thames_job_run(struct drm_s= ched_job *sched_job) > if (unlikely(job->base.s_fence->finished.error)) > return NULL; > =20 > + if (thames_core_is_dead(core)) > + return ERR_PTR(-ENODEV); > + > + if (thames_context_banned(job->file_priv)) > + return ERR_PTR(-ECANCELED); > + > /* The done fence keeps the seqno of the Job's first run. */ > job->seqno =3D ++core->emit_seqno; > if (!dma_fence_was_initialized(job->done_fence)) [Severity: High] Can thames_job_run() push a job onto core->submitted and advance ring->tail after thames_core_subdev_stop() has already failed submitted jobs? thames_job_run() checks thames_core_is_dead(core) without holding core->job_lock, and thames_core_subdev_stop() does not stop core->sched.submit_wq: CPU0 (submit_wq) CPU1 (remoteproc stop) thames_job_run() if (thames_core_is_dead(core)) --> false thames_core_subdev_stop() thames_core_test_and_set_offline(core) thames_job_complete(core) thames_job_fail_submitted(core) thames_job_hw_submit() lock(&core->job_lock) list_add_tail(&sched_job->node, &core->submitted) WRITE_ONCE(ring->tail, tail + 1) <-- job stranded on stopped core The job is left on core->submitted with an unsignaled done_fence on an offline core, and when remoteproc starts the core again, either thames_core_attach() fails with -EIO (seeing head !=3D tail) or the stranded job's 2000 ms timeout fires and takes the newly started core offline. [ ... ] > +static void thames_job_recover(struct thames_core *core, struct drm_sche= d_job *sched_job, > + struct thames_sched_job *bad, > + const struct thames_fault_record *record) > +{ > + struct drm_gpu_scheduler *sched =3D &core->sched; > + struct thames_sched_job *job; > + struct drm_sched_job *s_job; > + unsigned int resubmitted =3D 0; > + LIST_HEAD(lost); > + int err; > + > + drm_sched_wqueue_stop(sched); > + > + /* Failed before drm_sched_stop(), so the stop finds it complete. */ > + if (bad) { > + scoped_guard(mutex, &core->job_lock) > + list_del_init(&bad->node); > + > + dev_warn(core->dev, "Job seqno %llu of Context %u: the firmware faulte= d\n", > + bad->seqno, bad->file_priv->context_id); > + thames_job_set_fault(bad, record); > + thames_context_count_job(core, bad, true); > + dma_fence_set_error(bad->done_fence, -EIO); > + dma_fence_signal(bad->done_fence); > + thames_sched_job_put(bad); > + } else { > + dev_warn(core->dev, THAMES_CORE_FMT > + ": the firmware faulted with its Ring empty (IERR 0x%llx, NRP 0x%llx= )\n", > + THAMES_CORE_ARG(core), record->registers[THAMES_FAULT_REG_IERR], > + record->registers[THAMES_FAULT_REG_NRP]); > + } > + > + drm_sched_stop(sched, sched_job); > + > + scoped_guard(mutex, &core->job_lock) > + list_splice_init(&core->submitted, &lost); > + > + /* > + * The Jobs on lost stay allocated until the reset has stopped the core, > + * which may still be running one of their Kernels. > + */ > + err =3D thames_core_reset(core); > + if (err) { > + thames_core_test_and_set_offline(core); > + dev_crit(core->dev, THAMES_CORE_FMT > + " could not be reset (%d); it is offline until it is stopped and sta= rted again through remoteproc\n", > + THAMES_CORE_ARG(core), err); > + > + list_for_each_entry(job, &lost, node) > + thames_job_fail_done_fence(job, -ENODEV); > + > + scoped_guard(mutex, &core->job_lock) > + list_splice_tail_init(&lost, &core->held); > + > + drm_sched_start(sched, -ENODEV); > + return; > + } [Severity: Medium] If thames_core_reset() fails without stopping the core, does releasing bad before the reset free bad's buffers and page tables while the core is still powered on? thames_job_recover() signals bad->done_fence and drops bad's core->submitted reference with thames_sched_job_put(bad) before calling drm_sched_stop() and thames_core_reset(). If thames_core_reset() fails because thames_core_idles() times out, rproc_shutdown() fails, or another power count keeps the remoteproc running, only the remaining jobs in lost are moved to core->held, while bad is freed immediately when drm_sched_job_timedout() finishes. Conversely, if thames_core_reset() fails in thames_core_rproc_boot() or handshake after thames_core_rproc_shutdown() has already powered off the core, lost is spliced onto core->held instead of being released. > + > + scoped_guard(mutex, &core->job_lock) > + list_splice_tail_init(&lost, &core->held); > + > + thames_job_release_held(core); > + > + drm_sched_for_each_pending_job(s_job, sched, NULL) { > + struct dma_fence *fence =3D thames_job_run(s_job); > + > + if (IS_ERR_OR_NULL(fence)) { > + thames_job_fail_done_fence(to_thames_sched_job(s_job), > + fence ? PTR_ERR(fence) : -ECANCELED); > + continue; > + } > + > + s_job->s_fence->parent =3D fence; > + resubmitted++; > + } > + > + dev_info(core->dev, THAMES_CORE_FMT " restarted, %u Jobs resubmitted\n", > + THAMES_CORE_ARG(core), resubmitted); > + > + drm_sched_start(sched, 0); > +} [Severity: Low] Does a resubmission error in thames_job_recover() get overwritten with -ECANCELED on s_job->s_fence->finished? drm_sched_stop() detaches and clears s_job->s_fence->parent. When thames_job_run(s_job) returns an ERR_PTR (such as ERR_PTR(-ENODEV) or ERR_PTR(-ENOSPC)), thames_job_fail_done_fence() sets the error on the detached done_fence and leaves s_job->s_fence->parent NULL, so drm_sched_start(sched, 0) calls drm_sched_job_done(s_job, -ECANCELED) and signals the user-visible finished fence with -ECANCELED instead of PTR_ERR(fence). > + > +/* > + * Only job_lock: the core's fence lock may be held by a completion thre= ad that > + * died. > + */ > +static bool thames_job_in_completion(struct thames_core *core, struct th= ames_sched_job *job) > +{ > + struct thames_sched_job *pending; > + > + if (dma_fence_is_signaled(&job->base.s_fence->finished)) > + return false; > + > + guard(mutex)(&core->job_lock); > + list_for_each_entry(pending, &core->submitted, node) { > + if (pending =3D=3D job) > + return false; > + } > + > + return true; > +} > + > +static enum drm_gpu_sched_stat thames_job_timedout(struct drm_sched_job = *sched_job) > +{ > + struct thames_sched_job *job =3D to_thames_sched_job(sched_job); > + struct thames_sched_job *pending, *oldest =3D NULL; > + struct thames_core *core =3D container_of(sched_job->sched, struct tham= es_core, sched); > + struct thames_fault_record record; > + LIST_HEAD(dead_jobs); > + bool found =3D false; > + > + if (core->completion_stuck) > + return DRM_GPU_SCHED_STAT_ENODEV; > + > + if (thames_job_in_completion(core, job)) { > + if (core->unfinished_seqno !=3D job->seqno) { > + core->unfinished_seqno =3D job->seqno; > + return DRM_GPU_SCHED_STAT_NO_HANG; > + } > + > + core->completion_stuck =3D true; > + thames_core_test_and_set_offline(core); > + dev_crit(core->dev, "Job seqno %llu on " THAMES_CORE_FMT > + ": its completion never finished; taking the core offline, a reboot = is needed to use it again\n", > + job->seqno, THAMES_CORE_ARG(core)); > + return DRM_GPU_SCHED_STAT_ENODEV; > + } [Severity: High] Can thames_job_timedout() falsely trigger core->completion_stuck on the first timeout if a job has not been added to core->submitted yet? In drm_sched_run_job_work(), drm_sched_job_begin() puts sched_job on sched->pending_list before calling thames_job_run(). In thames_job_run(), job->seqno is 0 until ++core->emit_seqno, and remains 0 if thames_job_run() returns early (for instance because the context was just banned), while job is not added to core->submitted until thames_job_hw_submit(). If work_tdr runs during that window, thames_job_in_completion() returns true because s_fence->finished is not yet signaled and job is not on core->submitted. Since core->unfinished_seqno is also initialized to 0, core->unfinished_seqno !=3D job->seqno (0 !=3D 0) is false on the very first pass, permanently setting core->completion_stuck =3D true, taking the core offline until reboot, and returning DRM_GPU_SCHED_STAT_ENODEV (which also leaks sched_job because drm_sched_job_timedout() neither reinserts nor frees it on DRM_GPU_SCHED_STAT_ENODEV). > + > + thames_job_complete(core); > + > + scoped_guard(mutex, &core->job_lock) { > + oldest =3D list_first_entry_or_null(&core->submitted, struct thames_sc= hed_job, node); > + list_for_each_entry(pending, &core->submitted, node) { > + if (pending =3D=3D job) { > + found =3D true; > + break; > + } > + } > + } > + > + if (!found) > + return DRM_GPU_SCHED_STAT_NO_HANG; [Severity: Medium] Does returning DRM_GPU_SCHED_STAT_NO_HANG here delay firmware fault recovery by 2000 ms when an earlier job completes in the same pass? When job 1 completes and job 2 (now at the head of core->submitted) faults with DRM_THAMES_FAULT_FIRMWARE, thames_job_complete() signals job1->done_fence (which queues work_free_job on submit_wq, leaving job 1 at the head of sched->pending_list until work_free_job runs) and calls drm_sched_fault(&core->sched) to schedule work_tdr with delay 0. When thames_job_timedout() runs with sched_job =3D &job1->base, job 1 has already left core->submitted, so found is false and thames_job_timedout() returns DRM_GPU_SCHED_STAT_NO_HANG without checking oldest (job 2) for DRM_THAMES_FAULT_FIRMWARE. drm_sched_job_timedout() then restarts work_tdr with the full 2000 ms timeout, and because the firmware sends no more doorbells after parking in IDLE, recovery stalls for 2 seconds. [ ... ] > @@ -308,6 +682,7 @@ static void thames_job_cancel(struct drm_sched_job *s= ched_job) > =20 > static const struct drm_sched_backend_ops thames_sched_ops =3D { > .run_job =3D thames_job_run, > + .timedout_job =3D thames_job_timedout, > .free_job =3D thames_sched_job_free, > .cancel_job =3D thames_job_cancel, > }; [Severity: Medium] Should thames_job_complete() and thames_job_cancel() also bail out when core->completion_stuck is set? thames_core_subdev_stop() and thames_job_timedout() check core->completion_stuck to avoid acquiring core->fence_lock when a completion thread never returned while holding it. However, thames_job_complete() (called from thames_mbox_rx() and thames_job_drain()) and thames_job_cancel() (called during thames_core_fini() -> thames_job_fini() -> drm_sched_fini()) do not check core->completion_stuck before calling dma_fence_signal(job->done_fence), so they will spin forever on core->fence_lock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-thames-v4-= 0-003b1e3365bf@tomeuvizoso.net?part=3D9