[PATCH] drm/amd/pm: parse pp_handle under appropriate conditions

Chen, Guchun Guchun.Chen at amd.com
Sat May 6 03:50:29 UTC 2023


[AMD Official Use Only - General]

> -----Original Message-----
> From: Quan, Evan <Evan.Quan at amd.com>
> Sent: Saturday, May 6, 2023 9:51 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>; Lazar, Lijo <Lijo.Lazar at amd.com>; Koenig,
> Christian <Christian.Koenig at amd.com>; Pan, Xinhui <Xinhui.Pan at amd.com>
> Cc: Limonciello, Mario <Mario.Limonciello at amd.com>
> Subject: RE: [PATCH] drm/amd/pm: parse pp_handle under appropriate
> conditions
>
> [AMD Official Use Only - General]
>
> +Mario
>
> I believe the comment below from Mario points the right direction to
> suppress the "UBSAN: invalid-load..." warnings.
> https://gitlab.freedesktop.org/drm/amd/-/issues/2541#note_1898035
> However, it might be not right to simply drop the line below since the adev-
> >powerplay.pp_handle pointer is still needed for those APIs like
> amdgpu_dpm_read_sensor().
> - adev->powerplay.pp_handle = adev;

Thanks Mario and Evan. I think the new patch set v3 should fix that problem. I will ask reporter to have a try as well.

Regards,
Guchun

> BR
> Evan
> > -----Original Message-----
> > From: Chen, Guchun <Guchun.Chen at amd.com>
> > Sent: Friday, May 5, 2023 4:24 PM
> > To: amd-gfx at lists.freedesktop.org; Deucher, Alexander
> > <Alexander.Deucher at amd.com>; Zhang, Hawking
> <Hawking.Zhang at amd.com>;
> > Lazar, Lijo <Lijo.Lazar at amd.com>; Quan, Evan <Evan.Quan at amd.com>;
> > Koenig, Christian <Christian.Koenig at amd.com>; Pan, Xinhui
> > <Xinhui.Pan at amd.com>
> > Cc: Chen, Guchun <Guchun.Chen at amd.com>
> > Subject: [PATCH] drm/amd/pm: parse pp_handle under appropriate
> > conditions
> >
> > amdgpu_dpm_is_overdrive_supported is a common API across all asics, so
> > we should cast pp_handle into correct structure under different power
> > frameworks.
> >
> > Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2541
> > Fixes: ebfc253335af("drm/amd/pm: do not expose the smu_context
> > structure used internally in power")
> > Signed-off-by: Guchun Chen <guchun.chen at amd.com>
> > ---
> >  drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 +++++++++-------
> >  1 file changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > index f0068df2d073..ae45abeab5b5 100644
> > --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
> > @@ -1455,13 +1455,15 @@ int
> > amdgpu_dpm_get_smu_prv_buf_details(struct amdgpu_device *adev,
> >
> >  int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)  {
> > -   struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
> > -   struct smu_context *smu = adev->powerplay.pp_handle;
> > -
> > -   if ((is_support_sw_smu(adev) && smu->od_enabled) ||
> > -       (is_support_sw_smu(adev) && smu->is_apu) ||
> > -           (!is_support_sw_smu(adev) && hwmgr->od_enabled))
> > -           return true;
> > +   if (is_support_sw_smu(adev)) {
> > +           struct smu_context *smu = adev->powerplay.pp_handle;
> > +           if (smu->od_enabled || smu->is_apu)
> > +                   return true;
> > +   } else {
> > +           struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
> > +           if (hwmgr->od_enabled)
> > +                   return true;
> > +   }
> >
> >     return false;
> >  }
> > --
> > 2.25.1


More information about the amd-gfx mailing list