drm/amdgpu: fallback to default discovery offset/size in sriov guest
Subsystems (2)
PATCH 1/1 drm/amdgpu: fallback to default discovery offset/size in sriov guest
In SRIOV guest environment, if dynamic critical region is not enabled, fallback to default discovery offset and size to ensure proper initialization
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +12 -8
@@ -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 ;
Signature · 1 line
2.17.1
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Likun
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Friday, March 13, 2026 9:39 PM
To: [email protected]; Gao, Likun <[email protected]>; Xu, Feifei <[email protected]>
Cc: Zhang, Hawking <[email protected]>
Subject: [PATCH] drm/amdgpu: fallback to default discovery offset/size in sriov guest
In SRIOV guest environment, if dynamic critical region is not enabled, fallback to default discovery offset and size to ensure proper initialization
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +12 -8
@@ -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 ;
--
2.17.1