Re: [PATCH 2/2] drm/amdgpu: Fix null point errro

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

 



On Thu, Oct 18, 2018 at 11:47 PM Zhou, David(ChunMing)
<David1.Zhou@xxxxxxx> wrote:
>
> A minor suggestion, not sure if it's proper, Can we insert these callback checking to func? I know these func could be defined as a macro, can we change them to function definition?

I think we already do something similar with the other dpm macros.
Either way, the series is:
Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx>

>
> David
>
> > -----Original Message-----
> > From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Rex
> > Zhu
> > Sent: Friday, October 19, 2018 10:51 AM
> > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> > Cc: Zhu, Rex <Rex.Zhu@xxxxxxx>
> > Subject: [PATCH 2/2] drm/amdgpu: Fix null point errro
> >
> > need to check adev->powerplay.pp_funcs first, becasue from AI, the smu ip
> > may be disabled by user, and the pp_handle is null in this case.
> >
> > Signed-off-by: Rex Zhu <Rex.Zhu@xxxxxxx>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c    | 6 ++++--
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c    | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c     | 6 ++++--
> >  5 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > index 297a549..0a4fba1 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> > @@ -135,7 +135,8 @@ static int acp_poweroff(struct generic_pm_domain
> > *genpd)
> >        * 2. power off the acp tiles
> >        * 3. check and enter ulv state
> >        */
> > -             if (adev->powerplay.pp_funcs->set_powergating_by_smu)
> > +             if (adev->powerplay.pp_funcs &&
> > +                     adev->powerplay.pp_funcs-
> > >set_powergating_by_smu)
> >                       amdgpu_dpm_set_powergating_by_smu(adev,
> > AMD_IP_BLOCK_TYPE_ACP, true);
> >       }
> >       return 0;
> > @@ -517,7 +518,8 @@ static int acp_set_powergating_state(void *handle,
> >       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >       bool enable = state == AMD_PG_STATE_GATE ? true : false;
> >
> > -     if (adev->powerplay.pp_funcs->set_powergating_by_smu)
> > +     if (adev->powerplay.pp_funcs &&
> > +             adev->powerplay.pp_funcs->set_powergating_by_smu)
> >               amdgpu_dpm_set_powergating_by_smu(adev,
> > AMD_IP_BLOCK_TYPE_ACP, enable);
> >
> >       return 0;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 4fca67a..7dad682 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -1783,6 +1783,7 @@ static int amdgpu_device_set_pg_state(struct
> > amdgpu_device *adev, enum amd_power
> >                   adev->ip_blocks[i].version->type ==
> > AMD_IP_BLOCK_TYPE_VCE ||
> >                   adev->ip_blocks[i].version->type ==
> > AMD_IP_BLOCK_TYPE_VCN ||
> >                   adev->ip_blocks[i].version->type ==
> > AMD_IP_BLOCK_TYPE_ACP) &&
> > +                 adev->powerplay.pp_funcs &&
> >                   adev->powerplay.pp_funcs->set_powergating_by_smu) {
> >                       if (!adev->ip_blocks[i].status.valid) {
> >
> >       amdgpu_dpm_set_powergating_by_smu(adev, adev-
> > >ip_blocks[i].version->type, state == AMD_PG_STATE_GATE ?
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > index 790fd54..1a656b8 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> > @@ -392,7 +392,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device
> > *adev, bool enable)
> >       if (!(adev->powerplay.pp_feature & PP_GFXOFF_MASK))
> >               return;
> >
> > -     if (!adev->powerplay.pp_funcs->set_powergating_by_smu)
> > +     if (!adev->powerplay.pp_funcs ||
> > +!adev->powerplay.pp_funcs->set_powergating_by_smu)
> >               return;
> >
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> > b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> > index 14649f8..fd23ba1 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> > @@ -280,7 +280,7 @@ void mmhub_v1_0_update_power_gating(struct
> > amdgpu_device *adev,
> >               return;
> >
> >       if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
> > -             if (adev->powerplay.pp_funcs->set_powergating_by_smu)
> > +             if (adev->powerplay.pp_funcs &&
> > +adev->powerplay.pp_funcs->set_powergating_by_smu)
> >                       amdgpu_dpm_set_powergating_by_smu(adev,
> > AMD_IP_BLOCK_TYPE_GMC, true);
> >
> >       }
> > diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> > b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> > index 2e8365d..d97e6a2 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> > @@ -1595,7 +1595,8 @@ static int sdma_v4_0_hw_init(void *handle)
> >       int r;
> >       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >
> > -     if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs-
> > >set_powergating_by_smu)
> > +     if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs
> > &&
> > +                     adev->powerplay.pp_funcs-
> > >set_powergating_by_smu)
> >               amdgpu_dpm_set_powergating_by_smu(adev,
> > AMD_IP_BLOCK_TYPE_SDMA, false);
> >
> >       sdma_v4_0_init_golden_registers(adev);
> > @@ -1615,7 +1616,8 @@ static int sdma_v4_0_hw_fini(void *handle)
> >       sdma_v4_0_ctx_switch_enable(adev, false);
> >       sdma_v4_0_enable(adev, false);
> >
> > -     if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs-
> > >set_powergating_by_smu)
> > +     if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs
> > +                     && adev->powerplay.pp_funcs-
> > >set_powergating_by_smu)
> >               amdgpu_dpm_set_powergating_by_smu(adev,
> > AMD_IP_BLOCK_TYPE_SDMA, true);
> >
> >       return 0;
> > --
> > 1.9.1
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




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

  Powered by Linux