All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "André Draszik" <andre.draszik@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Badhri Jagan Sridharan <badhri@google.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Griffin <peter.griffin@linaro.org>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Juan Yescas <jyescas@google.com>,
	Amit Sunil Dhamne <amitsd@google.com>,
	kernel-team@android.com, linux-usb@vger.kernel.org,
	linux-rt-devel@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH 1/2] usb: typec: tcpm/tcpci_maxim: fix invalid wait context
Date: Wed, 25 Nov 2026 10:53:50 +0100	[thread overview]
Message-ID: <awawLjDE_AWj5Qkc@black.igk.intel.com> (raw)
In-Reply-To: <20261123-max77759-wait-v1-1-6fa54a751bb7@linaro.org>

On Mon, Nov 23, 2026 at 01:03:06PM +0000, André Draszik wrote:
> 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>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

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

-- 
heikki

  reply	other threads:[~2026-11-25  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-25  9:53   ` Heikki Krogerus [this message]
2026-11-23 13:03 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: init wakeup before irq André Draszik
2026-11-25  9:54   ` Heikki Krogerus
2026-11-23 13:06 ` [PATCH 0/2] usb: typec: tcpm/tcpci_maxim: lockdep and PM wakeup fixes sashiko-bot

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=awawLjDE_AWj5Qkc@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=amitsd@google.com \
    --cc=andre.draszik@linaro.org \
    --cc=badhri@google.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jyescas@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=tudor.ambarus@linaro.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 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.