[AMD Official Use Only - AMD Internal Distribution Only]

The series is:  Reviewed-by: YiPeng Chai <[email protected]>

Best Regards,
Thomas
-----Original Message-----
From: Su, Joe <[email protected]>
Sent: Tuesday, February 10, 2026 5:53 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Yang, Stanley 
<[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao 
<[email protected]>; Su, Joe <[email protected]>
Subject: [PATCH 5/5] drm/amd/ras: Handle check address validity in SR-IOV

Handle check address validity command in SR-IOV guest.

Signed-off-by: Jinzhou Su <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 26 ++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 4c890cfea1cc..ff759f6425fc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -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));

--
2.43.0

Reply via email to