From: sashiko-bot@kernel.org
To: "Armas Spann" <zappel@simple-co.de>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 6/9] drm/amdkfd: keep eviction and restore consistent when MES fails
Date: Thu, 26 Nov 2026 08:36:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-235043@kernel.org> (raw)
In-Reply-To: <20261125141933.154222-7-zappel@simple-co.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amdkfd: evict_process_queues_cpsch() returns 0 with
unretired MES queues
- [Medium] drm/amdkfd: missing kfd_flush_tlb() in
restore_process_queues_cpsch() rollback
--
commit 912d1284460b9827cb7b366431ada4596ab37d25
Author: Armas Spann <zappel@simple-co.de>
drm/amdkfd: keep eviction and restore consistent when MES fails
This commit continues evicting remaining queues when MES queue removal
fails, preserves -EIO across devices in kfd_process_evict_queues(), and
rolls back already-added queues when restore_process_queues_cpsch() fails.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index eabb9a6953451..f952880a66657 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
[ ... ]
> @@ -2227,6 +2243,27 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm,
> out:
> dqm_unlock(dqm);
> return retval;
> +
> +rollback:
> + /*
> + * A half restored process is a problem for the next eviction: it
> + * finds qpd->evicted set and leaves the queues restored so far
> + * running. Take those off the hardware again, so that the process
> + * is fully evicted and the retry starts from a known state. A
> + * removal that cannot be sent (-EIO) leaves the queue mapped and
> + * marked evicted, as evict_process_queues_cpsch() does.
> + */
> + list_for_each_entry(q, &qpd->queues_list, list) {
> + q->properties.is_evicted = true;
> + if (!q->properties.is_active)
> + continue;
> +
> + q->properties.is_active = false;
> + decrement_queue_count(dqm, qpd, q);
> + if (dqm->dev->kfd->shared_resources.enable_mes)
> + remove_queue_mes(dqm, q, qpd);
[Severity: Medium]
If remove_queue_mes() fails with -EIO here (or during an earlier call to
evict_process_queues_cpsch()), can a subsequent eviction return 0 while
unretired queues are still mapped in MES?
When a later queue fails add_queue_mes() (for instance with -ETIMEDOUT,
which fences MES, or -EIO when a reset starts), remove_queue_mes() in this
rollback returns -EIO and leaves the earlier queues mapped in MES with
qpd->evicted still set to 1. Because restore_process_helper() has already
armed a new eviction fence before calling kfd_process_restore_queues(), a
TTM eviction that runs before the restore retry sees qpd->evicted++ > 0 in
evict_process_queues_cpsch() and returns 0 instead of -EIO:
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:evict_process_queues_cpsch() {
dqm_lock(dqm);
if (qpd->evicted++ > 0) /* already evicted, do nothing */
goto out;
...
}
evict_process_worker() then signals the eviction fence and lets TTM move
or unmap BOs while those unretired queues are still on the hardware.
> + }
> + goto out;
> }
[Severity: Medium]
Does this rollback path also need to call kfd_flush_tlb(pdd) after
removing the already-restored queues from MES?
Queues added earlier in the loop may have started executing and issuing
memory accesses before a later queue failed dqm_repin_mqd_bo() or
add_queue_mes(). MES does not perform a heavyweight TLB flush on queue
removal, and because qpd->evicted stays 1, a subsequent call to
evict_process_queues_cpsch() before the restore retry takes the
qpd->evicted++ > 0 early exit and skips kfd_flush_tlb(pdd) as well,
allowing BOs or SVM ranges to be migrated or freed before in-flight memory
accesses complete.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125141933.154222-1-zappel@simple-co.de?part=6
next prev parent reply other threads:[~2026-11-26 8:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:19 [PATCH v2 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU Armas Spann
2026-11-25 14:19 ` [PATCH v2 1/9] drm/amdgpu/mes: distinguish rejected from timed out commands Armas Spann
2026-11-26 8:36 ` sashiko-bot
2026-11-25 14:19 ` [PATCH v2 2/9] drm/amdkfd: factor out freeing of per-queue MES resources Armas Spann
2026-11-25 14:19 ` [PATCH v2 3/9] drm/amdkfd: track whether MES knows each queue Armas Spann
2026-11-26 8:46 ` sashiko-bot
2026-11-25 14:19 ` [PATCH v2 4/9] drm/amdkfd: add a quarantine for queues MES has not retired Armas Spann
2026-11-26 8:49 ` sashiko-bot
2026-11-25 14:19 ` [PATCH v2 5/9] drm/amdkfd: keep queue storage until MES confirmed retirement Armas Spann
2026-11-26 8:39 ` sashiko-bot
2026-11-25 14:19 ` [PATCH v2 6/9] drm/amdkfd: keep eviction and restore consistent when MES fails Armas Spann
2026-11-26 8:36 ` sashiko-bot [this message]
2026-11-25 14:19 ` [PATCH v2 7/9] drm/amdkfd: apply queue property updates only after unmap Armas Spann
2026-11-25 14:19 ` [PATCH v2 8/9] drm/amdkfd: reconcile queue state with MES after a restart Armas Spann
2026-11-25 14:19 ` [PATCH v2 9/9] drm/amdkfd: force CWSR on with more than one MES GPU Armas Spann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-235043@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zappel@simple-co.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox