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 --- 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