rework stolen pre-OS fb allocation handling
Subsystems (2)
cover rework stolen pre-OS fb allocation handling
Split the allocations into two so we can still support the S3 workarounds required on some platforms while also avoiding any artifacts when transitioning from bios to driver.
In the future we could integrate handling of the ip discovery data and other vbios allocations into this helper function to consolidate handling of all of the vbios reservations.
Alex Deucher (14):
drm/amdgpu: handle bo size 0 in amdgpu_bo_create_kernel_at drm/amdgpu: use create_at for the stolen pre-OS buffer drm/amdgpu: use a define for the memory size of the vga emulator drm/amdgpu: move stolen vga bo from amdgpu to amdgpu.gmc drm/amdgpu: move keep stolen memory check into gmc core drm/amdgpu: add support for extended stolen vga memory drm/amdgpu/gmc: add new helper to get the FB size used by pre-OS
console
drm/amdgpu/gmc6: switch to using amdgpu_gmc_get_vbios_allocations drm/amdgpu/gmc7: switch to using amdgpu_gmc_get_vbios_allocations drm/amdgpu/gmc8: switch to using amdgpu_gmc_get_vbios_allocations drm/amdgpu/gmc9: switch to using amdgpu_gmc_get_vbios_allocations drm/amdgpu/gmc10: switch to using amdgpu_gmc_get_vbios_allocations drm/amdgpu: drop the CPU pointers for the stolen vga bos drm/amdgpu/gmc: disable keep_stolen_vga_memory on arcturus
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 42 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 +++-- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 57 +++++----- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 8 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 11 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 11 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 119 +++++++-------------- 10 files changed, 153 insertions(+), 138 deletions(-)
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/14 drm/amdgpu: handle bo size 0 in amdgpu_bo_create_kernel_at
Just return early to match other bo_create functions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -0
@@ -366,6 +366,11 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,unsigned int i;int r; +if (!size) { +amdgpu_bo_unref (bo_ptr); +return 0 ; + } + offset &=PAGE_MASK ; size =ALIGN (size,PAGE_SIZE );
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 01/14] drm/amdgpu: handle bo size 0 in amdgpu_bo_create_kernel_at
Am 2020-07-28 um 6:45 p.m. schrieb Alex Deucher:
Quoted 12 lines
Just return early to match other
bo_createfunctions.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev, · line 370
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-0@@ -366,6 +366,11 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,unsigned int i;int r; +if (!size) { +amdgpu_bo_unref (bo_ptr);
I was going to say, unreffing the bo_ptr before allocating anything seems weird. But amdgpu_bo_create_reserved, which is called just below, does the same thing. So this doesn't really change anything. Never mind.
Regards,
Felix
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev, · line 376
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-0+return 0 ; + } + offset &=PAGE_MASK ; size =ALIGN (size,PAGE_SIZE );
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 01/14] drm/amdgpu: handle bo size 0 in amdgpu_bo_create_kernel_at
In reply to Alex DeucherAm 29.07.20 um 00:45 schrieb Alex Deucher:
Quoted 12 lines
Just return early to match other
bo_createfunctions.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev, · line 373
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5
-0@@ -366,6 +366,11 @@ int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev,unsigned int i;int r; +if (!size) { +amdgpu_bo_unref (bo_ptr); +return 0 ; + } +
Maybe we could just check if amdgpu_bo_create_reserved() allocated a BO or not since we have the same check there already.
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_kernel_at(struct amdgpu_device *adev, · line 376
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0offset &=PAGE_MASK ; size =ALIGN (size,PAGE_SIZE );
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/14 drm/amdgpu: use create_at for the stolen pre-OS buffer
In reply to Alex DeucherShould be functionally the same since nothing else is allocated at that point, but let's be exact.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -4
@@ -1979,10 +1979,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)* This is used for VGA emulation and pre-OS scanout buffers to * avoid display artifacts while transitioning between pre-OS * and driver. */ - r =amdgpu_bo_create_kernel (adev, adev->gmc.stolen_size,PAGE_SIZE , -AMDGPU_GEM_DOMAIN_VRAM , - &adev->stolen_vga_memory, -NULL , &stolen_vga_buf); + r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_size, +AMDGPU_GEM_DOMAIN_VRAM , + &adev->stolen_vga_memory, + &stolen_vga_buf);if (r)return r;
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/14 drm/amdgpu: use a define for the memory size of the vga emulator
In reply to Alex DeucherRather than open coding it everywhere.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -212,6 +212,8 @@ extern int amdgpu_cik_support;#define AMDGPUFB_CONN_LIMIT 4#define AMDGPU_BIOS_NUM_SCRATCH 16 +#define AMDGPU_VBIOS_VGA_ALLOCATION (9 * 1024 * 1024)/* reserve 8MB for vga emulator and 1 MB for FB */ +/* hard reset data */ #define AMDGPU_ASIC_RESET_DATA 0x39d5e86b
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
@@ -707,7 +707,7 @@ static unsigned gmc_v10_0_get_vbios_fb_size(struct amdgpu_device *adev)unsigned size;if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =9 *1024 *1024 ;/* reserve 8MB for vga emulator and 1 MB for FB */ + size =AMDGPU_VBIOS_VGA_ALLOCATION ; }else {u32 viewport;u32 pitch;
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -1
@@ -805,7 +805,7 @@ static unsigned gmc_v6_0_get_vbios_fb_size(struct amdgpu_device *adev)unsigned size;if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =9 *1024 *1024 ;/* reserve 8MB for vga emulator and 1 MB for FB */ + size =AMDGPU_VBIOS_VGA_ALLOCATION ; }else {u32 viewport =RREG32 (mmVIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -970,7 +970,7 @@ static unsigned gmc_v7_0_get_vbios_fb_size(struct amdgpu_device *adev)unsigned size;if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =9 *1024 *1024 ;/* reserve 8MB for vga emulator and 1 MB for FB */ + size =AMDGPU_VBIOS_VGA_ALLOCATION ; }else {u32 viewport =RREG32 (mmVIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -1087,7 +1087,7 @@ static unsigned gmc_v8_0_get_vbios_fb_size(struct amdgpu_device *adev)unsigned size;if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =9 *1024 *1024 ;/* reserve 8MB for vga emulator and 1 MB for FB */ + size =AMDGPU_VBIOS_VGA_ALLOCATION ; }else {u32 viewport =RREG32 (mmVIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -2
@@ -1077,11 +1077,11 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)* Check related code in gmc_v9_0_sw_fini * */ if (gmc_v9_0_keep_stolen_memory (adev)) -return 9 *1024 *1024 ; +return AMDGPU_VBIOS_VGA_ALLOCATION ; d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL);if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =9 *1024 *1024 ;/* reserve 8MB for vga emulator and 1 MB for FB */ + size =AMDGPU_VBIOS_VGA_ALLOCATION ; }else {u32 viewport;
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/14 drm/amdgpu: move stolen vga bo from amdgpu to amdgpu.gmc
In reply to Alex DeucherSince that is where we store the other data related to the stolen vga memory.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -767,7 +767,6 @@ struct amdgpu_device {bool is_atom_fw;uint8_t *bios;uint32_t bios_size; -struct amdgpu_bo *stolen_vga_memory;uint32_t bios_scratch_reg_offset;uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH ];
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +2 -1
@@ -213,7 +213,8 @@ struct amdgpu_gmc {uint8_t vram_vendor;uint32_t srbm_soft_reset;bool prt_warning; -uint64_t stolen_size; +uint64_t stolen_vga_size; +struct amdgpu_bo *stolen_vga_memory;uint32_t sdpif_register;/* apertures */ u64 shared_aperture_start;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -3
@@ -1979,9 +1979,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)* This is used for VGA emulation and pre-OS scanout buffers to * avoid display artifacts while transitioning between pre-OS * and driver. */ - r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_size, + r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_vga_size,AMDGPU_GEM_DOMAIN_VRAM , - &adev->stolen_vga_memory, + &adev->gmc.stolen_vga_memory, &stolen_vga_buf);if (r)return r;
@@ -2043,7 +2043,7 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev) {void *stolen_vga_buf;/* return the VGA stolen memory (if any) back to VRAM */ -amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); }/**
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
@@ -812,7 +812,7 @@ static int gmc_v10_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v10_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v10_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -1
@@ -862,7 +862,7 @@ static int gmc_v6_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v6_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v6_0_get_vbios_fb_size (adev); r =amdgpu_bo_init (adev);if (r)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -1035,7 +1035,7 @@ static int gmc_v7_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v7_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v7_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -1160,7 +1160,7 @@ static int gmc_v8_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v8_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v8_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -2
@@ -1243,7 +1243,7 @@ static int gmc_v9_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v9_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v9_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
@@ -1282,7 +1282,7 @@ static int gmc_v9_0_sw_fini(void *handle)amdgpu_vm_manager_fini (adev);if (gmc_v9_0_keep_stolen_memory (adev)) -amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf);amdgpu_gart_table_vram_free (adev);amdgpu_bo_fini (adev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 04/14] drm/amdgpu: move stolen vga bo from amdgpu to amdgpu.gmc
Am 29.07.20 um 00:45 schrieb Alex Deucher:
Quoted 2 lines
Since that is where we store the other data related to the stolen vga memory.
Mhm, how about putting everything into struct amdgpu_mman instead?
This stuff is not at all GMC related as far as I can see.
We just put it into the GMC code because we have all the other memory sizes there as well.
Christian.
Quoted 130 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-1@@ -767,7 +767,6 @@ struct amdgpu_device {bool is_atom_fw;uint8_t *bios;uint32_t bios_size; -struct amdgpu_bo *stolen_vga_memory;uint32_t bios_scratch_reg_offset;uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH ];drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +2
-1@@ -213,7 +213,8 @@ struct amdgpu_gmc {uint8_t vram_vendor;uint32_t srbm_soft_reset;bool prt_warning; -uint64_t stolen_size; +uint64_t stolen_vga_size; +struct amdgpu_bo *stolen_vga_memory;uint32_t sdpif_register;/* apertures */ u64 shared_aperture_start;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3@@ -1979,9 +1979,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)* This is used for VGA emulation and pre-OS scanout buffers to * avoid display artifacts while transitioning between pre-OS * and driver. */ - r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_size, + r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_vga_size,AMDGPU_GEM_DOMAIN_VRAM , - &adev->stolen_vga_memory, + &adev->gmc.stolen_vga_memory, &stolen_vga_buf);if (r)return r;@@ -2043,7 +2043,7 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev) {void *stolen_vga_buf;/* return the VGA stolen memory (if any) back to VRAM */ -amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); }/** drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-1@@ -812,7 +812,7 @@ static int gmc_v10_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v10_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v10_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1
-1@@ -862,7 +862,7 @@ static int gmc_v6_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v6_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v6_0_get_vbios_fb_size (adev); r =amdgpu_bo_init (adev);if (r)drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1
-1@@ -1035,7 +1035,7 @@ static int gmc_v7_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v7_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v7_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1
-1@@ -1160,7 +1160,7 @@ static int gmc_v8_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v8_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v8_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-1@@ -1243,7 +1243,7 @@ static int gmc_v9_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_size =gmc_v9_0_get_vbios_fb_size (adev); + adev->gmc.stolen_vga_size =gmc_v9_0_get_vbios_fb_size (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 1288
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-1@@ -1282,7 +1282,7 @@ static int gmc_v9_0_sw_fini(void *handle)amdgpu_vm_manager_fini (adev);if (gmc_v9_0_keep_stolen_memory (adev)) -amdgpu_bo_free_kernel (&adev->stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf);amdgpu_gart_table_vram_free (adev);amdgpu_bo_fini (adev);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/14 drm/amdgpu: move keep stolen memory check into gmc core
In reply to Alex DeucherRather than leaving this as a gmc v9 specific hack.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 ++++++++- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 11 +++-------- 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
@@ -215,6 +215,7 @@ struct amdgpu_gmc {bool prt_warning;uint64_t stolen_vga_size;struct amdgpu_bo *stolen_vga_memory; +bool keep_stolen_vga_memory;uint32_t sdpif_register;/* apertures */ u64 shared_aperture_start;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -1
@@ -2042,8 +2042,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)void amdgpu_ttm_late_init (struct amdgpu_device *adev) {void *stolen_vga_buf; +/* return the VGA stolen memory (if any) back to VRAM */ -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); +if (!adev->gmc.keep_stolen_vga_memory) +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); }/**
@@ -2051,10 +2053,15 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_fini (struct amdgpu_device *adev) { +void *stolen_vga_buf; +if (!adev->mman.initialized)return ;amdgpu_ttm_training_reserve_vram_fini (adev); +/* return the stolen vga memory back to VRAM */ +if (adev->gmc.keep_stolen_vga_memory) +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf);/* return the IP Discovery TMR memory back to VRAM */ amdgpu_bo_free_kernel (&adev->discovery_memory,NULL ,NULL );amdgpu_ttm_fw_reserve_vram_fini (adev);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -8
@@ -932,8 +932,7 @@ static int gmc_v9_0_late_init(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int r; -if (!gmc_v9_0_keep_stolen_memory (adev)) -amdgpu_bo_late_init (adev); +amdgpu_bo_late_init (adev); r =amdgpu_gmc_allocate_vm_inv_eng (adev);if (r)
@@ -1076,7 +1075,7 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)* TODO Remove once GART corruption is resolved * Check related code in gmc_v9_0_sw_fini * */ -if (gmc_v9_0_keep_stolen_memory (adev)) +if (adev->gmc.keep_stolen_vga_memory)return AMDGPU_VBIOS_VGA_ALLOCATION ; d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL);
@@ -1243,6 +1242,7 @@ static int gmc_v9_0_sw_init(void *handle)if (r)return r; + adev->gmc.keep_stolen_vga_memory =gmc_v9_0_keep_stolen_memory (adev); adev->gmc.stolen_vga_size =gmc_v9_0_get_vbios_fb_size (adev);/* Memory manager */
@@ -1275,15 +1275,10 @@ static int gmc_v9_0_sw_init(void *handle)static int gmc_v9_0_sw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -void *stolen_vga_buf;amdgpu_gmc_ras_fini (adev);amdgpu_gem_force_release (adev);amdgpu_vm_manager_fini (adev); - -if (gmc_v9_0_keep_stolen_memory (adev)) -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); -amdgpu_gart_table_vram_free (adev);amdgpu_bo_fini (adev);amdgpu_gart_fini (adev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/14 drm/amdgpu: add support for extended stolen vga memory
In reply to Alex DeucherThis will allow us to split the allocation for systems where we have to keep the stolen memory around to avoid S3 issues. This way we don't waste as much memory and still avoid any screen artifacts during the bios to driver transition.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +2 -0
@@ -215,6 +215,8 @@ struct amdgpu_gmc {bool prt_warning;uint64_t stolen_vga_size;struct amdgpu_bo *stolen_vga_memory; +uint64_t stolen_extended_size; +struct amdgpu_bo *stolen_extended_memory;bool keep_stolen_vga_memory;uint32_t sdpif_register;/* apertures */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +11 -2
@@ -1915,7 +1915,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)uint64_t gtt_size;int r;u64 vis_vram_limit; -void *stolen_vga_buf; +void *stolen_vga_buf, *stolen_extended_buf;mutex_init (&adev->mman.gtt_window_lock);
@@ -1985,6 +1985,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) &stolen_vga_buf);if (r)return r; + r =amdgpu_bo_create_kernel_at (adev, adev->gmc.stolen_vga_size, + adev->gmc.stolen_extended_size, +AMDGPU_GEM_DOMAIN_VRAM , + &adev->gmc.stolen_extended_memory, + &stolen_extended_buf); +if (r) +return r;DRM_INFO ("amdgpu: %uM of VRAM memory ready\n" , (unsigned ) (adev->gmc.real_vram_size / (1024 *1024 )));
@@ -2041,11 +2048,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_late_init (struct amdgpu_device *adev) { -void *stolen_vga_buf; +void *stolen_vga_buf, *stolen_extended_buf;/* return the VGA stolen memory (if any) back to VRAM */ if (!adev->gmc.keep_stolen_vga_memory)amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_extended_memory,NULL , + &stolen_extended_buf); }/**
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/14 drm/amdgpu/gmc: add new helper to get the FB size used by pre-OS console
In reply to Alex DeucherThis adds a new gmc callback to get the size reserved by the pre-OS console and provides a helper function for use by gmc IP drivers.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 43 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 5 +++ 2 files changed, 48 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +43 -0
@@ -27,6 +27,7 @@#include <linux/io-64-nonatomic-lo-hi.h> #include "amdgpu.h" +#include "amdgpu_gmc.h" #include "amdgpu_ras.h" #include "amdgpu_xgmi.h"
@@ -431,3 +432,45 @@ void amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,WREG32 (reg, tmp); } } + +void amdgpu_gmc_get_vbios_allocations (struct amdgpu_device *adev) +{ +unsigned size; + +/* +* TODO: +* Currently there is a bug where some memory client outside +* of the driver writes to first 8M of VRAM on S3 resume, +* this overrides GART which by default gets placed in first 8M and +* causes VM_FAULTS once GTT is accessed. +* Keep the stolen memory reservation until the while this is not solved. +*/ +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_RAVEN : +case CHIP_ARCTURUS : +case CHIP_RENOIR : + adev->gmc.keep_stolen_vga_memory = true; +break ; +default : + adev->gmc.keep_stolen_vga_memory = false; +break ; + } + +if (!amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_DCE )) + size =0 ; +else + size =amdgpu_gmc_get_vbios_fb_size (adev); + +/* set to 0 if the pre-OS buffer uses up most of vram */ +if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) + size =0 ; + +if (size >AMDGPU_VBIOS_VGA_ALLOCATION ) { + adev->gmc.stolen_vga_size =AMDGPU_VBIOS_VGA_ALLOCATION ; + adev->gmc.stolen_extended_size = size - adev->gmc.stolen_vga_size; + }else { + adev->gmc.stolen_vga_size = size; + adev->gmc.stolen_extended_size =0 ; + } +}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +5 -0
@@ -131,6 +131,8 @@ struct amdgpu_gmc_funcs {void (*get_vm_pte)(struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping,uint64_t *flags); +/* get the amount of memory used by the vbios for pre-OS console */ +unsigned int (*get_vbios_fb_size)(struct amdgpu_device *adev); };struct amdgpu_xgmi {
@@ -253,6 +255,7 @@ struct amdgpu_gmc {#define amdgpu_gmc_map_mtype (adev, flags) (adev)->gmc.gmc_funcs->map_mtype((adev),(flags))#define amdgpu_gmc_get_vm_pde (adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))#define amdgpu_gmc_get_vm_pte (adev, mapping, flags) (adev)->gmc.gmc_funcs->get_vm_pte((adev), (mapping), (flags)) +#define amdgpu_gmc_get_vbios_fb_size (adev) (adev)->gmc.gmc_funcs->get_vbios_fb_size((adev))/** * amdgpu_gmc_vram_full_visible - Check if full VRAM is visible through the BAR
@@ -307,4 +310,6 @@ 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); +#endif
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/14 drm/amdgpu/gmc6: switch to using amdgpu_gmc_get_vbios_allocations
In reply to Alex DeucherThe new helper centralizes the logic in one place.
--- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
@@ -812,9 +812,6 @@ static unsigned gmc_v6_0_get_vbios_fb_size(struct amdgpu_device *adev)REG_GET_FIELD (viewport,VIEWPORT_SIZE ,VIEWPORT_WIDTH ) * 4); } -/* return 0 if the pre-OS buffer uses up most of vram */ -if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) -return 0 ;return size; }
@@ -862,7 +859,7 @@ static int gmc_v6_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_vga_size =gmc_v6_0_get_vbios_fb_size (adev); +amdgpu_gmc_get_vbios_allocations (adev); r =amdgpu_bo_init (adev);if (r)
@@ -1136,6 +1133,7 @@ static const struct amdgpu_gmc_funcs gmc_v6_0_gmc_funcs = { .set_prt = gmc_v6_0_set_prt, .get_vm_pde = gmc_v6_0_get_vm_pde, .get_vm_pte = gmc_v6_0_get_vm_pte, + .get_vbios_fb_size = gmc_v6_0_get_vbios_fb_size, };static const struct amdgpu_irq_src_funcs gmc_v6_0_irq_funcs = {
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/14 drm/amdgpu/gmc7: switch to using amdgpu_gmc_get_vbios_allocations
In reply to Alex DeucherThe new helper centralizes the logic in one place.
--- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -5
@@ -977,9 +977,7 @@ static unsigned gmc_v7_0_get_vbios_fb_size(struct amdgpu_device *adev)REG_GET_FIELD (viewport,VIEWPORT_SIZE ,VIEWPORT_WIDTH ) * 4); } -/* return 0 if the pre-OS buffer uses up most of vram */ -if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) -return 0 ; +return size; }
@@ -1035,7 +1033,7 @@ static int gmc_v7_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_vga_size =gmc_v7_0_get_vbios_fb_size (adev); +amdgpu_gmc_get_vbios_allocations (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
@@ -1372,7 +1370,8 @@ static const struct amdgpu_gmc_funcs gmc_v7_0_gmc_funcs = { .emit_pasid_mapping = gmc_v7_0_emit_pasid_mapping, .set_prt = gmc_v7_0_set_prt, .get_vm_pde = gmc_v7_0_get_vm_pde, - .get_vm_pte = gmc_v7_0_get_vm_pte + .get_vm_pte = gmc_v7_0_get_vm_pte, + .get_vbios_fb_size = gmc_v7_0_get_vbios_fb_size, };static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/14 drm/amdgpu/gmc8: switch to using amdgpu_gmc_get_vbios_allocations
In reply to Alex DeucherThe new helper centralizes the logic in one place.
--- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +4 -5
@@ -1094,9 +1094,7 @@ static unsigned gmc_v8_0_get_vbios_fb_size(struct amdgpu_device *adev)REG_GET_FIELD (viewport,VIEWPORT_SIZE ,VIEWPORT_WIDTH ) * 4); } -/* return 0 if the pre-OS buffer uses up most of vram */ -if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) -return 0 ; +return size; }
@@ -1160,7 +1158,7 @@ static int gmc_v8_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_vga_size =gmc_v8_0_get_vbios_fb_size (adev); +amdgpu_gmc_get_vbios_allocations (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
@@ -1739,7 +1737,8 @@ static const struct amdgpu_gmc_funcs gmc_v8_0_gmc_funcs = { .emit_pasid_mapping = gmc_v8_0_emit_pasid_mapping, .set_prt = gmc_v8_0_set_prt, .get_vm_pde = gmc_v8_0_get_vm_pde, - .get_vm_pte = gmc_v8_0_get_vm_pte + .get_vm_pte = gmc_v8_0_get_vm_pte, + .get_vbios_fb_size = gmc_v8_0_get_vbios_fb_size, };static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/14 drm/amdgpu/gmc9: switch to using amdgpu_gmc_get_vbios_allocations
In reply to Alex DeucherThe new helper centralizes the logic in one place.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 112 +++++++++----------------- 1 file changed, 38 insertions(+), 74 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +38 -74
@@ -827,6 +827,41 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev, *flags |=AMDGPU_PTE_SNOOPED ; } +static unsigned gmc_v9_0_get_vbios_fb_size (struct amdgpu_device *adev) +{ +u32 d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL); +unsigned size; + +if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { + size =AMDGPU_VBIOS_VGA_ALLOCATION ; + }else { +u32 viewport; + +switch (adev->asic_type) { +case CHIP_RAVEN : +case CHIP_RENOIR : + viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); + size = (REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * +REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_WIDTH ) * +4 ); +break ; +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_VEGA20 : +default : + viewport =RREG32_SOC15 (DCE ,0 , mmSCL0_VIEWPORT_SIZE); + size = (REG_GET_FIELD (viewport,SCL0_VIEWPORT_SIZE ,VIEWPORT_HEIGHT ) * +REG_GET_FIELD (viewport,SCL0_VIEWPORT_SIZE ,VIEWPORT_WIDTH ) * +4 ); +break ; + } + } + +return size; +} +static const struct amdgpu_gmc_funcs gmc_v9_0_gmc_funcs = { .flush_gpu_tlb = gmc_v9_0_flush_gpu_tlb, .flush_gpu_tlb_pasid = gmc_v9_0_flush_gpu_tlb_pasid,
@@ -834,7 +869,8 @@ static const struct amdgpu_gmc_funcs gmc_v9_0_gmc_funcs = { .emit_pasid_mapping = gmc_v9_0_emit_pasid_mapping, .map_mtype = gmc_v9_0_map_mtype, .get_vm_pde = gmc_v9_0_get_vm_pde, - .get_vm_pte = gmc_v9_0_get_vm_pte + .get_vm_pte = gmc_v9_0_get_vm_pte, + .get_vbios_fb_size = gmc_v9_0_get_vbios_fb_size, };static void gmc_v9_0_set_gmc_funcs (struct amdgpu_device *adev)
@@ -902,31 +938,6 @@ static int gmc_v9_0_early_init(void *handle)return 0 ; } -static bool gmc_v9_0_keep_stolen_memory (struct amdgpu_device *adev) -{ - -/* -* TODO: -* Currently there is a bug where some memory client outside -* of the driver writes to first 8M of VRAM on S3 resume, -* this overrides GART which by default gets placed in first 8M and -* causes VM_FAULTS once GTT is accessed. -* Keep the stolen memory reservation until the while this is not solved. -* Also check code in gmc_v9_0_get_vbios_fb_size and gmc_v9_0_late_init -*/ -switch (adev->asic_type) { -case CHIP_VEGA10 : -case CHIP_RAVEN : -case CHIP_ARCTURUS : -case CHIP_RENOIR : -return true; -case CHIP_VEGA12 : -case CHIP_VEGA20 : -default : -return false; - } -} -static int gmc_v9_0_late_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -1066,52 +1077,6 @@ static int gmc_v9_0_gart_init(struct amdgpu_device *adev)return amdgpu_gart_table_vram_alloc (adev); } -static unsigned gmc_v9_0_get_vbios_fb_size (struct amdgpu_device *adev) -{ -u32 d1vga_control; -unsigned size; - -/* -* TODO Remove once GART corruption is resolved -* Check related code in gmc_v9_0_sw_fini -* */ -if (adev->gmc.keep_stolen_vga_memory) -return AMDGPU_VBIOS_VGA_ALLOCATION ; - - d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL); -if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =AMDGPU_VBIOS_VGA_ALLOCATION ; - }else { -u32 viewport; - -switch (adev->asic_type) { -case CHIP_RAVEN : -case CHIP_RENOIR : - viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); - size = (REG_GET_FIELD (viewport, -HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * -REG_GET_FIELD (viewport, -HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_WIDTH ) * -4 ); -break ; -case CHIP_VEGA10 : -case CHIP_VEGA12 : -case CHIP_VEGA20 : -default : - viewport =RREG32_SOC15 (DCE ,0 , mmSCL0_VIEWPORT_SIZE); - size = (REG_GET_FIELD (viewport,SCL0_VIEWPORT_SIZE ,VIEWPORT_HEIGHT ) * -REG_GET_FIELD (viewport,SCL0_VIEWPORT_SIZE ,VIEWPORT_WIDTH ) * -4 ); -break ; - } - } -/* return 0 if the pre-OS buffer uses up most of vram */ -if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) -return 0 ; - -return size; -} -static int gmc_v9_0_sw_init (void *handle) {int r, vram_width =0 , vram_type =0 , vram_vendor =0 ;
@@ -1242,8 +1207,7 @@ static int gmc_v9_0_sw_init(void *handle)if (r)return r; - adev->gmc.keep_stolen_vga_memory =gmc_v9_0_keep_stolen_memory (adev); - adev->gmc.stolen_vga_size =gmc_v9_0_get_vbios_fb_size (adev); +amdgpu_gmc_get_vbios_allocations (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/14 drm/amdgpu/gmc10: switch to using amdgpu_gmc_get_vbios_allocations
In reply to Alex DeucherThe new helper centralizes the logic in one place.
--- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 57 +++++++++++--------------- 1 file changed, 25 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +25 -32
@@ -553,6 +553,28 @@ static void gmc_v10_0_get_vm_pte(struct amdgpu_device *adev, } } +static unsigned gmc_v10_0_get_vbios_fb_size (struct amdgpu_device *adev) +{ +u32 d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL); +unsigned size; + +if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { + size =AMDGPU_VBIOS_VGA_ALLOCATION ; + }else { +u32 viewport; +u32 pitch; + + viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); + pitch =RREG32_SOC15 (DCE ,0 , mmHUBPREQ0_DCSURF_SURFACE_PITCH); + size = (REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * +REG_GET_FIELD (pitch,HUBPREQ0_DCSURF_SURFACE_PITCH ,PITCH ) * +4 ); + } + +return size; +} +static const struct amdgpu_gmc_funcs gmc_v10_0_gmc_funcs = { .flush_gpu_tlb = gmc_v10_0_flush_gpu_tlb, .flush_gpu_tlb_pasid = gmc_v10_0_flush_gpu_tlb_pasid,
@@ -560,7 +582,8 @@ static const struct amdgpu_gmc_funcs gmc_v10_0_gmc_funcs = { .emit_pasid_mapping = gmc_v10_0_emit_pasid_mapping, .map_mtype = gmc_v10_0_map_mtype, .get_vm_pde = gmc_v10_0_get_vm_pde, - .get_vm_pte = gmc_v10_0_get_vm_pte + .get_vm_pte = gmc_v10_0_get_vm_pte, + .get_vbios_fb_size = gmc_v10_0_get_vbios_fb_size, };static void gmc_v10_0_set_gmc_funcs (struct amdgpu_device *adev)
@@ -701,36 +724,6 @@ static int gmc_v10_0_gart_init(struct amdgpu_device *adev)return amdgpu_gart_table_vram_alloc (adev); } -static unsigned gmc_v10_0_get_vbios_fb_size (struct amdgpu_device *adev) -{ -u32 d1vga_control =RREG32_SOC15 (DCE ,0 , mmD1VGA_CONTROL); -unsigned size; - -if (REG_GET_FIELD (d1vga_control,D1VGA_CONTROL ,D1VGA_MODE_ENABLE )) { - size =AMDGPU_VBIOS_VGA_ALLOCATION ; - }else { -u32 viewport; -u32 pitch; - - viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); - pitch =RREG32_SOC15 (DCE ,0 , mmHUBPREQ0_DCSURF_SURFACE_PITCH); - size = (REG_GET_FIELD (viewport, -HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * -REG_GET_FIELD (pitch,HUBPREQ0_DCSURF_SURFACE_PITCH ,PITCH ) * -4 ); - } -/* return 0 if the pre-OS buffer uses up most of vram */ -if ((adev->gmc.real_vram_size - size) < (8 *1024 *1024 )) { -DRM_ERROR ("Warning: pre-OS buffer uses most of vram, \ -be aware of gart table overwrite\n" ); -return 0 ; - } - -return size; -} - - -static int gmc_v10_0_sw_init (void *handle) {int r, vram_width =0 , vram_type =0 , vram_vendor =0 ;
@@ -812,7 +805,7 @@ static int gmc_v10_0_sw_init(void *handle)if (r)return r; - adev->gmc.stolen_vga_size =gmc_v10_0_get_vbios_fb_size (adev); +amdgpu_gmc_get_vbios_allocations (adev);/* Memory manager */ r =amdgpu_bo_init (adev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/14 drm/amdgpu: drop the CPU pointers for the stolen vga bos
In reply to Alex DeucherWe never use them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -11
@@ -1915,7 +1915,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)uint64_t gtt_size;int r;u64 vis_vram_limit; -void *stolen_vga_buf, *stolen_extended_buf;mutex_init (&adev->mman.gtt_window_lock);
@@ -1982,14 +1981,14 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_vga_size,AMDGPU_GEM_DOMAIN_VRAM , &adev->gmc.stolen_vga_memory, - &stolen_vga_buf); +NULL );if (r)return r; r =amdgpu_bo_create_kernel_at (adev, adev->gmc.stolen_vga_size, adev->gmc.stolen_extended_size,AMDGPU_GEM_DOMAIN_VRAM , &adev->gmc.stolen_extended_memory, - &stolen_extended_buf); +NULL );if (r)return r;
@@ -2048,13 +2047,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_late_init (struct amdgpu_device *adev) { -void *stolen_vga_buf, *stolen_extended_buf; -/* return the VGA stolen memory (if any) back to VRAM */ if (!adev->gmc.keep_stolen_vga_memory) -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); -amdgpu_bo_free_kernel (&adev->gmc.stolen_extended_memory,NULL , - &stolen_extended_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL ,NULL ); +amdgpu_bo_free_kernel (&adev->gmc.stolen_extended_memory,NULL ,NULL ); }/**
@@ -2062,15 +2058,13 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_fini (struct amdgpu_device *adev) { -void *stolen_vga_buf; -if (!adev->mman.initialized)return ;amdgpu_ttm_training_reserve_vram_fini (adev);/* return the stolen vga memory back to VRAM */ if (adev->gmc.keep_stolen_vga_memory) -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL ,NULL );/* return the IP Discovery TMR memory back to VRAM */ amdgpu_bo_free_kernel (&adev->discovery_memory,NULL ,NULL );amdgpu_ttm_fw_reserve_vram_fini (adev);
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 13/14] drm/amdgpu: drop the CPU pointers for the stolen vga bos
Am 29.07.20 um 00:46 schrieb Alex Deucher:
Quoted 3 lines
We never use them.
Signed-off-by Alex Deucher <[email protected]>
Quoted 56 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-10@@ -1915,7 +1915,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)uint64_t gtt_size;int r;u64 vis_vram_limit; -void *stolen_vga_buf, *stolen_extended_buf;mutex_init (&adev->mman.gtt_window_lock);@@ -1982,14 +1981,14 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) r =amdgpu_bo_create_kernel_at (adev,0 , adev->gmc.stolen_vga_size,AMDGPU_GEM_DOMAIN_VRAM , &adev->gmc.stolen_vga_memory, - &stolen_vga_buf); +NULL );if (r)return r; r =amdgpu_bo_create_kernel_at (adev, adev->gmc.stolen_vga_size, adev->gmc.stolen_extended_size,AMDGPU_GEM_DOMAIN_VRAM , &adev->gmc.stolen_extended_memory, - &stolen_extended_buf); +NULL );if (r)return r;@@ -2048,13 +2047,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_late_init (struct amdgpu_device *adev) { -void *stolen_vga_buf, *stolen_extended_buf; -/* return the VGA stolen memory (if any) back to VRAM */ if (!adev->gmc.keep_stolen_vga_memory) -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); -amdgpu_bo_free_kernel (&adev->gmc.stolen_extended_memory,NULL , - &stolen_extended_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL ,NULL ); +amdgpu_bo_free_kernel (&adev->gmc.stolen_extended_memory,NULL ,NULL ); }/** @@ -2062,15 +2058,13 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)*/ void amdgpu_ttm_fini (struct amdgpu_device *adev) { -void *stolen_vga_buf; -if (!adev->mman.initialized)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c void amdgpu_ttm_late_init(struct amdgpu_device *adev) · line 2070
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1return ;amdgpu_ttm_training_reserve_vram_fini (adev);/* return the stolen vga memory back to VRAM */ if (adev->gmc.keep_stolen_vga_memory) -amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL , &stolen_vga_buf); +amdgpu_bo_free_kernel (&adev->gmc.stolen_vga_memory,NULL ,NULL );/* return the IP Discovery TMR memory back to VRAM */ amdgpu_bo_free_kernel (&adev->discovery_memory,NULL ,NULL );amdgpu_ttm_fw_reserve_vram_fini (adev);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/14 drm/amdgpu/gmc: disable keep_stolen_vga_memory on arcturus
In reply to Alex DeucherI suspect the only reason this was set was to avoid touching the display related registers on arcturus. Someone should double check this on arcturus with S3.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -1
@@ -448,7 +448,6 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)switch (adev->asic_type) {case CHIP_VEGA10 :case CHIP_RAVEN : -case CHIP_ARCTURUS :case CHIP_RENOIR : adev->gmc.keep_stolen_vga_memory = true;break ;
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 14/14] drm/amdgpu/gmc: disable keep_stolen_vga_memory on arcturus
Am 2020-07-28 um 6:46 p.m. schrieb Alex Deucher:
Quoted 3 lines
I suspect the only reason this was set was to avoid touching the display related registers on arcturus. Someone should double check this on arcturus with S3.
Sounds reasonable, given that the other offenders here are all APUs. AFAIK, we haven't tried S3 on Arcturus. Doesn't seem like something one would do on a server.
See one more comment on patch 1. Other than that the series is
Regards,
Felix
Quoted 11 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev) · line 453
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0
-1@@ -448,7 +448,6 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)switch (adev->asic_type) {case CHIP_VEGA10 :case CHIP_RAVEN : -case CHIP_ARCTURUS :case CHIP_RENOIR : adev->gmc.keep_stolen_vga_memory = true;break ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx