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 02/12] drm/amdgpu/sdma: Refactor SI DMA clock gating functions to be per-instance
Date: Mon, 7 Sep 2026 22:33:06 +0200 [thread overview]
Message-ID: <20260907203316.159103-3-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/si_dma.c | 63 +++++++++++++----------------
1 file changed, 29 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c
index 483a0cfb7c8f..fa67415acbc4 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dma.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c
@@ -654,45 +654,40 @@ static int si_dma_process_trap_irq(struct amdgpu_device *adev,
return 0;
}
-static int si_dma_set_clockgating_state(struct amdgpu_ip_block *ip_block,
- enum amd_clockgating_state state)
+static void si_dma_enable_mgcg(struct amdgpu_device *adev,
+ const u32 instance_id,
+ const bool enable)
{
- u32 orig, data, offset;
- int i;
- bool enable;
- struct amdgpu_device *adev = ip_block->adev;
-
- enable = (state == AMD_CG_STATE_GATE);
+ const u32 reg_offset = sdma_offsets[instance_id];
+ u32 orig, data;
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_MGCG)) {
- for (i = 0; i < adev->sdma.num_instances; i++) {
- if (i == 0)
- offset = DMA0_REGISTER_OFFSET;
- else
- offset = DMA1_REGISTER_OFFSET;
- orig = data = RREG32(mmDMA_POWER_CNTL + offset);
- data &= ~DMA_POWER_CNTL__MEM_POWER_OVERRIDE_MASK;
- if (data != orig)
- WREG32(mmDMA_POWER_CNTL + offset, data);
- WREG32(mmDMA_CLK_CTRL + offset, 0x00000100);
- }
+ orig = data = RREG32(mmDMA_POWER_CNTL + reg_offset);
+ data &= ~DMA_POWER_CNTL__MEM_POWER_OVERRIDE_MASK;
+ if (data != orig)
+ WREG32(mmDMA_POWER_CNTL + reg_offset, data);
+ WREG32(mmDMA_CLK_CTRL + reg_offset, 0x00000100);
} else {
- for (i = 0; i < adev->sdma.num_instances; i++) {
- if (i == 0)
- offset = DMA0_REGISTER_OFFSET;
- else
- offset = DMA1_REGISTER_OFFSET;
- orig = data = RREG32(mmDMA_POWER_CNTL + offset);
- data |= DMA_POWER_CNTL__MEM_POWER_OVERRIDE_MASK;
- if (data != orig)
- WREG32(mmDMA_POWER_CNTL + offset, data);
-
- orig = data = RREG32(mmDMA_CLK_CTRL + offset);
- data = 0xff000000;
- if (data != orig)
- WREG32(mmDMA_CLK_CTRL + offset, data);
- }
+ orig = data = RREG32(mmDMA_POWER_CNTL + reg_offset);
+ data |= DMA_POWER_CNTL__MEM_POWER_OVERRIDE_MASK;
+ if (data != orig)
+ WREG32(mmDMA_POWER_CNTL + reg_offset, data);
+
+ orig = data = RREG32(mmDMA_CLK_CTRL + reg_offset);
+ data = 0xff000000;
+ if (data != orig)
+ WREG32(mmDMA_CLK_CTRL + reg_offset, data);
}
+}
+
+static int si_dma_set_clockgating_state(struct amdgpu_ip_block *const ip_block,
+ const enum amd_clockgating_state state)
+{
+ struct amdgpu_device *const adev = ip_block->adev;
+ int i;
+
+ for (i = 0; i < adev->sdma.num_instances; i++)
+ si_dma_enable_mgcg(adev, i, state == AMD_CG_STATE_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 ` Timur Kristóf [this message]
2026-09-07 20:33 ` [PATCH 03/12] drm/amdgpu/sdma: Refactor CIK SDMA " Timur Kristóf
2026-09-07 20:33 ` [PATCH 04/12] drm/amdgpu/sdma: Refactor CIK SDMA clock gating functions to be per-instance Timur Kristóf
2026-09-07 20:33 ` [PATCH 05/12] drm/amdgpu/sdma: Refactor SDMA v2.4 functions to be per instance 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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox