RE: [PATCH] drm/amdgpu: Use READ_ONCE() when reading the values in 'sdma_v4_4_2_ring_get_rptr'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - General]

Reviewed-by: Le Ma <le.ma@xxxxxxx>

> -----Original Message-----
> From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@xxxxxxx>
> Sent: Friday, August 4, 2023 1:47 PM
> To: Koenig, Christian <Christian.Koenig@xxxxxxx>; Deucher, Alexander
> <Alexander.Deucher@xxxxxxx>; Chen, Guchun <Guchun.Chen@xxxxxxx>;
> Pan, Xinhui <Xinhui.Pan@xxxxxxx>
> Cc: amd-gfx@xxxxxxxxxxxxxxxxxxxxx; SHANMUGAM, SRINIVASAN
> <SRINIVASAN.SHANMUGAM@xxxxxxx>; Ma, Le <Le.Ma@xxxxxxx>; Zhang,
> Hawking <Hawking.Zhang@xxxxxxx>
> Subject: [PATCH] drm/amdgpu: Use READ_ONCE() when reading the values in
> 'sdma_v4_4_2_ring_get_rptr'
>
> Instead of declaring pointers use READ_ONCE(), when accessing those values to
> make sure that the compiler doesn't voilate any cache coherences
>
> Cc: Guchun Chen <guchun.chen@xxxxxxx>
> Cc: Christian König <christian.koenig@xxxxxxx>
> Cc: Alex Deucher <alexander.deucher@xxxxxxx>
> Cc: "Pan, Xinhui" <Xinhui.Pan@xxxxxxx>
> Cc: Le Ma <le.ma@xxxxxxx>
> Cc: Hawking Zhang <Hawking.Zhang@xxxxxxx>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
> ---
>  drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> index f413898dda37..267c1b7b8dcd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> @@ -154,13 +154,13 @@ static int sdma_v4_4_2_init_microcode(struct
> amdgpu_device *adev)
>   */
>  static uint64_t sdma_v4_4_2_ring_get_rptr(struct amdgpu_ring *ring)  {
> -     u64 *rptr;
> +     u64 rptr;
>
>       /* XXX check if swapping is necessary on BE */
> -     rptr = ((u64 *)&ring->adev->wb.wb[ring->rptr_offs]);
> +     rptr = READ_ONCE(*((u64 *)&ring->adev->wb.wb[ring->rptr_offs]));
>
> -     DRM_DEBUG("rptr before shift == 0x%016llx\n", *rptr);
> -     return ((*rptr) >> 2);
> +     DRM_DEBUG("rptr before shift == 0x%016llx\n", rptr);
> +     return rptr >> 2;
>  }
>
>  /**
> --
> 2.25.1





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux