Skip to contentSkip to conversation

platform/surface: platform_profile: add fan profile switching

PATCH Superseded Ivor Wanders 3 participants 5 messages Mar 2, 2024 – Mar 11, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover platform/surface: platform_profile: add fan profile switching

This patch adds functionality that switches the fan profile when the platform profile is switched on the Microsoft Surface Pro 9.

Previously, the fan profile was not changed and that results in poor thermal performance. This makes the behaviour and functionality identical to what the Windows drivers do.

A plot of the different responses to system load, as well as recordings from the SSAM bus can be found at [1]. Based on discussions with Maximilian Luz there this patch proposes the following changes:

In surface_aggregator_registry:
- Rename ssam_node_tmp_pprof to ssam_node_tmp_perf_profile for clarity.
- Introduce ssam_node_tmp_perf_profile_with_fan that has the has_fan boolean property set.
- Use the new ssam_node_tmp_perf_profile_with_fan for the Surface Pro 9.

In the platform profile module:
- Rename ssam_tmp_profile_device to ssam_platform_profile_device to make it clear it handles more than just the TMP subsystem.
- Rename the enum conversion method to make distinction between TMP and FAN clear.
- Add enum and set function & request for the fan profile.
- Ensure that if the module's has_fan boolean is true, the fan profile is switched whenever the platform profile changes.

[1]: https://github.com/linux-surface/kernel/pull/145

Ivor Wanders (1):
platform/surface: platform_profile: add fan profile switching

 .../surface/surface_aggregator_registry.c     | 36 +++++---
 .../surface/surface_platform_profile.c        | 86 ++++++++++++++++---
 2 files changed, 99 insertions(+), 23 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 platform/surface: platform_profile: add fan profile switching

Change naming from tmp to platform profile to clarify the module may interact with both the TMP and FAN subystems. Add functionality that switches the fan profile when the platform profile is changed when a fan is present.

---
 .../surface/surface_aggregator_registry.c     | 36 +++++---
 .../surface/surface_platform_profile.c        | 86 ++++++++++++++++---
 2 files changed, 99 insertions(+), 23 deletions(-)
drivers/platform/surface/surface_aggregator_registry.c +25 -11
index aeb3feae40ff..05fd98998d67 100644
@@ -68,12 +68,26 @@ static const struct software_node ssam_node_bat_sb3base = {
 	.parent = &ssam_node_hub_base,
 };
 
