On 10/13/26 09:56, Sunil Khatri wrote:
> Every remaining caller of adev->gfx.rlc.funcs->update_spm_vmid() passes
> NULL for ring, since the only callers that ever passed a real ring
> were removed earlier in this series. Drop the parameter, and the
> dead SR-IOV one-VF ring-replay code in gfx_v11_0/gfx_v12_0/gfx_v12_1
> that only ran when ring was non-NULL.
> 
> Signed-off-by: Sunil Khatri <[email protected]>
> Suggested-by: Christian König <[email protected]>

Good that we have this removed, the implementations in gfx11 and gfx12 where 
totally buggy and could crash if one application uses SPM immediately after 
another stopped using it.

Reviewed-by: Christian König <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 12 ++----------
>  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 11 +----------
>  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 15 +++------------
>  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   |  4 ++--
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   |  4 ++--
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c |  4 ++--
>  9 files changed, 15 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h
> index 2ae2c1d0f702b..e38a8ea02c520 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h
> @@ -292,7 +292,7 @@ struct amdgpu_rlc_funcs {
>       void (*reset)(struct amdgpu_device *adev);
>       void (*start)(struct amdgpu_device *adev);
>       void (*update_spm_vmid)(struct amdgpu_device *adev, int xcc_id,
> -                     struct amdgpu_ring *ring, unsigned vmid);
> +                     unsigned int vmid);
>       bool (*is_rlcg_access_range)(struct amdgpu_device *adev, uint32_t reg);
>  };
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> index fce651d9bc613..b6f61f4a08e5a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> @@ -8320,7 +8320,7 @@ static void gfx_v10_0_update_spm_vmid_internal(struct 
> amdgpu_device *adev,
>  }
>  
>  static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -             struct amdgpu_ring *ring, unsigned int vmid)
> +             unsigned int vmid)
>  {
>       amdgpu_gfx_off_ctrl(adev, false);
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 1f2ad47adb9fe..315dfd806d56f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(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, NULL, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -5748,7 +5748,7 @@ static int gfx_v11_0_update_gfx_clock_gating(struct 
> amdgpu_device *adev,
>  }
>  
>  static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -             struct amdgpu_ring *ring, unsigned vmid)
> +             unsigned int vmid)
>  {
>       u32 reg, pre_data, data;
>  
> @@ -5769,14 +5769,6 @@ static void gfx_v11_0_update_spm_vmid(struct 
> amdgpu_device *adev, int xcc_id,
>                       WREG32_SOC15(GC, 0, regRLC_SPM_MC_CNTL, data);
>       }
>       amdgpu_gfx_off_ctrl(adev, true);
> -
> -     if (ring
> -             && amdgpu_sriov_is_pp_one_vf(adev)
> -             && (pre_data != data)
> -             && ((ring->funcs->type == AMDGPU_RING_TYPE_GFX)
> -                     || (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE))) {
> -             amdgpu_ring_emit_wreg(ring, reg, data);
> -     }
>  }
>  
>  static const struct amdgpu_rlc_funcs gfx_v11_0_rlc_funcs = {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> index 72ceb113689e8..d82e7f115b7ef 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> @@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(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, NULL, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -4075,7 +4075,6 @@ static void gfx_v12_0_update_perf_clk(struct 
> amdgpu_device *adev,
>  
>  static void gfx_v12_0_update_spm_vmid(struct amdgpu_device *adev,
>                                     int xcc_id,
> -                                   struct amdgpu_ring *ring,
>                                     unsigned vmid)
>  {
>       u32 reg, data;
> @@ -4093,14 +4092,6 @@ static void gfx_v12_0_update_spm_vmid(struct 
> amdgpu_device *adev,
>               WREG32_SOC15_NO_KIQ(GC, 0, regRLC_SPM_MC_CNTL, data);
>       else
>               WREG32_SOC15(GC, 0, regRLC_SPM_MC_CNTL, data);
> -
> -     if (ring
> -         && amdgpu_sriov_is_pp_one_vf(adev)
> -         && ((ring->funcs->type == AMDGPU_RING_TYPE_GFX)
> -             || (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE))) {
> -             uint32_t reg = SOC15_REG_OFFSET(GC, 0, regRLC_SPM_MC_CNTL);
> -             amdgpu_ring_emit_wreg(ring, reg, data);
> -     }
>  }
>  
>  static const struct amdgpu_rlc_funcs gfx_v12_0_rlc_funcs = {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> index b44f5ec68714d..147bed75261c1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
> @@ -214,7 +214,7 @@ static int gfx_v12_1_init_cp_compute_microcode_bo(struct 
> amdgpu_device *adev);
>  static void gfx_v12_1_xcc_update_medium_grain_clock_gating(
>       struct amdgpu_device *adev, bool enable, int xcc_id, bool force);
>  static void gfx_v12_1_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -                                   struct amdgpu_ring *ring, unsigned vmid);
> +                                   unsigned int vmid);
>  
>  static void gfx_v12_1_wait_reg_mem(struct amdgpu_ring *ring, int eng_sel,
>                                  int mem_space, int opt, uint32_t addr0,
> @@ -1861,7 +1861,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct 
> amdgpu_device *adev,
>       int r;
>  
>       /* init spm vmid with 0xf */
> -     gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 
> adev->vm_manager.spm_vmid);
> +     gfx_v12_1_update_spm_vmid(adev, xcc_id, adev->vm_manager.spm_vmid);
>  
>       if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
>               gfx_v12_1_xcc_init_csb(adev, xcc_id);
> @@ -2918,8 +2918,7 @@ static void gfx_v12_1_update_perf_clk(struct 
> amdgpu_device *adev,
>  
>  static void gfx_v12_1_update_spm_vmid(struct amdgpu_device *adev,
>                                     int xcc_id,
> -                                   struct amdgpu_ring *ring,
> -                                   unsigned vmid)
> +                                   unsigned int vmid)
>  {
>       u32 reg, data;
>  
> @@ -2936,14 +2935,6 @@ static void gfx_v12_1_update_spm_vmid(struct 
> amdgpu_device *adev,
>               WREG32_SOC15_NO_KIQ(GC, GET_INST(GC, xcc_id), 
> regRLC_SPM_MC_CNTL, data);
>       else
>               WREG32_SOC15(GC, GET_INST(GC, xcc_id), regRLC_SPM_MC_CNTL, 
> data);
> -
> -     if (ring
> -         && amdgpu_sriov_is_pp_one_vf(adev)
> -         && ((ring->funcs->type == AMDGPU_RING_TYPE_GFX)
> -             || (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE))) {
> -             uint32_t reg = SOC15_REG_OFFSET(GC, GET_INST(GC, xcc_id), 
> regRLC_SPM_MC_CNTL);
> -             amdgpu_ring_emit_wreg(ring, reg, data);
> -     }
>  }
>  
>  static const struct amdgpu_rlc_funcs gfx_v12_1_rlc_funcs = {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> index 91ce21425126f..dd00be109d7cc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> @@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(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, NULL, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -3479,7 +3479,7 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device 
> *adev)
>  }
>  
>  static void gfx_v7_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -             struct amdgpu_ring *ring, unsigned vmid)
> +             unsigned int vmid)
>  {
>       u32 data;
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 479480e39fe47..c9268cc5715b9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(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, NULL, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -5491,7 +5491,7 @@ 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,
> -             struct amdgpu_ring *ring, unsigned vmid)
> +             unsigned int vmid)
>  {
>       u32 data;
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index 8afcdb54a0f56..75d1bbdb421ff 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -5225,7 +5225,7 @@ static void gfx_v9_0_update_spm_vmid_internal(struct 
> amdgpu_device *adev,
>  }
>  
>  static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
> -             struct amdgpu_ring *ring, unsigned int vmid)
> +             unsigned int vmid)
>  {
>       amdgpu_gfx_off_ctrl(adev, false);
>  
> 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 1d1973fd8f677..0ffdef21df0ae 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
> @@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(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, NULL, 
> adev->vm_manager.spm_vmid);
> +             adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, 
> adev->vm_manager.spm_vmid);
>  
>       return 0;
>  }
> @@ -1607,7 +1607,7 @@ 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, struct amdgpu_ring 
> *ring, unsigned int vmid)
> +                                           int inst, unsigned int vmid)
>  {
>       u32 reg, pre_data, data;
>  

Reply via email to