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

Chen, Guchun Guchun.Chen at amd.com
Tue May 9 05:05:26 UTC 2023



> -----Original Message-----
> From: Lazar, Lijo <Lijo.Lazar at amd.com>
> Sent: Tuesday, May 9, 2023 11:47 AM
> To: Chen, Guchun <Guchun.Chen at amd.com>; amd-
> gfx at lists.freedesktop.org; Deucher, Alexander
> <Alexander.Deucher at amd.com>; Zhang, Hawking
> <Hawking.Zhang at amd.com>; Quan, Evan <Evan.Quan at amd.com>
> Subject: Re: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy
> asics
> 
> 
> 
> On 5/9/2023 7:12 AM, Guchun Chen wrote:
> > Prevent further casting on chip MULLINS/KABINI/KAVERI when calling
> > amdgpu_dpm_is_overdrive_supported, this can avoid UBSAN complain in
> > init sequence.
> >
> > Suggested-by: Evan Quan <evan.quan at amd.com>
> > Signed-off-by: Guchun Chen <guchun.chen at amd.com>
> > ---
> >   drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 10 ++++++++--
> >   1 file changed, 8 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..ccd3ea89eacf 100644
> > --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > @@ -1467,8 +1467,14 @@ int
> amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
> >   	} else {
> >   		struct pp_hwmgr *hwmgr;
> >
> 
> Instead of family check, what if you wrap it like -
> 
> is_legacy_dpm(adev)
> 	return (adev->powerplay.pp_handle == adev)
> 
> Could be useful for legacy dpm checks.

Sounds good. Will address it in v2.

Regards,
Guchun
> Thanks,
> Lijo
> 
> > -		/* SI asic does not carry od_enabled */
> > -		if (adev->family == AMDGPU_FAMILY_SI)
> > +		/*
> > +		 * SI asic and chip MULLINS/KABINI/KAVERI do not carry
> > +		 * od_enabled, as its pp_handle is casted from adev.
> > +		 */
> > +		if ((adev->family == AMDGPU_FAMILY_SI) ||
> > +		    (adev->asic_type == CHIP_MULLINS) ||
> > +		    (adev->asic_type == CHIP_KABINI) ||
> > +		    (adev->asic_type == CHIP_KAVERI))
> >   			return false;
> >
> >   		hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;


More information about the amd-gfx mailing list