From: Hawking Zhang <[email protected]>

To enable querying the total number of xccs in the xcp

Signed-off-by: Hawking Zhang <[email protected]>
Reviewed-by: Likun Gao <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h |  1 +
 drivers/gpu/drm/amd/amdgpu/imu_v12_1.c  | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h
index 484e936812e45..932976b6f391d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h
@@ -36,6 +36,7 @@ struct amdgpu_imu_funcs {
     int (*start_imu)(struct amdgpu_device *adev);
     void (*program_rlc_ram)(struct amdgpu_device *adev);
     int (*wait_for_reset_status)(struct amdgpu_device *adev);
+    int (*get_xccs_per_xcp)(struct amdgpu_device *adev);
 };
 
 struct imu_rlc_ram_golden {
diff --git a/drivers/gpu/drm/amd/amdgpu/imu_v12_1.c 
b/drivers/gpu/drm/amd/amdgpu/imu_v12_1.c
index 28932604d986d..13108fd4584c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/imu_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/imu_v12_1.c
@@ -133,7 +133,18 @@ static int imu_v12_1_load_microcode(struct amdgpu_device 
*adev)
        return 0;
 }
 
+static int imu_v12_1_get_xccs_per_xcp(struct amdgpu_device *adev)
+{
+       u32 reg_data;
+
+       /* the register data is expected to be the same on all instances */
+       reg_data = RREG32_SOC15(GC, GET_INST(GC, 0), 
regGFX_IMU_PARTITION_SWITCH);
+
+       return REG_GET_FIELD(reg_data, GFX_IMU_PARTITION_SWITCH, 
TOTAL_XCCS_IN_XCP);
+}
+
 const struct amdgpu_imu_funcs gfx_v12_1_imu_funcs = {
        .init_microcode = imu_v12_1_init_microcode,
        .load_microcode = imu_v12_1_load_microcode,
+       .get_xccs_per_xcp = imu_v12_1_get_xccs_per_xcp,
 };
-- 
2.51.1

Reply via email to