]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: fallback to default discovery offset/size in sriov guest
authorHawking Zhang <Hawking.Zhang@amd.com>
Fri, 13 Mar 2026 13:32:03 +0000 (21:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 14:42:22 +0000 (10:42 -0400)
In SRIOV guest environment, if dynamic critical region
is not enabled, fallback to default discovery offset
and size to ensure proper initialization

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Likun Gao <Likun.Gao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

index 4209945af66f19a70572a22b1c4992fd634ffb56..037c7990e69599f964229f450fce35eb21784f98 100644 (file)
@@ -296,13 +296,17 @@ static int amdgpu_discovery_get_tmr_info(struct amdgpu_device *adev,
        if (vram_size)
                adev->discovery.offset = (vram_size << 20) - DISCOVERY_TMR_OFFSET;
 
-       if (amdgpu_sriov_vf(adev) && adev->virt.is_dynamic_crit_regn_enabled) {
-               adev->discovery.offset =
-                       adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].offset;
-               adev->discovery.size =
-                       adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb << 10;
-               if (!adev->discovery.offset || !adev->discovery.size)
-                       return -EINVAL;
+       if (amdgpu_sriov_vf(adev)) {
+               if (adev->virt.is_dynamic_crit_regn_enabled) {
+                       adev->discovery.offset =
+                               adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].offset;
+                       adev->discovery.size =
+                               adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb << 10;
+                       if (!adev->discovery.offset || !adev->discovery.size)
+                               return -EINVAL;
+               } else {
+                       goto out;
+               }
        } else {
                tmr_size = RREG32(mmDRIVER_SCRATCH_2);
                if (tmr_size) {
@@ -322,7 +326,7 @@ static int amdgpu_discovery_get_tmr_info(struct amdgpu_device *adev,
                        adev->discovery.offset = tmr_offset + tmr_size - DISCOVERY_TMR_OFFSET;
                }
        }
-
+out:
        adev->discovery.bin = kzalloc(adev->discovery.size, GFP_KERNEL);
        if (!adev->discovery.bin)
                return -ENOMEM;