* [PATCH 0/2] Possible xHCI driver fix for ZHAOXIN hosts
@ 2024-12-17 11:29 Niklas Neronin
2024-12-17 11:29 ` [PATCH 1/2] usb: xhci: set page size to the xHCI-supported size Niklas Neronin
2024-12-17 11:29 ` [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts" Niklas Neronin
0 siblings, 2 replies; 4+ messages in thread
From: Niklas Neronin @ 2024-12-17 11:29 UTC (permalink / raw)
To: WeitaoWang-oc, mathias.nyman; +Cc: linux-usb, Niklas Neronin
Hi Weitao Wang,
You fixed an issue in the Linux xHCI driver which concerned TRB prefetch on
ZHAOXIN hosts [1]. The fix was to allocate two pages for a segment instead
of one, on some ZHAOXIN hosts.
I recently noticed that the xHCI driver always sets the page size to 4096
bytes, regardless of whether a 4096-page size is supported. This may be the
root issue that your patch fixed.
I do not have access to a ZHAOXIN system, so could you please test the two
patches? The first patch sets the xHCI page size to the size supported by
the xHCI controller, and the second patch reverts your fix [1].
The patches are built on top of Linux 6.12.
[1], commit 2a865a652299 ("xhci: Fix TRB prefetch issue of ZHAOXIN hosts")
Niklas Neronin (2):
usb: xhci: set page size to the xHCI-supported size
Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts"
drivers/usb/host/xhci-mem.c | 36 ++++++++++++++----------------------
drivers/usb/host/xhci-pci.c | 7 +------
drivers/usb/host/xhci.h | 10 +++++-----
3 files changed, 20 insertions(+), 33 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] usb: xhci: set page size to the xHCI-supported size
2024-12-17 11:29 [PATCH 0/2] Possible xHCI driver fix for ZHAOXIN hosts Niklas Neronin
@ 2024-12-17 11:29 ` Niklas Neronin
2024-12-17 11:29 ` [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts" Niklas Neronin
1 sibling, 0 replies; 4+ messages in thread
From: Niklas Neronin @ 2024-12-17 11:29 UTC (permalink / raw)
To: WeitaoWang-oc, mathias.nyman; +Cc: linux-usb, Niklas Neronin
The current xHCI driver does not validate whether a page size of 4096
bytes is supported. Address the issue by setting the page size to the
value supported by the xHCI controller, as read from the Page Size
register.
Additionally, this commit removes unnecessary debug messages and instead
prints the supported and used page size once.
The xHCI controller supports page sizes of (2^{(n+12)}) bytes, where 'n'
is the Page Size Bit. Only one page size is supported, with a maximum
page size of 128 KB.
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
drivers/usb/host/xhci-mem.c | 28 ++++++++++++----------------
drivers/usb/host/xhci.h | 8 ++++----
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d2900197a49e..471afeba2828 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1959,7 +1959,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
xhci->interrupters = NULL;
xhci->page_size = 0;
- xhci->page_shift = 0;
xhci->usb2_rhub.bus_state.bus_suspended = 0;
xhci->usb3_rhub.bus_state.bus_suspended = 0;
}
@@ -2378,6 +2377,16 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs,
}
EXPORT_SYMBOL_GPL(xhci_create_secondary_interrupter);
+static void xhci_hcd_page_size(struct xhci_hcd *xhci)
+{
+ u32 page_shift;
+
+ page_shift = readl(&xhci->op_regs->page_size) & XHCI_PAGE_SIZE_MASK;
+ xhci->page_size = page_shift << 12;
+ xhci_dbg_trace(xhci, trace_xhci_dbg_init, "HCD page size set to %iK",
+ xhci->page_size >> 10);
+}
+
int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
{
struct xhci_interrupter *ir;
@@ -2385,7 +2394,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
dma_addr_t dma;
unsigned int val, val2;
u64 val_64;
- u32 page_size, temp;
+ u32 temp;
int i;
INIT_LIST_HEAD(&xhci->cmd_list);
@@ -2394,20 +2403,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
init_completion(&xhci->cmd_ring_stop_completion);
- page_size = readl(&xhci->op_regs->page_size);
- xhci_dbg_trace(xhci, trace_xhci_dbg_init,
- "Supported page size register = 0x%x", page_size);
- i = ffs(page_size);
- if (i < 16)
- xhci_dbg_trace(xhci, trace_xhci_dbg_init,
- "Supported page size of %iK", (1 << (i+12)) / 1024);
- else
- xhci_warn(xhci, "WARN: no supported page size\n");
- /* Use 4K pages, since that's common and the minimum the HC supports */
- xhci->page_shift = 12;
- xhci->page_size = 1 << xhci->page_shift;
- xhci_dbg_trace(xhci, trace_xhci_dbg_init,
- "HCD page size set to %iK", xhci->page_size / 1024);
+ xhci_hcd_page_size(xhci);
/*
* Program the Number of Device Slots Enabled field in the CONFIG
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f0fb696d5619..03c0f2226571 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -211,6 +211,9 @@ struct xhci_op_regs {
#define CONFIG_CIE (1 << 9)
/* bits 10:31 - reserved and should be preserved */
+/* bits 15:0 - HCD page shift bit */
+#define XHCI_PAGE_SIZE_MASK 0xffff
+
/**
* struct xhci_intr_reg - Interrupt Register Set
* @irq_pending: IMAN - Interrupt Management Register. Used to enable
@@ -1502,10 +1505,7 @@ struct xhci_hcd {
u16 max_interrupters;
/* imod_interval in ns (I * 250ns) */
u32 imod_interval;
- /* 4KB min, 128MB max */
- int page_size;
- /* Valid values are 12 to 20, inclusive */
- int page_shift;
+ u32 page_size;
/* MSI-X/MSI vectors */
int nvecs;
/* optional clocks */
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts"
2024-12-17 11:29 [PATCH 0/2] Possible xHCI driver fix for ZHAOXIN hosts Niklas Neronin
2024-12-17 11:29 ` [PATCH 1/2] usb: xhci: set page size to the xHCI-supported size Niklas Neronin
@ 2024-12-17 11:29 ` Niklas Neronin
2024-12-18 6:55 ` Greg KH
1 sibling, 1 reply; 4+ messages in thread
From: Niklas Neronin @ 2024-12-17 11:29 UTC (permalink / raw)
To: WeitaoWang-oc, mathias.nyman; +Cc: linux-usb, Niklas Neronin
This reverts commit 2a865a652299f5666f3b785cbe758c5f57453036.
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
drivers/usb/host/xhci-mem.c | 8 ++------
drivers/usb/host/xhci-pci.c | 7 +------
drivers/usb/host/xhci.h | 2 +-
3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 471afeba2828..3a0b98a427e9 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2439,12 +2439,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
* and our use of dma addresses in the trb_address_map radix tree needs
* TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need.
*/
- if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH)
- xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
- TRB_SEGMENT_SIZE * 2, TRB_SEGMENT_SIZE * 2, xhci->page_size * 2);
- else
- xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
- TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size);
+ xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
+ TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size);
/* See Table 46 and Note on Figure 55 */
xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev,
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index cb07cee9ed0c..c8322bb828a6 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -473,13 +473,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
xhci->quirks |= XHCI_ZHAOXIN_HOST;
xhci->quirks |= XHCI_LPM_SUPPORT;
- if (pdev->device == 0x9202) {
+ if (pdev->device == 0x9202)
xhci->quirks |= XHCI_RESET_ON_RESUME;
- xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH;
- }
-
- if (pdev->device == 0x9203)
- xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH;
}
if (pdev->vendor == PCI_DEVICE_ID_CADENCE &&
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 03c0f2226571..03a1c31228fc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1620,7 +1620,7 @@ struct xhci_hcd {
#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)
#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)
#define XHCI_RESET_TO_DEFAULT BIT_ULL(44)
-#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45)
+#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) /* Deprecated */
#define XHCI_ZHAOXIN_HOST BIT_ULL(46)
#define XHCI_WRITE_64_HI_LO BIT_ULL(47)
#define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48)
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts"
2024-12-17 11:29 ` [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts" Niklas Neronin
@ 2024-12-18 6:55 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-12-18 6:55 UTC (permalink / raw)
To: Niklas Neronin; +Cc: WeitaoWang-oc, mathias.nyman, linux-usb
On Tue, Dec 17, 2024 at 01:29:17PM +0200, Niklas Neronin wrote:
> This reverts commit 2a865a652299f5666f3b785cbe758c5f57453036.
>
> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
You need to document a reason why this is being reverted :(
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-18 6:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 11:29 [PATCH 0/2] Possible xHCI driver fix for ZHAOXIN hosts Niklas Neronin
2024-12-17 11:29 ` [PATCH 1/2] usb: xhci: set page size to the xHCI-supported size Niklas Neronin
2024-12-17 11:29 ` [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts" Niklas Neronin
2024-12-18 6:55 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox