Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb+git@google.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konradybcio@kernel.org>,
	Abel Vesa <abelvesa@kernel.org>,
	 Dmitry Baryshkov <lumag@kernel.org>,
	linux-arm-msm@vger.kernel.org
Subject: [PATCH 6/7] platform: arm64: lenovo-yoga-c630: Disable the EC interrupt while suspended
Date: Wed, 11 Nov 2026 12:53:10 +0100	[thread overview]
Message-ID: <20261111115303.3749380-15-ardb+git@google.com> (raw)
In-Reply-To: <20261111115303.3749380-9-ardb+git@google.com>

From: Ard Biesheuvel <ardb@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@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



  parent reply	other threads:[~2026-11-11 11:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 11:53 [PATCH 0/7] Lenovo Yoga C630 (sdm845) fixes Ard Biesheuvel
2026-11-11 11:53 ` [PATCH 1/7] arm64: dts: qcom: sdm845: Bump fastrpc shared DMA pool to 32MB for 16k pages Ard Biesheuvel
2026-11-11 14:42   ` Abel Vesa
2026-11-11 11:53 ` [PATCH 2/7] arm64: dts: qcom: c630: Use LN_BB_CLK2 as the eDP bridge reference clock Ard Biesheuvel
2026-11-11 12:43   ` Dmitry Baryshkov
2026-11-11 13:15     ` Ard Biesheuvel
2026-11-11 13:45       ` Ard Biesheuvel
2026-11-11 11:53 ` [PATCH 3/7] arm64: dts: qcom: c630: Enable DisplayPort alt mode Ard Biesheuvel
2026-11-11 12:50   ` Dmitry Baryshkov
2026-11-11 14:42   ` Abel Vesa
2026-11-11 11:53 ` [PATCH 4/7] arm64: dts: qcom: c630: Use the idle states from the ACPI tables Ard Biesheuvel
2026-11-11 12:56   ` Dmitry Baryshkov
2026-11-11 14:42   ` Abel Vesa
2026-11-11 11:53 ` [PATCH 5/7] arm64: dts: qcom: c630: Wait for the touchpad at resume Ard Biesheuvel
2026-11-11 12:22   ` Ard Biesheuvel
2026-11-11 12:58     ` Dmitry Baryshkov
2026-11-11 13:16       ` Ard Biesheuvel
2026-11-11 12:56   ` Dmitry Baryshkov
2026-11-11 11:53 ` Ard Biesheuvel [this message]
2026-11-11 12:57   ` [PATCH 6/7] platform: arm64: lenovo-yoga-c630: Disable the EC interrupt while suspended Dmitry Baryshkov
2026-11-11 11:53 ` [PATCH 7/7] platform: arm64: lenovo-yoga-c630: Expose the keyboard backlight as an LED Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261111115303.3749380-15-ardb+git@google.com \
    --to=ardb+git@google.com \
    --cc=abelvesa@kernel.org \
    --cc=andersson@kernel.org \
    --cc=ardb@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=lumag@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox