All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tipd: mask interrupt across suspend to fix IRQ storm
@ 2026-09-18  5:18 jianfeng.gao
  0 siblings, 0 replies; 3+ messages in thread
From: jianfeng.gao @ 2026-09-18  5:18 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Li Yifan, Munirah Izyani Mohammad Amin,
	Gao Jianfeng, stable

From: Gao Jianfeng <jianfeng.gao@intel.com>

When tps->wakeup is false, tps6598x_suspend() left the IRQ enabled
because disable_irq() was gated inside the "if (tps->wakeup)" branch.
During hibernation the parent I2C (designware) adapter suspends right
after the child's freeze callback, so with the IRQ still enabled and the
type-C line still asserted, tps6598x_interrupt() keeps re-firing. Its
register reads now fail with -ESHUTDOWN, the handler bails with
event1/event2 == 0 and returns IRQ_NONE, so the line is never acked and
the handler loops, flooding the log with "failed to read ..." errors
until the noirq phase finally masks interrupts.

Mask the interrupt unconditionally in suspend and re-enable it in
resume, keeping enable_irq()/disable_irq() balanced. The wake-source
arming stays conditional on tps->wakeup.

The resume error paths jump to a common exit so the IRQ is re-enabled
(and the wake source disarmed) even when the controller fails to come
back. The line is requested with IRQF_SHARED, so a leaked disable_irq()
would mask it for every other device sharing it, and the imbalance would
never be recovered by a later resume.

Fixes: 481735d64794 ("usb: typec: tipd: Support wakeup")
Cc: stable@vger.kernel.org
Co-developed-by: Li Yifan <yifan2.li@intel.com>
Signed-off-by: Li Yifan <yifan2.li@intel.com>
Signed-off-by: Gao Jianfeng <jianfeng.gao@intel.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Munirah Izyani Mohammad Amin <munirah.izyani.mohammad.amin@intel.com>
---
 drivers/usb/typec/tipd/core.c | 38 ++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 9248f0dd3f49..5ed573e30479 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1972,12 +1972,19 @@ static int __maybe_unused tps6598x_suspend(struct device *dev)
 	struct i2c_client *client = to_i2c_client(dev);
 	struct tps6598x *tps = i2c_get_clientdata(client);
 
-	if (tps->wakeup) {
+	/*
+	 * Mask the interrupt before the parent I2C controller is suspended:
+	 * otherwise a still-asserted level IRQ keeps re-entering the handler,
+	 * whose register reads then fail with -ESHUTDOWN, producing an
+	 * interrupt storm until the noirq phase globally disables interrupts.
+	 */
+	if (client->irq)
 		disable_irq(client->irq);
+
+	if (tps->wakeup)
 		enable_irq_wake(client->irq);
-	} else if (tps->reset) {
+	else if (tps->reset)
 		gpiod_set_value_cansleep(tps->reset, 1);
-	}
 
 	if (!client->irq)
 		cancel_delayed_work_sync(&tps->wq_poll);
@@ -1993,18 +2000,16 @@ static int __maybe_unused tps6598x_resume(struct device *dev)
 
 	ret = tps6598x_check_mode(tps);
 	if (ret < 0)
-		return ret;
+		goto out_enable_irq;
 
 	if (ret == TPS_MODE_PTCH) {
 		ret = tps->data->init(tps);
 		if (ret)
-			return ret;
+			goto out_enable_irq;
 	}
+	ret = 0;
 
-	if (tps->wakeup) {
-		disable_irq_wake(client->irq);
-		enable_irq(client->irq);
-	} else if (tps->reset) {
+	if (!tps->wakeup && tps->reset) {
 		gpiod_set_value_cansleep(tps->reset, 0);
 		msleep(TPS_SETUP_MS);
 	}
@@ -2013,7 +2018,20 @@ static int __maybe_unused tps6598x_resume(struct device *dev)
 		queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
 				   msecs_to_jiffies(POLL_INTERVAL));
 
