[PATCH] drm/amdgpu: Add memory vendor information

Chen, Guchun Guchun.Chen at amd.com
Fri Aug 11 07:06:08 UTC 2023


[Public]

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Lijo
> Lazar
> Sent: Friday, August 11, 2023 12:12 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Zhang, Hawking
> <Hawking.Zhang at amd.com>
> Subject: [PATCH] drm/amdgpu: Add memory vendor information
>
> For ASICs with GC v9.4.3, determine the vendor information from scratch
> register.
>
> Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
> Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 26 ++++++++++++++++++-------
> -
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 880460cd3239..f9a5a2c0573e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -1998,6 +1998,19 @@ static int gmc_v9_0_init_mem_ranges(struct
> amdgpu_device *adev)
>       return 0;
>  }
>
> +static void gmc_v9_4_3_init_vram_info(struct amdgpu_device *adev) {
> +     static const u32 regBIF_BIOS_SCRATCH_4 = 0x50;

Any reason to use a static variable here?

Regards,
Guchun

> +     u32 vram_info;
> +
> +     if (!amdgpu_sriov_vf(adev)) {
> +             vram_info = RREG32(regBIF_BIOS_SCRATCH_4);
> +             adev->gmc.vram_vendor = vram_info & 0xF;
> +     }
> +     adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
> +     adev->gmc.vram_width = 128 * 64;
> +}
> +
>  static int gmc_v9_0_sw_init(void *handle)  {
>       int r, vram_width = 0, vram_type = 0, vram_vendor = 0,
> dma_addr_bits; @@ -2010,15 +2023,12 @@ static int
> gmc_v9_0_sw_init(void *handle)
>
>       spin_lock_init(&adev->gmc.invalidate_lock);
>
> -     if (!(adev->bios) || adev->gmc.is_app_apu) {
> +     if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) {
> +             gmc_v9_4_3_init_vram_info(adev);
> +     } else if (!adev->bios) {
>               if (adev->flags & AMD_IS_APU) {
> -                     if (adev->gmc.is_app_apu) {
> -                             adev->gmc.vram_type =
> AMDGPU_VRAM_TYPE_HBM;
> -                             adev->gmc.vram_width = 128 * 64;
> -                     } else {
> -                             adev->gmc.vram_type =
> AMDGPU_VRAM_TYPE_DDR4;
> -                             adev->gmc.vram_width = 64 * 64;
> -                     }
> +                     adev->gmc.vram_type =
> AMDGPU_VRAM_TYPE_DDR4;
> +                     adev->gmc.vram_width = 64 * 64;
>               } else {
>                       adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
>                       adev->gmc.vram_width = 128 * 64;
> --
> 2.25.1



More information about the amd-gfx mailing list