mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/1] platform/surface: platform_profile: handle fan standby state
@ 2026-11-11  2:09 Peter Marshall
  2026-11-11  2:09 ` [PATCH] " Peter Marshall
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Marshall @ 2026-11-11  2:09 UTC (permalink / raw)
  To: Maximilian Luz, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Peter Marshall

This patch extends the Microsoft Surface platform driver to signal the
system's standby state to the SAM, stopping the fan during PM suspend and
restarting it during resume.

Without this change, the fan continues to run during suspend as if the
system was still powered on, and takes a few minutes to slow down and stop
as the chassis cools.

Tested on a Microsoft Surface Pro 9 running kernel 7.3.0.

Peter Marshall (1):
  platform/surface: platform_profile: handle fan standby state

 .../surface/surface_platform_profile.c        | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] platform/surface: platform_profile: handle fan standby state
  2026-11-11  2:09 [PATCH 0/1] platform/surface: platform_profile: handle fan standby state Peter Marshall
@ 2026-11-11  2:09 ` Peter Marshall
  2026-11-11 14:14   ` kernel test robot
  2026-11-11 21:26   ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Marshall @ 2026-11-11  2:09 UTC (permalink / raw)
  To: Maximilian Luz, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Peter Marshall

Send a fan standby command if a fan is present when entering a PM
suspend transition and set it back to normal during resume.

Signed-off-by: Peter Marshall <pm@petermarshall.ca>
---
 .../surface/surface_platform_profile.c        | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 0e479e35e66e..203d21aa715c 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -32,6 +32,11 @@ enum ssam_fan_profile {
 	SSAM_FAN_PROFILE_BEST_PERFORMANCE   = 4,
 };
 
+enum ssam_fan_state {
+	SSAM_FAN_STATE_NORMAL  = 1,
+	SSAM_FAN_STATE_STANDBY = 2,
+};
+
 struct ssam_tmp_profile_info {
 	__le32 profile;
 	__le16 unknown1;
@@ -61,6 +66,13 @@ SSAM_DEFINE_SYNC_REQUEST_W(__ssam_fan_profile_set, u8, {
 	.instance_id = 0x01,
 });
 
+SSAM_DEFINE_SYNC_REQUEST_W(__ssam_fan_state_set, u8, {
+	.target_category = SSAM_SSH_TC_FAN,
+	.target_id = SSAM_SSH_TID_SAM,
+	.command_id = 0x0f,
+	.instance_id = 0x01,
+});
+
 static int ssam_tmp_profile_get(struct ssam_device *sdev, enum ssam_tmp_profile *p)
 {
 	struct ssam_tmp_profile_info info;
@@ -88,6 +100,13 @@ static int ssam_fan_profile_set(struct ssam_device *sdev, enum ssam_fan_profile
 	return ssam_retry(__ssam_fan_profile_set, sdev->ctrl, &profile);
 }
 
+static int ssam_fan_state_set(struct ssam_device *sdev, enum ssam_fan_state s)
+{
+	const u8 state = s;
+
+	return ssam_retry(__ssam_fan_state_set, sdev->ctrl, &state);
+}
+
 static int convert_ssam_tmp_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p)
 {
 	switch (p) {
@@ -236,6 +255,49 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
 	return PTR_ERR_OR_ZERO(tpd->ppdev);
 }
 
+#ifdef CONFIG_PM_SLEEP
+
+static int surface_platform_profile_pm_prepare(struct device *dev)
+{
+	struct ssam_platform_profile_device *tpd;
+	int status;
+
+	tpd = dev_get_drvdata(dev);
+
+	if (tpd->has_fan) {
+		status = ssam_fan_state_set(tpd->sdev, SSAM_FAN_STATE_STANDBY);
+		if (status)
+			dev_err(&tpd->sdev->dev, "pm: fan standby notification failed");
+	}
+
+	return status;
+}
+
+static void surface_platform_profile_pm_complete(struct device *dev)
+{
+	struct ssam_platform_profile_device *tpd;
+	int status;
+
+	tpd = dev_get_drvdata(dev);
+
+	if (tpd->has_fan) {
+		status = ssam_fan_state_set(tpd->sdev, SSAM_FAN_STATE_NORMAL);
+		if (status)
+			dev_err(&tpd->sdev->dev, "pm: fan resume notification failed");
+	}
+}
+
+static const struct dev_pm_ops surface_platform_profile_pm_ops = {
+	.prepare  = surface_platform_profile_pm_prepare,
+	.complete = surface_platform_profile_pm_complete,
+};
+
+#else /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops surface_platform_profile_pm_ops = { };
+
+#endif /* CONFIG_PM_SLEEP */
+
 static const struct ssam_device_id ssam_platform_profile_match[] = {
 	{ SSAM_SDEV(TMP, SAM, 0x00, 0x01) },
 	{ },
@@ -247,6 +309,7 @@ static struct ssam_device_driver surface_platform_profile = {
 	.match_table = ssam_platform_profile_match,
 	.driver = {
 		.name = "surface_platform_profile",
+		.pm = &surface_platform_profile_pm_ops,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
 };
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/surface: platform_profile: handle fan standby state
  2026-11-11  2:09 ` [PATCH] " Peter Marshall
