public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
Cc: mani@kernel.org, kwilczynski@kernel.org, kishon@kernel.org,
	bhelgaas@google.com, Frank.Li@nxp.com, dlemoal@kernel.org,
	christian.bruel@foss.st.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] PCI: endpoint: pci-epf-test: Fix sleeping function being called from atomic context
Date: Thu, 9 Oct 2025 11:37:29 +0200	[thread overview]
Message-ID: <aOeCWdbdfMpWIKv_@ryzen> (raw)
In-Reply-To: <20250930023809.7931-1-bhanuseshukumar@gmail.com>

On Tue, Sep 30, 2025 at 08:08:09AM +0530, Bhanu Seshu Kumar Valluri wrote:
> When Root Complex(RC) triggers a Doorbell MSI interrupt to Endpoint(EP) it triggers a warning
> in the EP. pci_endpoint kselftest target is compiled and used to run the Doorbell test in RC.
> 
> [  474.686193] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:271
> [  474.710934] Call trace:
> [  474.710995]  __might_resched+0x130/0x158
> [  474.711011]  __might_sleep+0x70/0x88
> [  474.711023]  mutex_lock+0x2c/0x80
> [  474.711036]  pci_epc_get_msi+0x78/0xd8
> [  474.711052]  pci_epf_test_raise_irq.isra.0+0x74/0x138
> [  474.711063]  pci_epf_test_doorbell_handler+0x34/0x50
> 
> The BUG arises because the EP's pci_epf_test_doorbell_handler is making an
> indirect call to pci_epc_get_msi, which uses mutex inside, from interrupt context.
> 
> To fix the issue convert hard irq handler to a threaded irq handler to allow it
> to call functions that can sleep during bottom half execution. Register threaded
> irq handler with IRQF_ONESHOT to keep interrupt line disabled until the threaded
> irq handler completes execution.
> 
> Fixes: eff0c286aa91 ("PCI: endpoint: pci-epf-test: Add doorbell test support")
> Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
> ---

All other calls to pci_epf_test_raise_irq() is done from the workqueue.

While we could change pci_epf_test_doorbell_handler() to queue some work on
the workqueue (and let that work call pci_epf_test_raise_irq()), converting
pci_epf_test_doorbell_handler() to be a threaded IRQ handler seems like the
less invasive change, thus:

Reviewed-by: Niklas Cassel <cassel@kernel.org>

  parent reply	other threads:[~2025-10-09  9:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30  2:38 [PATCH v2] PCI: endpoint: pci-epf-test: Fix sleeping function being called from atomic context Bhanu Seshu Kumar Valluri
2025-10-09  5:51 ` Bhanu Seshu Kumar Valluri
2025-10-09  9:37 ` Niklas Cassel [this message]
2025-10-13 21:40 ` Bjorn Helgaas
2025-10-14  2:46   ` Bhanu Seshu Kumar Valluri

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=aOeCWdbdfMpWIKv_@ryzen \
    --to=cassel@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=bhanuseshukumar@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=christian.bruel@foss.st.com \
    --cc=dlemoal@kernel.org \
    --cc=kishon@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox