From: Will Aitken <[email protected]>

In sriov, fb-sharing can be disabled via the xgmi ta. For this scenario,
hive_id alone is insufficient for determining peer accessibility.
fb-sharing enable flag needs to be checked as well.

v2: Move fb-sharing gate to amdgpu_xgmi_same_hive from
amdgpu_dmabuf_is_xgmi_accessible. All xgmi connectivity checks need it.

Signed-off-by: Will Aitken <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 45e31b3daf06..ccd6429ad7b2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -349,6 +349,9 @@ int amdgpu_get_xgmi_link_status(struct amdgpu_device *adev, 
int global_link_num)
  * The XGMI memory space is built by contiguously adding the power of
  * two padded VRAM space from each node to each other.
  *
+ * Note that even if multiple GPUs have the same hive ID, sharing between their
+ * memory spaces via XGMI links can be disabled in firmware, i.e. hive
+ * membership does not guarantee connectivity.
  */
 
 static struct attribute amdgpu_xgmi_hive_id = {
@@ -1484,7 +1487,8 @@ bool amdgpu_xgmi_same_hive(struct amdgpu_device *adev,
 {
        return (amdgpu_use_xgmi_p2p && adev != bo_adev &&
                adev->gmc.xgmi.hive_id &&
-               adev->gmc.xgmi.hive_id == bo_adev->gmc.xgmi.hive_id);
+               adev->gmc.xgmi.hive_id == bo_adev->gmc.xgmi.hive_id &&
+               amdgpu_xgmi_get_is_sharing_enabled(adev, bo_adev));
 }
 
 void amdgpu_xgmi_early_init(struct amdgpu_device *adev)
-- 
2.43.0

Reply via email to