[AMD Official Use Only - AMD Internal Distribution Only] Reviewed-by: Stanley.Yang <[email protected]>
Regards, Stanley > -----Original Message----- > From: Xie, Patrick <[email protected]> > Sent: Thursday, December 4, 2025 6:30 PM > To: [email protected] > Cc: Zhou1, Tao <[email protected]>; Yang, Stanley > <[email protected]>; Xie, Patrick <[email protected]> > Subject: [PATCH] drm/amdgpu: refine memory usage for ras > > check and extend record memory before use, clear record memory after > allocation > > Signed-off-by: Gangliang Xie <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > index 00f890bbe912..c933ac1d6c83 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > @@ -3001,6 +3001,7 @@ static int > amdgpu_ras_realloc_eh_data_space(struct amdgpu_device *adev, > } > > if (data->bps) { > + memset(bps, 0, align_space); > memcpy(bps, data->bps, > data->count * sizeof(*data->bps)); > kfree(data->bps); > @@ -3090,6 +3091,11 @@ static int > __amdgpu_ras_restore_bad_pages(struct amdgpu_device *adev, > struct ras_err_handler_data *data = con->eh_data; > > for (j = 0; j < count; j++) { > + if (!data->space_left && > + amdgpu_ras_realloc_eh_data_space(adev, data, 256)) { > + return -ENOMEM; > + } > + > if (amdgpu_ras_check_bad_page_unlock(con, > bps[j].retired_page << AMDGPU_GPU_PAGE_SHIFT)) { > data->count++; > @@ -3097,11 +3103,6 @@ static int > __amdgpu_ras_restore_bad_pages(struct amdgpu_device *adev, > continue; > } > > - if (!data->space_left && > - amdgpu_ras_realloc_eh_data_space(adev, data, 256)) { > - return -ENOMEM; > - } > - > amdgpu_ras_reserve_page(adev, bps[j].retired_page); > > memcpy(&data->bps[data->count], &(bps[j]), > -- > 2.34.1
