Skip to content

Commit 13ccaa8

Browse files
Ellen Panalexdeucher
authored andcommitted
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 <yunru.pan@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 07009df commit 13ccaa8

3 files changed

Lines changed: 30 additions & 18 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,22 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev)
181181
u8 frev, crev;
182182
int usage_bytes = 0;
183183

184-
if (amdgpu_atom_parse_data_header(ctx, index, NULL, &frev, &crev, &data_offset)) {
185-
if (frev == 2 && crev == 1) {
186-
fw_usage_v2_1 =
187-
(struct vram_usagebyfirmware_v2_1 *)(ctx->bios + data_offset);
188-
amdgpu_atomfirmware_allocate_fb_v2_1(adev,
189-
fw_usage_v2_1,
190-
&usage_bytes);
191-
} else if (frev >= 2 && crev >= 2) {
192-
fw_usage_v2_2 =
193-
(struct vram_usagebyfirmware_v2_2 *)(ctx->bios + data_offset);
194-
amdgpu_atomfirmware_allocate_fb_v2_2(adev,
195-
fw_usage_v2_2,
196-
&usage_bytes);
184+
/* Skip atomfirmware allocation for SRIOV VFs when dynamic crit regn is enabled */
185+
if (!(amdgpu_sriov_vf(adev) && adev->virt.is_dynamic_crit_regn_enabled)) {
186+
if (amdgpu_atom_parse_data_header(ctx, index, NULL, &frev, &crev, &data_offset)) {
187+
if (frev == 2 && crev == 1) {
188+
fw_usage_v2_1 =
189+
(struct vram_usagebyfirmware_v2_1 *)(ctx->bios + data_offset);
190+
amdgpu_atomfirmware_allocate_fb_v2_1(adev,
191+
fw_usage_v2_1,
192+
&usage_bytes);
193+
} else if (frev >= 2 && crev >= 2) {
194+
fw_usage_v2_2 =
195+
(struct vram_usagebyfirmware_v2_2 *)(ctx->bios + data_offset);
196+
amdgpu_atomfirmware_allocate_fb_v2_2(adev,
197+
fw_usage_v2_2,
198+
&usage_bytes);
199+
}
197200
}
198201
}
199202

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,17 +1941,17 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
19411941
return r;
19421942

19431943
/*
1944-
*The reserved vram for driver must be pinned to the specified
1945-
*place on the VRAM, so reserve it early.
1944+
* The reserved VRAM for the driver must be pinned to a specific
1945+
* location in VRAM, so reserve it early.
19461946
*/
19471947
r = amdgpu_ttm_drv_reserve_vram_init(adev);
19481948
if (r)
19491949
return r;
19501950

19511951
/*
1952-
* only NAVI10 and onwards ASIC support for IP discovery.
1953-
* If IP discovery enabled, a block of memory should be
1954-
* reserved for IP discovey.
1952+
* only NAVI10 and later ASICs support IP discovery.
1953+
* If IP discovery is enabled, a block of memory should be
1954+
* reserved for it.
19551955
*/
19561956
if (adev->discovery.reserve_tmr) {
19571957
r = amdgpu_ttm_reserve_tmr(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,15 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev)
10081008
init_data_hdr->bad_page_size_in_kb;
10091009
}
10101010

1011+
/* reserved memory starts from crit region base offset with the size of 5MB */
1012+
adev->mman.fw_vram_usage_start_offset = adev->virt.crit_regn.offset;
1013+
adev->mman.fw_vram_usage_size = adev->virt.crit_regn.size_kb << 10;
1014+
dev_info(adev->dev,
1015+
"critical region v%d requested to reserve memory start at %08llx with %llu KB.\n",
1016+
init_data_hdr->version,
1017+
adev->mman.fw_vram_usage_start_offset,
1018+
adev->mman.fw_vram_usage_size >> 10);
1019+
10111020
adev->virt.is_dynamic_crit_regn_enabled = true;
10121021

10131022
out:

0 commit comments

Comments
 (0)