drm/amdgpu: Group filling reserve region details
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 26 Mar 2026 05:09:16 +0000 (10:39 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 3 Apr 2026 17:50:09 +0000 (13:50 -0400)
Add a function which groups filling of reserve region information. It
may not cover all as info on some regions are still filled outside like
those from atomfirmware tables.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index c3b83d9..285e217 100644 (file)
@@ -1033,10 +1033,13 @@ void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
        }
 }
 
-void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
+void amdgpu_gmc_init_vga_resv_regions(struct amdgpu_device *adev)
 {
        unsigned size;
 
+       if (adev->gmc.is_app_apu)
+               return;
+
        /*
         * Some ASICs need to reserve a region of video memory to avoid access
         * from driver
index 32e73e8..6ab4c1e 100644 (file)
@@ -456,7 +456,7 @@ extern void
 amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
                              bool enable);
 
-void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
+void amdgpu_gmc_init_vga_resv_regions(struct amdgpu_device *adev);
 
 void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev);
 uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);
index 9f02b9e..a6364a5 100644 (file)
@@ -1687,6 +1687,16 @@ void amdgpu_ttm_init_vram_resv(struct amdgpu_device *adev,
        resv->needs_cpu_map = needs_cpu_map;
 }
 
+static void amdgpu_ttm_init_vram_resv_regions(struct amdgpu_device *adev)
+{
+       /* Initialize memory reservations as required for VGA.
+        * This is used for VGA emulation and pre-OS scanout buffers to
+        * avoid display artifacts while transitioning between pre-OS
+        * and driver.
+        */
+       amdgpu_gmc_init_vga_resv_regions(adev);
+}
+
 int amdgpu_ttm_mark_vram_reserved(struct amdgpu_device *adev,
                                  enum amdgpu_resv_region_id id)
 {
@@ -2086,6 +2096,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                                adev->gmc.visible_vram_size);
 #endif
 
+       amdgpu_ttm_init_vram_resv_regions(adev);
+
        /*
         *The reserved vram for firmware must be pinned to the specified
         *place on the VRAM, so reserve it early.
@@ -2123,26 +2135,17 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
                        return r;
        }
 
-       /* allocate memory as required for VGA
-        * This is used for VGA emulation and pre-OS scanout buffers to
-        * avoid display artifacts while transitioning between pre-OS
-        * and driver.
-        */
-       if (!adev->gmc.is_app_apu) {
-               r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_VGA);
-               if (r)
-                       return r;
+       r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_VGA);
+       if (r)
+               return r;
 
-               r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_EXTENDED);
-               if (r)
-                       return r;
+       r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_EXTENDED);
+       if (r)
+               return r;
 
-               r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_RESERVED);
-               if (r)
-                       return r;
-       } else {
-               DRM_DEBUG_DRIVER("Skipped stolen memory reservation\n");
-       }
+       r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_STOLEN_RESERVED);
+       if (r)
+               return r;
 
        dev_info(adev->dev, " %uM of VRAM memory ready\n",
                 (unsigned int)(adev->gmc.real_vram_size / (1024 * 1024)));
index fd691b2..e1ace7d 100644 (file)
@@ -860,8 +860,6 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        /* Memory manager */
        r = amdgpu_bo_init(adev);
        if (r)
index e6db87b..94d6631 100644 (file)
@@ -834,8 +834,6 @@ static int gmc_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        /* Memory manager */
        r = amdgpu_bo_init(adev);
        if (r)
index 6e184ea..e10ac97 100644 (file)
@@ -924,8 +924,6 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
 #ifdef HAVE_ACPI_DEV_GET_FIRST_MATCH_DEV
        if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0)) {
                r = amdgpu_gmc_init_mem_ranges(adev);
index 886bf77..cc272a9 100644 (file)
@@ -854,8 +854,6 @@ static int gmc_v6_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        r = amdgpu_bo_init(adev);
        if (r)
                return r;
index d25fded..bb16ba2 100644 (file)
@@ -1034,8 +1034,6 @@ static int gmc_v7_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        /* Memory manager */
        r = amdgpu_bo_init(adev);
        if (r)
index 4910e55..a59174f 100644 (file)
@@ -1149,8 +1149,6 @@ static int gmc_v8_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        /* Memory manager */
        r = amdgpu_bo_init(adev);
        if (r)
index d865059..e7b7802 100644 (file)
@@ -2010,8 +2010,6 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)
        if (r)
                return r;
 
-       amdgpu_gmc_get_vbios_allocations(adev);
-
        if (amdgpu_is_multi_aid(adev)) {
                r = amdgpu_gmc_init_mem_ranges(adev);
                if (r)