All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>
Subject: [PATCH v2 09/11] hw/usb/aspeed-udc: Add trace events for the transfer paths
Date: Mon, 5 Oct 2026 06:44:29 +0000	[thread overview]
Message-ID: <20261005064418.3060881-10-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20261005064418.3060881-1-jamin_lin@aspeedtech.com>

The register traces show what the guest wrote, but not which transfer
path the write chose, how much each call moved, or when the host gave up
on a packet.

Add one event per path, so the name says which path ran and a single
path can be enabled on its own: a kick, a transfer result, and a
cancelled packet.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/usb/aspeed-udc.c | 23 +++++++++++++++++++++++
 hw/usb/trace-events |  7 +++++++
 2 files changed, 30 insertions(+)

diff --git a/hw/usb/aspeed-udc.c b/hw/usb/aspeed-udc.c
index 09f5913aef..1c99e45d9a 100644
--- a/hw/usb/aspeed-udc.c
+++ b/hw/usb/aspeed-udc.c
@@ -565,6 +565,9 @@ static AspeedUDCXferResult aspeed_udc_ep_xfer_in_desc(AspeedUDCState *s,
         aspeed_udc_raise_ep_ack(s, ep);
     }
 
+    trace_aspeed_udc_ep_xfer_in_desc(ep, (uint32_t)p->actual_length,
+                                     done ? "done" : "more");
+
     return done ? ASPEED_UDC_XFER_DONE : ASPEED_UDC_XFER_MORE;
 }
 
@@ -606,6 +609,9 @@ static AspeedUDCXferResult aspeed_udc_ep_xfer_in_single(AspeedUDCState *s,
      * buffer, and the next IN request sends the rest.
      */
     if (e->single_buf_off < buf_len) {
+        trace_aspeed_udc_ep_xfer_in_single(ep,
+                                           (uint32_t)p->actual_length,
+                                           "buffer left");
         return ASPEED_UDC_XFER_DONE;
     }
 
@@ -619,6 +625,9 @@ static AspeedUDCXferResult aspeed_udc_ep_xfer_in_single(AspeedUDCState *s,
                                         PROC_STS, EP_DMA_CTRL_STS_TX_IDLE);
     aspeed_udc_raise_ep_ack(s, ep);
 
+    trace_aspeed_udc_ep_xfer_in_single(ep, (uint32_t)p->actual_length,
+                                       "done");
+
     return ASPEED_UDC_XFER_DONE;
 }
 
@@ -664,9 +673,15 @@ static AspeedUDCXferResult aspeed_udc_ep_xfer_out_single(AspeedUDCState *s,
     aspeed_udc_raise_ep_ack(s, ep);
 
     if ((uint32_t)p->actual_length >= pktiov->size) {
+        trace_aspeed_udc_ep_xfer_out_single(ep,
+                                            (uint32_t)p->actual_length,
+                                            "done");
         return ASPEED_UDC_XFER_DONE;
     }
 
+    trace_aspeed_udc_ep_xfer_out_single(ep, (uint32_t)p->actual_length,
+                                        "more");
+
     return ASPEED_UDC_XFER_MORE;
 }
 
