]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/ras: Handle check address validity in SR-IOV
authorJinzhou Su <jinzhou.su@amd.com>
Tue, 10 Feb 2026 06:49:35 +0000 (14:49 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 25 Feb 2026 21:56:33 +0000 (16:56 -0500)
Handle check address validity command in SR-IOV
guest.

Signed-off-by: Jinzhou Su <jinzhou.su@amd.com>
Reviewed-by: YiPeng Chai <YiPeng.Chai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

index c0336ca9bf6a8eabd397f66d8812cd650719969d..45d601b27c3aadf3ce13e7661a23c4f40c2fc64d 100644 (file)
@@ -42,6 +42,7 @@
 #include "amdgpu_reset.h"
 #include "amdgpu_psp.h"
 #include "amdgpu_ras_mgr.h"
+#include "amdgpu_virt_ras_cmd.h"
 
 #ifdef CONFIG_X86_MCE_AMD
 #include <asm/mce.h>
@@ -228,19 +229,30 @@ static int amdgpu_check_address_validity(struct amdgpu_device *adev,
                return 0;
 
        if (amdgpu_sriov_vf(adev)) {
-               if (amdgpu_virt_check_vf_critical_region(adev, address, &hit))
-                       return -EPERM;
-               return hit ? -EACCES : 0;
+               if (amdgpu_uniras_enabled(adev)) {
+                       if (amdgpu_virt_ras_check_address_validity(adev, address, &hit))
+                               return -EPERM;
+                       if (hit)
+                               return -EACCES;
+               } else {
+                       if (amdgpu_virt_check_vf_critical_region(adev, address, &hit))
+                               return -EPERM;
+                       return hit ? -EACCES : 0;
+               }
        }
 
        if ((address >= adev->gmc.mc_vram_size) ||
            (address >= RAS_UMC_INJECT_ADDR_LIMIT))
                return -EFAULT;
 
-       if (amdgpu_uniras_enabled(adev))
-               count = amdgpu_ras_mgr_lookup_bad_pages_in_a_row(adev, address,
-                       page_pfns, ARRAY_SIZE(page_pfns));
-       else
+       if (amdgpu_uniras_enabled(adev)) {
+               if (amdgpu_sriov_vf(adev))
+                       count = amdgpu_virt_ras_convert_retired_address(adev, address,
+                               page_pfns, ARRAY_SIZE(page_pfns));
+               else
+                       count = amdgpu_ras_mgr_lookup_bad_pages_in_a_row(adev, address,
+                               page_pfns, ARRAY_SIZE(page_pfns));
+       } else
                count = amdgpu_umc_lookup_bad_pages_in_a_row(adev,
                                address, page_pfns, ARRAY_SIZE(page_pfns));