[PATCH] drm/amd/powerplay: widely share the API for data table retrieving

Alex Deucher alexdeucher at gmail.com
Fri Jul 17 04:47:18 UTC 2020


On Thu, Jul 16, 2020 at 1:12 AM Evan Quan <evan.quan at amd.com> wrote:
>
> Considering the data table retrieving can be more widely shared,
> amdgpu_atombios.c is the right place.
>
> Change-Id: Id89476c14709b5676bbf043371a27f27b94a58ed
> Signed-off-by: Evan Quan <evan.quan at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c    | 17 +++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h    |  7 +++++++
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c      | 16 ----------------
>  drivers/gpu/drm/amd/powerplay/arcturus_ppt.c    |  3 ++-
>  drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h  |  4 ----
>  drivers/gpu/drm/amd/powerplay/navi10_ppt.c      |  5 +++--
>  .../gpu/drm/amd/powerplay/sienna_cichlid_ppt.c  |  3 ++-
>  drivers/gpu/drm/amd/powerplay/smu_v11_0.c       |  5 +++--
>  8 files changed, 34 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> index c687432da426..29f767e026e4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> @@ -2036,3 +2036,20 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
>         return 0;
>  }
>
> +int amdgpu_atombios_get_data_table(struct amdgpu_device *adev,
> +                                  uint32_t table,
> +                                  uint16_t *size,
> +                                  uint8_t *frev,
> +                                  uint8_t *crev,
> +                                  uint8_t **addr)
> +{
> +       uint16_t data_start;
> +
> +       if (!amdgpu_atom_parse_data_header(adev->mode_info.atom_context, table,
> +                                          size, frev, crev, &data_start))
> +               return -EINVAL;
> +
> +       *addr = (uint8_t *)adev->mode_info.atom_context->bios + data_start;
> +
> +       return 0;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> index fd8f18074f7a..1321ec09c734 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> @@ -216,6 +216,13 @@ int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev,
>                               u8 voltage_type,
>                               u8 *svd_gpio_id, u8 *svc_gpio_id);
>
> +int amdgpu_atombios_get_data_table(struct amdgpu_device *adev,
> +                                  uint32_t table,
> +                                  uint16_t *size,
> +                                  uint8_t *frev,
> +                                  uint8_t *crev,
> +                                  uint8_t **addr);
> +
>  void amdgpu_atombios_fini(struct amdgpu_device *adev);
>  int amdgpu_atombios_init(struct amdgpu_device *adev);
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 03125c8a2145..01d669a36e1f 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -676,22 +676,6 @@ static int smu_late_init(void *handle)
>         return 0;
>  }
>
> -int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
> -                           uint16_t *size, uint8_t *frev, uint8_t *crev,
> -                           uint8_t **addr)
> -{
> -       struct amdgpu_device *adev = smu->adev;
> -       uint16_t data_start;
> -
> -       if (!amdgpu_atom_parse_data_header(adev->mode_info.atom_context, table,
> -                                          size, frev, crev, &data_start))
> -               return -EINVAL;
> -
> -       *addr = (uint8_t *)adev->mode_info.atom_context->bios + data_start;
> -
> -       return 0;
> -}
> -
>  static int smu_init_fb_allocations(struct smu_context *smu)
>  {
>         struct amdgpu_device *adev = smu->adev;
> diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> index 56dc20a617fd..578c50e294c7 100644
> --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> @@ -27,6 +27,7 @@
>  #include "smu_internal.h"
>  #include "atomfirmware.h"
>  #include "amdgpu_atomfirmware.h"
> +#include "amdgpu_atombios.h"
>  #include "smu_v11_0.h"
>  #include "smu11_driver_if_arcturus.h"
>  #include "soc15_common.h"
> @@ -488,7 +489,7 @@ static int arcturus_append_powerplay_table(struct smu_context *smu)
>         index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
>                                            smc_dpm_info);
>
> -       ret = smu_get_atom_data_table(smu, index, NULL, NULL, NULL,
> +       ret = amdgpu_atombios_get_data_table(smu->adev, index, NULL, NULL, NULL,
>                                       (uint8_t **)&smc_dpm_table);
>         if (ret)
>                 return ret;
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> index 70181ba7ee0c..ba9beffb887d 100644
> --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> @@ -678,10 +678,6 @@ bool smu_mode1_reset_is_support(struct smu_context *smu);
>  int smu_mode1_reset(struct smu_context *smu);
>  int smu_mode2_reset(struct smu_context *smu);
>
> -extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
> -                                  uint16_t *size, uint8_t *frev, uint8_t *crev,
> -                                  uint8_t **addr);
> -
>  extern const struct amd_ip_funcs smu_ip_funcs;
>
>  extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;
> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index ead135f39c7e..0c21e5de8997 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -28,6 +28,7 @@
>  #include "smu_internal.h"
>  #include "atomfirmware.h"
>  #include "amdgpu_atomfirmware.h"
> +#include "amdgpu_atombios.h"
>  #include "soc15_common.h"
>  #include "smu_v11_0.h"
>  #include "smu11_driver_if_navi10.h"
> @@ -467,7 +468,7 @@ static int navi10_append_powerplay_table(struct smu_context *smu)
>         index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
>                                            smc_dpm_info);
>
> -       ret = smu_get_atom_data_table(smu, index, NULL, NULL, NULL,
> +       ret = amdgpu_atombios_get_data_table(adev, index, NULL, NULL, NULL,
>                                       (uint8_t **)&smc_dpm_table);
>         if (ret)
>                 return ret;
> @@ -487,7 +488,7 @@ static int navi10_append_powerplay_table(struct smu_context *smu)
>                         sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header));
>                 break;
>         case 7: /* nv12 */
> -               ret = smu_get_atom_data_table(smu, index, NULL, NULL, NULL,
> +               ret = amdgpu_atombios_get_data_table(adev, index, NULL, NULL, NULL,
>                                               (uint8_t **)&smc_dpm_table_v4_7);
>                 if (ret)
>                         return ret;
> diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
> index 5faef41b63a3..389d8350534a 100644
> --- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
> @@ -28,6 +28,7 @@
>  #include "smu_internal.h"
>  #include "atomfirmware.h"
>  #include "amdgpu_atomfirmware.h"
> +#include "amdgpu_atombios.h"
>  #include "smu_v11_0.h"
>  #include "smu11_driver_if_sienna_cichlid.h"
>  #include "soc15_common.h"
> @@ -399,7 +400,7 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu)
>         index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
>                                             smc_dpm_info);
>
> -       ret = smu_get_atom_data_table(smu, index, NULL, NULL, NULL,
> +       ret = amdgpu_atombios_get_data_table(smu->adev, index, NULL, NULL, NULL,
>                                       (uint8_t **)&smc_dpm_table);
>         if (ret)
>                 return ret;
> diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> index 829c15984847..06a2ea12cba0 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -32,6 +32,7 @@
>  #include "smu_internal.h"
>  #include "atomfirmware.h"
>  #include "amdgpu_atomfirmware.h"
> +#include "amdgpu_atombios.h"
>  #include "smu_v11_0.h"
>  #include "soc15_common.h"
>  #include "atom.h"
> @@ -416,7 +417,7 @@ int smu_v11_0_setup_pptable(struct smu_context *smu)
>                 index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
>                                                     powerplayinfo);
>
> -               ret = smu_get_atom_data_table(smu, index, &atom_table_size, &frev, &crev,
> +               ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev,
>                                               (uint8_t **)&table);
>                 if (ret)
>                         return ret;
> @@ -631,7 +632,7 @@ int smu_v11_0_get_vbios_bootup_values(struct smu_context *smu)
>         index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
>                                             firmwareinfo);
>
> -       ret = smu_get_atom_data_table(smu, index, &size, &frev, &crev,
> +       ret = amdgpu_atombios_get_data_table(smu->adev, index, &size, &frev, &crev,
>                                       (uint8_t **)&header);
>         if (ret)
>                 return ret;
> --
> 2.27.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list