-	return 0;
+out_enable_irq:
+	/*
+	 * Unwind suspend unconditionally, including on the error paths above:
+	 * the line is requested with IRQF_SHARED, so a leaked disable_irq()
+	 * would mask it for every other device on it, and the imbalance would
+	 * never be recovered by a later resume.
+	 */
+	if (tps->wakeup)
+		disable_irq_wake(client->irq);
+
+	if (client->irq)
+		enable_irq(client->irq);
+
+	return ret;
 }
 
 static const struct dev_pm_ops tps6598x_pm_ops = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] usb: typec: tipd: mask interrupt across suspend to fix IRQ storm
@ 2026-12-01  8:46 jianfeng.gao
  2026-12-01  9:00 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: jianfeng.gao @ 2026-12-01  8:46 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Li Yifan

From: JianFeng Gao <jianfeng.gao@intel.com>

When tps->wakeup is false, tps6598x_suspend() left the IRQ enabled because
disable_irq() was gated inside the "if (tps->wakeup)" branch.

During hibernation the parent I2C (designware) adapter suspends right
after the child's freeze callback, so with the IRQ still enabled and the
type-C line still asserted, tps6598x_interrupt() keeps re-firing. Its
register reads now fail with -ESHUTDOWN, the handler bails with
event1/event2 == 0 and returns IRQ_NONE, so the line is never acked and
the handler loops, flooding the log with "failed to read ..." errors
until the noirq phase finally masks interrupts.

Mask the interrupt unconditionally in suspend and re-enable it in resume,
keeping enable_irq()/disable_irq() balanced. The wake-source arming stays
conditional on tps->wakeup.

Fixes: 481735d64794 ("usb: typec: tipd: Support wakeup")
Cc: stable@vger.kernel.org
Co-developed-by: Li Yifan <yifan2.li@intel.com>
Signed-off-by: Li Yifan <yifan2.li@intel.com>
Signed-off-by: JianFeng Gao <jianfeng.gao@intel.com>
Tested-by: Munirah Izyani Mohammad Amin <munirah.izyani.mohammad.amin@intel.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/tipd/core.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 02539378ffed..aba000a36a06 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1973,12 +1973,19 @@ static int __maybe_unused tps6598x_suspend(struct device *dev)
 	struct i2c_client *client = to_i2c_client(dev);
 	struct tps6598x *tps = i2c_get_clientdata(client);
 
-	if (tps->wakeup) {
+	/*
+	 * Mask the interrupt before the parent I2C controller is suspended:
+	 * otherwise a still-asserted level IRQ keeps re-entering the handler,
+	 * whose register reads then fail with -ESHUTDOWN, producing an
+	 * interrupt storm until the noirq phase globally disables interrupts.
+	 */
+	if (client->irq)
 		disable_irq(client->irq);
+
+	if (tps->wakeup)
 		enable_irq_wake(client->irq);
-	} else if (tps->reset) {
+	else if (tps->reset)
 		gpiod_set_value_cansleep(tps->reset, 1);
-	}
 
 	if (!client->irq)
 		cancel_delayed_work_sync(&tps->wq_poll);
@@ -2004,12 +2011,15 @@ static int __maybe_unused tps6598x_resume(struct device *dev)
 
 	if (tps->wakeup) {
 		disable_irq_wake(client->irq);
-		enable_irq(client->irq);
 	} else if (tps->reset) {
 		gpiod_set_value_cansleep(tps->reset, 0);
 		msleep(TPS_SETUP_MS);
 	}
 
+	/* Balance the unconditional disable_irq() in tps6598x_suspend() */
+	if (client->irq)
+		enable_irq(client->irq);
+
 	if (!client->irq)
 		queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
 				   msecs_to_jiffies(POLL_INTERVAL));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tipd: mask interrupt across suspend to fix IRQ storm
  2026-12-01  8:46 [PATCH] usb: typec: tipd: mask interrupt across suspend to fix IRQ storm jianfeng.gao
