]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amdgpu: Assign unique id to compute partition
authorLijo Lazar <lijo.lazar@amd.com>
Mon, 4 Aug 2025 08:23:21 +0000 (13:53 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Aug 2025 18:34:47 +0000 (14:34 -0400)
Assign unique id to compute partition. This is the unique id of the
first XCD instance belonging to the partition.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h

index 699acc1b46b59a7bbc0581d2da885b4d4309545f..1083db8cea2ebda59a95f9ff05dbc9442b526e49 100644 (file)
@@ -120,6 +120,25 @@ static void __amdgpu_xcp_add_block(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id,
        xcp->valid = true;
 }
 
+static void __amdgpu_xcp_set_unique_id(struct amdgpu_xcp_mgr *xcp_mgr,
+                                      int xcp_id)
+{
+       struct amdgpu_xcp *xcp = &xcp_mgr->xcp[xcp_id];
+       struct amdgpu_device *adev = xcp_mgr->adev;
+       uint32_t inst_mask;
+       uint64_t uid;
+       int i;
+
+       if (!amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX, &inst_mask) &&
+           inst_mask) {
+               i = GET_INST(GC, (ffs(inst_mask) - 1));
+               uid = amdgpu_device_get_uid(xcp_mgr->adev->uid_info,
+                                           AMDGPU_UID_TYPE_XCD, i);
+               if (uid)
+                       xcp->unique_id = uid;
+       }
+}
+
 int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
 {
        struct amdgpu_device *adev = xcp_mgr->adev;
@@ -158,6 +177,7 @@ int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
                        else
                                xcp_mgr->xcp[i].mem_id = mem_id;
                }
+               __amdgpu_xcp_set_unique_id(xcp_mgr, i);
        }
 
        xcp_mgr->num_xcps = num_xcps;
index 70a0f8400b5783ee551c05e8432f2440b0c43eec..1928d9e224fcabde733a0cd0914d03f00599eb40 100644 (file)
@@ -112,6 +112,7 @@ struct amdgpu_xcp {
        struct amdgpu_sched     gpu_sched[AMDGPU_HW_IP_NUM][AMDGPU_RING_PRIO_MAX];
        struct amdgpu_xcp_mgr *xcp_mgr;
        struct kobject kobj;
+       uint64_t unique_id;
 };
 
 struct amdgpu_xcp_mgr {