From: Nicholas Piggin <npiggin@gmail.com>
To: qemu-devel@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Fabiano Rosas <farosas@suse.de>,
Laurent Vivier <lvivier@redhat.com>,
Phil Dennis-Jordan <phil@philjordan.eu>,
Bernhard Beschow <shentey@gmail.com>
Subject: [PATCH v3 5/8] tests/qtest/xhci: add a test for TR NOOP commands
Date: Fri, 11 Apr 2025 17:58:47 +1000 [thread overview]
Message-ID: <20250411075851.206995-6-npiggin@gmail.com> (raw)
In-Reply-To: <20250411075851.206995-1-npiggin@gmail.com>
Run some TR NOOP commands through the transfer ring.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
tests/qtest/usb-hcd-xhci-test.c | 36 ++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/usb-hcd-xhci-test.c b/tests/qtest/usb-hcd-xhci-test.c
index b9fb2356d26..63359fb70b9 100644
--- a/tests/qtest/usb-hcd-xhci-test.c
+++ b/tests/qtest/usb-hcd-xhci-test.c
@@ -361,9 +361,33 @@ static void submit_cr_trb(XHCIQState *s, XHCITRB *trb)
xhci_db_writel(s, 0, 0); /* doorbell 0 */
}
+static void submit_tr_trb(XHCIQState *s, int slot, XHCITRB *trb)
+{
+ XHCIQSlotState *sl = &s->slots[slot];
+ uint64_t tr_addr = sl->transfer_ring + sl->tr_trb_idx * TRB_SIZE;
+ XHCITRB t;
+
+ trb->control |= sl->tr_trb_c; /* C */
+
+ t.parameter = cpu_to_le64(trb->parameter);
+ t.status = cpu_to_le32(trb->status);
+ t.control = cpu_to_le32(trb->control);
+
+ qtest_memwrite(s->parent->qts, tr_addr, &t, TRB_SIZE);
+ sl->tr_trb_idx++;
+ /* Last entry contains the link, so wrap back */
+ if (sl->tr_trb_idx == sl->tr_trb_entries - 1) {
+ set_link_trb(s, sl->transfer_ring, sl->tr_trb_c, sl->tr_trb_entries);
+ sl->tr_trb_idx = 0;
+ sl->tr_trb_c ^= 1;
+ }
+ xhci_db_writel(s, slot, 1); /* doorbell slot, EP0 target */
+}
+
/*
* This test brings up an endpoint and runs some noops through its command
- * ring and gets responses back on the event ring.
+ * ring and gets responses back on the event ring, then brings up a device
+ * context and runs some noops through its transfer ring.
*
* This could be librified in future (like AHCI0 to have a way to bring up
* an endpoint to test device protocols.
@@ -519,6 +543,16 @@ static void pci_xhci_stress_rings(void)
/* XXX: Could check EP state is running */
+ /* Wrap the transfer ring a few times */
+ for (i = 0; i < 100; i++) {
+ /* Issue a transfer ring slot 0 noop */
+ memset(&trb, 0, TRB_SIZE);
+ trb.control |= TR_NOOP << TRB_TYPE_SHIFT;
+ trb.control |= TRB_TR_IOC;
+ submit_tr_trb(s, slotid, &trb);
+ wait_event_trb(s, &trb);
+ }
+
/* Shut it down */
qpci_msix_disable(s->dev);
--
2.47.1
next prev parent reply other threads:[~2025-04-11 8:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 7:58 [PATCH v3 0/8] usb/xhci: TR NOOP, TI HCD device, more qtests Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 1/8] hw/usb/xhci: Move HCD constants to a header and add register constants Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 2/8] hw/usb/xhci: Rename and move HCD register region constants to header Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 3/8] tests/qtest/xhci: Add controller and device setup and ring tests Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 4/8] hw/usb/xhci: Support TR NOOP commands Nicholas Piggin
2025-04-11 7:58 ` Nicholas Piggin [this message]
2025-04-11 7:58 ` [PATCH v3 6/8] tests/qtest/xhci: test the qemu-xhci device Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 7/8] hw/usb/hcd-xhci-pci: Make PCI device more configurable Nicholas Piggin
2025-04-11 7:58 ` [PATCH v3 8/8] hw/usb/hcd-xhci-pci: Add TI TUSB73X0 XHCI controller model Nicholas Piggin
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=20250411075851.206995-6-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=phil@philjordan.eu \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.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 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.