-/* Platform profile / performance-mode device. */
-static const struct software_node ssam_node_tmp_pprof = {
+/* Platform profile / performance-mode device without a fan. */
+static const struct software_node ssam_node_tmp_perf_profile = {
 	.name = "ssam:01:03:01:00:01",
 	.parent = &ssam_node_root,
 };
 
+/* Platform profile / performance-mode device with a fan, such that
+ * the fan controller profile can also be switched.
+ */
+static const struct property_entry ssam_node_tmp_perf_profile_has_fan[] = {
+	PROPERTY_ENTRY_BOOL("has_fan"),
+	{ }
+};
+
+static const struct software_node ssam_node_tmp_perf_profile_with_fan = {
+	.name = "ssam:01:03:01:00:01",
+	.parent = &ssam_node_root,
+	.properties = ssam_node_tmp_perf_profile_has_fan,
+};
+
 /* Tablet-mode switch via KIP subsystem. */
 static const struct software_node ssam_node_kip_tablet_switch = {
 	.name = "ssam:01:0e:01:00:01",
@@ -202,7 +216,7 @@ static const struct software_node ssam_node_pos_tablet_switch = {
  */
 static const struct software_node *ssam_node_group_gen5[] = {
 	&ssam_node_root,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	NULL,
 };
 
@@ -213,7 +227,7 @@ static const struct software_node *ssam_node_group_sb3[] = {
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
 	&ssam_node_bat_sb3base,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	&ssam_node_bas_dtx,
 	&ssam_node_hid_base_keyboard,
 	&ssam_node_hid_base_touchpad,
@@ -227,7 +241,7 @@ static const struct software_node *ssam_node_group_sl3[] = {
 	&ssam_node_root,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	&ssam_node_hid_main_keyboard,
 	&ssam_node_hid_main_touchpad,
 	&ssam_node_hid_main_iid5,
@@ -239,7 +253,7 @@ static const struct software_node *ssam_node_group_sl5[] = {
 	&ssam_node_root,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	&ssam_node_hid_main_keyboard,
 	&ssam_node_hid_main_touchpad,
 	&ssam_node_hid_main_iid5,
@@ -252,7 +266,7 @@ static const struct software_node *ssam_node_group_sls[] = {
 	&ssam_node_root,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	&ssam_node_pos_tablet_switch,
 	&ssam_node_hid_sam_keyboard,
 	&ssam_node_hid_sam_penstash,
@@ -268,7 +282,7 @@ static const struct software_node *ssam_node_group_slg1[] = {
 	&ssam_node_root,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	NULL,
 };
 
@@ -277,7 +291,7 @@ static const struct software_node *ssam_node_group_sp7[] = {
 	&ssam_node_root,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	NULL,
 };
 
@@ -287,7 +301,7 @@ static const struct software_node *ssam_node_group_sp8[] = {
 	&ssam_node_hub_kip,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile,
 	&ssam_node_kip_tablet_switch,
 	&ssam_node_hid_kip_keyboard,
 	&ssam_node_hid_kip_penstash,
@@ -304,7 +318,7 @@ static const struct software_node *ssam_node_group_sp9[] = {
 	&ssam_node_hub_kip,
 	&ssam_node_bat_ac,
 	&ssam_node_bat_main,
-	&ssam_node_tmp_pprof,
+	&ssam_node_tmp_perf_profile_with_fan,
 	&ssam_node_pos_tablet_switch,
 	&ssam_node_hid_kip_keyboard,
 	&ssam_node_hid_kip_penstash,
drivers/platform/surface/surface_platform_profile.c +74 -12

169 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer Reviewed-by on the v1 series
#4 lore raw
In reply to Ivor Wanders
Quoted 27 lines · Ivor Wanders

This patch adds functionality that switches the fan profile when the platform profile is switched on the Microsoft Surface Pro 9.

Previously, the fan profile was not changed and that results in poor thermal performance. This makes the behaviour and functionality identical to what the Windows drivers do.

A plot of the different responses to system load, as well as recordings from the SSAM bus can be found at [1]. Based on discussions with Maximilian Luz there this patch proposes the following changes:

In surface_aggregator_registry:
- Rename ssam_node_tmp_pprof to ssam_node_tmp_perf_profile for clarity.
- Introduce ssam_node_tmp_perf_profile_with_fan that has the has_fan boolean property set.
- Use the new ssam_node_tmp_perf_profile_with_fan for the Surface Pro 9.

In the platform profile module:
- Rename ssam_tmp_profile_device to ssam_platform_profile_device to make it clear it handles more than just the TMP subsystem.
- Rename the enum conversion method to make distinction between TMP and FAN clear.
- Add enum and set function & request for the fan profile.
- Ensure that if the module's has_fan boolean is true, the fan profile is switched whenever the platform profile changes.

Quoted 9 lines

[1]: https://github.com/linux-surface/kernel/pull/145

Ivor Wanders (1):
platform/surface: platform_profile: add fan profile switching

  .../surface/surface_aggregator_registry.c     | 36 +++++---
  .../surface/surface_platform_profile.c        | 86 ++++++++++++++++---
  2 files changed, 99 insertions(+), 23 deletions(-)

Looks good to me.

maintainer
#2 lore raw
In reply to Ivor Wanders
Quoted 14 lines · Ivor Wanders

Change naming from tmp to platform profile to clarify the module may interact with both the TMP and FAN subystems. Add functionality that switches the fan profile when the platform profile is changed when a fan is present.

---

drivers/platform/surface/surface_platform_profile.c +0 -0
index a5a3941b3f43..e54d0a8f7daa 100644

drivers/platform/surface/surface_platform_profile.c SSAM_DEFINE_SYNC_REQUEST_CL_W(__ssam_tmp_profile_set, __le32, { · line 57

Quoted 4 lines
drivers/platform/surface/surface_platform_profile.c +1 -0
@@ -42,6 +54,13 @@ SSAM_DEFINE_SYNC_REQUEST_CL_W(__ssam_tmp_profile_set, __le32, {
 	.command_id      = 0x03,
 });
 
+SSAM_DEFINE_SYNC_REQUEST_W(__ssam_fan_profile_set, char, {

Is char correct type here or do you perhaps mean e.g., u8 that is more approriate for 1-byte long binary data?

Quoted 10 lines
drivers/platform/surface/surface_platform_profile.c +6 -0
+	.target_category = SSAM_SSH_TC_FAN,
+	.target_id = SSAM_SSH_TID_SAM,
+	.command_id = 0x0e,
+	.instance_id = 0x01,
+});
+
 static int ssam_tmp_profile_get(struct ssam_device *sdev, enum ssam_tmp_profile *p)
 {
 	struct ssam_tmp_profile_info info;

drivers/platform/surface/surface_platform_profile.c static int ssam_tmp_profile_set(struct ssam_device *sdev, enum ssam_tmp_profile · line 86

Quoted 7 lines
drivers/platform/surface/surface_platform_profile.c +3 -1
@@ -62,7 +81,14 @@ static int ssam_tmp_profile_set(struct ssam_device *sdev, enum ssam_tmp_profile
 	return ssam_retry(__ssam_tmp_profile_set, sdev, &profile_le);
 }
 
-static int convert_ssam_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p)
+static int ssam_fan_profile_set(struct ssam_device *sdev, enum ssam_fan_profile p)
+{
+	char profile = p;

u8 ?

Signature · 1 line
 i.
#3 lore raw
Quoted 1 line

Is char correct type here or do you perhaps mean e.g., u8 that is more

approriate for 1-byte long binary data? [...] u8 ?

Thanks for the review Ilpo. Agreed, u8 would be better, I also noticed that this variable, and the profile_le one in the function just above it can be const, I'll change this type to u8 and make both profile variable const in v2.

~Ivor