Skip to contentSkip to conversation

drm/amdgpu: Ensure fb-sharing is enabled for xgmi same hive check

PATCH In review [email protected] 2 participants 2 messages Oct 13 – Oct 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: Ensure fb-sharing is enabled for xgmi same hive check

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +5 -1
index 45e31b3daf06..ccd6429ad7b2 100644
@@ -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)
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · On Tue, Oct 13, 2026 at 2:01 PM <[email protected]> wrote:

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.

Quoted 31 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +5 -2
index 45e31b3daf06..ccd6429ad7b2 100644
@@ -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