From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Kane Chen" <kane_chen@aspeedtech.com>,
"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>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PATCH v3 06/12] hw/usb/aspeed-udc: Store the EP_DMA_STS write first
Date: Tue, 10 Nov 2026 08:29:24 +0000 [thread overview]
Message-ID: <20261110082917.240329-7-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20261110082917.240329-1-jamin_lin@aspeedtech.com>
The other helpers run after EP_DMA_STS is written. The descriptor mode
kick did not: it had to run before the write, because it stored the
value itself.
Write the register first in every case, then call the helper. The order
is now the same everywhere, so a later change cannot go wrong on it,
and the code is easier to maintain.
No functional change.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/usb/aspeed-udc.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/usb/aspeed-udc.c b/hw/usb/aspeed-udc.c
index 33a197af54..5f7b9f94f0 100644
--- a/hw/usb/aspeed-udc.c
+++ b/hw/usb/aspeed-udc.c
@@ -629,12 +629,13 @@ static AspeedUDCXferResult aspeed_udc_ep_xfer_out_single(AspeedUDCState *s,
* If the request needs more data than was queued, keep it parked and wait for
* the next kick.
*/
-static void aspeed_udc_ep_in_kick_desc(AspeedUDCState *s, int ep, uint32_t val)
+static void aspeed_udc_ep_in_kick_desc(AspeedUDCState *s, int ep,
+ uint32_t old_val)
{
AspeedUDCEP *e = &s->ep[ep];
- uint32_t cur_rptr = FIELD_EX32(e->regs[R_EP_DMA_STS], EP_DMA_STS, RPTR);
- uint32_t new_rptr = FIELD_EX32(val, EP_DMA_STS, RPTR);
- uint32_t new_wptr = FIELD_EX32(val, EP_DMA_STS, WPTR);
+ uint32_t new_rptr = FIELD_EX32(e->regs[R_EP_DMA_STS], EP_DMA_STS, RPTR);
+ uint32_t new_wptr = FIELD_EX32(e->regs[R_EP_DMA_STS], EP_DMA_STS, WPTR);
+ uint32_t cur_rptr = FIELD_EX32(old_val, EP_DMA_STS, RPTR);
USBPacket *p = e->pkt;
/*
@@ -651,8 +652,9 @@ static void aspeed_udc_ep_in_kick_desc(AspeedUDCState *s, int ep, uint32_t val)
cur_rptr = new_rptr;
e->desc_off = 0;
}
- /* store the guest's write, but keep our own read pointer */
- e->regs[R_EP_DMA_STS] = FIELD_DP32(val, EP_DMA_STS, RPTR, cur_rptr);
+ /* keep our own read pointer */
+ e->regs[R_EP_DMA_STS] = FIELD_DP32(e->regs[R_EP_DMA_STS], EP_DMA_STS,
+ RPTR, cur_rptr);
/* nothing to do unless an IN packet is waiting and the ring has data */
if (!p || cur_rptr == new_wptr) {
@@ -725,6 +727,7 @@ static void aspeed_udc_ep_write(void *opaque, hwaddr offset, uint64_t data,
AspeedUDCEP *e = opaque;
AspeedUDCState *s = container_of(e - e->index, AspeedUDCState, ep[0]);
uint32_t reg = offset >> 2;
+ uint32_t old_val = e->regs[reg];
uint32_t val = data;
trace_aspeed_udc_ep_write(e->index, offset, val);
@@ -735,12 +738,12 @@ static void aspeed_udc_ep_write(void *opaque, hwaddr offset, uint64_t data,
break;
case R_EP_DMA_STS:
val &= 0x77ffffff;
+ e->regs[reg] = val;
if (FIELD_EX32(e->regs[R_EP_DMA_CTRL], EP_DMA_CTRL, DESC_OP_EN)) {
/* IN, descriptor-list mode */
- aspeed_udc_ep_in_kick_desc(s, e->index, val);
+ aspeed_udc_ep_in_kick_desc(s, e->index, old_val);
} else {
/* OUT, single-stage mode */
- e->regs[reg] = val;
aspeed_udc_ep_out_kick_single(s, e->index);
}
break;
--
2.43.0
next prev parent reply other threads:[~2026-11-10 8:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:29 [PATCH v3 00/12] hw/usb/aspeed-udc: Add AST1030 UDC support Jamin Lin
2026-11-10 8:29 ` [PATCH v3 01/12] hw/usb/aspeed-udc: Make the SETUP buffer byte addressable Jamin Lin
2026-11-10 8:29 ` [PATCH v3 02/12] hw/usb/aspeed-udc: Finish an EP0 IN transfer at the status stage Jamin Lin
2026-11-10 8:29 ` [PATCH v3 03/12] hw/usb/aspeed-udc: Mask the reserved bits on register writes Jamin Lin
2026-11-10 8:29 ` [PATCH v3 04/12] hw/usb/aspeed-udc: Clear EP_POOL_ACK when no endpoint ack is left Jamin Lin
2026-11-10 8:29 ` [PATCH v3 05/12] hw/usb/aspeed-udc: Rename the transfer helpers after their DMA mode Jamin Lin
2026-11-10 8:29 ` Jamin Lin [this message]
2026-11-10 8:29 ` [PATCH v3 07/12] hw/usb/aspeed-udc: Pick the EP_DMA_STS path by direction Jamin Lin
2026-11-10 8:29 ` [PATCH v3 08/12] hw/usb/aspeed-udc: Support single-stage IN transfers Jamin Lin
2026-11-10 8:29 ` [PATCH v3 09/12] hw/usb/aspeed-udc: Use the endpoint max packet size for OUT transfers Jamin Lin
2026-11-10 8:29 ` [PATCH v3 10/12] hw/usb/aspeed-udc: Add trace events for the transfer paths Jamin Lin
2026-11-10 8:29 ` [PATCH v3 11/12] hw/arm/aspeed_ast10x0: Add the USB device controller Jamin Lin
2026-11-10 8:29 ` [PATCH v3 12/12] 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=20261110082917.240329-7-jamin_lin@aspeedtech.com \
--to=jamin_lin@aspeedtech.com \
--cc=clg@kaod.org \
--cc=clg@redhat.com \
--cc=kane_chen@aspeedtech.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--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.