Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ellen Pan and committed by
Alex Deucher
13ccaa84 07009df6

+30 -18
+16 -13
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
··· 181 181 u8 frev, crev; 182 182 int usage_bytes = 0; 183 183 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 + } 197 200 } 198 201 } 199 202
+5 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 1941 1941 return r; 1942 1942 1943 1943 /* 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. 1946 1946 */ 1947 1947 r = amdgpu_ttm_drv_reserve_vram_init(adev); 1948 1948 if (r) 1949 1949 return r; 1950 1950 1951 1951 /* 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. 1955 1955 */ 1956 1956 if (adev->discovery.reserve_tmr) { 1957 1957 r = amdgpu_ttm_reserve_tmr(adev);
+9
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
··· 1008 1008 init_data_hdr->bad_page_size_in_kb; 1009 1009 } 1010 1010 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 + 1011 1020 adev->virt.is_dynamic_crit_regn_enabled = true; 1012 1021 1013 1022 out: