All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wessel <jason.wessel@windriver.com>
To: u-boot@lists.denx.de
Subject: [PATCH 6/9] xhci-ring: Fix crash when issuing "usb reset"
Date: Fri, 24 Jul 2020 14:50:46 -0700	[thread overview]
Message-ID: <20200724215049.163379-7-jason.wessel@windriver.com> (raw)
In-Reply-To: <20200724215049.163379-1-jason.wessel@windriver.com>

If a "usb reset" is issued when the poll_pend state is set the
abort_td() function will hit one of the BUG() statements in abort_td()
or the BUG() statement at the end of xhci_wait_for_event().

The controller has been reset, so the rest of the cleanup should be
skipped and poll_pend flag should be cleared.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
 drivers/usb/host/xhci-ring.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d6339f4f0a..f2a07204cd 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -483,6 +483,8 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected,
 	if (expected == TRB_TRANSFER)
 		return NULL;
 
+	if (poll_pend)
+		return NULL;
 	printf("XHCI timeout on event type %d... cannot recover.\n", expected);
 	BUG();
 }
@@ -505,11 +507,16 @@ static void abort_td(struct usb_device *udev, int ep_index)
 	xhci_queue_command(ctrl, NULL, udev->slot_id, ep_index, TRB_STOP_RING);
 
 	event = xhci_wait_for_event(ctrl, TRB_TRANSFER, false);
-	field = le32_to_cpu(event->trans_event.flags);
-	BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id);
-	BUG_ON(TRB_TO_EP_INDEX(field) != ep_index);
-	BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len
-		!= COMP_STOP)));
+	if (event) {
+		field = le32_to_cpu(event->trans_event.flags);
+		BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id);
+		BUG_ON(TRB_TO_EP_INDEX(field) != ep_index);
+		BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len
+						 != COMP_STOP)));
+	} else {
+		debug("XHCI abort timeout\n");
+		return;
+	}
 	xhci_acknowledge_event(ctrl);
 
 	event = xhci_wait_for_event(ctrl, TRB_COMPLETION, false);
-- 
2.17.1

  parent reply	other threads:[~2020-07-24 21:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 21:50 [PULL][PATCH 0/9] Raspberry pi improvements qemu/usb/ethernet Jason Wessel
2020-07-24 21:50 ` [PATCH 1/9] fs/fat/fat.c: Do not perform zero block reads if there are no blocks left Jason Wessel
2020-07-25 15:27   ` Heinrich Schuchardt
2020-07-24 21:50 ` [PATCH 2/9] xhci: Add polling support for USB keyboards Jason Wessel
2020-07-24 21:50 ` [PATCH 3/9] usb_kbd: succeed even if no interrupt is pending Jason Wessel
2020-07-24 21:50 ` [PATCH 4/9] common/usb.c: Work around keyboard reporting "USB device not accepting new address" Jason Wessel
2020-07-24 21:50 ` [PATCH 5/9] xhci-ring.c: Add the poll_pend state to properly abort transactions Jason Wessel
2020-08-20  8:26   ` Bin Meng
2020-08-24  3:35     ` Jason Wessel
2020-07-24 21:50 ` Jason Wessel [this message]
2020-07-24 21:50 ` [PATCH 7/9] usb.c: Add a retry in the usb_prepare_device() Jason Wessel
2020-07-24 21:50 ` [PATCH 8/9] bcmgenet: fix DMA buffer management Jason Wessel
2020-07-24 21:50 ` [PATCH 9/9] bcmgenet: Add support for rgmii-rxid Jason Wessel

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=20200724215049.163379-7-jason.wessel@windriver.com \
    --to=jason.wessel@windriver.com \
    --cc=u-boot@lists.denx.de \
    /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.