AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heng Zhou" <Heng.Zhou@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdkfd: rebuild CWSR trap buffers after hibernation
Date: Mon, 23 Nov 2026 10:21:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-229033@kernel.org> (raw)
In-Reply-To: <20261123095605.162656-1-Heng.Zhou@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amdkfd: kfd_process_rebuild_cwsr() skips S3 resume due to
  in_s4 check
- [Low] drm/amdkfd: missing Fixes trailer for commit 5088a1ba6d6d
--

commit cee0c9930133433e39014ce7869f89cb97cc145b
Author: Heng Zhou <Heng.Zhou@amd.com>

> drm/amdkfd: rebuild CWSR trap buffers after hibernation
>
> The CWSR trap buffer can reside in pinned VRAM, which is skipped by
> TTM eviction during hibernation. Restoring the process GPUVM mappings
> does not restore the buffer contents. This can lead to SQ errors and
> failed queue preemption after resume.
>
> Keep the second-level TBA/TMA and trap flags in system memory. Rebuild
> the buffer from the trap ISA and saved TMA values and flush HDP before
> restoring process queues.
>
> Signed-off-by: Heng Zhou <Heng.Zhou@amd.com>

[Severity: Low]
This fixes the regression introduced when CWSR trap buffers were moved to
pinned VRAM in 5088a1ba6d6d ("drm/amdkfd: move TBA/TMA from system to
device memory").  Should the commit message include:

  Fixes: 5088a1ba6d6d ("drm/amdkfd: move TBA/TMA from system to device memory")

> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 546721b4d59ac..342ad7178ed69 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c

[ ... ]

> @@ -1681,12 +1683,40 @@ void kfd_process_set_trap_debug_flag(struct qcm_process_device *qpd,
>  				     bool enabled)
>  {
>  	if (!iosys_map_is_null(&qpd->cwsr_map)) {
> +		qpd->cwsr_tma_flags = enabled;
>  		iosys_map_wr(&qpd->cwsr_map,
>  			     KFD_CWSR_TMA_OFFSET + 2 * sizeof(uint64_t),
>  			     uint64_t, enabled);
>  	}
>  }
>  
> +static void kfd_process_rebuild_cwsr(struct kfd_process *p)
> +{
> +	struct kfd_process_device *pdd;
> +	struct qcm_process_device *qpd;
> +	int i;
> +
> +	for (i = 0; i < p->n_pdds; i++) {
> +		pdd = p->pdds[i];
> +		qpd = &pdd->qpd;
> +
> +		if (!pdd->dev->adev->in_s4 || !qpd->cwsr_base ||
> +		    iosys_map_is_null(&qpd->cwsr_map))
> +			continue;

[Severity: Medium]
Does checking !pdd->dev->adev->in_s4 leave the VRAM CWSR trap buffer
uninitialized after an S3 suspend/resume cycle?

All discrete GPUs with GC >= 9.4.2 (including GFX10, GFX11 and GFX12
dGPUs) allocate and pin qpd->cwsr_mem in VRAM.  During S3 suspend,
amdgpu_device_evict_resources() evicts unpinned VRAM BOs while skipping
the pinned qpd->cwsr_mem BO, and VRAM loses its contents while the dGPU is
powered down.  Because adev->in_s3 is set instead of adev->in_s4,
kfd_process_rebuild_cwsr() skips the rebuild on S3 resume before
restore_process_helper() restores the queues, leading to the same SQ
errors and failed queue preemption when CWSR executes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123095605.162656-1-Heng.Zhou@amd.com?part=1

  reply	other threads:[~2026-11-23 10:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:56 [PATCH] drm/amdkfd: rebuild CWSR trap buffers after hibernation Heng Zhou
2026-11-23 10:21 ` sashiko-bot [this message]
2026-12-01  7:44 ` Heng Zhou
2026-12-01 18:56   ` Felix Kuehling

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-229033@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Heng.Zhou@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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