Re: [PATCH] drm/radeon/ci_dpm: Remove needless NULL checks of dpm tables

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

 



On Thu, Feb 13, 2025 at 12:03 PM Nikita Zhandarovich
<n.zhandarovich@xxxxxxxxxx> wrote:
>
> Gentle ping :)

Was already applied:
https://gitlab.freedesktop.org/agd5f/linux/-/commit/189abca05a89fc7b422811e497a7116b3e4f4dca

Thanks,

Alex

>
> On 1/14/25 16:58, Nikita Zhandarovich wrote:
> > This patch removes useless NULL pointer checks in functions like
> > ci_set_private_data_variables_based_on_pptable() and
> > ci_setup_default_dpm_tables().
> >
> > The pointers in question are initialized as addresses to existing
> > structures such as rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk by
> > utilizing & operator and therefore are not in danger of being NULL.
> >
> > Fix this by removing extra checks thus cleaning the code a tiny bit.
> >
> > Found by Linux Verification Center (linuxtesting.org) with static
> > analysis tool SVACE.
> >
> > Fixes: cc8dbbb4f62a ("drm/radeon: add dpm support for CI dGPUs (v2)")
> > Signed-off-by: Nikita Zhandarovich <n.zhandarovich@xxxxxxxxxx>
> > ---
> >  drivers/gpu/drm/radeon/ci_dpm.c | 34 ++++++++++------------------------
> >  1 file changed, 10 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
> > index abe9d65cc460..7c3a960f486a 100644
> > --- a/drivers/gpu/drm/radeon/ci_dpm.c
> > +++ b/drivers/gpu/drm/radeon/ci_dpm.c
> > @@ -3405,12 +3405,8 @@ static int ci_setup_default_dpm_tables(struct radeon_device *rdev)
> >               &rdev->pm.dpm.dyn_state.cac_leakage_table;
> >       u32 i;
> >
> > -     if (allowed_sclk_vddc_table == NULL)
> > -             return -EINVAL;
> >       if (allowed_sclk_vddc_table->count < 1)
> >               return -EINVAL;
> > -     if (allowed_mclk_table == NULL)
> > -             return -EINVAL;
> >       if (allowed_mclk_table->count < 1)
> >               return -EINVAL;
> >
> > @@ -3468,24 +3464,20 @@ static int ci_setup_default_dpm_tables(struct radeon_device *rdev)
> >       pi->dpm_table.vddc_table.count = allowed_sclk_vddc_table->count;
> >
> >       allowed_mclk_table = &rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk;
> > -     if (allowed_mclk_table) {
> > -             for (i = 0; i < allowed_mclk_table->count; i++) {
> > -                     pi->dpm_table.vddci_table.dpm_levels[i].value =
> > -                             allowed_mclk_table->entries[i].v;
> > -                     pi->dpm_table.vddci_table.dpm_levels[i].enabled = true;
> > -             }
> > -             pi->dpm_table.vddci_table.count = allowed_mclk_table->count;
> > +     for (i = 0; i < allowed_mclk_table->count; i++) {
> > +             pi->dpm_table.vddci_table.dpm_levels[i].value =
> > +                     allowed_mclk_table->entries[i].v;
> > +             pi->dpm_table.vddci_table.dpm_levels[i].enabled = true;
> >       }
> > +     pi->dpm_table.vddci_table.count = allowed_mclk_table->count;
> >
> >       allowed_mclk_table = &rdev->pm.dpm.dyn_state.mvdd_dependency_on_mclk;
> > -     if (allowed_mclk_table) {
> > -             for (i = 0; i < allowed_mclk_table->count; i++) {
> > -                     pi->dpm_table.mvdd_table.dpm_levels[i].value =
> > -                             allowed_mclk_table->entries[i].v;
> > -                     pi->dpm_table.mvdd_table.dpm_levels[i].enabled = true;
> > -             }
> > -             pi->dpm_table.mvdd_table.count = allowed_mclk_table->count;
> > +     for (i = 0; i < allowed_mclk_table->count; i++) {
> > +             pi->dpm_table.mvdd_table.dpm_levels[i].value =
> > +                     allowed_mclk_table->entries[i].v;
> > +             pi->dpm_table.mvdd_table.dpm_levels[i].enabled = true;
> >       }
> > +     pi->dpm_table.mvdd_table.count = allowed_mclk_table->count;
> >
> >       ci_setup_default_pcie_tables(rdev);
> >
> > @@ -4880,16 +4872,10 @@ static int ci_set_private_data_variables_based_on_pptable(struct radeon_device *
> >       struct radeon_clock_voltage_dependency_table *allowed_mclk_vddci_table =
> >               &rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk;
> >
> > -     if (allowed_sclk_vddc_table == NULL)
> > -             return -EINVAL;
> >       if (allowed_sclk_vddc_table->count < 1)
> >               return -EINVAL;
> > -     if (allowed_mclk_vddc_table == NULL)
> > -             return -EINVAL;
> >       if (allowed_mclk_vddc_table->count < 1)
> >               return -EINVAL;
> > -     if (allowed_mclk_vddci_table == NULL)
> > -             return -EINVAL;
> >       if (allowed_mclk_vddci_table->count < 1)
> >               return -EINVAL;
> >
>




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux