Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp48597pxa; Fri, 21 Aug 2020 00:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfrda5TNcaKbv07+AHmHEN16Dd1nw4ed7n442PT4EBi7YK8vrMz5L/gGx0KYztbHVzS4MM X-Received: by 2002:aa7:c246:: with SMTP id y6mr1614747edo.78.1597994516801; Fri, 21 Aug 2020 00:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597994516; cv=none; d=google.com; s=arc-20160816; b=zxZjNxjtva3uyX5tSLe+mkmK/BwbNLyb3EFneqE+VuBodMogLvTifhbzAFXDNpVvO2 Zta1n5mGI/YKyK9iJGLL7EvJx4L3NapxAn0D9obul6Kwjw8W1QGJLls15pXxBHJugg0y uB1zjcLgxW2yO5d49ed+bgYSmnxiXcHPD1pLjbl+SjzYBMyTmT75kSIVNuKIoT8OLvUU 3pVnYPO8yrAqLLSY7kbxHU86l/8AIRftHpw8H3e2Jp8xAk183UoKYLEDHjp/aB0LjU5s NON9Cgzg4dYYWX6fZ6XrLPUZasNTxvbMQ9g9hXOjaqt3GE5YjRlxLt4ifVm5dij8GrZL aGYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=XDt37sdwY2Q0QQWRjuuzgJ3X4AiSm1QOi+lc+cEptGI=; b=nYfhEgqzt77HDYYeYO0FROygTLqvWVNI6Pn9mFRiGFcEg9YZICAiYq0xQei/o5ar1G m+G6XlmHQ+bRrQnn1aSvfk6HtukXSqlJfyB1lj5juzOwwGkzSVsYEmCZekxaVmJ+m/pT GDJQK0G8YpLKQBKfpcBRbeKMKZ0urxJ6mx2RlrjuQ0MfhK33WdHpL2+5CW3846nWZreg o6yePikmiGSX5Scz0RfnQVsy9EeAno7DtTJnICBM0K/Y5ByONyhp43mCbeEkkayCwhZr o0XIQqnxgWGMTfSoQq2XBYGFgJI3IhzVG69fZW8/TASFScl38cgnCdF+NotkGAAl2Aii e+KA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si633082ejc.319.2020.08.21.00.21.33; Fri, 21 Aug 2020 00:21:56 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbgHUHTw (ORCPT + 99 others); Fri, 21 Aug 2020 03:19:52 -0400 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:46897 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728397AbgHUHTN (ORCPT ); Fri, 21 Aug 2020 03:19:13 -0400 X-Greylist: delayed 525 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 Aug 2020 03:19:11 EDT Received: from localhost.localdomain (unknown [113.89.244.43]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id 15E1248271C; Fri, 21 Aug 2020 15:10:22 +0800 (CST) From: Ding Hui To: mathias.nyman@intel.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Ding Hui Subject: [PATCH] xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed Date: Fri, 21 Aug 2020 15:06:52 +0800 Message-Id: <20200821070652.27782-1-dinghui@sangfor.com.cn> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZTB5MQkkaQhpLGB0dVkpOQkxCQkhDSUlISUxVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKQ1VKS0tZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nio6NTo4Ez8hSzMaDgxNMx0M OAkKC0lVSlVKTkJMQkJIQ0lJQ0tLVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKSkhVQ0JVSU9PVU9IWVdZCAFZQUlKT0w3Bg++ X-HM-Tid: 0a740fdaa83593bakuws15e1248271c Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some devices driver call libusb_clear_halt when target ep queue is not empty. (eg. spice client connected to qemu for usb redir) Before commit f5249461b504 ("xhci: Clear the host side toggle manually when endpoint is soft reset"), that works well. But now, we got the error log: EP not empty, refuse reset xhch_endpoint_reset failed and left ep_state's EP_SOFT_CLEAR_TOGGLE bit is still on So all the subsequent urb sumbit to the ep will fail with the warn log: Can't enqueue URB while manually clearing toggle We need restore ep_state EP_SOFT_CLEAR_TOGGLE bit after xhci_endpoint_reset, even if it is failed. Signed-off-by: Ding Hui --- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 3c41b14ecce7..e9884ae9c77d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, wait_for_completion(cfg_cmd->completion); - ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE; xhci_free_command(xhci, cfg_cmd); cleanup: xhci_free_command(xhci, stop_cmd); + if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE) + ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE; } static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, -- 2.17.1