From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BC8DC4320A for ; Thu, 12 Aug 2021 12:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E77360F91 for ; Thu, 12 Aug 2021 12:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237234AbhHLMDf (ORCPT ); Thu, 12 Aug 2021 08:03:35 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:29623 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237216AbhHLMDf (ORCPT ); Thu, 12 Aug 2021 08:03:35 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1628769790; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=6QsmkNZbQwVsN9LnELcdMHAkKo6gl/13f9/auIf990s=; b=o2SxTNGj9biSTwCrHYO3Pyx/H9vNLZNYmU6a4s9J3dPyzfnIJ1UxBflAmpNeRdx4SvPwQFGw 0ntwCMU2CVyuy5uMUg4TdoH//kfKvvlRPy70BoD/hHiis8vkE+bBBNpXKVpoAmmrksvkl6jR A5aJBt7ecYbafzMsCP7OiS7XXt8= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyIxZTE2YSIsICJsaW51eC11c2JAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 61150dceb14e7e2ecbf32184 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 12 Aug 2021 12:02:22 GMT Sender: wat=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B6EC2C43217; Thu, 12 Aug 2021 12:02:21 +0000 (UTC) Received: from cbsp-sh-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wat) by smtp.codeaurora.org (Postfix) with ESMTPSA id 17E84C433D3; Thu, 12 Aug 2021 12:02:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 17E84C433D3 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=wat@codeaurora.org From: Tao Wang To: quic_wat@quicinc.com, linyyuan@qti.qualcomm.com, hongwus@qti.qualcomm.com, zhijunw@qti.qualcomm.com, wat@codeaurora.org Cc: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] usb: xhci-ring: USB SSD may fail to unmount if disconnect during data transferring. Date: Thu, 12 Aug 2021 20:02:07 +0800 Message-Id: <1628769727-45046-1-git-send-email-wat@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Tao Wang it stuck in usb_kill_urb() due to urb use_count will not become zero, this means urb giveback is not happen. in xhci_handle_cmd_set_deq() will giveback urb if td's cancel_status equal to TD_CLEARING_CACHE, but in xhci_invalidate_cancelled_tds(), only last canceled td's cancel_status change to TD_CLEARING_CACHE, thus giveback only happen to last urb. this change set all cancelled_td's cancel_status to TD_CLEARING_CACHE rather than the last one, so all urb can giveback. Signed-off-by: Tao Wang --- drivers/usb/host/xhci-ring.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 8fea44b..c7dd7c0 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -960,19 +960,19 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep) td_to_noop(xhci, ring, td, false); td->cancel_status = TD_CLEARED; } - } - if (cached_td) { - cached_td->cancel_status = TD_CLEARING_CACHE; - - err = xhci_move_dequeue_past_td(xhci, slot_id, ep->ep_index, - cached_td->urb->stream_id, - cached_td); - /* Failed to move past cached td, try just setting it noop */ - if (err) { - td_to_noop(xhci, ring, cached_td, false); - cached_td->cancel_status = TD_CLEARED; + if (cached_td) { + cached_td->cancel_status = TD_CLEARING_CACHE; + + err = xhci_move_dequeue_past_td(xhci, slot_id, ep->ep_index, + cached_td->urb->stream_id, + cached_td); + /* Failed to move past cached td, try just setting it noop */ + if (err) { + td_to_noop(xhci, ring, cached_td, false); + cached_td->cancel_status = TD_CLEARED; + } + cached_td = NULL; } - cached_td = NULL; } return 0; } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project