From patchwork Mon Apr 16 12:29:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 10342879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3DA9601D7 for ; Mon, 16 Apr 2018 12:30:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A013628712 for ; Mon, 16 Apr 2018 12:30:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EA8728748; Mon, 16 Apr 2018 12:30:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8177828742 for ; Mon, 16 Apr 2018 12:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754625AbeDPMat (ORCPT ); Mon, 16 Apr 2018 08:30:49 -0400 Received: from mga04.intel.com ([192.55.52.120]:41222 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754273AbeDPMas (ORCPT ); Mon, 16 Apr 2018 08:30:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 05:30:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="220773897" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.68.37]) by fmsmga005.fm.intel.com with ESMTP; 16 Apr 2018 05:30:47 -0700 From: Felipe Balbi To: Mathias Nyman Cc: Linux USB , Felipe Balbi Subject: [PATCH 10/20] usb: host: xhci: check DYING state earlier Date: Mon, 16 Apr 2018 15:29:20 +0300 Message-Id: <20180416122930.15697-10-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180416122930.15697-1-felipe.balbi@linux.intel.com> References: <20180416122930.15697-1-felipe.balbi@linux.intel.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP in case where xHCI dies, we can bail out a little earlier. Not really a functional change, just making the code follow a more straight-forward order. Signed-off-by: Felipe Balbi --- drivers/usb/host/xhci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 3b19444aa1f3..6be3eb721157 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1444,6 +1444,13 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) if (ret) goto done; + /* If xHC is dead take it down and return ALL URBs in xhci_hc_died() */ + temp = readl(&xhci->op_regs->status); + if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) { + xhci_hc_died(xhci); + goto done; + } + /* give back URB now if we can't queue it for cancel */ vdev = xhci->devs[urb->dev->slot_id]; urb_priv = urb->hcpriv; @@ -1456,13 +1463,6 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) if (!ep || !ep_ring) goto err_giveback; - /* If xHC is dead take it down and return ALL URBs in xhci_hc_died() */ - temp = readl(&xhci->op_regs->status); - if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) { - xhci_hc_died(xhci); - goto done; - } - if (xhci->xhc_state & XHCI_STATE_HALTED) { xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "HC halted, freeing TD manually.");