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 3/5] drm/amd/pm/smu7: Notify SMU7 of DC->AC switch
Date: Tue, 19 May 2026 10:41:56 +0200 [thread overview]
Message-ID: <20260519084158.72960-4-timur.kristof@gmail.com> (raw)
In-Reply-To: <20260519084158.72960-1-timur.kristof@gmail.com>
When ATOM_PP_PLATFORM_CAP_HARDWAREDC is set,
the SMU has a GPIO pin for detecting AC/DC switch
and everything works automatically.
Otherwise when there is no GPIO pin, the SMU can
automatically detect switching to DC, but needs
to be notified of switching to AC.
Use PPSMC_MSG_RunningOnAC to notify the SMC
when switching to AC.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
---
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 12 ++++++++++++
.../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 15 +++++++++++++++
drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 0bbb89788335..19e74baa2b85 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
@@ -1550,6 +1550,17 @@ static void pp_pm_compute_clocks(void *handle)
NULL);
}
+static void pp_dpm_notify_ac_dc(void *handle)
+{
+ struct pp_hwmgr *hwmgr = handle;
+
+ if (!hwmgr || !hwmgr->pm_en)
+ return;
+
+ if (hwmgr->hwmgr_func->notify_ac_dc)
+ hwmgr->hwmgr_func->notify_ac_dc(hwmgr);
+}
+
static const struct amd_pm_funcs pp_dpm_funcs = {
.load_firmware = pp_dpm_load_fw,
.wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1615,4 +1626,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.gfx_state_change_set = pp_gfx_state_change_set,
.get_smu_prv_buf_details = pp_get_prv_buffer_details,
.pm_compute_clocks = pp_pm_compute_clocks,
+ .notify_ac_dc = pp_dpm_notify_ac_dc,
};
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
index 4436ab2bb51f..416b9380a70e 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -5854,6 +5854,20 @@ static int smu7_power_off_asic(struct pp_hwmgr *hwmgr)
return result;
}
+static void smu7_notify_ac_dc(struct pp_hwmgr *hwmgr)
+{
+ struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+
+ /* Check if the platform already manages the AC/DC switch via dedicated GPIO. */
+ if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
+ PHM_PlatformCaps_AutomaticDCTransition))
+ return;
+
+ /* The SMU automatically notices DC, but needs to be notified when switching to AC. */
+ if (adev->pm.ac_power)
+ smum_send_msg_to_smc(hwmgr, PPSMC_MSG_RunningOnAC, NULL);
+}
+
static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
.backend_init = &smu7_hwmgr_backend_init,
.backend_fini = &smu7_hwmgr_backend_fini,
@@ -5916,6 +5930,7 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
.get_asic_baco_state = smu7_baco_get_state,
.set_asic_baco_state = smu7_baco_set_state,
.power_off_asic = smu7_power_off_asic,
+ .notify_ac_dc = smu7_notify_ac_dc,
};
uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock,
diff --git a/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
index 3ae45eac0c5c..84de2ccad7a3 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
@@ -364,6 +364,7 @@ struct pp_hwmgr_func {
bool disable);
ssize_t (*get_gpu_metrics)(struct pp_hwmgr *hwmgr, void **table);
int (*gfx_state_change)(struct pp_hwmgr *hwmgr, uint32_t state);
+ void (*notify_ac_dc)(struct pp_hwmgr *hwmgr);
};
struct pp_table_func {
--
2.54.0
next prev 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 ` Timur Kristóf [this message]
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 ` [PATCH 5/5] drm/amd/pm/si: Notify the SMC when switching to AC Timur Kristóf
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-4-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 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.