AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	christian.koenig@amd.com, Natalie Vock <natalie.vock@gmx.de>,
	Jeremy Klarenbeek <jeremy.klarenbeek99@gmail.com>
Cc: "Timur Kristóf" <timur.kristof@gmail.com>
Subject: [PATCH 5/5] drm/amd/pm/si: Notify the SMC when switching to AC
Date: Tue, 19 May 2026 10:41:58 +0200	[thread overview]
Message-ID: <20260519084158.72960-6-timur.kristof@gmail.com> (raw)
In-Reply-To: <20260519084158.72960-1-timur.kristof@gmail.com>

From: Jeremy Klarenbeek <jeremy.klarenbeek99@gmail.com>

There are some platforms that don't have a dedicated
GPIO line to manage the AC/DC switch. In this case,
the SI SMC automatically notices when switching to DC,
but needs to be notified when switching to AC.

Fixup and use si_notify_hw_of_powersource() which was
previously hidden behind an "#if 0".

This fixes some SI laptop GPUs to be able to use their
performance power states after switching from DC to AC.

Some affected GPUs are:
FirePro W4170M - Dell Precision M2800
Radeon HD 8790M - Dell Latitude E6540

Co-developed-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Jeremy Klarenbeek <jeremy.klarenbeek99@gmail.com>
---
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index 04f3ba5f8f46..832953941266 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -3888,16 +3888,18 @@ static void si_notify_hardware_vpu_recovery_event(struct amdgpu_device *adev)
 }
 #endif
 
-#if 0
-static int si_notify_hw_of_powersource(struct amdgpu_device *adev, bool ac_power)
+static void si_notify_hw_of_powersource(void *handle)
 {
-	if (ac_power)
-		return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
-			0 : -EINVAL;
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-	return 0;
+	/* Check if the platform already manages the AC/DC switch via dedicated GPIO. */
+	if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
+		return;
+
+	/* The SMU automatically notices DC, but needs to be notified when switching to AC. */
+	if (adev->pm.ac_power)
+		amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC);
 }
-#endif
 
 static PPSMC_Result si_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
 						      PPSMC_Msg msg, u32 parameter)
@@ -8166,6 +8168,7 @@ static const struct amd_pm_funcs si_dpm_funcs = {
 	.get_vce_clock_state = amdgpu_get_vce_clock_state,
 	.read_sensor = &si_dpm_read_sensor,
 	.pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks,
+	.notify_ac_dc = si_notify_hw_of_powersource,
 };
 
 static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
-- 
2.54.0


  parent reply	other threads:[~2026-05-19  8:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  8:41 [PATCH 0/5] drm/amd/pm: Fix laptop issues on SMU6-7 Timur Kristóf
2026-05-19  8:41 ` [PATCH 1/5] drm/amd/pm/si: Disregard vblank time when no displays are connected Timur Kristóf
2026-05-19 15:09   ` Alex Deucher
2026-05-19  8:41 ` [PATCH 2/5] drm/amd/pm: Rename enable_bapm() to notify_ac_dc() Timur Kristóf
2026-05-19  8:41 ` [PATCH 3/5] drm/amd/pm/smu7: Notify SMU7 of DC->AC switch Timur Kristóf
2026-05-19  8:41 ` [PATCH 4/5] drm/amd/pm/si: Fix updating clock limits from power states Timur Kristóf
2026-05-19  8:41 ` Timur Kristóf [this message]
2026-05-21  0:52 ` [PATCH 0/5] drm/amd/pm: Fix laptop issues on SMU6-7 Jeremy Klarenbeek
2026-05-24  6:38 ` Jeremy Klarenbeek
2026-05-24 11:32   ` Timur Kristóf
2026-05-29 20:33     ` Deucher, Alexander
2026-05-30 10:07       ` Jeremy Klarenbeek
2026-05-30 10:32         ` Timur Kristóf
2026-05-30 12:51           ` Jeremy Klarenbeek

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=20260519084158.72960-6-timur.kristof@gmail.com \
    --to=timur.kristof@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=jeremy.klarenbeek99@gmail.com \
    --cc=natalie.vock@gmx.de \
    /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