From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "philmd@linaro.org" <philmd@linaro.org>,
"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>,
"flwu@google.com" <flwu@google.com>,
"nabihestefan@google.com" <nabihestefan@google.com>
Subject: [PATCH v3 03/17] hw/usb/hcd-ehci.c: Fix coding style issues reported by checkpatch
Date: Thu, 16 Apr 2026 01:49:36 +0000 [thread overview]
Message-ID: <20260416014928.1279360-4-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260416014928.1279360-1-jamin_lin@aspeedtech.com>
No functional change.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
hw/usb/hcd-ehci.c | 126 +++++++++++++++++++++++++---------------------
1 file changed, 69 insertions(+), 57 deletions(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 5ea8461f70..9b92384bac 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -41,21 +41,23 @@
#define FRAME_TIMER_NS (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)
#define UFRAME_TIMER_NS (FRAME_TIMER_NS / 8)
-#define NB_MAXINTRATE 8 // Max rate at which controller issues ints
-#define BUFF_SIZE 5*4096 // Max bytes to transfer per transaction
-#define MAX_QH 100 // Max allowable queue heads in a chain
+#define NB_MAXINTRATE 8 /* Max rate at which controller issues ints */
+#define BUFF_SIZE (5 * 4096) /* Max bytes to transfer per transaction */
+#define MAX_QH 100 /* Max allowable queue heads in a chain */
#define MIN_UFR_PER_TICK 24 /* Min frames to process when catching up */
#define PERIODIC_ACTIVE 512 /* Micro-frames */
-/* Internal periodic / asynchronous schedule state machine states
+/*
+ * Internal periodic / asynchronous schedule state machine states
*/
typedef enum {
EST_INACTIVE = 1000,
EST_ACTIVE,
EST_EXECUTING,
EST_SLEEPING,
- /* The following states are internal to the state machine function
- */
+ /*
+ * The following states are internal to the state machine function
+ */
EST_WAITLISTHEAD,
EST_FETCHENTRY,
EST_FETCHQH,
@@ -71,13 +73,13 @@ typedef enum {
/* macros for accessing fields within next link pointer entry */
#define NLPTR_GET(x) ((x) & 0xffffffe0)
#define NLPTR_TYPE_GET(x) (((x) >> 1) & 3)
-#define NLPTR_TBIT(x) ((x) & 1) // 1=invalid, 0=valid
+#define NLPTR_TBIT(x) ((x) & 1) /* 1=invalid, 0=valid */
/* link pointer types */
-#define NLPTR_TYPE_ITD 0 // isoc xfer descriptor
-#define NLPTR_TYPE_QH 1 // queue head
-#define NLPTR_TYPE_STITD 2 // split xaction, isoc xfer descriptor
-#define NLPTR_TYPE_FSTN 3 // frame span traversal node
+#define NLPTR_TYPE_ITD 0 /* isoc xfer descriptor */
+#define NLPTR_TYPE_QH 1 /* queue head */
+#define NLPTR_TYPE_STITD 2 /* split xaction, isoc xfer descriptor */
+#define NLPTR_TYPE_FSTN 3 /* frame span traversal node */
#define SET_LAST_RUN_CLOCK(s) \
(s)->last_run_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
@@ -88,10 +90,10 @@ typedef enum {
#define set_field(data, newval, field) do { \
uint32_t val = *data; \
- val &= ~ field##_MASK; \
+ val &= ~field##_MASK; \
val |= ((newval) << field##_SH) & field##_MASK; \
*data = val; \
- } while(0)
+ } while (0)
static const char *ehci_state_names[] = {
[EST_INACTIVE] = "INACTIVE",
@@ -472,8 +474,10 @@ static bool ehci_verify_pid(EHCIQueue *q, EHCIqtd *qtd)
}
}
-/* Finish executing and writeback a packet outside of the regular
- fetchqh -> fetchqtd -> execute -> writeback cycle */
+/*
+ * Finish executing and writeback a packet outside of the regular
+ * fetchqh -> fetchqtd -> execute -> writeback cycle
+ */
static void ehci_writeback_async_complete_packet(EHCIPacket *p)
{
EHCIQueue *q = p->queue;
@@ -733,7 +737,7 @@ static void ehci_detach(USBPort *port)
ehci_queues_rip_device(s, port->dev, 0);
ehci_queues_rip_device(s, port->dev, 1);
- *portsc &= ~(PORTSC_CONNECT|PORTSC_PED|PORTSC_SUSPEND);
+ *portsc &= ~(PORTSC_CONNECT | PORTSC_PED | PORTSC_SUSPEND);
*portsc |= PORTSC_CSC;
ehci_raise_irq(s, USBSTS_PCD);
@@ -858,7 +862,7 @@ void ehci_reset(void *opaque)
* Do the detach before touching portsc, so that it correctly gets send to
* us or to our companion based on PORTSC_POWNER before the reset.
*/
- for(i = 0; i < EHCI_PORTS; i++) {
+ for (i = 0; i < EHCI_PORTS; i++) {
devs[i] = s->ports[i].dev;
if (devs[i] && devs[i]->attached) {
usb_detach(&s->ports[i]);
@@ -877,7 +881,7 @@ void ehci_reset(void *opaque)
s->astate = EST_INACTIVE;
s->pstate = EST_INACTIVE;
- for(i = 0; i < EHCI_PORTS; i++) {
+ for (i = 0; i < EHCI_PORTS; i++) {
if (s->companion_ports[i]) {
s->portsc[i] = PORTSC_POWNER | PORTSC_PPOWER;
} else {
@@ -942,8 +946,9 @@ static void handle_port_owner_write(EHCIState *s, int port, uint32_t owner)
uint32_t *portsc = &s->portsc[port];
uint32_t orig;
- if (s->companion_ports[port] == NULL)
+ if (s->companion_ports[port] == NULL) {
return;
+ }
owner = owner & PORTSC_POWNER;
orig = *portsc & PORTSC_POWNER;
@@ -988,7 +993,7 @@ static void ehci_port_write(void *ptr, hwaddr addr,
trace_usb_ehci_port_reset(port, 1);
}
- if (!(val & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {
+ if (!(val & PORTSC_PRESET) && (*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 0);
if (dev && dev->attached) {
usb_port_reset(&s->ports[port]);
@@ -1065,8 +1070,10 @@ static void ehci_opreg_write(void *ptr, hwaddr addr,
break;
case USBSTS:
- val &= USBSTS_RO_MASK; // bits 6 through 31 are RO
- ehci_clear_usbsts(s, val); // bits 0 through 5 are R/WC
+ /* bits 6 through 31 are RO */
+ val &= USBSTS_RO_MASK;
+ /* bits 0 through 5 are R/WC */
+ ehci_clear_usbsts(s, val);
val = s->usbsts;
ehci_update_irq(s);
break;
@@ -1131,8 +1138,7 @@ static void ehci_flush_qh(EHCIQueue *q)
put_dwords(q->ehci, addr + 3 * sizeof(uint32_t), qh + 3, dwords - 3);
}
-// 4.10.2
-
+/* 4.10.2 */
static int ehci_qh_do_overlay(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
@@ -1145,8 +1151,7 @@ static int ehci_qh_do_overlay(EHCIQueue *q)
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
- // remember values in fields to preserve in qh after overlay
-
+ /* remember values in fields to preserve in qh after overlay */
dtoggle = q->qh.token & QTD_TOKEN_DTOGGLE;
ping = q->qh.token & QTD_TOKEN_PING;
@@ -1170,7 +1175,7 @@ static int ehci_qh_do_overlay(EHCIQueue *q)
}
if (!(q->qh.epchar & QH_EPCHAR_DTC)) {
- // preserve QH DT bit
+ /* preserve QH DT bit */
q->qh.token &= ~QTD_TOKEN_DTOGGLE;
q->qh.token |= dtoggle;
}
@@ -1397,9 +1402,7 @@ static int ehci_execute(EHCIPacket *p, const char *action)
return 1;
}
-/* 4.7.2
- */
-
+/* 4.7.2 */
static int ehci_process_itd(EHCIState *ehci,
EHCIitd *itd,
uint32_t addr)
@@ -1411,13 +1414,13 @@ static int ehci_process_itd(EHCIState *ehci,
ehci->periodic_sched_active = PERIODIC_ACTIVE;
- dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
+ dir = (itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT);
- for(i = 0; i < 8; i++) {
+ for (i = 0; i < 8; i++) {
if (itd->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(itd->transact[i], ITD_XACT_PGSEL);
off = itd->transact[i] & ITD_XACT_OFFSET_MASK;
@@ -1513,8 +1516,9 @@ static int ehci_process_itd(EHCIState *ehci,
}
-/* This state is the entry point for asynchronous schedule
- * processing. Entry here constitutes a EHCI start event state (4.8.5)
+/*
+ * This state is the entry point for asynchronous schedule
+ * processing. Entry here constitutes a EHCI start event state (4.8.5)
*/
static int ehci_state_waitlisthead(EHCIState *ehci, int async)
{
@@ -1531,7 +1535,7 @@ static int ehci_state_waitlisthead(EHCIState *ehci, int async)
ehci_queues_rip_unused(ehci, async);
/* Find the head of the list (4.9.1.1) */
- for(i = 0; i < MAX_QH; i++) {
+ for (i = 0; i < MAX_QH; i++) {
if (get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2) < 0) {
return 0;
@@ -1564,8 +1568,9 @@ out:
}
-/* This state is the entry point for periodic schedule processing as
- * well as being a continuation state for async processing.
+/*
+ * This state is the entry point for periodic schedule processing as
+ * well as being a continuation state for async processing.
*/
static int ehci_state_fetchentry(EHCIState *ehci, int async)
{
@@ -1674,7 +1679,7 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
#if EHCI_DEBUG
if (q->qhaddr != q->qh.next) {
- DPRINTF("FETCHQH: QH 0x%08x (h %x halt %x active %x) next 0x%08x\n",
+ DPRINTF("FETCHQH: QH 0x%08x (h %x halt %x active %x) next 0x%08x\n",
q->qhaddr,
q->qh.epchar & QH_EPCHAR_H,
q->qh.token & QTD_TOKEN_HALT,
@@ -1924,8 +1929,10 @@ static int ehci_state_execute(EHCIQueue *q)
return -1;
}
- // TODO verify enough time remains in the uframe as in 4.4.1.1
- // TODO write back ptr to async list when done or out of time
+ /*
+ * TODO verify enough time remains in the uframe as in 4.4.1.1
+ * TODO write back ptr to async list when done or out of time
+ */
/* 4.10.3, bottom of page 82, go horizontal on transaction counter == 0 */
if (!q->async && q->transact_ctr == 0) {
@@ -2036,7 +2043,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
int again;
do {
- switch(ehci_get_state(ehci, async)) {
+ switch (ehci_get_state(ehci, async)) {
case EST_WAITLISTHEAD:
again = ehci_state_waitlisthead(ehci, async);
break;
@@ -2115,21 +2122,20 @@ static void ehci_advance_state(EHCIState *ehci, int async)
ehci_reset(ehci);
again = 0;
}
- }
- while (again);
+ } while (again);
}
static void ehci_advance_async_state(EHCIState *ehci)
{
const int async = 1;
- switch(ehci_get_state(ehci, async)) {
+ switch (ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!ehci_async_enabled(ehci)) {
break;
}
ehci_set_state(ehci, async, EST_ACTIVE);
- // No break, fall through to ACTIVE
+ /* No break, fall through to ACTIVE */
case EST_ACTIVE:
if (!ehci_async_enabled(ehci)) {
@@ -2153,7 +2159,8 @@ static void ehci_advance_async_state(EHCIState *ehci)
ehci_set_state(ehci, async, EST_WAITLISTHEAD);
ehci_advance_state(ehci, async);
- /* If the doorbell is set, the guest wants to make a change to the
+ /*
+ * If the doorbell is set, the guest wants to make a change to the
* schedule. The host controller needs to release cached data.
* (section 4.8.2)
*/
@@ -2180,13 +2187,13 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
uint32_t list;
const int async = 0;
- // 4.6
+ /* 4.6 */
- switch(ehci_get_state(ehci, async)) {
+ switch (ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!(ehci->frindex & 7) && ehci_periodic_enabled(ehci)) {
ehci_set_state(ehci, async, EST_ACTIVE);
- // No break, fall through to ACTIVE
+ /* No break, fall through to ACTIVE */
} else
break;
@@ -2210,7 +2217,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
DPRINTF("PERIODIC state adv fr=%d. [%08X] -> %08X\n",
ehci->frindex / 8, list, entry);
- ehci_set_fetch_addr(ehci, async,entry);
+ ehci_set_fetch_addr(ehci, async, entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
ehci_advance_state(ehci, async);
ehci_queues_rip_unused(ehci, async);
@@ -2235,7 +2242,8 @@ static void ehci_update_frindex(EHCIState *ehci, int uframes)
ehci_raise_irq(ehci, USBSTS_FLR);
}
- /* How many times will frindex roll over 0x4000 with this frame count?
+ /*
+ * How many times will frindex roll over 0x4000 with this frame count?
* usbsts_frindex is decremented by 0x4000 on rollover until it reaches 0
*/
int rollovers = (ehci->frindex + uframes) / 0x4000;
@@ -2315,8 +2323,9 @@ static void ehci_work_bh(void *opaque)
ehci->async_stepdown++;
}
- /* Async is not inside loop since it executes everything it can once
- * called
+ /*
+ * Async is not inside loop since it executes everything it can once
+ * called
*/
if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) {
need_timer++;
@@ -2334,15 +2343,18 @@ static void ehci_work_bh(void *opaque)
}
if (need_timer) {
- /* If we've raised int, we speed up the timer, so that we quickly
- * notice any new packets queued up in response */
+ /*
+ * If we've raised int, we speed up the timer, so that we quickly
+ * notice any new packets queued up in response
+ */
if (ehci->int_req_by_async && (ehci->usbsts & USBSTS_INT)) {
expire_time = t_now +
NANOSECONDS_PER_SECOND / (FRAME_TIMER_FREQ * 4);
ehci->int_req_by_async = false;
} else {
- expire_time = t_now + (NANOSECONDS_PER_SECOND
- * (ehci->async_stepdown+1) / FRAME_TIMER_FREQ);
+ expire_time = t_now
+ + (NANOSECONDS_PER_SECOND * (ehci->async_stepdown + 1) /
+ FRAME_TIMER_FREQ);
}
timer_mod(ehci->frame_timer, expire_time);
}
--
2.43.0
next prev parent reply other threads:[~2026-04-16 1:52 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 1:49 [PATCH v3 00/17] hw/usb/ehci: Add 64-bit descriptor addressing support Jamin Lin
2026-04-16 1:49 ` [PATCH v3 01/17] hw/usb/hcd-ehci: Remove unused EHCIfstn structure and dead code Jamin Lin
2026-04-16 12:09 ` BALATON Zoltan
2026-04-17 1:16 ` Jamin Lin
2026-04-17 2:25 ` Jamin Lin
2026-04-17 9:47 ` BALATON Zoltan
2026-04-20 3:46 ` Jamin Lin
2026-04-17 6:30 ` Cédric Le Goater
2026-04-16 1:49 ` [PATCH v3 02/17] hw/usb/hcd-ehci.h: Fix coding style issues reported by checkpatch Jamin Lin
2026-04-17 6:32 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` Jamin Lin [this message]
2026-04-17 6:31 ` [PATCH v3 03/17] hw/usb/hcd-ehci.c: " Cédric Le Goater
2026-04-17 6:32 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 04/17] hw/usb/hcd-ehci.c: Replace fprintf(stderr, ...) with qemu_log_mask(LOG_GUEST_ERROR) Jamin Lin
2026-04-17 6:31 ` Philippe Mathieu-Daudé
2026-04-17 8:41 ` Jamin Lin
2026-04-16 1:49 ` [PATCH v3 05/17] hw/usb/hcd-ehci: Replace DPRINTF debug logs with trace events Jamin Lin
2026-04-17 5:04 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 06/17] hw/usb/hcd-ehci: Change descriptor addresses to 64-bit Jamin Lin
2026-04-17 4:54 ` Philippe Mathieu-Daudé
2026-04-17 7:01 ` Cédric Le Goater
2026-04-17 15:10 ` Peter Xu
2026-04-20 5:56 ` Jamin Lin
2026-04-20 13:34 ` Peter Xu
2026-04-22 9:21 ` Jamin Lin
2026-04-22 14:37 ` Peter Xu
2026-04-23 1:48 ` Jamin Lin
2026-04-23 16:03 ` Peter Xu
2026-04-20 16:04 ` Cédric Le Goater
2026-04-22 9:10 ` Jamin Lin
2026-04-16 1:49 ` [PATCH v3 07/17] hw/usb/hcd-ehci: Add property to advertise 64-bit addressing capability Jamin Lin
2026-04-17 4:55 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 08/17] hw/usb/hcd-ehci: Reject CTRLDSSEGMENT writes without 64-bit capability Jamin Lin
2026-04-17 6:33 ` Philippe Mathieu-Daudé
2026-04-17 8:07 ` Jamin Lin
2026-04-16 1:49 ` [PATCH v3 09/17] hw/usb/hcd-ehci: Implement 64-bit QH descriptor addressing Jamin Lin
2026-04-17 5:03 ` Philippe Mathieu-Daudé
2026-04-17 5:40 ` Jamin Lin
2026-04-17 6:14 ` Philippe Mathieu-Daudé
2026-04-17 7:02 ` Jamin Lin
2026-04-16 1:49 ` [PATCH v3 10/17] hw/usb/hcd-ehci: Implement 64-bit qTD " Jamin Lin
2026-04-17 6:14 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 11/17] hw/usb/hcd-ehci: Implement 64-bit iTD " Jamin Lin
2026-04-17 6:15 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 12/17] hw/usb/hcd-ehci: Implement 64-bit siTD " Jamin Lin
2026-04-17 6:27 ` Philippe Mathieu-Daudé
2026-04-17 7:44 ` Jamin Lin
2026-04-17 8:42 ` Philippe Mathieu-Daudé
2026-04-16 1:49 ` [PATCH v3 13/17] hw/usb/hcd-ehci: Add descriptor address offset property Jamin Lin
2026-04-17 6:23 ` Philippe Mathieu-Daudé
2026-04-22 5:00 ` Jamin Lin
2026-04-17 6:45 ` Cédric Le Goater
2026-04-17 7:08 ` Philippe Mathieu-Daudé
2026-04-20 5:47 ` Jamin Lin
2026-04-20 7:08 ` Cédric Le Goater
2026-04-22 6:58 ` Jamin Lin
2026-04-16 1:50 ` [PATCH v3 14/17] hw/arm/aspeed_ast27x0: Enable 64-bit EHCI DMA addressing Jamin Lin
2026-04-17 6:23 ` Philippe Mathieu-Daudé
2026-04-16 1:50 ` [PATCH v3 15/17] hw/arm/aspeed_ast27x0: Set EHCI descriptor address offset Jamin Lin
2026-04-17 6:25 ` Philippe Mathieu-Daudé
2026-04-22 5:03 ` Jamin Lin
2026-04-16 1:50 ` [PATCH v3 16/17] tests/functional/arm/test_aspeed_ast2600_sdk: Add USB EHCI test for AST2600 SDK Jamin Lin
2026-04-17 6:27 ` Philippe Mathieu-Daudé
2026-04-17 7:40 ` Jamin Lin
2026-04-17 8:44 ` Philippe Mathieu-Daudé
2026-04-17 8:50 ` Jamin Lin
2026-04-16 1:50 ` [PATCH v3 17/17] tests/functional/aarch64/test_aspeed_ast2700: Add USB EHCI test for AST2700 A1/A2 Jamin Lin
2026-04-17 6:27 ` Philippe Mathieu-Daudé
2026-04-17 6:35 ` [PATCH v3 00/17] hw/usb/ehci: Add 64-bit descriptor addressing support Philippe Mathieu-Daudé
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=20260416014928.1279360-4-jamin_lin@aspeedtech.com \
--to=jamin_lin@aspeedtech.com \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=flwu@google.com \
--cc=joel@jms.id.au \
--cc=kane_chen@aspeedtech.com \
--cc=leetroy@gmail.com \
--cc=nabihestefan@google.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@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.