Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/amdgpu: hardcoded XCC 0 in gfx_v9_4_3_xcc_rlc_resume()
  skips XCCs 1..N-1
- [Medium] drm/amdgpu: gfx9 compute emit_frame_size exceeds max_dw in
  amdgpu_ring_init()
- [Medium] drm/amdgpu: update_spm_vmid() skipped on SR-IOV VFs in
  gfx_v8_0 and gfx_v9_4_3
--

commit 08b45306962b59cde3c232193cc26534f308aaa2
Author: Alex Deucher <[email protected]>

drm/amdgpu: bring back the ring parameter for update_spm_vmid()

This commit restores the ring parameter to update_spm_vmid() so that GFX9,
GFX10, GFX11, and GFX12.0 emit the SPM VMID update on the ring during IB
scheduling while skipping MMIO updates when a ring is provided.

[ ... ]

> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index df935827b002a..e818280139791 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -4084,7 +4084,8 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device 
> *adev)
>  
>       /* init spm vmid with 0xf */
>       if (adev->gfx.rlc.funcs->update_spm_vmid)
> -             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 
> adev->vm_manager.spm_vmid);
> +
>       return 0;
>  }
>  
> @@ -5483,10 +5484,13 @@ static void gfx_v8_0_unset_safe_mode(struct 
> amdgpu_device *adev, int xcc_id)
>  }
>  
>  static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -             unsigned int vmid)
> +             struct amdgpu_ring *ring, unsigned vmid)
>  {
>       u32 data;
>  
> +     if (ring)
> +             return;
> +
>       amdgpu_gfx_off_ctrl(adev, false);
>  
>       if (amdgpu_sriov_is_pp_one_vf(adev))

[Severity: Medium]
Does returning early when ring is non-NULL leave mmRLC_SPM_VMID unprogrammed
on SR-IOV VFs in one-VF mode?

gfx_v8_0_rlc_resume() returns early when amdgpu_sriov_vf(adev) is true before
reaching the update_spm_vmid(adev, 0, NULL, ...) call:

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c:gfx_v8_0_rlc_resume() {
        if (amdgpu_sriov_vf(adev)) {
                gfx_v8_0_init_csb(adev);
                return 0;
        }
    ...
}

With amdgpu_ib_schedule() passing a non-NULL ring, gfx_v8_0_update_spm_vmid()
now returns before reaching the amdgpu_sriov_is_pp_one_vf(adev) branch, so
mmRLC_SPM_VMID is never programmed on SR-IOV VFs.  The same issue affects
gfx_v9_4_3_update_spm_vmid(), because both gfx_v9_4_3_rlc_resume() and
gfx_v9_4_3_xcp_resume() skip calling gfx_v9_4_3_xcc_rlc_resume() when
amdgpu_sriov_vf(adev) is true.

> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index 2e2673a6dbbf5..be45c10b6f579 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

[ ... ]

> @@ -7663,6 +7675,7 @@ static const struct amdgpu_ring_funcs 
> gfx_v9_0_ring_funcs_compute = {
>       .get_wptr = gfx_v9_0_ring_get_wptr_compute,
>       .set_wptr = gfx_v9_0_ring_set_wptr_compute,
>       .emit_frame_size =
> +             5 + /* update_spm_vmid */
>               20 + /* gfx_v9_0_ring_emit_gds_switch */
>               7 + /* gfx_v9_0_ring_emit_hdp_flush */
>               5 + /* hdp invalidate */

[Severity: Medium]
Does adding 5 dwords here trigger WARN_ON(max_ibs_dw > max_dw) in
amdgpu_ring_init() for every GFX9 compute ring?

This increases gfx_v9_0_ring_funcs_compute.emit_frame_size from 145 to 150.
In amdgpu_ring_init(), max_ibs_dw is 150 + 125 * 7 = 1025, which rounds up to
1280 with align_mask (0xff), exceeding the max_dw of 1024 passed by
gfx_v9_0_compute_ring_init().

> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> index 151336e6094f7..f28ffe8a5ac55 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> @@ -1586,7 +1586,7 @@ static int gfx_v9_4_3_xcc_rlc_resume(struct 
> amdgpu_device *adev, int xcc_id)
>  
>       /* init spm vmid with 0xf */
>       if (adev->gfx.rlc.funcs->update_spm_vmid)
> -             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -1609,10 +1609,13 @@ static int gfx_v9_4_3_rlc_resume(struct amdgpu_device 
> *adev)
>  }
>  
>  static void gfx_v9_4_3_update_spm_vmid(struct amdgpu_device *adev,
> -                                           int inst, unsigned int vmid)
> +                                           int inst, struct amdgpu_ring 
> *ring, unsigned int vmid)
>  {
>       u32 reg, pre_data, data;
>  
> +     if (ring)
> +             return;
> +
>       reg = SOC15_REG_OFFSET(GC, GET_INST(GC, inst), regRLC_SPM_MC_CNTL);

[Severity: High]
Should gfx_v9_4_3_xcc_rlc_resume() pass xcc_id instead of 0 to
update_spm_vmid()?

Previously, amdgpu_ib_schedule() called update_spm_vmid() with ring->xcc_id on
each IB submission, programming regRLC_SPM_MC_CNTL on all XCCs.  Now that
gfx_v9_4_3_update_spm_vmid() returns early when ring is non-NULL,
gfx_v9_4_3_xcc_rlc_resume() is the only caller that programs the register, and
passing hardcoded 0 leaves XCCs 1..num_xcc-1 at their hardware reset value of
VMID 0 (the kernel VMID).

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

Reply via email to