Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu: amdgpu_gfx_disable_kgq() skips post-reset unmap
  on GFX11
--

commit 0c68dfc74c61f610dfe69cfef805b4a5d17edd1f
Author: Matt Turner <[email protected]>

drm/amdgpu: don't unmap legacy queues through MES during reset

This commit skips the MES legacy queue unmap in amdgpu_gfx_disable_kcq()
and amdgpu_gfx_disable_kgq() when a GPU reset is in progress.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index c5a2dcff5058a..0e9456b57577b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
[ ... ]
> @@ -636,6 +640,10 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, 
> int xcc_id)
>       int j;
>  
>       if (adev->enable_mes) {
> +             /* As below for KIQ: the reset tears down and rebuilds the 
> queues. */
> +             if (amdgpu_in_reset(adev))
> +                     return 0;
> +
>               if (amdgpu_gfx_is_master_xcc(adev, xcc_id)) {
>                       for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
>                               j = i + xcc_id * adev->gfx.num_gfx_rings;

[Severity: Medium]
Does returning early when amdgpu_in_reset(adev) is true prevent
gfx_v11_0_cp_resume() from unmapping the temporary gfx_ring[0] during
post-reset resume when adev->gfx.disable_kq is set?

During GPU recovery, amdgpu_device_gpu_recover() holds the reset domain
lock (keeping in_gpu_reset set to 1) across amdgpu_device_asic_reset(),
including post-reset IP reinitialization in
amdgpu_device_reinit_after_reset() -> ... -> gfx_v11_0_cp_resume().  When
adev->gfx.disable_kq is true, gfx_v11_0_cp_resume() temporarily maps
gfx_ring[0] via amdgpu_gfx_enable_kgq() to initialize clear state and
then immediately calls amdgpu_gfx_disable_kgq(adev, 0) to unmap it:

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:gfx_v11_0_cp_resume() {
    ...
        if (adev->gfx.disable_kq) {
                for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
                        ring = &adev->gfx.gfx_ring[i];
                        /* we don't want to set ring->ready */
                        r = amdgpu_ring_test_ring(ring);
                        if (r)
                                return r;
                }
                amdgpu_gfx_disable_kgq(adev, 0);
        }
    ...
}

Because amdgpu_in_reset(adev) is still true at that point,
amdgpu_gfx_disable_kgq() now returns early without calling
amdgpu_mes_unmap_legacy_queue().  That leaves gfx_ring[0] mapped on an HQD
that amdgpu_mes_init() did not reserve for kernel queues and instead
exposed in adev->mes.gfx_hqd_mask for MES user queues.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to