From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: uttkarsh.aggarwal@oss.qualcomm.com
Cc: mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
wesley.cheng@oss.qualcomm.com
Subject: [TESTPATCH] xhci: testpatch add temporary debug to cmd ring handling
Date: Fri, 7 Nov 2025 17:46:03 +0200 [thread overview]
Message-ID: <20251107154604.1301374-1-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <5e55d9ba-6b4f-4d92-bb47-04b4a68328d2@linux.intel.com>
print messages with CMDDBG prefix if command ring is cleared
with pending commands, or fails to start due to sw state
TESTPATCH
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-ring.c | 5 ++++-
drivers/usb/host/xhci.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b9e676d37a33..f8029d837428 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -421,8 +421,11 @@ static unsigned int xhci_ring_expansion_needed(struct xhci_hcd *xhci, struct xhc
/* Ring the host controller doorbell after placing a command on the ring */
void xhci_ring_cmd_db(struct xhci_hcd *xhci)
{
- if (!(xhci->cmd_ring_state & CMD_RING_STATE_RUNNING))
+ if (!(xhci->cmd_ring_state & CMD_RING_STATE_RUNNING)) {
+ xhci_err(xhci, "%pS Failed to start cmd ring, sw cmd_ring_state %d\n",
+ __builtin_return_address(0), xhci->cmd_ring_state);
return;
+ }
xhci_dbg(xhci, "// Ding dong!\n");
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d3063f796130..fe157813c136 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -504,6 +504,14 @@ static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
dma_addr_t deq_dma;
u64 crcr;
+ if (!list_empty(&xhci->cmd_list))
+ xhci_err(xhci, "%pS CMDDBG set cmd ring deq pendig commands\n",
+ __builtin_return_address(0));
+ if (xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue)
+ xhci_err(xhci,"%pS CMDDBG set cmd ring deq: %p and enq %p mismatch\n",
+ __builtin_return_address(0),
+ xhci->cmd_ring->dequeue, xhci->cmd_ring->enqueue);
+
deq_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, xhci->cmd_ring->dequeue);
deq_dma &= CMD_RING_PTR_MASK;
@@ -871,6 +879,14 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci)
struct xhci_segment *seg;
ring = xhci->cmd_ring;
+
+ if (!list_empty(&xhci->cmd_list))
+ xhci_err(xhci, "CMDDBG Clearing command ring with pendig commands\n");
+
+ if (ring->dequeue != ring->enqueue)
+ xhci_err(xhci,"CMDDBG clear cmd ring deq: %p and enq %p mismatch\n",
+ ring->dequeue, ring->enqueue);
+
xhci_for_each_ring_seg(ring->first_seg, seg) {
/* erase all TRBs before the link */
memset(seg->trbs, 0, sizeof(union xhci_trb) * (TRBS_PER_SEGMENT - 1));
--
2.43.0
prev parent reply other threads:[~2025-11-07 15:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 10:00 [RFC PATCH] usb: host: xhci: Release spinlock before xhci_handshake in command ring abort Uttkarsh Aggarwal
2025-10-22 12:49 ` Mathias Nyman
2025-11-06 9:57 ` Uttkarsh Aggarwal
2025-11-07 13:07 ` Mathias Nyman
2025-11-07 13:11 ` Mathias Nyman
2025-11-07 15:46 ` Mathias Nyman [this message]
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=20251107154604.1301374-1-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=uttkarsh.aggarwal@oss.qualcomm.com \
--cc=wesley.cheng@oss.qualcomm.com \
/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;
as well as URLs for NNTP newsgroup(s).