From: eli.billauer@gmail.com
To: mathias.nyman@linux.intel.com
Cc: mathias.nyman@intel.com, linux-usb@vger.kernel.org,
Eli Billauer <eli.billauer@gmail.com>
Subject: [PATCH] xhci: No XHCI_TRUST_TX_LENGTH check in the absence of matching TD
Date: Wed, 13 Nov 2019 15:06:09 +0200 [thread overview]
Message-ID: <20191113130609.32831-1-eli.billauer@gmail.com> (raw)
From: Eli Billauer <eli.billauer@gmail.com>
When an IN transfer ends with a short packet, the xHCI controller is
required to submit an event TRB with Completion Code COMP_SHORT_PACKET
against the data TRB that was in effect when the short packet arrived, as
well as any event TRBs it submits on behalf of this transfer.
Alas, some controllers (e.g. Renesas) mark the subsequent events TRBs (if
any) with COMP_SUCCESS. As these subsequent event TRBs are useless, they
are ignored on the basis that they have no matching TD queued (it was
dequeued in response to the first COMP_SHORT_PACKET event TRB).
Accordingly, the quirk handling and kernel log warning is moved to after
the TD match check, in particular in order to avoid unnecessary warnings
messages.
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---
drivers/usb/host/xhci-ring.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9741cdeea9d7..96680eb71a45 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2376,14 +2376,6 @@ static int handle_tx_event(struct xhci_hcd *xhci,
* transfer type
*/
case COMP_SUCCESS:
- if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0)
- break;
- if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
- trb_comp_code = COMP_SHORT_PACKET;
- else
- xhci_warn_ratelimited(xhci,
- "WARN Successful completion on short TX for slot %u ep %u: needs XHCI_TRUST_TX_LENGTH quirk?\n",
- slot_id, ep_index);
case COMP_SHORT_PACKET:
break;
/* Completion codes for endpoint stopped state */
@@ -2586,6 +2578,17 @@ static int handle_tx_event(struct xhci_hcd *xhci,
skip_isoc_td(xhci, td, event, ep, &status);
goto cleanup;
}
+
+ if ((trb_comp_code == COMP_SUCCESS) &&
+ (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0)) {
+ if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
+ trb_comp_code = COMP_SHORT_PACKET;
+ else
+ xhci_warn_ratelimited(xhci,
+ "WARN Successful completion on short TX for slot %u ep %u: needs XHCI_TRUST_TX_LENGTH quirk?\n",
+ slot_id, ep_index);
+ }
+
if (trb_comp_code == COMP_SHORT_PACKET)
ep_ring->last_td_was_short = true;
else
--
2.17.1
next reply other threads:[~2019-11-13 13:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 13:06 eli.billauer [this message]
2019-11-18 16:08 ` [PATCH] xhci: No XHCI_TRUST_TX_LENGTH check in the absence of matching TD Mathias Nyman
2019-11-19 11:48 ` Eli Billauer
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=20191113130609.32831-1-eli.billauer@gmail.com \
--to=eli.billauer@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).