From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, Michal Pecio <michal.pecio@gmail.com>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 6/9] xhci: fix matching completion events with TDs
Date: Thu, 29 Feb 2024 16:14:35 +0200 [thread overview]
Message-ID: <20240229141438.619372-7-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20240229141438.619372-1-mathias.nyman@linux.intel.com>
From: Michal Pecio <michal.pecio@gmail.com>
A trb_in_td() call is used to determine if a completion event matches
any TRB of the currently executing TD. This function is told to start
searching right after the last finished TD, which is not at all where
the currently expected TD is guaranteed to begin, because some TDs in
between may have been cancelled.
Not only is a pointless work performed, but a bug resulting in the HC
executing cancelled TDs was seen to trick the driver into associating
events from a TD just cancelled with an unrelated future TD.
Since the ring is being traversed for the specific purpose of finding
a match with the current TD, always start from its first TRB. This is
the most reliable bit of information that we posses.
Tracking of HC's work progress is not affected, except for cases when
a misattributed event would have moved dequeue past a pending TD.
Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-ring.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 95ed26114ee8..b2116501048c 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2813,7 +2813,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
td_num--;
/* Is this a TRB in the currently executing TD? */
- ep_seg = trb_in_td(xhci, ep_ring->deq_seg, ep_ring->dequeue,
+ ep_seg = trb_in_td(xhci, td->start_seg, td->first_trb,
td->last_trb, ep_trb_dma, false);
/*
@@ -2881,9 +2881,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
"part of current TD ep_index %d "
"comp_code %u\n", ep_index,
trb_comp_code);
- trb_in_td(xhci, ep_ring->deq_seg,
- ep_ring->dequeue, td->last_trb,
- ep_trb_dma, true);
+ trb_in_td(xhci, td->start_seg, td->first_trb,
+ td->last_trb, ep_trb_dma, true);
return -ESHUTDOWN;
}
}
--
2.25.1
next prev parent reply other threads:[~2024-02-29 14:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 14:14 [PATCH 0/9] xhci features for usb-next Mathias Nyman
2024-02-29 14:14 ` [PATCH 1/9] xhci: rework how real & fake ports are found Mathias Nyman
2024-02-29 14:14 ` [PATCH 2/9] xhci: replace real & fake port with pointer to root hub port Mathias Nyman
2024-04-02 0:50 ` Thinh Nguyen
2024-04-02 10:23 ` Mathias Nyman
2024-04-02 23:13 ` Thinh Nguyen
2024-04-03 8:19 ` Mathias Nyman
2024-02-29 14:14 ` [PATCH 3/9] xhci: save slot ID in struct 'xhci_port' Mathias Nyman
2024-02-29 14:14 ` [PATCH 4/9] usb: xhci: remove duplicate code from 'xhci_clear_command_ring()' Mathias Nyman
2024-02-29 14:14 ` [PATCH 5/9] usb: xhci: utilize 'xhci_free_segments_for_ring()' for freeing segments Mathias Nyman
2024-02-29 14:14 ` Mathias Nyman [this message]
2024-02-29 14:14 ` [PATCH 7/9] xhci: retry Stop Endpoint on buggy NEC controllers Mathias Nyman
2024-02-29 14:14 ` [PATCH 8/9] xhci: dbc: poll at different rate depending on data transfer activity Mathias Nyman
2024-02-29 14:14 ` [PATCH 9/9] usb: xhci: Add error handling in xhci_map_urb_for_dma Mathias Nyman
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=20240229141438.619372-7-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=michal.pecio@gmail.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.