drm/amdgpu: Reuse fw_vram_usage_* for dynamic critical region in SRIOV
Subsystems (2)
PATCH 4/6 drm/amdgpu: Reuse fw_vram_usage_* for dynamic critical region in SRIOV
- During guest driver init, asa VFs receive PF msg to init dynamic critical region(v2), VFs reuse fw_vram_usage_* from ttm to store critical region tables in a 5MB chunk.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 +++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 8 ++++++ 2 files changed, 26 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -15
@@ -1943,23 +1943,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)if (r)return r; -/* -*The reserved vram for driver must be pinned to the specified -*place on the VRAM, so reserve it early. -*/ - r =amdgpu_ttm_drv_reserve_vram_init (adev); -if (r) -return r; - -/* -* only NAVI10 and onwards ASIC support for IP discovery. -* If IP discovery enabled, a block of memory should be -* reserved for IP discovey. -*/ -if (adev->mman.discovery_bin) { - r =amdgpu_ttm_reserve_tmr (adev); +/* VFs using dynamic critical regions(v2) won't need to reserve for below memory */ +if (!amdgpu_sriov_vf (adev) || (adev->virt.req_init_data_ver !=GPU_CRIT_REGION_V2 )) { +/* +*The reserved vram for driver must be pinned to the specified +*place on the VRAM, so reserve it early. +*/ + r =amdgpu_ttm_drv_reserve_vram_init (adev);if (r)return r; + +/* +* only NAVI10 and onwards ASIC support for IP discovery. +* If IP discovery enabled, a block of memory should be +* reserved for IP discovey. +*/ +if (adev->mman.discovery_bin) { + r =amdgpu_ttm_reserve_tmr (adev); +if (r) +return r; + } }/* allocate memory as required for VGA
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +8 -0
@@ -931,6 +931,14 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) adev->virt.crit_region_sizes_kb[AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID ] = init_data_hdr->bad_page_size_in_kb; +/* reserved memory starts from crit region base offset with the size of 5MB */ + adev->mman.fw_vram_usage_start_offset = adev->virt.crit_region_base_offset; + adev->mman.fw_vram_usage_size = adev->virt.crit_region_size_in_kb <<10 ; +DRM_INFO ("critical region v%d requested to reserve memory start at %08x with %d KB.\n" , + init_data_hdr->version, + adev->mman.fw_vram_usage_start_offset, + adev->mman.fw_vram_usage_size >>10 ); + adev->virt.init_data_done = true;break ;default :
Signature · 1 line
2.34.1
Christian König
maintainerQuoted 25 lines · Ellen Pan
- During guest driver init, asa VFs receive PF msg to init dynamic critical region(v2), VFs reuse fw_vram_usage_* from ttm to store critical region tables in a 5MB chunk.
Signed-off-by Ellen Pan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 +++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 8 ++++++ 2 files changed, 26 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-7@@ -1943,23 +1943,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)if (r)return r; -/* -*The reserved vram for driver must be pinned to the specified -*place on the VRAM, so reserve it early. -*/ - r =amdgpu_ttm_drv_reserve_vram_init (adev); -if (r) -return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1947
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-8- -/* -* only NAVI10 and onwards ASIC support for IP discovery. -* If IP discovery enabled, a block of memory should be -* reserved for IP discovey. -*/ -if (adev->mman.discovery_bin) { - r =amdgpu_ttm_reserve_tmr (adev); +/* VFs using dynamic critical regions(v2) won't need to reserve for below memory */ +if (!amdgpu_sriov_vf (adev) || (adev->virt.req_init_data_ver !=GPU_CRIT_REGION_V2 )) {
That comment says what is done, but not why it is done.
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1959
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-0+/* +*The reserved vram for driver must be pinned to the specified +*place on the VRAM, so reserve it early. +*/ + r =amdgpu_ttm_drv_reserve_vram_init (adev);if (r)return r; + +/* +* only NAVI10 and onwards ASIC support for IP discovery. +* If IP discovery enabled, a block of memory should be +* reserved for IP discovey.
While at it there are a couple of typos in the comment, please fix.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6
-0+*/ +if (adev->mman.discovery_bin) { + r =amdgpu_ttm_reserve_tmr (adev); +if (r) +return r; + } }/* allocate memory as required for VGA drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0
-0@@ -931,6 +931,14 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) adev->virt.crit_region_sizes_kb[AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID] =
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) · line 941
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +8
-0init_data_hdr->bad_page_size_in_kb; +/* reserved memory starts from crit region base offset with the size of 5MB */ + adev->mman.fw_vram_usage_start_offset = adev->virt.crit_region_base_offset; + adev->mman.fw_vram_usage_size = adev->virt.crit_region_size_in_kb <<10 ; +DRM_INFO ("critical region v%d requested to reserve memory start at %08x with %d KB.\n" , + init_data_hdr->version, + adev->mman.fw_vram_usage_start_offset, + adev->mman.fw_vram_usage_size >>10 ); +
Same as on the other patch, using dev_info might be more adequate than DRM_INFO.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0
-0adev->virt.init_data_done = true;break ;default :
Quoted 62 lines · Ellen Pan
- During guest driver init, asa VFs receive PF msg to init dynamic critical region(v2), VFs reuse fw_vram_usage_* from ttm to store critical region tables in a 5MB chunk.
Signed-off-by Ellen Pan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 +++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 8 ++++++ 2 files changed, 26 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18
-15@@ -1943,23 +1943,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)if (r)return r; -/* -*The reserved vram for driver must be pinned to the specified -*place on the VRAM, so reserve it early. -*/ - r =amdgpu_ttm_drv_reserve_vram_init (adev); -if (r) -return r; - -/* -* only NAVI10 and onwards ASIC support for IP discovery. -* If IP discovery enabled, a block of memory should be -* reserved for IP discovey. -*/ -if (adev->mman.discovery_bin) { - r =amdgpu_ttm_reserve_tmr (adev); +/* VFs using dynamic critical regions(v2) won't need to reserve for below memory */ +if (!amdgpu_sriov_vf (adev) || (adev->virt.req_init_data_ver !=GPU_CRIT_REGION_V2 )) { +/* +*The reserved vram for driver must be pinned to the specified +*place on the VRAM, so reserve it early. +*/ + r =amdgpu_ttm_drv_reserve_vram_init (adev);if (r)return r; + +/* +* only NAVI10 and onwards ASIC support for IP discovery. +* If IP discovery enabled, a block of memory should be +* reserved for IP discovey. +*/ +if (adev->mman.discovery_bin) { + r =amdgpu_ttm_reserve_tmr (adev); +if (r) +return r; + } }/* allocate memory as required for VGA drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) · line 937
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +4
-0@@ -931,6 +931,14 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) adev->virt.crit_region_sizes_kb[AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID ] = init_data_hdr->bad_page_size_in_kb; +/* reserved memory starts from crit region base offset with the size of 5MB */ + adev->mman.fw_vram_usage_start_offset = adev->virt.crit_region_base_offset; + adev->mman.fw_vram_usage_size = adev->virt.crit_region_size_in_kb <<10 ; + DRM_INFO("critical region v%d requested to reserve memory start at %08x with %d KB.\n",
Please use dev_info() here so we have proper multi-gpu support.
Alex
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +4
-1+ init_data_hdr->version, + adev->mman.fw_vram_usage_start_offset, + adev->mman.fw_vram_usage_size >> 10); + adev->virt.init_data_done = true;break ;default : --2.34.1
[Public]
Quoted 90 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Ellen Pan
Sent: Thursday, October 9, 2025 9:01 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Gande, Shravan kumar <[email protected]>; Pan, Ellen <[email protected]>
Subject: [PATCH 4/6] drm/amdgpu: Reuse fw_vram_usage_* for dynamic critical region in SRIOV- During guest driver init, asa VFs receive PF msg to init dynamic critical region(v2), VFs reuse fw_vram_usage_* from ttm to store critical region tables in a 5MB chunk.
Signed-off-by Ellen Pan <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 33 +++++++++++++----------
-drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c| 8 ++++++2 files changed, 26 insertions(+), 15 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-15@@ -1943,23 +1943,26 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)if (r)return r; -/* -*The reserved vram for driver must be pinned to the specified -*place on the VRAM, so reserve it early. -*/ - r =amdgpu_ttm_drv_reserve_vram_init (adev); -if (r) -return r; - -/* -* only NAVI10 and onwards ASIC support for IP discovery. -* If IP discovery enabled, a block of memory should be -* reserved for IP discovey. -*/ -if (adev->mman.discovery_bin) { - r =amdgpu_ttm_reserve_tmr (adev); +/* VFs using dynamic critical regions(v2) won't need to reserve for below memory */
+ if (!amdgpu_sriov_vf(adev) || (adev->virt.req_init_data_ver!=GPU_CRIT_REGION_V2)) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +16
-0+/* +*The reserved vram for driver must be pinned to the specified +*place on the VRAM, so reserve it early. +*/ + r =amdgpu_ttm_drv_reserve_vram_init (adev);if (r)return r; + +/* +* only NAVI10 and onwards ASIC support for IP discovery. +* If IP discovery enabled, a block of memory should be +* reserved for IP discovey. +*/ +if (adev->mman.discovery_bin) { + r =amdgpu_ttm_reserve_tmr (adev); +if (r) +return r; + } }/* allocate memory as required for VGA diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index46c19e96086a..e9dbab53cb06100644drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0
-0@@ -931,6 +931,14 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) adev-Quoted 1 line
virt.crit_region_sizes_kb[AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID] =
init_data_hdr->bad_page_size_in_kb;+ /* reserved memory starts from crit region base offset with the
size of 5MB */
+adev->mman.fw_vram_usage_start_offset= adev-Quoted 1 line
virt.crit_region_base_offset;
+
adev->mman.fw_vram_usage_size= adev-Quoted 1 line
virt.crit_region_size_in_kb << 10;
+ DRM_INFO("critical region v%d requested to reserve memory
start at %08x with %d KB.\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c int amdgpu_virt_init_critical_region(struct amdgpu_device *adev) · line 941
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +4
-0+ init_data_hdr->version, + adev->mman.fw_vram_usage_start_offset, + adev->mman.fw_vram_usage_size >> 10); +
[lijo]
There is another place where this gets set - amdgpu_atomfirmware_allocate_fb_v2_2. Is the assumption that vbios table no longer will have the flags set?
Thanks,
Lijo
Quoted 5 lines
adev->virt.init_data_done = true; break; default:--
2.34.1