From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org, "Marek Olšák" <maraeo@gmail.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
pierre-eric.pelloux-prayer@amd.com,
"Natalie Vock" <nat@pixelcluster.dev>,
"Lijo Lazar" <lijo.lazar@amd.com>,
"Felix Kuehling" <Felix.Kuehling@amd.com>
Cc: "Timur Kristóf" <timur.kristof@gmail.com>
Subject: [PATCH 04/12] drm/amdgpu/sdma: Refactor CIK SDMA clock gating functions to be per-instance
Date: Mon, 7 Sep 2026 22:33:08 +0200 [thread overview]
Message-ID: <20260907203316.159103-5-timur.kristof@gmail.com> (raw)
In-Reply-To: <20260907203316.159103-1-timur.kristof@gmail.com>
Refactor clock gating functions to take the SDMA engine
instance ID as an argument and only affect one SDMA engine
instance at once.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 50 ++++++++++-----------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 78fea0621ed9..61ff76fb8fc2 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -854,51 +854,39 @@ static void cik_sdma_ring_emit_wreg(struct amdgpu_ring *ring,
}
static void cik_enable_sdma_mgcg(struct amdgpu_device *adev,
- bool enable)
+ const u32 instance_id,
+ const bool enable)
{
+ const u32 reg_offset = sdma_offsets[instance_id];
u32 orig, data;
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_MGCG)) {
- WREG32(mmSDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, 0x00000100);
- WREG32(mmSDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, 0x00000100);
+ WREG32(mmSDMA0_CLK_CTRL + reg_offset, 0x00000100);
} else {
- orig = data = RREG32(mmSDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET);
- data |= 0xff000000;
- if (data != orig)
- WREG32(mmSDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, data);
-
- orig = data = RREG32(mmSDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET);
+ orig = data = RREG32(mmSDMA0_CLK_CTRL + reg_offset);
data |= 0xff000000;
if (data != orig)
- WREG32(mmSDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, data);
+ WREG32(mmSDMA0_CLK_CTRL + reg_offset, data);
}
}
static void cik_enable_sdma_mgls(struct amdgpu_device *adev,
- bool enable)
+ const u32 instance_id,
+ const bool enable)
{
+ const u32 reg_offset = sdma_offsets[instance_id];
u32 orig, data;
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_LS)) {
- orig = data = RREG32(mmSDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET);
- data |= 0x100;
- if (orig != data)
- WREG32(mmSDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data);
-
- orig = data = RREG32(mmSDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET);
+ orig = data = RREG32(mmSDMA0_POWER_CNTL + reg_offset);
data |= 0x100;
if (orig != data)
- WREG32(mmSDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data);
+ WREG32(mmSDMA0_POWER_CNTL + reg_offset, data);
} else {
- orig = data = RREG32(mmSDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET);
+ orig = data = RREG32(mmSDMA0_POWER_CNTL + reg_offset);
data &= ~0x100;
if (orig != data)
- WREG32(mmSDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data);
-
- orig = data = RREG32(mmSDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET);
- data &= ~0x100;
- if (orig != data)
- WREG32(mmSDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data);
+ WREG32(mmSDMA0_POWER_CNTL + reg_offset, data);
}
}
@@ -1184,14 +1172,14 @@ static int cik_sdma_process_illegal_inst_irq(struct amdgpu_device *adev,
static int cik_sdma_set_clockgating_state(struct amdgpu_ip_block *ip_block,
enum amd_clockgating_state state)
{
- bool gate = false;
+ const bool gate = state == AMD_CG_STATE_GATE;
struct amdgpu_device *adev = ip_block->adev;
+ int i;
- if (state == AMD_CG_STATE_GATE)
- gate = true;
-
- cik_enable_sdma_mgcg(adev, gate);
- cik_enable_sdma_mgls(adev, gate);
+ for (i = 0; i < adev->sdma.num_instances; i++) {
+ cik_enable_sdma_mgcg(adev, i, gate);
+ cik_enable_sdma_mgls(adev, i, gate);
+ }
return 0;
}
--
2.55.0
next prev parent reply other threads:[~2026-09-07 20:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 20:33 [PATCH 00/12] RFC: drm/amdgpu/sdma: Refactor SDMA v4 and older functions to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 01/12] drm/amdgpu/sdma: Refactor SI DMA functions to be per instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 02/12] drm/amdgpu/sdma: Refactor SI DMA clock gating functions to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 03/12] drm/amdgpu/sdma: Refactor CIK SDMA functions to be per instance Timur Kristóf
2026-09-07 20:33 ` Timur Kristóf [this message]
2026-09-07 20:33 ` [PATCH 05/12] drm/amdgpu/sdma: Refactor SDMA v2.4 " Timur Kristóf
2026-09-07 20:33 ` [PATCH 06/12] drm/amdgpu/sdma: Refactor SDMA v2.4 golden registers to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 07/12] drm/amdgpu/sdma: Refactor SDMA v3.0 functions to be per instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 08/12] drm/amdgpu/sdma: Refactor SDMA v3.0 clock gating functions to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 09/12] drm/amdgpu/sdma: Refactor SDMA v3.0 golden registers " Timur Kristóf
2026-09-07 20:33 ` [PATCH 10/12] drm/amdgpu/sdma: Refactor SDMA v4.0 functions to be per instance Timur Kristóf
2026-09-08 7:41 ` Tvrtko Ursulin
2026-09-08 8:14 ` Timur Kristóf
2026-09-10 14:44 ` Tvrtko Ursulin
2026-09-07 20:33 ` [PATCH 11/12] drm/amdgpu/sdma: Refactor SDMA v4.0 clock gating functions to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 12/12] drm/amdgpu/sdma: Refactor SDMA v4.0 golden registers " Timur Kristóf
2026-09-11 19:00 ` [PATCH 00/12] RFC: drm/amdgpu/sdma: Refactor SDMA v4 and older functions " Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907203316.159103-5-timur.kristof@gmail.com \
--to=timur.kristof@gmail.com \
--cc=Felix.Kuehling@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=lijo.lazar@amd.com \
--cc=maraeo@gmail.com \
--cc=nat@pixelcluster.dev \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=tursulin@ursulin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.