@ 2026-11-11 14:14   ` kernel test robot
  2026-11-11 21:26   ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-11-11 14:14 UTC (permalink / raw)
  To: Peter Marshall, Maximilian Luz, Hans de Goede, Ilpo Järvinen
  Cc: oe-kbuild-all, platform-driver-x86, linux-kernel, Peter Marshall

Hi Peter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v7.4-rc2 next-20261110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Peter-Marshall/platform-surface-platform_profile-handle-fan-standby-state/20261110-210916
base:   linus/master
patch link:    https://lore.kernel.org/r/20261111020916.3557508-2-pm%40petermarshall.ca
patch subject: [PATCH] platform/surface: platform_profile: handle fan standby state
config: i386-randconfig-1013-20261111 (https://download.01.org/0day-ci/archive/20261111/202611112200.LGfh2iNB-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261111/202611112200.LGfh2iNB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611112200.LGfh2iNB-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/platform/surface/surface_platform_profile.c:103:12: warning: 'ssam_fan_state_set' defined but not used [-Wunused-function]
     103 | static int ssam_fan_state_set(struct ssam_device *sdev, enum ssam_fan_state s)
         |            ^~~~~~~~~~~~~~~~~~


vim +/ssam_fan_state_set +103 drivers/platform/surface/surface_platform_profile.c

   102	
 > 103	static int ssam_fan_state_set(struct ssam_device *sdev, enum ssam_fan_state s)
   104	{
   105		const u8 state = s;
   106	
   107		return ssam_retry(__ssam_fan_state_set, sdev->ctrl, &state);
   108	}
   109	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/surface: platform_profile: handle fan standby state
  2026-11-11  2:09 ` [PATCH] " Peter Marshall
  2026-11-11 14:14   ` kernel test robot
@ 2026-11-11 21:26   ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-11-11 21:26 UTC (permalink / raw)
  To: Peter Marshall, Maximilian Luz, Hans de Goede, Ilpo Järvinen
  Cc: llvm, oe-kbuild-all, platform-driver-x86, linux-kernel, Peter Marshall

Hi Peter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v7.4-rc2 next-20261110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Peter-Marshall/platform-surface-platform_profile-handle-fan-standby-state/20261110-210916
base:   linus/master
patch link:    https://lore.kernel.org/r/20261111020916.3557508-2-pm%40petermarshall.ca
patch subject: [PATCH] platform/surface: platform_profile: handle fan standby state
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20261112/202611120527.xw8ZORYY-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261112/202611120527.xw8ZORYY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611120527.xw8ZORYY-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/platform/surface/surface_platform_profile.c:267:6: warning: variable 'status' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     267 |         if (tpd->has_fan) {
         |             ^~~~~~~~~~~~
   drivers/platform/surface/surface_platform_profile.c:273:9: note: uninitialized use occurs here
     273 |         return status;
         |                ^~~~~~
   drivers/platform/surface/surface_platform_profile.c:267:2: note: remove the 'if' if its condition is always true
     267 |         if (tpd->has_fan) {
         |         ^~~~~~~~~~~~~~~~~
   drivers/platform/surface/surface_platform_profile.c:263:12: note: initialize the variable 'status' to silence this warning
     263 |         int status;
         |                   ^
         |                    = 0
   1 warning generated.


vim +267 drivers/platform/surface/surface_platform_profile.c

   259	
   260	static int surface_platform_profile_pm_prepare(struct device *dev)
   261	{
   262		struct ssam_platform_profile_device *tpd;
   263		int status;
   264	
   265		tpd = dev_get_drvdata(dev);
   266	
 > 267		if (tpd->has_fan) {
   268			status = ssam_fan_state_set(tpd->sdev, SSAM_FAN_STATE_STANDBY);
   269			if (status)
   270				dev_err(&tpd->sdev->dev, "pm: fan standby notification failed");
   271		}
   272	
   273		return status;
   274	}
   275	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-11 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11  2:09 [PATCH 0/1] platform/surface: platform_profile: handle fan standby state Peter Marshall
2026-11-11  2:09 ` [PATCH] " Peter Marshall
2026-11-11 14:14   ` kernel test robot
2026-11-11 21:26   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®