From: Luca Lauro via B4 Relay <devnull+famlauro93l.gmail.com@kernel.org>
To: Sascha Hauer <s.hauer@pengutronix.de>,
"open list:BAREBOX" <barebox@lists.infradead.org>
Cc: Luca Lauro <famlauro93l@gmail.com>
Subject: [PATCH v2 09/10] usb: ehci: minor fixes for Marvell compatibility
Date: Tue, 28 Jul 2026 19:43:21 +0200 [thread overview]
Message-ID: <20260728-rn102-rn104-series-v2-9-ae31f55b7bc8@gmail.com> (raw)
In-Reply-To: <20260728-rn102-rn104-series-v2-0-ae31f55b7bc8@gmail.com>
From: Luca Lauro <famlauro93l@gmail.com>
The Marvell EHCI controller requires a slightly different initialization
sequence compared to generic EHCI implementations.
- Calling ehci_halt() before ehci_reset() can leave the controller in an
inconsistent state on Marvell SoCs. U-Boot and Linux avoid halting the
controller before issuing a reset, so drop the early ehci_halt() call.
- The periodic queue DMA address must be explicitly stored in
ehci->periodic_queue_dma. Without this, the periodic schedule points to
an uninitialized address, breaking interrupt polling and HID enumeration.
- Only allocate the periodic list when it is NULL. The previous code
allocated a new list unconditionally, leaking memory and breaking
reinitialization paths.
- Use ehci->periodic_list_dma directly without casting, as it already
contains the correct dma_addr_t value.
Whitespace-only changes have been removed.
Signed-off-by: Luca Lauro <famlauro93l@gmail.com>
---
drivers/usb/host/ehci-hcd.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 51b9e52a4f..69b20b7487 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -857,8 +857,6 @@ static int ehci_init(struct usb_host *host)
struct QH *periodic;
int i;
- ehci_halt(ehci);
-
/* EHCI spec section 4.1 */
if (ehci_reset(ehci) != 0)
return -1;
@@ -870,16 +868,16 @@ static int ehci_init(struct usb_host *host)
}
ehci->qh_list[0].qh_link = cpu_to_hc32(ehci_qh_dma(ehci, &ehci->qh_list[1]) |
- QH_LINK_TYPE_QH);
+ QH_LINK_TYPE_QH);
ehci->qh_list[0].qh_endpt1 = cpu_to_hc32(QH_ENDPT1_H(1) |
- QH_ENDPT1_EPS(USB_SPEED_HIGH));
+ QH_ENDPT1_EPS(USB_SPEED_HIGH));
ehci->qh_list[0].qh_curtd = cpu_to_hc32(QT_NEXT_TERMINATE);
ehci->qh_list[0].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
ehci->qh_list[0].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
ehci->qh_list[0].qt_token = cpu_to_hc32(QT_TOKEN_STATUS_HALTED);
ehci->qh_list[1].qh_link = cpu_to_hc32(ehci_qh_dma(ehci,
- &ehci->qh_list[0]) |
+ &ehci->qh_list[0]) |
QH_LINK_TYPE_QH);
ehci->qh_list[1].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
@@ -897,6 +895,7 @@ static int ehci_init(struct usb_host *host)
periodic->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
periodic->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
+ ehci->periodic_queue_dma = ehci_qh_dma(ehci, periodic);
/*
* Step 2: Setup frame-list: Every microframe, USB tries the same list.
* In particular, device specifications on polling frequency
@@ -906,23 +905,25 @@ static int ehci_init(struct usb_host *host)
* Split Transactions will be spread across microframes using
* S-mask and C-mask.
*/
- if (ehci->periodic_list == NULL)
+ if (ehci->periodic_list == NULL) {
+ ehci->periodic_list = dma_alloc_coherent(DMA_DEVICE_BROKEN,
+ 1024 * 4,
+ &ehci->periodic_list_dma);
+ }
/*
* FIXME: this memory chunk have to be 4k aligned AND
* reside in coherent memory. Current implementation of
* dma_alloc_coherent() allocates PAGE_SIZE aligned memory chunks.
* PAGE_SIZE less then 4k will break this code.
*/
- ehci->periodic_list = dma_alloc_coherent(DMA_DEVICE_BROKEN, 1024 * 4,
- &ehci->periodic_list_dma);
for (i = 0; i < 1024; i++) {
- ehci->periodic_list[i] = cpu_to_hc32((unsigned long)ehci->periodic_queue_dma
- | QH_LINK_TYPE_QH);
+ ehci->periodic_list[i] = cpu_to_hc32(ehci->periodic_queue_dma |
+ QH_LINK_TYPE_QH);
}
/* Set periodic list base address */
ehci_writel(&ehci->hcor->or_periodiclistbase,
- (uint32_t)ehci->periodic_list_dma);
+ ehci->periodic_list_dma);
reg = ehci_readl(&ehci->hccr->cr_hcsparams);
descriptor.hub.bNbrPorts = HCS_N_PORTS(reg);
--
2.47.3
next prev parent reply other threads:[~2026-07-28 17:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 17:43 [PATCH v2 00/10] ARM: mvebu: add Netgear RN102/RN104 support and related drivers Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 01/10] ARM: mvebu: add Netgear RN102 support Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 02/10] ARM: mvebu: enable RN102 in mvebu_defconfig Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 03/10] ARM: mvebu: add Netgear RN104 support Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 04/10] ARM: mvebu: rename PUTC_LL to MVEBU_PUTC_LL Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 05/10] drivers: fan: add fan framework and API Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 06/10] commands: add fan control command Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 07/10] commands: integrate fan command into Kconfig and Makefile Luca Lauro via B4 Relay
2026-07-28 17:43 ` [PATCH v2 08/10] usb: ehci: add Marvell EHCI host controller driver Luca Lauro via B4 Relay
2026-07-28 17:43 ` Luca Lauro via B4 Relay [this message]
2026-07-28 17:43 ` [PATCH v2 10/10] ata: ahci: add PCI AHCI support and Marvell-specific fixes Luca Lauro via B4 Relay
2026-07-29 14:48 ` Lucas Stach
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=20260728-rn102-rn104-series-v2-9-ae31f55b7bc8@gmail.com \
--to=devnull+famlauro93l.gmail.com@kernel.org \
--cc=barebox@lists.infradead.org \
--cc=famlauro93l@gmail.com \
--cc=s.hauer@pengutronix.de \
/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