mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: samsung-galaxybook: Re-enable ACPI features on resume
@ 2026-11-12 16:54 Jamil Khan
  0 siblings, 0 replies; only message in thread
From: Jamil Khan @ 2026-11-12 16:54 UTC (permalink / raw)
  To: Joshua Grisham
  Cc: Jamil Khan, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel

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.

Link: https://github.com/joshuagrisham/samsung-galaxybook-extras/issues/12
Signed-off-by: Jamil Khan <khanjamilahmed202@gmail.com>
---
 drivers/platform/x86/samsung-galaxybook.c | 45 +++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/platform/x86/samsung-galaxybook.c b/drivers/platform/x86/samsung-galaxybook.c
index b150e1f..27a2d27 100644
--- a/drivers/platform/x86/samsung-galaxybook.c
+++ b/drivers/platform/x86/samsung-galaxybook.c
@@ -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,
 };
-- 
2.56.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-12 16:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 16:54 [PATCH] platform/x86: samsung-galaxybook: Re-enable ACPI features on resume Jamil Khan

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®