* [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes
@ 2026-11-23 13:03 André Draszik
2026-11-23 13:03 ` [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context André Draszik
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: André Draszik @ 2026-11-23 13:03 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Badhri Jagan Sridharan
Cc: Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, linux-rt-devel, André Draszik,
stable
Hi,
These two patches fix a lockdep invalid wait context splat and a
probe/unbind wakeup-event race in the Maxim 77759 TCPCI driver:
- Call pm_wakeup_event() from the threaded IRQ handler instead of the
hard IRQ handler (the driver uses IRQF_ONESHOT, so the primary handler
runs in hard IRQ context even on PREEMPT_RT).
- Initialise device wakeup before requesting the IRQ, so a pending alert
or an interrupt during unbind cannot miss recording a wakeup event.
Tested on Pixel 6 (Oriole) with CONFIG_PROVE_RAW_LOCK_NESTING=y enabled.
Cheers
Andre'
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
André Draszik (2):
usb: typec: tcpm/tcpci_maxim: fix invalid wait context
usb: typec: tcpm/tcpci_maxim: init wakeup before irq
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
---
base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4
change-id: 20261123-max77759-wait-10974f4c312d
Best regards,
--
André Draszik <andre.draszik@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context
2026-11-23 13:03 [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes André Draszik
@ 2026-11-23 13:03 ` André Draszik
2026-11-23 13:03 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: init wakeup before irq André Draszik
2026-11-23 13:06 ` [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2026-11-23 13:03 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Badhri Jagan Sridharan
Cc: Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, linux-rt-devel, André Draszik,
stable
Lockdep reports the following with CONFIG_PROVE_RAW_LOCK_NESTING=y:
[ BUG: Invalid wait context ]
swapper/0/0 is trying to lock:
(&dev->power.lock){-...}-{3:3}, at: pm_wakeup_dev_event+0x38/0x80
other info that might help us debug this:
context-{2:2}
locks held by swapper/0/0: 0, on CPU#0
Call trace:
_raw_spin_lock_irqsave+0x60/0x98
pm_wakeup_dev_event+0x38/0x80
max_tcpci_isr+0x2c/0x58 [tcpci_maxim]
__handle_irq_event_percpu+0xc4/0x4d8
handle_irq_event+0x4c/0x100
handle_level_irq+0xe8/0x188
max_tcpci_isr() calls pm_wakeup_event(), which acquires two spinlocks
(spinlock_t): dev->power.lock and the lock of the device's wakeup
source. On PREEMPT_RT, spinlock_t turns into a sleeping lock. Since the
interrupt is requested with IRQF_ONESHOT, max_tcpci_isr() is never
force-threaded and runs in hard irq context even on PREEMPT_RT. Taking
a sleeping lock in hard irq context is invalid, triggering the lockdep
report above.
Move pm_wakeup_event() to the interrupt thread max_tcpci_irq() instead.
Drop max_tcpci_isr() altogether, since its chip->port check is already
duplicated in max_tcpci_irq(), and request the interrupt without a
primary handler.
Note: Moving pm_wakeup_event() to the interrupt thread doesn't allow
the system to suspend before the event is reported:
suspend_device_irqs() uses synchronize_irq() to wait for the interrupt
thread to finish, and pm_wakeup_pending() is checked after
suspend_device_irqs() returns. Once suspend_device_irqs() has armed the
wake interrupt, the interrupt core reports the wakeup itself and
doesn't call the driver's handlers.
Fixes: 6f413b559f86 ("usb: typec: tcpci_maxim: Chip level TCPC driver")
Cc: stable@vger.kernel.org
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
index a19f52515429..6e202171f57a 100644
--- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
+++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
@@ -411,6 +411,8 @@ static irqreturn_t max_tcpci_irq(int irq, void *dev_id)
irqreturn_t irq_return = IRQ_HANDLED;
int ret;
+ pm_wakeup_event(chip->dev, PD_ACTIVITY_TIMEOUT_MS);
+
if (!chip->port)
return IRQ_HANDLED;
@@ -430,18 +432,6 @@ static irqreturn_t max_tcpci_irq(int irq, void *dev_id)
return irq_return;
}
-static irqreturn_t max_tcpci_isr(int irq, void *dev_id)
-{
- struct max_tcpci_chip *chip = dev_id;
-
- pm_wakeup_event(chip->dev, PD_ACTIVITY_TIMEOUT_MS);
-
- if (!chip->port)
- return IRQ_HANDLED;
-
- return IRQ_WAKE_THREAD;
-}
-
static int max_tcpci_start_toggling(struct tcpci *tcpci, struct tcpci_data *tdata,
enum typec_cc_status cc)
{
@@ -538,7 +528,7 @@ static int max_tcpci_probe(struct i2c_client *client)
chip->port = tcpci_get_tcpm_port(chip->tcpci);
- ret = devm_request_threaded_irq(&client->dev, client->irq, max_tcpci_isr, max_tcpci_irq,
+ ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, max_tcpci_irq,
(IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev),
chip);
if (ret < 0)
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: init wakeup before irq
2026-11-23 13:03 [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes André Draszik
2026-11-23 13:03 ` [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context André Draszik
@ 2026-11-23 13:03 ` André Draszik
2026-11-23 13:06 ` [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2026-11-23 13:03 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Badhri Jagan Sridharan
Cc: Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, linux-rt-devel, André Draszik,
stable
max_tcpci_probe() requests the TCPC interrupt before it initialises
the wakeup source of the device. Since the interrupt is level
triggered, an already asserted alert can trigger the interrupt handler
before devm_device_init_wakeup() is called. Its pm_wakeup_event() does
nothing while the device has no wakeup source, so the wakeup event of
such an early interrupt is not recorded, meaning the system is then not
prevented from suspending for PD_ACTIVITY_TIMEOUT_MS while handling
that alert.
When the driver unbinds, devres works in reverse order and in this case
removes the wakeup source before it frees the interrupt, which leaves a
similar window.
Call devm_device_init_wakeup() before devm_request_threaded_irq(), so
that the wakeup source exists for as long as the interrupt handler can
run.
Fixes: 6f413b559f86 ("usb: typec: tcpci_maxim: Chip level TCPC driver")
Cc: stable@vger.kernel.org
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
index 6e202171f57a..2bb306b6b1f9 100644
--- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
+++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
@@ -528,16 +528,16 @@ static int max_tcpci_probe(struct i2c_client *client)
chip->port = tcpci_get_tcpm_port(chip->tcpci);
+ ret = devm_device_init_wakeup(chip->dev);
+ if (ret)
+ return dev_err_probe(chip->dev, ret, "Failed to init wakeup\n");
+
ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, max_tcpci_irq,
(IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev),
chip);
if (ret < 0)
return ret;
- ret = devm_device_init_wakeup(chip->dev);
- if (ret)
- return dev_err_probe(chip->dev, ret, "Failed to init wakeup\n");
-
return 0;
}
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes
2026-11-23 13:03 [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes André Draszik
2026-11-23 13:03 ` [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context André Draszik
2026-11-23 13:03 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: init wakeup before irq André Draszik
@ 2026-11-23 13:06 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-23 13:06 UTC (permalink / raw)
To: André Draszik; +Cc: linux-usb
Sashiko has reviewed this 2-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-max77759-wait-v1-0-6fa54a751bb7@linaro.org
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 13:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 13:03 [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes André Draszik
2026-11-23 13:03 ` [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context André Draszik
2026-11-23 13:03 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: init wakeup before irq André Draszik
2026-11-23 13:06 ` [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox