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 Acked-by: Heikki Krogerus Signed-off-by: André Draszik --- 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.839.g22a8290db9-goog