@ 2026-12-01  9:00 ` sashiko-bot
  0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-01  9:00 UTC (permalink / raw)
  To: jianfeng.gao; +Cc: linux-usb

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: typec: tipd: unbalanced disable_irq() on error in
  tps6598x_resume()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] usb: typec: tipd: shared IRQ line globally disabled in
  tps6598x_suspend() [1]
--

commit bad1fa24a640cc758aca2387c46de94a7477d077
Author: JianFeng Gao <jianfeng.gao@intel.com>

usb: typec: tipd: mask interrupt across suspend to fix IRQ storm

This commit disables client->irq unconditionally in tps6598x_suspend() and
re-enables it in tps6598x_resume() to prevent an interrupt storm when the
parent I2C controller suspends while tps->wakeup is false.

> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 67471c363a687..28a4f60629dfa 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1973,12 +1973,19 @@ static int __maybe_unused tps6598x_suspend(struct device *dev)
>  	struct i2c_client *client = to_i2c_client(dev);
>  	struct tps6598x *tps = i2c_get_clientdata(client);
>  
> -	if (tps->wakeup) {
> +	/*
> +	 * Mask the interrupt before the parent I2C controller is suspended:
> +	 * otherwise a still-asserted level IRQ keeps re-entering the handler,
> +	 * whose register reads then fail with -ESHUTDOWN, producing an
> +	 * interrupt storm until the noirq phase globally disables interrupts.
> +	 */
> +	if (client->irq)
>  		disable_irq(client->irq);

[Severity: High]
This problem wasn't introduced by this patch, but calling
disable_irq(client->irq) here globally masks a shared interrupt line at the
interrupt controller [1].  Because the driver requests client->irq
with IRQF_SHARED, masking the line across suspend starves any other devices
sharing the IRQ during their suspend sequence and prevents them from waking
the system.

> +
> +	if (tps->wakeup)
>  		enable_irq_wake(client->irq);
> -	} else if (tps->reset) {
> +	else if (tps->reset)
>  		gpiod_set_value_cansleep(tps->reset, 1);
> -	}
>  
>  	if (!client->irq)
>  		cancel_delayed_work_sync(&tps->wq_poll);
> @@ -2004,12 +2011,15 @@ static int __maybe_unused tps6598x_resume(struct device *dev)
>  
>  	if (tps->wakeup) {
>  		disable_irq_wake(client->irq);
> -		enable_irq(client->irq);
>  	} else if (tps->reset) {
>  		gpiod_set_value_cansleep(tps->reset, 0);
>  		msleep(TPS_SETUP_MS);
>  	}
>  
> +	/* Balance the unconditional disable_irq() in tps6598x_suspend() */
> +	if (client->irq)
> +		enable_irq(client->irq);

[Severity: Medium]
Can an early error return in tps6598x_resume() leave client->irq disabled?

Before reaching enable_irq(client->irq), tps6598x_resume() returns early if
tps6598x_check_mode() or tps->data->init() fails:

drivers/usb/typec/tipd/core.c:tps6598x_resume() {
	ret = tps6598x_check_mode(tps);
	if (ret < 0)
		return ret;

	if (ret == TPS_MODE_PTCH) {
		ret = tps->data->init(tps);
		if (ret)
			return ret;
	}
	...
}

In particular, when tps->wakeup is false and tps->reset is present,
tps6598x_suspend() now disables client->irq and asserts reset, and
tps6598x_resume() runs tps6598x_check_mode() over I2C while the chip is
still held in reset before de-asserting tps->reset.  When that read (or any
resume I2C transfer) fails, client->irq stays disabled so Type-C events are
no longer serviced, and later suspend cycles call disable_irq() again and
increase the disable depth.

[1] https://sashiko.dev/#/bug/linux-c47210b1-54f4-4549-9e9f-d91fbab89bb8

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201084650.3697134-1-jianfeng.gao@intel.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:46 [PATCH] usb: typec: tipd: mask interrupt across suspend to fix IRQ storm jianfeng.gao
2026-12-01  9:00 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-09-18  5:18 jianfeng.gao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.