Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp433206pxb; Thu, 12 Aug 2021 21:06:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYooU4Npj8o+qBH0k/knLK6jwIUyuY+FS2xfZsZQ3ro23QT5nRx6w+qY2EY0/Gdkac0qmN X-Received: by 2002:a02:781c:: with SMTP id p28mr349776jac.72.1628827562306; Thu, 12 Aug 2021 21:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628827562; cv=none; d=google.com; s=arc-20160816; b=ICKJNk8/a3eNVrJtVitFBnJ9xfGVYhDFctZgL02g+TG0+bX+uK4iHbqretYY3viWix nVWq6Jqjb6J/SS7AiNfNbnQWcPPcwKdqDEE6lE2DQvT10Ff8ck004avO4VH3Dc10ugOJ hwQPkxrAOi2se9U0sS9ZmUBVz3/zwzBzL6YmFjMAl5SGjte7PcmTuB3AEqPQOEaN0MzW xjmC1LOn9f2xJ9HE6j/Z45vUXgEolGloQ0NfHZJfKANhPOZfVf2qqd+lI9Xy+t7+4KEw ZESh87CEZBoZxuGwveJwO70RlUnoLnHEVswtR4htEQL4repOKTxeVZpa9UPgDhSMgsGA L9yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=+sXnDd5NzLQp8aMTaouqrcnUqs/sQpYuHKr+B/RA/Ro=; b=H7eNpxa8IBDqgbPrJSJEYFnR9PrBdao5g74bcWVhJnMIVPaVHNXiKdIHT+eOr9c5ec vEsMwSF9X0yrS31Farpy4JjvPXJ8wu6NxFPp5wwFUfuxj8OhB6Ezwl2KJifYlfgBNDOQ 1nbFDWay9oAzpuEypdRMAU2RkvIsVM66f8PvE3BOqWnneE+Aj4BXIs6HHHgE7du3OiQV t/ibKzx7RK282Vs5OHv9jiN82Nafz0rHuIz+s9UAL3OzBGoc5r1IRlCHbTl5qGGKcLFA 87YEgagke7cGtyRP7Ct+fbsrWN3F1FGeUE5OADeZLsGApTKliqz+a4/MWC3RnHSr6YXp MAmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=w+mWhwsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si203527ilc.143.2021.08.12.21.05.51; Thu, 12 Aug 2021 21:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=w+mWhwsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238457AbhHMCou (ORCPT + 99 others); Thu, 12 Aug 2021 22:44:50 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:30302 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238357AbhHMCou (ORCPT ); Thu, 12 Aug 2021 22:44:50 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1628822664; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=+sXnDd5NzLQp8aMTaouqrcnUqs/sQpYuHKr+B/RA/Ro=; b=w+mWhwsydM9D8zaeKyIB0/M3D70uXGIoMSVA3jc3rBcgdKP0p1ND6ouzMzebHNDFtbZDpcwa DTthHThH4WtdviKswzSeQTWMqaKbtb+a58uHFq3XX+qUBuRwWFheRB5qwEyLxPTcQFozMqnB 5+q4OposM+ELKSPrW9hxRaypWfs= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 6115dc7191487ad5207df2fc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 13 Aug 2021 02:44:01 GMT Sender: wat=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A3BACC43217; Fri, 13 Aug 2021 02:44:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 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 7F584C433F1; Fri, 13 Aug 2021 02:43:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F584C433F1 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: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list) Cc: Tao Wang Subject: [PATCH] usb: xhci-ring: set all cancelled_td's cancel_status to TD_CLEARING_CACHE Date: Fri, 13 Aug 2021 10:43:23 +0800 Message-Id: <1628822604-29239-1-git-send-email-wat@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org USB SSD may fail to unmount if disconnect during data transferring. 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