Skip to content

Commit 7476a22

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: move link chain bit quirk checks into one helper function.
Older 0.95 xHCI hosts and some other specific newer hosts require the chain bit to be set for Link TRBs even if the link TRB is not in the middle of a transfer descriptor (TD). move the checks for all those cases into one xhci_link_chain_quirk() function to clean up and avoid code duplication. No functional changes. [skip renaming chain_links flag, reword commit message -Mathias] Signed-off-by: Niklas Neronin <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2c0df12 commit 7476a22

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring,
136136
if (!ring || !first || !last)
137137
return;
138138

139-
/* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */
140-
chain_links = !!(xhci_link_trb_quirk(xhci) ||
141-
(ring->type == TYPE_ISOC &&
142-
(xhci->quirks & XHCI_AMD_0x96_HOST)));
139+
chain_links = xhci_link_chain_quirk(xhci, ring->type);
143140

144141
next = ring->enq_seg->next;
145142
xhci_link_segments(ring->enq_seg, first, ring->type, chain_links);
@@ -335,10 +332,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
335332
struct xhci_segment *prev;
336333
bool chain_links;
337334

338-
/* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */
339-
chain_links = !!(xhci_link_trb_quirk(xhci) ||
340-
(type == TYPE_ISOC &&
341-
(xhci->quirks & XHCI_AMD_0x96_HOST)));
335+
chain_links = xhci_link_chain_quirk(xhci, type);
342336

343337
prev = xhci_segment_alloc(xhci, cycle_state, max_packet, num, flags);
344338
if (!prev)

drivers/usb/host/xhci-ring.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring,
250250
* AMD 0.96 host, carry over the chain bit of the previous TRB
251251
* (which may mean the chain bit is cleared).
252252
*/
253-
if (!(ring->type == TYPE_ISOC &&
254-
(xhci->quirks & XHCI_AMD_0x96_HOST)) &&
255-
!xhci_link_trb_quirk(xhci)) {
253+
if (!xhci_link_chain_quirk(xhci, ring->type)) {
256254
next->link.control &= cpu_to_le32(~TRB_CHAIN);
257255
next->link.control |= cpu_to_le32(chain);
258256
}
@@ -3250,9 +3248,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
32503248
/* If we're not dealing with 0.95 hardware or isoc rings
32513249
* on AMD 0.96 host, clear the chain bit.
32523250
*/
3253-
if (!xhci_link_trb_quirk(xhci) &&
3254-
!(ep_ring->type == TYPE_ISOC &&
3255-
(xhci->quirks & XHCI_AMD_0x96_HOST)))
3251+
if (!xhci_link_chain_quirk(xhci, ep_ring->type))
32563252
ep_ring->enqueue->link.control &=
32573253
cpu_to_le32(~TRB_CHAIN);
32583254
else

drivers/usb/host/xhci.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,9 +1750,12 @@ static inline void xhci_write_64(struct xhci_hcd *xhci,
17501750
lo_hi_writeq(val, regs);
17511751
}
17521752

1753-
static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci)
1753+
1754+
/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC rings */
1755+
static inline bool xhci_link_chain_quirk(struct xhci_hcd *xhci, enum xhci_ring_type type)
17541756
{
1755-
return xhci->quirks & XHCI_LINK_TRB_QUIRK;
1757+
return (xhci->quirks & XHCI_LINK_TRB_QUIRK) ||
1758+
(type == TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST));
17561759
}
17571760

17581761
/* xHCI debugging */

0 commit comments

Comments
 (0)