From: Paul Menzel <pmenzel@molgen.mpg.de>
To: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>,
George D Sworo <george.d.sworo@intel.com>,
Rajat Jain <rajatja@google.com>,
Sean Paul <seanpaul@chromium.org>,
Tzung-Bi Shih <tzungbi@chromium.org>,
Matt DeVillier <matt.devillier@gmail.com>,
Paul Menzel <pmenzel@molgen.mpg.de>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] xhci: add helper to check for pending interrupt
Date: Fri, 22 May 2026 10:58:25 +0200 [thread overview]
Message-ID: <20260522085828.24142-2-pmenzel@molgen.mpg.de> (raw)
From: Mathias Nyman <mathias.nyman@linux.intel.com>
xhci driver needs to manually check if xHC has raised an interrupt in
several places. Add a helper for it, use it in `xhci_pending_portevent()`.
Return 1 if there is a pending interrupt, -ENODEV on error (dead device),
0 otherwise.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
(cherry picked from commit 741aeecfd9a1b2437c5ee1d70745b1bfd90fb7d6
git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git for-usb-next)
[pmenzel: As of 7.1-rc4, the commit is not Linus’ master branch, so port
it from the ChromiumOS Linux kernel branch chromium/chromeos-6.12.]
BUG=b:192925463
TEST=Test S0ix for 500 cycles on brya.
Signed-off-by: George D Sworo <george.d.sworo@intel.com>
Change-Id: If7d584369e107a6497b10f3346c05e0c32920bcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3313527
Reviewed-by: Rajat Jain <rajatja@google.com>
Commit-Queue: Rajat Jain <rajatja@google.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3399807
Tested-by: Rajat Jain <rajatja@google.com>
Origin-6-6: 8651d395a93eba47285700a373c12aa53be047ea
Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Link: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/9fc38e27c31ae70d7b7829ff61cfcd18c18d3514
Assisted-by: Claude Sonnet 4.6
Cc: Matt DeVillier <matt.devillier@gmail.com>
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
drivers/usb/host/xhci.c | 17 ++++++++++++++---
drivers/usb/host/xhci.h | 1 +
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a54f5b57f205..8d4d6a524d05 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -97,6 +97,19 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, u64 timeout_us)
return ret;
}
+/* return 1 if there is a pending interrupt, -ENODEV on error, 0 otherwise */
+int xhci_pending_interrupt(struct xhci_hcd *xhci)
+{
+ u32 status;
+
+ status = readl(&xhci->op_regs->status);
+
+ if (status == ~(u32)0)
+ return -ENODEV;
+
+ return !!(status & STS_EINT);
+}
+
/*
* Disable interrupts and begin the xHCI halting process.
*/
@@ -918,11 +931,9 @@ static bool xhci_pending_portevent(struct xhci_hcd *xhci)
{
struct xhci_port **ports;
int port_index;
- u32 status;
u32 portsc;
- status = readl(&xhci->op_regs->status);
- if (status & STS_EINT)
+ if (xhci_pending_interrupt(xhci) > 0)
return true;
/*
* Checking STS_EINT is not enough as there is a lag between a change
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index aeecd301f207..82a0596c0ae9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1955,6 +1955,7 @@ void xhci_ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
void xhci_cleanup_command_queue(struct xhci_hcd *xhci);
void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring);
unsigned int count_trbs(u64 addr, u64 len);
+int xhci_pending_interrupt(struct xhci_hcd *xhci);
int xhci_stop_endpoint_sync(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
int suspend, gfp_t gfp_flags);
void xhci_process_cancelled_tds(struct xhci_virt_ep *ep);
--
2.53.0
next reply other threads:[~2026-05-22 9:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 8:58 Paul Menzel [this message]
2026-05-22 8:58 ` [PATCH 2/2] xhci: check for a pending command completion during command timeout Paul Menzel
2026-05-22 9:23 ` Greg Kroah-Hartman
2026-05-22 9:35 ` Paul Menzel
2026-05-22 10:39 ` Greg Kroah-Hartman
2026-05-22 11:11 ` Mathias Nyman
2026-05-22 12:38 ` Paul Menzel
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=20260522085828.24142-2-pmenzel@molgen.mpg.de \
--to=pmenzel@molgen.mpg.de \
--cc=george.d.sworo@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.com \
--cc=matt.devillier@gmail.com \
--cc=rajatja@google.com \
--cc=seanpaul@chromium.org \
--cc=tzungbi@chromium.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
all inboxes | Powered by JetHome®