On partitioned devices every partition is exposed as an own render
node and fpriv->xcp_id records which partition a drm file belongs to.
But AMDGPU_VM_OP_RESERVE_VMID reserves the VMID on every GFXHUB of the
device: a reservation made on one partition's render node blocks every
other partition from reserving, and rebinds the VMID's page table base
on XCCs the caller can't even submit to.

Derive the GFXHUB set from the caller's partition instead. The
reservation then only covers the XCCs of the caller's partition, and
each partition can hold the reserved VMID on its own hubs
independently, matching the isolation the render nodes promise.
Unreserve keeps operating on every hub, freeing whatever the VM
actually holds.

Without partitioning, or on the whole-device node, the mask stays the
full set of XCCs and nothing changes.

Signed-off-by: James Zhu <[email protected]>
Assisted-by: Claude:claude-fable-5
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index e81fbe32e3c8..131bafb5530f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3035,6 +3035,20 @@ int amdgpu_vm_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
                uint32_t gfxhub_mask = amdgpu_gfx_logical_xcc_mask(adev);
                int r;
 
+               /*
+                * Scope the reservation to the hardware partition behind the
+                * caller's render node, so other partitions can hold the
+                * reserved VMID on their own XCCs independently. The
+                * partition's inst_mask is logical like the GFXHUB indices.
+                */
+               if (adev->xcp_mgr && fpriv->xcp_id != AMDGPU_XCP_NO_PARTITION) {
+                       r = amdgpu_xcp_get_inst_details(
+                                       &adev->xcp_mgr->xcp[fpriv->xcp_id],
+                                       AMDGPU_XCP_GFX, &gfxhub_mask);
+                       if (r)
+                               return r;
+               }
+
                /*
                 * The root PD reservation serializes the per-VM reservation
                 * state and keeps new jobs of this VM from grabbing a freshly
-- 
2.34.1

Reply via email to