Skip to contentSkip to conversation

drm/amd/pm: Implement notify_ac_dc callback for swsmu

PATCH In review Lijo Lazar 2 participants 3 messages Aug 4 – Aug 5

Subsystems (3)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/2 drm/amd/pm: Implement notify_ac_dc callback for swsmu

Wire up the notify_ac_dc pp_funcs callback for swsmu instead of special-casing is_support_sw_smu in the ACPI event handler. This keeps AC/DC transition notification through the same callback path as used by legacy powerplay and legacy-dpm backends.

---
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 ---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 10 +++++++++-
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  2 --
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -3
index ce526db4d24a..107448fbda46 100644
@@ -507,9 +507,6 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 		    adev->powerplay.pp_funcs->notify_ac_dc)
 			amdgpu_dpm_notify_ac_dc(adev);
 
-		if (is_support_sw_smu(adev))
-			smu_set_ac_dc(adev->powerplay.pp_handle, true);
-
 		mutex_unlock(&adev->pm.mutex);
 	}
 }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9 -1
index cca32f74abf0..84ac824837ac 100644
@@ -2774,7 +2774,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle,
 	return smu_set_watermarks_table(smu, clock_ranges);
 }
 
-int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
+static int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
 {
 	int ret = 0;
 
@@ -2800,6 +2800,13 @@ int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
 	return 0;
 }
 
+static void smu_notify_ac_dc(void *handle)
+{
+	struct smu_context *smu = handle;
+
+	smu_set_ac_dc(smu, true);
+}
+
 const struct amd_ip_funcs smu_ip_funcs = {
 	.name = "smu",
 	.early_init = smu_early_init,
@@ -4000,6 +4007,7 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
 	.set_pp_table            = smu_sys_set_pp_table,
 	.switch_power_profile    = smu_switch_power_profile,
 	.pause_power_profile     = smu_pause_power_profile,
+	.notify_ac_dc            = smu_notify_ac_dc,
 	/* export to amdgpu */
 	.dispatch_tasks          = smu_handle_dpm_task,
 	.load_firmware           = smu_load_microcode,
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -2
index 3ec65630ab99..92658eb3886d 100644
@@ -1952,8 +1952,6 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_type
 
 int smu_set_gfx_power_up_by_imu(struct smu_context *smu);
 
-int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy);
-
 int smu_set_xgmi_plpd_mode(struct smu_context *smu,
 			   enum pp_xgmi_plpd_mode mode);
 
Signature · 1 line
2.49.0
author
#1 lore raw

PATCH 2/2 drm/amd/pm: Separate PPT limit restore from smu_set_ac_dc

Move the PPT limit restore out of smu_set_ac_dc. Keep smu_set_ac_dc only for switching the power source. Drop the restore ppt limit policy parameter and add the restore logic to ac/dc notification path.

---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +6 -6
index 84ac824837ac..bcb74bb2bd60 100644
@@ -960,7 +960,7 @@ static int smu_late_init(struct amdgpu_ip_block *ip_block)
 	 * is unnecessary.
 	 */
 	adev->pm.ac_power = power_supply_is_system_supplied() > 0;
-	smu_set_ac_dc(smu, false);
+	smu_set_ac_dc(smu);
 
 	if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 1)) ||
 	    (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 3)))
@@ -2774,7 +2774,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle,
 	return smu_set_watermarks_table(smu, clock_ranges);
 }
 
-static int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
+static int smu_set_ac_dc(struct smu_context *smu)
 {
 	int ret = 0;
 
@@ -2794,9 +2794,6 @@ static int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
 		}
 	}
 
-	if (restore_ppt_policy)
-		smu_restore_ppt_limits(smu, true);
-
 	return 0;
 }
 
@@ -2804,7 +2801,10 @@ static void smu_notify_ac_dc(void *handle)
 {
 	struct smu_context *smu = handle;
 
-	smu_set_ac_dc(smu, true);
+	if (smu_set_ac_dc(smu))
+		return;
+
+	smu_restore_ppt_limits(smu, true);
 }
 
 const struct amd_ip_funcs smu_ip_funcs = {
Signature · 1 line
2.49.0
Reviewed-by on v1 1/2
#2 lore raw
In reply to Lijo Lazar

AMD General

Series is

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, August 4, 2026 5:00 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH 1/2] drm/amd/pm: Implement notify_ac_dc callback for swsmu

Wire up the notify_ac_dc pp_funcs callback for swsmu instead of special-casing is_support_sw_smu in the ACPI event handler. This keeps AC/DC transition notification through the same callback path as used by legacy powerplay and legacy-dpm backends.

---
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  3 ---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 10 +++++++++-
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  2 --
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -3
index ce526db4d24a..107448fbda46 100644
@@ -507,9 +507,6 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
                    adev->powerplay.pp_funcs->notify_ac_dc)
                        amdgpu_dpm_notify_ac_dc(adev);
 
-               if (is_support_sw_smu(adev))
-                       smu_set_ac_dc(adev->powerplay.pp_handle, true);
-
                mutex_unlock(&adev->pm.mutex);
        }
 }
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +9 -1
index cca32f74abf0..84ac824837ac 100644
@@ -2774,7 +2774,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle,
        return smu_set_watermarks_table(smu, clock_ranges);  }
 
-int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
+static int smu_set_ac_dc(struct smu_context *smu, bool
+restore_ppt_policy)
 {
        int ret = 0;
 
@@ -2800,6 +2800,13 @@ int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy)
        return 0;
 }
 
+static void smu_notify_ac_dc(void *handle) {
+       struct smu_context *smu = handle;
+
+       smu_set_ac_dc(smu, true);
+}
+
 const struct amd_ip_funcs smu_ip_funcs = {
        .name = "smu",
        .early_init = smu_early_init,
@@ -4000,6 +4007,7 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
        .set_pp_table            = smu_sys_set_pp_table,
        .switch_power_profile    = smu_switch_power_profile,
        .pause_power_profile     = smu_pause_power_profile,
+       .notify_ac_dc            = smu_notify_ac_dc,
        /* export to amdgpu */
        .dispatch_tasks          = smu_handle_dpm_task,
        .load_firmware           = smu_load_microcode,
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -2
index 3ec65630ab99..92658eb3886d 100644
@@ -1952,8 +1952,6 @@ int smu_set_soft_freq_range(struct smu_context *smu, enum pp_clock_type clk_type
 
 int smu_set_gfx_power_up_by_imu(struct smu_context *smu);
 
-int smu_set_ac_dc(struct smu_context *smu, bool restore_ppt_policy);
-
 int smu_set_xgmi_plpd_mode(struct smu_context *smu,
                           enum pp_xgmi_plpd_mode mode);
 

--
2.49.0