@@ -686,6 +701,8 @@ static void aspeed_udc_ep_in_kick_desc(AspeedUDCState *s, int ep,
     uint32_t cur_rptr = FIELD_EX32(old_val, EP_DMA_STS, RPTR);
     USBPacket *p = e->pkt;
 
+    trace_aspeed_udc_ep_in_kick_desc(ep);
+
     /*
      * A normal kick only sets the write pointer and leaves the read-pointer
      * field 0 (the read pointer is ours to advance). The guest resets the ring
@@ -735,6 +752,8 @@ static void aspeed_udc_ep_in_kick_single(AspeedUDCState *s, int ep)
     AspeedUDCEP *e = &s->ep[ep];
     USBPacket *p = e->pkt;
 
+    trace_aspeed_udc_ep_in_kick_single(ep);
+
     /* Do nothing if no host request is waiting, or no buffer was queued. */
     if (!p || !FIELD_EX32(e->regs[R_EP_DMA_STS], EP_DMA_STS, WPTR)) {
         return;
@@ -770,6 +789,8 @@ static void aspeed_udc_ep_out_kick_single(AspeedUDCState *s, int ep)
     AspeedUDCEP *e = &s->ep[ep];
     USBPacket *p = e->pkt;
 
+    trace_aspeed_udc_ep_out_kick_single(ep);
+
     /* nothing to do unless an OUT packet is waiting and a buffer is ready */
     if (!p || !FIELD_EX32(e->regs[R_EP_DMA_STS], EP_DMA_STS, WPTR)) {
         return;
@@ -1155,6 +1176,8 @@ static void aspeed_udc_gadget_cancel_packet(USBDevice *udev, USBPacket *p)
     AspeedUDCState *s = ASPEED_UDC_GADGET(udev)->udc;
     int i;
 
+    trace_aspeed_udc_cancel_packet(p->ep->nr);
+
     if (s->ep0_packet == p) {
         s->ep0_packet = NULL;
     }
diff --git a/hw/usb/trace-events b/hw/usb/trace-events
index aa260dacad..661011b07e 100644
--- a/hw/usb/trace-events
+++ b/hw/usb/trace-events
@@ -395,3 +395,10 @@ aspeed_udc_handle_data(int ep_nr, const char *dir, uint32_t iov, int ep_idx) "ep
 aspeed_udc_ep_data_in(unsigned ep, uint32_t rptr, uint32_t wptr, uint32_t iov) "ep %u, rptr %u, wptr %u, iov %u"
 aspeed_udc_ep_data_out(unsigned ep, uint32_t wptr, uint32_t avail, uint32_t iov) "ep %u, wptr %u, avail %u, iov %u"
 aspeed_udc_ep_ack(unsigned ep) "ep %u"
+aspeed_udc_ep_in_kick_desc(int ep) "ep %d"
+aspeed_udc_ep_in_kick_single(int ep) "ep %d"
+aspeed_udc_ep_out_kick_single(int ep) "ep %d"
+aspeed_udc_ep_xfer_in_desc(int ep, uint32_t sent, const char *res) "ep %d, sent %u, %s"
+aspeed_udc_ep_xfer_in_single(int ep, uint32_t sent, const char *res) "ep %d, sent %u, %s"
+aspeed_udc_ep_xfer_out_single(int ep, uint32_t received, const char *res) "ep %d, received %u, %s"
+aspeed_udc_cancel_packet(int ep) "ep %d"
-- 
2.43.0


  parent reply	other threads:[~2026-10-05  6:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05  6:44 [PATCH v2 00/11] hw/usb/aspeed-udc: Add AST1030 UDC support Jamin Lin
2026-10-05  6:44 ` [PATCH v2 01/11] hw/usb/aspeed-udc: Make the SETUP buffer byte addressable Jamin Lin
2026-10-12  6:27   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 02/11] hw/usb/aspeed-udc: Mask the reserved bits on register writes Jamin Lin
2026-10-12  6:27   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 03/11] hw/usb/aspeed-udc: Clear EP_POOL_ACK when no endpoint ack is left Jamin Lin
2026-10-12  6:28   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 04/11] hw/usb/aspeed-udc: Rename the transfer helpers after their DMA mode Jamin Lin
2026-10-12  6:28   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 05/11] hw/usb/aspeed-udc: Store the EP_DMA_STS write first Jamin Lin
2026-10-12  6:28   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 06/11] hw/usb/aspeed-udc: Pick the EP_DMA_STS path by direction Jamin Lin
2026-10-12  6:29   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 07/11] hw/usb/aspeed-udc: Support single-stage IN transfers Jamin Lin
2026-10-05  6:44 ` [PATCH v2 08/11] hw/usb/aspeed-udc: Use the endpoint max packet size for OUT transfers Jamin Lin
2026-10-05  6:44 ` Jamin Lin [this message]
2026-10-12  6:29   ` [PATCH v2 09/11] hw/usb/aspeed-udc: Add trace events for the transfer paths Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 10/11] hw/arm/aspeed_ast10x0: Add the USB device controller Jamin Lin
2026-10-12  6:29   ` Cédric Le Goater
2026-10-05  6:44 ` [PATCH v2 11/11] tests/functional/arm/test_aspeed_ast1030: Test the usbredir server transport Jamin Lin

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=20261005064418.3060881-10-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=kane_chen@aspeedtech.com \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=troy_lee@aspeedtech.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.