drm/amdgpu: Derive RLC SPM xcc from GFXHUB
Subsystems (2)
PATCH 1/1 drm/amdgpu: Derive RLC SPM xcc from GFXHUB
RLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 31 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1 -1
@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_ring_emit_pipeline_sync (ring);if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +31 -0
@@ -27,6 +27,37 @@#include "amdgpu_gfx.h" #include "amdgpu_rlc.h" +/** +* amdgpu_gfx_rlc_update_spm - update RLC SPM VMID +* +* @adev: amdgpu_device pointer +* @ring: ring the VMID got assigned to +* @vmid: VMID to program +* +* RLC SPM counters are used only for GFX and GFX Cache subsystem. Only jobs submitted to +* rings in GFX subsystem need to update RLC SPM counters. Derive xcc_id from ring->vm_hub. +*/ +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid) +{ +int xcc_id, num_xcc; + +if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) +return ; + +if (!AMDGPU_IS_GFXHUB (ring->vm_hub)) +return ; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { +if (AMDGPU_GFXHUB (xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid (adev, xcc_id, ring, + vmid); +return ; + } + } +} +/** * amdgpu_gfx_rlc_enter_safe_mode - Set RLC into safe mode *
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +2 -0
@@ -370,6 +370,8 @@ struct amdgpu_rlc {struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES ]; }; +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid);void amdgpu_gfx_rlc_enter_safe_mode (struct amdgpu_device *adev,int xcc_id);void amdgpu_gfx_rlc_exit_safe_mode (struct amdgpu_device *adev,int xcc_id);int amdgpu_gfx_rlc_init_sr (struct amdgpu_device *adev,u32 dws);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid);if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,
Signature · 1 line
2.49.0
Quoted 6 lines · Lijo Lazar
RLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
I don't know the hardware well enough to review or be certain of what I will ask, but if you remember the "kitten dies" meme it often comes to my mind that "every time amdgpu repeatedly walks a list of everything to find something at runtime a kitten dies". :)
On a serious note, question I have following the statement from the commit message that xcc id is not always correct for all rings is, would it be feasible to make it correct? At ring init time I mean. And so avoid having to repeatedly look for it.
Regards,
Tvrtko
Quoted 89 lines
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 31 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-1@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_ring_emit_pipeline_sync (ring);if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +31
-0@@ -27,6 +27,37 @@#include "amdgpu_gfx.h" #include "amdgpu_rlc.h" +/** +* amdgpu_gfx_rlc_update_spm - update RLC SPM VMID +* +* @adev: amdgpu_device pointer +* @ring: ring the VMID got assigned to +* @vmid: VMID to program +* +* RLC SPM counters are used only for GFX and GFX Cache subsystem. Only jobs submitted to +* rings in GFX subsystem need to update RLC SPM counters. Derive xcc_id from ring->vm_hub. +*/ +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid) +{ +int xcc_id, num_xcc; + +if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) +return ; + +if (!AMDGPU_IS_GFXHUB (ring->vm_hub)) +return ; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { +if (AMDGPU_GFXHUB (xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid (adev, xcc_id, ring, + vmid); +return ; + } + } +} +/** * amdgpu_gfx_rlc_enter_safe_mode - Set RLC into safe mode * drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +2
-0@@ -370,6 +370,8 @@ struct amdgpu_rlc {struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES ]; }; +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid);void amdgpu_gfx_rlc_enter_safe_mode (struct amdgpu_device *adev,int xcc_id);void amdgpu_gfx_rlc_exit_safe_mode (struct amdgpu_device *adev,int xcc_id);int amdgpu_gfx_rlc_init_sr (struct amdgpu_device *adev,u32 dws);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid);if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,
Quoted 9 lines · Tvrtko Ursulin
Quoted 6 lines · Lijo Lazar
RLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
Quoted 4 lines
I don't know the hardware well enough to review or be certain of what I will ask, but if you remember the "kitten dies" meme it often comes to my mind that "every time amdgpu repeatedly walks a list of everything to find something at runtime a kitten dies". :)
On a serious note, question I have following the statement from the commit message that xcc id is not always correct for all rings is, would it be feasible to make it correct? At ring init time I mean. And so avoid having to repeatedly look for it.
Having to associate xcc_id with every ring (for ex: vcn/jpeg) is overloading it with too many things.
This is one of the changes in another set to remove xcc_id and keep a dedicated ip_inst. Then realized that a sdma job also could trigger a spm vmid update, then using ring->ip_inst doesn't work (even now, xcc id for sdma ring is not assigned properly).
That said, so far for gfxhub, xcc_id = ring->vmhub holds. The loop is only to appear it technically good. Also, max xcc = 8 (so far).
Thanks,
Lijo
Quoted 94 lines
Regards,
Tvrtko
Quoted 89 lines
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +-drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c| 31 +++++++++++++++++++++++++drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h| 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-4 files changed, 35 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-1@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring,struct amdgpu_job *job, amdgpu_ring_emit_pipeline_sync(ring); if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid(adev, ring->xcc_id, ring, job->vmid); + amdgpu_gfx_rlc_update_spm(adev, ring, job->vmid); if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +8
-0@@ -27,6 +27,37 @@ #include "amdgpu_gfx.h" #include "amdgpu_rlc.h" +/** +* amdgpu_gfx_rlc_update_spm - update RLC SPM VMID +* +* @adev: amdgpu_device pointer +* @ring: ring the VMID got assigned to +* @vmid: VMID to program +* +* RLC SPM counters are used only for GFX and GFX Cache subsystem. Only jobs submitted to
+ * rings in GFX subsystem need to update RLC SPM counters. Derivexcc_idfromring->vm_hub.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +21
-0+void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, + struct amdgpu_ring *ring, unsigned int vmid) +{ + int xcc_id, num_xcc; + + if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) + return; + + if (!AMDGPU_IS_GFXHUB(ring->vm_hub)) + return; + + num_xcc = NUM_XCC(adev->gfx.xcc_mask); + for (xcc_id = 0; xcc_id < num_xcc; xcc_id++) { + if (AMDGPU_GFXHUB(xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid(adev, xcc_id, ring, + vmid); + return; + } + } +} +/**
*amdgpu_gfx_rlc_enter_safe_mode- Set RLC into safe mode *drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +2
-0@@ -370,6 +370,8 @@ struct amdgpu_rlc { struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES]; }; +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, + struct amdgpu_ring *ring, unsigned int vmid); void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev, int xcc_id); void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev, int xcc_id); int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring,struct amdgpu_job *job, amdgpu_gmc_emit_pasid_mapping(ring, job->vmid, job->pasid); if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid(adev, ring->xcc_id, ring, job->vmid); + amdgpu_gfx_rlc_update_spm(adev, ring, job->vmid); if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,
Public
<Ping>
Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Friday, September 25, 2026 3:07 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhu, James <[email protected]>; Ma, Bing <[email protected]>
Subject: [PATCH] drm/amdgpu: Derive RLC SPM xcc from GFXHUB
RLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 31 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1 -1
@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_ring_emit_pipeline_sync (ring);if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
index 002fae3c380e..f791e1bcbf17 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +31 -0
@@ -27,6 +27,37 @@#include "amdgpu_gfx.h" #include "amdgpu_rlc.h" +/** +* amdgpu_gfx_rlc_update_spm - update RLC SPM VMID +* +* @adev: amdgpu_device pointer +* @ring: ring the VMID got assigned to +* @vmid: VMID to program +* +* RLC SPM counters are used only for GFX and GFX Cache subsystem. Only +jobs submitted to +* rings in GFX subsystem need to update RLC SPM counters. Derive xcc_id from ring->vm_hub. +*/ +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid) { +int xcc_id, num_xcc; + +if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) +return ; + +if (!AMDGPU_IS_GFXHUB (ring->vm_hub)) +return ; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { +if (AMDGPU_GFXHUB (xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid (adev, xcc_id, ring, + vmid); +return ; + } + } +} +/** * amdgpu_gfx_rlc_enter_safe_mode - Set RLC into safe mode *
drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +2 -0
@@ -370,6 +370,8 @@ struct amdgpu_rlc {struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES ]; }; +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid); void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev, int xcc_id); void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev, int xcc_id); int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 29a66e39f3d6..dc8f85176b8b 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid);if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,
--
2.49.0
<Ping + 1>
Quoted 97 lines · Lijo
<Ping>
Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Friday, September 25, 2026 3:07 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhu, James <[email protected]>; Ma, Bing <[email protected]>
Subject: [PATCH] drm/amdgpu: Derive RLC SPM xcc from GFXHUBRLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 31 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-1@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_ring_emit_pipeline_sync (ring);if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.cindex
002fae3c380e..f791e1bcbf17100644drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +31
-0@@ -27,6 +27,37 @@#include "amdgpu_gfx.h" #include "amdgpu_rlc.h" +/** +* amdgpu_gfx_rlc_update_spm - update RLC SPM VMID +* +* @adev: amdgpu_device pointer +* @ring: ring the VMID got assigned to +* @vmid: VMID to program +* +* RLC SPM counters are used only for GFX and GFX Cache subsystem. Only +jobs submitted to +* rings in GFX subsystem need to update RLC SPM counters. Derive xcc_id from ring->vm_hub. +*/ +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid) { +int xcc_id, num_xcc; + +if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) +return ; + +if (!AMDGPU_IS_GFXHUB (ring->vm_hub)) +return ; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { +if (AMDGPU_GFXHUB (xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid (adev, xcc_id, ring, + vmid); +return ; + } + } +} +/** * amdgpu_gfx_rlc_enter_safe_mode - Set RLC into safe mode * drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +2
-0@@ -370,6 +370,8 @@ struct amdgpu_rlc {struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES ]; }; +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, +struct amdgpu_ring *ring,unsigned int vmid); void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev, int xcc_id); void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev, int xcc_id); int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.cindex
29a66e39f3d6..dc8f85176b8b100644drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-2@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid);if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); +amdgpu_gfx_rlc_update_spm (adev, ring, job->vmid);if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, --2.49.0
Christian König
maintainerThe patch looks correct, but I've just reviewed the patch from Sunil to completely remove this code.
So I'm pretty sure we don't need this change any more.
Regards,
Christian.
Quoted 95 lines · Lijo
<Ping + 1>
Quoted 91 lines · Lijo
<Ping>
Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Friday, September 25, 2026 3:07 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhu, James <[email protected]>; Ma, Bing <[email protected]>
Subject: [PATCH] drm/amdgpu: Derive RLC SPM xcc from GFXHUBRLC SPM is updated for GFX subsystem related performance counters. Only jobs on rings that use GFX subsystem need to be updated. Some rings like SDMA could be inside/outside of GFX subsytem based on SOC. Identify the rings using GFXHUB assignment and use hub id assigned to find the right GC rather than relying on xcc id. xcc id may not be necessarily assigned properly for all rings.
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +-drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c| 31 +++++++++++++++++++++++++drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h| 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-4 files changed, 35 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-1@@ -212,7 +212,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job, amdgpu_ring_emit_pipeline_sync(ring); if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid(adev, ring->xcc_id, ring, job->vmid); + amdgpu_gfx_rlc_update_spm(adev, ring, job->vmid); if (emit_gds_needed)amdgpu_ring_emit_gds_switch(ring,
job->vmid,job->gds_base, diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.cindex002fae3c380e..f791e1bcbf17100644drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +0
-0@@ -27,6 +27,37 @@ #include "amdgpu_gfx.h" #include "amdgpu_rlc.h"+/**
+ *amdgpu_gfx_rlc_update_spm- update RLC SPM VMID
+ *
+ * @adev:amdgpu_devicepointer
+ * @ring: ring the VMID got assigned to
+ * @vmid: VMID to program
+ *
+ * RLC SPM counters are used only for GFX and GFX Cache subsystem. Onlydrivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c +23
-0+jobs submitted to +* rings in GFX subsystem need to update RLC SPM counters. Derive xcc_id from ring->vm_hub. +*/ +void amdgpu_gfx_rlc_update_spm (struct amdgpu_device *adev, + struct amdgpu_ring *ring, unsigned int vmid) { + int xcc_id, num_xcc; + + if (!adev->gfx.rlc.funcs->update_spm_vmid || !ring) + return; + + if (!AMDGPU_IS_GFXHUB(ring->vm_hub)) + return; + + num_xcc = NUM_XCC(adev->gfx.xcc_mask); + for (xcc_id = 0; xcc_id < num_xcc; xcc_id++) { + if (AMDGPU_GFXHUB(xcc_id) == ring->vm_hub) { + adev->gfx.rlc.funcs->update_spm_vmid(adev, xcc_id, ring, + vmid); + return; + } + } +} +/**
*amdgpu_gfx_rlc_enter_safe_mode- Set RLC into safe mode *drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h +1
-0@@ -370,6 +370,8 @@ struct amdgpu_rlc { struct amdgpu_rlcg_reg_access_ctrl reg_access_ctrl[AMDGPU_MAX_RLC_INSTANCES]; }; +void amdgpu_gfx_rlc_update_spm(struct amdgpu_device *adev, + struct amdgpu_ring *ring, unsigned int vmid);void
amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev, int xcc_id); voidamdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev, int xcc_id); intamdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws); diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.cindex29a66e39f3d6..dc8f85176b8b100644drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -865,7 +865,7 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, amdgpu_gmc_emit_pasid_mapping(ring, job->vmid, job->pasid); if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid(adev, ring->xcc_id, ring, job->vmid); + amdgpu_gfx_rlc_update_spm(adev, ring, job->vmid); if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base,Signature · 1 line
2.49.0