[PATCH 6/7] platform: arm64: lenovo-yoga-c630: Disable the EC interrupt while suspended

Ard Biesheuvel ardb+git at google.com
Wed Nov 11 03:53:10 PST 2026


From: Ard Biesheuvel <ardb at kernel.org>

The EC interrupt handler reads the pending event from the EC over I2C. If
the interrupt fires while the system is suspending or resuming, between
the late suspend and early resume phases of the I2C controller, the
transfer fails, as runtime PM is disabled for the controller:

  geni_i2c 884000.i2c: error turning SE resources:-13

The handler then returns without having read the event, and as the
interrupt is level triggered, it fires again right away. On the Yoga C630,
this shows up as tens to thousands of these errors in about half of the
suspends.

So disable the EC interrupt when suspending, and enable it again when
resuming. Pending events are then handled once the I2C controller can be
used again.

Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
 drivers/platform/arm64/lenovo-yoga-c630.c | 34 +++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/arm64/lenovo-yoga-c630.c b/drivers/platform/arm64/lenovo-yoga-c630.c
index cad40c58c55b..2776063bfb58 100644
--- a/drivers/platform/arm64/lenovo-yoga-c630.c
+++ b/drivers/platform/arm64/lenovo-yoga-c630.c
@@ -10,11 +10,13 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
 #include <linux/irqreturn.h>
 #include <linux/lockdep.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/notifier.h>
+#include <linux/pm.h>
 #include <linux/slab.h>
 #include <linux/platform_data/lenovo-yoga-c630.h>
 
@@ -216,6 +218,7 @@ static int yoga_c630_ec_probe(struct i2c_client *client)
 	mutex_init(&ec->lock);
 	ec->client = client;
 	BLOCKING_INIT_NOTIFIER_HEAD(&ec->notifier_list);
+	i2c_set_clientdata(client, ec);
 
 	ret = devm_request_threaded_irq(dev, client->irq,
 					NULL, yoga_c630_ec_thread_intr,
@@ -230,6 +233,34 @@ static int yoga_c630_ec_probe(struct i2c_client *client)
 	return yoga_c630_aux_init(dev, YOGA_C630_DEV_UCSI, ec);
 }
 
+/*
+ * Keep the EC interrupt disabled until the system has resumed. Its
+ * handler reads the pending event over I2C, which fails between the late
+ * suspend and early resume phases of the I2C controller, and as the
+ * interrupt is level triggered, it would fire over and over again until the
+ * handler gets to read the event.
+ */
+static int yoga_c630_ec_suspend(struct device *dev)
+{
+	struct yoga_c630_ec *ec = dev_get_drvdata(dev);
+
+	disable_irq(ec->client->irq);
+
+	return 0;
+}
+
+static int yoga_c630_ec_resume(struct device *dev)
+{
+	struct yoga_c630_ec *ec = dev_get_drvdata(dev);
+
+	enable_irq(ec->client->irq);
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(yoga_c630_ec_pm_ops, yoga_c630_ec_suspend,
+				yoga_c630_ec_resume);
+
 
 static const struct of_device_id yoga_c630_ec_of_match[] = {
 	{ .compatible = "lenovo,yoga-c630-ec" },
@@ -246,7 +277,8 @@ MODULE_DEVICE_TABLE(i2c, yoga_c630_ec_i2c_id_table);
 static struct i2c_driver yoga_c630_ec_i2c_driver = {
 	.driver = {
 		.name = "yoga-c630-ec",
-		.of_match_table = yoga_c630_ec_of_match
+		.of_match_table = yoga_c630_ec_of_match,
+		.pm = pm_sleep_ptr(&yoga_c630_ec_pm_ops),
 	},
 	.probe = yoga_c630_ec_probe,
 	.id_table = yoga_c630_ec_i2c_id_table,
-- 
2.56.0.611.g1030f0b940-goog




More information about the linux-arm-kernel mailing list