* [PATCH 0/4] xhci fixes for usb-linus
@ 2023-09-15 14:31 Mathias Nyman
2023-09-15 14:31 ` [PATCH 1/4] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer Mathias Nyman
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Mathias Nyman @ 2023-09-15 14:31 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
A few small xhci fixes for 6.6
Use correct dev in dma bounce buffer mapping, fix event handling
issues, and track suspended ports correctly in software
Thanks
Mathias
Lukas Wunner (2):
xhci: Clear EHB bit only at end of interrupt handler
xhci: Preserve RsvdP bits in ERSTBA register correctly
Mathias Nyman (1):
xhci: track port suspend state correctly in unsuccessful resume cases
Wesley Cheng (1):
usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer
drivers/usb/host/xhci-hub.c | 19 ++++++++++---------
drivers/usb/host/xhci-mem.c | 4 ++--
drivers/usb/host/xhci-ring.c | 16 +++++++++-------
drivers/usb/host/xhci.h | 2 +-
4 files changed, 22 insertions(+), 19 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer
2023-09-15 14:31 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
@ 2023-09-15 14:31 ` Mathias Nyman
2023-09-15 14:31 ` [PATCH 2/4] xhci: track port suspend state correctly in unsuccessful resume cases Mathias Nyman
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2023-09-15 14:31 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Wesley Cheng, stable, Mathias Nyman
From: Wesley Cheng <quic_wcheng@quicinc.com>
As mentioned in:
commit 474ed23a6257 ("xhci: align the last trb before link if it is
easily splittable.")
A bounce buffer is utilized for ensuring that transfers that span across
ring segments are aligned to the EP's max packet size. However, the device
that is used to map the DMA buffer to is currently using the XHCI HCD,
which does not carry any DMA operations in certain configrations.
Migration to using the sysdev entry was introduced for DWC3 based
implementations where the IOMMU operations are present.
Replace the reference to the controller device to sysdev instead. This
allows the bounce buffer to be properly mapped to any implementations that
have an IOMMU involved.
cc: <stable@vger.kernel.org>
Fixes: 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA configuration")
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1dde53f6eb31..98389b568633 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -798,7 +798,7 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
struct xhci_ring *ring, struct xhci_td *td)
{
- struct device *dev = xhci_to_hcd(xhci)->self.controller;
+ struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
struct xhci_segment *seg = td->bounce_seg;
struct urb *urb = td->urb;
size_t len;
@@ -3469,7 +3469,7 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,
static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
u32 *trb_buff_len, struct xhci_segment *seg)
{
- struct device *dev = xhci_to_hcd(xhci)->self.controller;
+ struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
unsigned int unalign;
unsigned int max_pkt;
u32 new_buff_len;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] xhci: track port suspend state correctly in unsuccessful resume cases
2023-09-15 14:31 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
2023-09-15 14:31 ` [PATCH 1/4] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer Mathias Nyman
@ 2023-09-15 14:31 ` Mathias Nyman
2023-09-15 14:31 ` [PATCH 3/4] xhci: Clear EHB bit only at end of interrupt handler Mathias Nyman
2023-09-15 14:31 ` [PATCH 4/4] xhci: Preserve RsvdP bits in ERSTBA register correctly Mathias Nyman
3 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2023-09-15 14:31 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman, stable, Wesley Cheng
xhci-hub.c tracks suspended ports in a suspended_port bitfield.
This is checked when responding to a Get_Status(PORT) request to see if a
port in running U0 state was recently resumed, and adds the required
USB_PORT_STAT_C_SUSPEND change bit in those cases.
The suspended_port bit was left uncleared if a device is disconnected
during suspend. The bit remained set even when a new device was connected
and enumerated. The set bit resulted in a incorrect Get_Status(PORT)
response with a bogus USB_PORT_STAT_C_SUSPEND change
bit set once the new device reached U0 link state.
USB_PORT_STAT_C_SUSPEND change bit is only used for USB2 ports, but
xhci-hub keeps track of both USB2 and USB3 suspended ports.
Cc: stable@vger.kernel.org
Reported-by: Wesley Cheng <quic_wcheng@quicinc.com>
Closes: https://lore.kernel.org/linux-usb/d68aa806-b26a-0e43-42fb-b8067325e967@quicinc.com/
Fixes: 1d5810b6923c ("xhci: Rework port suspend structures for limited ports.")
Tested-by: Wesley Cheng <quic_wcheng@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-hub.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 0054d02239e2..0df5d807a77e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1062,19 +1062,19 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
*status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
/* USB3 specific wPortStatus bits */
- if (portsc & PORT_POWER) {
+ if (portsc & PORT_POWER)
*status |= USB_SS_PORT_STAT_POWER;
- /* link state handling */
- if (link_state == XDEV_U0)
- bus_state->suspended_ports &= ~(1 << portnum);
- }
- /* remote wake resume signaling complete */
- if (bus_state->port_remote_wakeup & (1 << portnum) &&
+ /* no longer suspended or resuming */
+ if (link_state != XDEV_U3 &&
link_state != XDEV_RESUME &&
link_state != XDEV_RECOVERY) {
- bus_state->port_remote_wakeup &= ~(1 << portnum);
- usb_hcd_end_port_resume(&hcd->self, portnum);
+ /* remote wake resume signaling complete */
+ if (bus_state->port_remote_wakeup & (1 << portnum)) {
+ bus_state->port_remote_wakeup &= ~(1 << portnum);
+ usb_hcd_end_port_resume(&hcd->self, portnum);
+ }
+ bus_state->suspended_ports &= ~(1 << portnum);
}
xhci_hub_report_usb3_link_state(xhci, status, portsc);
@@ -1131,6 +1131,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
}
port->rexit_active = 0;
+ bus_state->suspended_ports &= ~(1 << portnum);
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] xhci: Clear EHB bit only at end of interrupt handler
2023-09-15 14:31 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
2023-09-15 14:31 ` [PATCH 1/4] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer Mathias Nyman
2023-09-15 14:31 ` [PATCH 2/4] xhci: track port suspend state correctly in unsuccessful resume cases Mathias Nyman
@ 2023-09-15 14:31 ` Mathias Nyman
2023-09-15 14:31 ` [PATCH 4/4] xhci: Preserve RsvdP bits in ERSTBA register correctly Mathias Nyman
3 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2023-09-15 14:31 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Lukas Wunner, stable, Peter Chen, Mathias Nyman
From: Lukas Wunner <lukas@wunner.de>
The Event Handler Busy bit shall be cleared by software when the Event
Ring is empty. The xHC is thereby informed that it may raise another
interrupt once it has enqueued new events (sec 4.17.2).
However since commit dc0ffbea5729 ("usb: host: xhci: update event ring
dequeue pointer on purpose"), the EHB bit is already cleared after half
a segment has been processed.
As a result, spurious interrupts may occur:
- xhci_irq() processes half a segment, clears EHB, continues processing
remaining events.
- xHC enqueues new events. Because EHB has been cleared, xHC sets
Interrupt Pending bit. Interrupt moderation countdown begins.
- Meanwhile xhci_irq() continues processing events. Interrupt
moderation countdown reaches zero, so an MSI interrupt is signaled.
- xhci_irq() empties the Event Ring, clears EHB again and is done.
- Because an MSI interrupt has been signaled, xhci_irq() is run again.
It discovers there's nothing to do and returns IRQ_NONE.
Avoid by clearing the EHB bit only at the end of xhci_irq().
Fixes: dc0ffbea5729 ("usb: host: xhci: update event ring dequeue pointer on purpose")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v5.5+
Cc: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-ring.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 98389b568633..3e5dc0723a8f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2996,7 +2996,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir)
*/
static void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
struct xhci_interrupter *ir,
- union xhci_trb *event_ring_deq)
+ union xhci_trb *event_ring_deq,
+ bool clear_ehb)
{
u64 temp_64;
dma_addr_t deq;
@@ -3017,12 +3018,13 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci,
return;
/* Update HC event ring dequeue pointer */
- temp_64 &= ERST_PTR_MASK;
+ temp_64 &= ERST_DESI_MASK;
temp_64 |= ((u64) deq & (u64) ~ERST_PTR_MASK);
}
/* Clear the event handler busy flag (RW1C) */
- temp_64 |= ERST_EHB;
+ if (clear_ehb)
+ temp_64 |= ERST_EHB;
xhci_write_64(xhci, temp_64, &ir->ir_set->erst_dequeue);
}
@@ -3103,7 +3105,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
while (xhci_handle_event(xhci, ir) > 0) {
if (event_loop++ < TRBS_PER_SEGMENT / 2)
continue;
- xhci_update_erst_dequeue(xhci, ir, event_ring_deq);
+ xhci_update_erst_dequeue(xhci, ir, event_ring_deq, false);
event_ring_deq = ir->event_ring->dequeue;
/* ring is half-full, force isoc trbs to interrupt more often */
@@ -3113,7 +3115,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
event_loop = 0;
}
- xhci_update_erst_dequeue(xhci, ir, event_ring_deq);
+ xhci_update_erst_dequeue(xhci, ir, event_ring_deq, true);
ret = IRQ_HANDLED;
out:
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] xhci: Preserve RsvdP bits in ERSTBA register correctly
2023-09-15 14:31 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
` (2 preceding siblings ...)
2023-09-15 14:31 ` [PATCH 3/4] xhci: Clear EHB bit only at end of interrupt handler Mathias Nyman
@ 2023-09-15 14:31 ` Mathias Nyman
3 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2023-09-15 14:31 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Lukas Wunner, stable, Mathias Nyman
From: Lukas Wunner <lukas@wunner.de>
xhci_add_interrupter() erroneously preserves only the lowest 4 bits when
writing the ERSTBA register, not the lowest 6 bits. Fix it.
Migrate the ERST_BASE_RSVDP macro to the modern GENMASK_ULL() syntax to
avoid a u64 cast.
This was previously fixed by commit 8c1cbec9db1a ("xhci: fix event ring
segment table related masks and variables in header"), but immediately
undone by commit b17a57f89f69 ("xhci: Refactor interrupter code for
initial multi interrupter support.").
Fixes: b17a57f89f69 ("xhci: Refactor interrupter code for initial multi interrupter support.")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v6.3+
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-mem.c | 4 ++--
drivers/usb/host/xhci.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8714ab5bf04d..0a37f0d511cf 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2285,8 +2285,8 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir,
writel(erst_size, &ir->ir_set->erst_size);
erst_base = xhci_read_64(xhci, &ir->ir_set->erst_base);
- erst_base &= ERST_PTR_MASK;
- erst_base |= (ir->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK);
+ erst_base &= ERST_BASE_RSVDP;
+ erst_base |= ir->erst.erst_dma_addr & ~ERST_BASE_RSVDP;
xhci_write_64(xhci, erst_base, &ir->ir_set->erst_base);
/* Set the event ring dequeue address of this interrupter */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 7e282b4522c0..5df370482521 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -514,7 +514,7 @@ struct xhci_intr_reg {
#define ERST_SIZE_MASK (0xffff << 16)
/* erst_base bitmasks */
-#define ERST_BASE_RSVDP (0x3f)
+#define ERST_BASE_RSVDP (GENMASK_ULL(5, 0))
/* erst_dequeue bitmasks */
/* Dequeue ERST Segment Index (DESI) - Segment number (or alias)
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 0/4] xhci fixes for usb-linus
@ 2024-01-25 15:27 Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2024-01-25 15:27 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
This series fixes gaps discovered in isochronous transfer error
handling, and a couple small issues in the newly added secondary
interrupter code (6.8-rc1).
Thanks
-Mathias
Mathias Nyman (3):
xhci: fix possible null pointer dereference at secondary interrupter
removal
xhci: fix off by one check when adding a secondary interrupter.
xhci: process isoc TD properly when there was a transaction error mid
TD.
Michal Pecio (1):
xhci: handle isoc Babble and Buffer Overrun events properly
drivers/usb/host/xhci-mem.c | 14 +++----
drivers/usb/host/xhci-ring.c | 80 +++++++++++++++++++++++++++++-------
drivers/usb/host/xhci.h | 1 +
3 files changed, 73 insertions(+), 22 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/4] xhci fixes for usb-linus
@ 2022-10-24 14:27 Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2022-10-24 14:27 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
Some xhci fixes for usb-linus, mostly tuning quirks, but also fixing
one linked list issue.
Thanks
Mathias
Jens Glathe (1):
usb: xhci: add XHCI_SPURIOUS_SUCCESS to ASM1042 despite being a V0.96
controller
Mario Limonciello (1):
xhci-pci: Set runtime PM as default policy on all xHC 1.2 or later
devices
Mathias Nyman (2):
xhci: Add quirk to reset host back to default state at shutdown
xhci: Remove device endpoints from bandwidth list when freeing the
device
drivers/usb/host/xhci-mem.c | 20 ++++++++++-------
drivers/usb/host/xhci-pci.c | 44 +++++++++++++------------------------
drivers/usb/host/xhci.c | 10 +++++++--
drivers/usb/host/xhci.h | 1 +
4 files changed, 36 insertions(+), 39 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/4] xhci fixes for usb-linus
@ 2022-06-23 11:19 Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2022-06-23 11:19 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
A few xhci fixes for 5.19
Adding a couple PCI IDs, turning off port power in shutdown, and delay
xHC interrupt generation until host is running.
Thanks
Mathias
Hongyu Xie (1):
xhci: Keep interrupt disabled in initialization until host is running.
Mathias Nyman (1):
xhci: turn off port power in shutdown
Tanveer Alam (1):
xhci-pci: Allow host runtime PM as default for Intel Raptor Lake xHCI
Utkarsh Patel (1):
xhci-pci: Allow host runtime PM as default for Intel Meteor Lake xHCI
drivers/usb/host/xhci-hub.c | 2 +-
drivers/usb/host/xhci-pci.c | 6 ++++-
drivers/usb/host/xhci.c | 50 ++++++++++++++++++++++++++-----------
drivers/usb/host/xhci.h | 2 ++
4 files changed, 43 insertions(+), 17 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/4] xhci fixes for usb-linus
@ 2021-03-11 11:53 Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2021-03-11 11:53 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
Fix a couple power management related xHCI issues, and a couple
vendor specific workarounds.
-Mathias
Forest Crossman (1):
usb: xhci: Fix ASMedia ASM1042A and ASM3242 DMA addressing
Mathias Nyman (2):
xhci: Improve detection of device initiated wake signal.
xhci: Fix repeated xhci wake after suspend due to uncleared internal
wake state
Stanislaw Gruszka (1):
usb: xhci: do not perform Soft Retry for some xHCI hosts
drivers/usb/host/xhci-pci.c | 13 +++++-
drivers/usb/host/xhci-ring.c | 3 +-
drivers/usb/host/xhci.c | 78 ++++++++++++++++++++----------------
drivers/usb/host/xhci.h | 1 +
4 files changed, 57 insertions(+), 38 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/4] xhci fixes for usb-linus
@ 2020-02-10 13:45 Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2020-02-10 13:45 UTC (permalink / raw)
To: gregkh; +Cc: linux-usb, Mathias Nyman
Hi Greg
A few xhci fixes resolving an issue entering runtime suspend PCI D3 for
some Intel hosts, fixing a memory leak, and forcing max packet size to
valid values allowing some older FS devices to function with xhci.
-Mathias
Mathias Nyman (4):
xhci: Force Maximum Packet size for Full-speed bulk devices to valid
range.
xhci: Fix memory leak when caching protocol extended capability PSI
tables
xhci: fix runtime pm enabling for quirky Intel hosts
xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
drivers/usb/host/xhci-hub.c | 25 ++++++++-----
drivers/usb/host/xhci-mem.c | 70 ++++++++++++++++++++++++-------------
drivers/usb/host/xhci-pci.c | 10 +++---
drivers/usb/host/xhci.h | 14 ++++++--
4 files changed, 79 insertions(+), 40 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-01-25 15:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15 14:31 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
2023-09-15 14:31 ` [PATCH 1/4] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer Mathias Nyman
2023-09-15 14:31 ` [PATCH 2/4] xhci: track port suspend state correctly in unsuccessful resume cases Mathias Nyman
2023-09-15 14:31 ` [PATCH 3/4] xhci: Clear EHB bit only at end of interrupt handler Mathias Nyman
2023-09-15 14:31 ` [PATCH 4/4] xhci: Preserve RsvdP bits in ERSTBA register correctly Mathias Nyman
-- strict thread matches above, loose matches on Subject: below --
2024-01-25 15:27 [PATCH 0/4] xhci fixes for usb-linus Mathias Nyman
2022-10-24 14:27 Mathias Nyman
2022-06-23 11:19 Mathias Nyman
2021-03-11 11:53 Mathias Nyman
2020-02-10 13:45 Mathias Nyman
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.