drm/amdgpu: Add memory vendor information
authorLijo Lazar <lijo.lazar@amd.com>
Fri, 4 Aug 2023 04:22:23 +0000 (09:52 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 16 Aug 2023 15:38:11 +0000 (11:38 -0400)
For ASICs with GC v9.4.3, determine the vendor information from scratch
register.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index 880460cd323980cb8c20f2cfa205ded89e5e9b41..f9a5a2c0573e4110969bf015c36b4d4590001329 100644 (file)
@@ -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;
+       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;