RE: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy asics

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

 




> -----Original Message-----
> From: Lazar, Lijo <Lijo.Lazar@xxxxxxx>
> Sent: Tuesday, May 9, 2023 3:29 PM
> To: Chen, Guchun <Guchun.Chen@xxxxxxx>; amd-
> gfx@xxxxxxxxxxxxxxxxxxxxx; Deucher, Alexander
> <Alexander.Deucher@xxxxxxx>; Zhang, Hawking
> <Hawking.Zhang@xxxxxxx>; Quan, Evan <Evan.Quan@xxxxxxx>
> Subject: Re: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy
> asics
> 
> 
> 
> On 5/9/2023 10:59 AM, Guchun Chen wrote:
> > Prevent further dpm casting on legacy asics without od_enabled in
> > amdgpu_dpm_is_overdrive_supported. This can avoid UBSAN complain in
> > init sequence.
> >
> > v2: add a macro to check legacy dpm instead of checking asic
> > family/type
> >
> > Suggested-by: Evan Quan <evan.quan@xxxxxxx>
> > Signed-off-by: Guchun Chen <guchun.chen@xxxxxxx> > ---
> >   drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 9 +++++++--
> >   1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > index 86246f69dbe1..4b28fd62ed7a 100644
> > --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > @@ -36,6 +36,8 @@
> >   #define amdgpu_dpm_enable_bapm(adev, e) \
> >
> > ((adev)->powerplay.pp_funcs->enable_bapm((adev)-
> >powerplay.pp_handle,
> > (e)))
> >
> > +#define is_legacy_dpm(adev) ((adev)->powerplay.pp_handle == (adev))
> > +
> 
> For consistent naming, you may use amdgpu_dpm_is_legacy_dpm().

Will update it before pushing. Thanks for your review.

Regards,
Guchun

> Regardless,
> 
> Reviewed-by: Lijo Lazar <lijo.lazar@xxxxxxx>
> 
> Thanks,
> Lijo
> 
> >   int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low)
> >   {
> >   	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
> @@
> > -1467,8 +1469,11 @@ int amdgpu_dpm_is_overdrive_supported(struct
> amdgpu_device *adev)
> >   	} else {
> >   		struct pp_hwmgr *hwmgr;
> >
> > -		/* SI asic does not carry od_enabled */
> > -		if (adev->family == AMDGPU_FAMILY_SI)
> > +		/*
> > +		 * dpm on some legacy asics don't carry od_enabled member
> > +		 * as its pp_handle is casted directly from adev.
> > +		 */
> > +		if (is_legacy_dpm(adev))
> >   			return false;
> >
> >   		hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;




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

  Powered by Linux