Skip to contentSkip to conversation

platform/x86: samsung-galaxybook: Re-enable ACPI features on resume

PATCH In review Jamil Khan 3 participants 3 messages Nov 12 – Nov 23

Subsystems (2)
lore
Share & tools
lore

Jamil Khan

author
#0 lore raw

PATCH 1/1 platform/x86: samsung-galaxybook: Re-enable ACPI features on resume

The driver enables the ACPI device (SDLS) and its features (notifications, power management, keyboard backlight, block recording) only at probe time. On a Galaxy Book4 (750XGK, SAM0430) this state is lost across hibernation, and after restore every CSFI call fails:

acpi SAM0430:00: failed to execute CSFI; device responded with failure code 0xff

so charge_control_end_threshold, the keyboard backlight and the firmware-attributes all return -ENXIO until the driver is re-bound. The performance mode (CSXI) is not affected.

Add a resume callback that repeats the probe-time enable sequence in the same order, and use it for both system resume and restore from hibernation.

Tested with a hibernate/restore cycle on a Galaxy Book4 750XGK (BIOS P11CFP.025.251116.HQ): without this patch all CSFI calls fail after restore, with it they keep working.

---
 drivers/platform/x86/samsung-galaxybook.c | 45 +++++++++++++++++++++++
 1 file changed, 45 insertions(+)
drivers/platform/x86/samsung-galaxybook.c +45 -0
index b150e1f..27a2d27 100644
@@ -1381,6 +1381,7 @@ static int galaxybook_probe(struct platform_device *pdev)
 
 	galaxybook->platform = pdev;
 	galaxybook->acpi = adev;
+	platform_set_drvdata(pdev, galaxybook);
 
 	/*
 	 * Features must be enabled and initialized in the following order to
@@ -1432,6 +1433,49 @@ static int galaxybook_probe(struct platform_device *pdev)
 	return 0;
 }
 
+/*
+ * The firmware forgets that the ACPI device and its features were enabled
+ * when the system is restored from hibernation, after which every CSFI call
+ * fails with 0xff. Repeat the enable sequence from probe, in the same order.
+ */
+static int galaxybook_resume(struct device *dev)
+{
+	struct samsung_galaxybook *galaxybook = dev_get_drvdata(dev);
+	acpi_status status;
+	int err;
+
+	status = acpi_execute_simple_method(galaxybook->acpi->handle, GB_ACPI_METHOD_ENABLE,
+					    GB_ACPI_METHOD_ENABLE_ON);
+	if (ACPI_FAILURE(status)) {
+		dev_warn(dev, "failed to re-enable ACPI device on resume\n");
+		return 0;
+	}
+
+	err = galaxybook_enable_acpi_notify(galaxybook);
+	if (err)
+		dev_dbg(dev, "failed to re-enable ACPI notifications, error %d\n", err);
+
+	err = galaxybook_enable_acpi_feature(galaxybook, GB_SASB_POWER_MANAGEMENT);
+	if (err)
+		dev_dbg(dev, "failed to re-enable power management features, error %d\n", err);
+
+	if (galaxybook->has_kbd_backlight) {
+		err = galaxybook_enable_acpi_feature(galaxybook, GB_SASB_KBD_BACKLIGHT);
+		if (err)
+			dev_dbg(dev, "failed to re-enable kbd_backlight, error %d\n", err);
+	}
+
+	if (galaxybook->has_block_recording) {
+		err = galaxybook_enable_acpi_feature(galaxybook, GB_SASB_BLOCK_RECORDING);
+		if (err)
+			dev_dbg(dev, "failed to re-enable block_recording, error %d\n", err);
+	}
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(galaxybook_pm_ops, NULL, galaxybook_resume);
+
 static const struct acpi_device_id galaxybook_device_ids[] = {
 	{ "SAM0426" },
 	{ "SAM0427" },
@@ -1447,6 +1491,7 @@ static struct platform_driver galaxybook_platform_driver = {
 	.driver = {
 		.name = DRIVER_NAME,
 		.acpi_match_table = galaxybook_device_ids,
+		.pm = pm_sleep_ptr(&galaxybook_pm_ops),
 	},
 	.probe = galaxybook_probe,
 };
Signature · 1 line
2.56.0
Tested-by on v1 1/1
#1 lore raw

Hi Jamil,

Same problem here on another model: Galaxy Book5 Pro 940XHA (SAM0430, Core Ultra 7 258V, BIOS P07VAJ.330.250516.01), on Arch's linux-zen 7.3.4. I applied your patch to the 7.3.4 driver source (it applies with offsets), built it out-of-tree and loaded it in place of the stock module. Hibernation goes to a swap file via systemctl hibernate.

With the stock module, after one hibernate/restore cycle:

  $ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
  cat: /sys/class/power_supply/BAT1/charge_control_end_threshold: No such device or address
  $ wc -c < /sys/class/power_supply/BAT1/uevent
  0
  $ cat /sys/class/firmware-attributes/samsung-galaxybook/attributes/power_on_lid_open/current_value
  cat: [...]/power_on_lid_open/current_value: No such device or address

and right after "PM: hibernation: hibernation exit" the log has 50 of

acpi SAM0430:00: failed to execute CSFI; device responded with failure code 0xff power_supply BAT1: driver failed to report `charge_control_end_threshold' property: -6

They keep coming for as long as something reads the battery: an earlier boot on 7.2.15 logged 5443 of them.

With the patch, over two hibernate/restore cycles and one s2idle cycle, charge_control_end_threshold still reads 80, BAT1/uevent is complete, power_on_lid_open and usb_charging read back, and there are no CSFI errors or other new messages after resume. platform_profile works with and without the patch, as you noted.

maintainer
#2 lore raw
In reply to Jamil Khan
Quoted 8 lines · Jamil Khan

The driver enables the ACPI device (SDLS) and its features (notifications, power management, keyboard backlight, block recording) only at probe time. On a Galaxy Book4 (750XGK, SAM0430) this state is lost across hibernation, and after restore every CSFI call fails:

acpi SAM0430:00: failed to execute CSFI; device responded with failure code 0xff

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: samsung-galaxybook: Re-enable ACPI features on resume

      commit: 94b6cb8cada6c91b9d070a815348f3ca900ca144

--
i.