From patchwork Tue Sep 1 15:10:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264754 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=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 904A1C433E6 for ; Tue, 1 Sep 2020 15:34:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CD7821582 for ; Tue, 1 Sep 2020 15:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974443; bh=XZofRMEuhipyLINL8hAHelkVwYgHCkVlOIbGVYdKOns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fl8CrGP3WHxyxk2mfzcG2zaBGN9o/CiTcZyZKpo9EaJJpF8QQ5n5dWbB8WHwLceDG suX/Gf0ydG1MpT+ulTxUNcu9IAr1fYVH3MqyXBv7K3EqP4aDRcRt1TkXitV7T8o5NJ CP3gkVJ25EySR4jE0p6x4WEcpb2JDYpj9xVYoHjQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728393AbgIAPdz (ORCPT ); Tue, 1 Sep 2020 11:33:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:38280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731147AbgIAPdt (ORCPT ); Tue, 1 Sep 2020 11:33:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DE6C20E65; Tue, 1 Sep 2020 15:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974428; bh=XZofRMEuhipyLINL8hAHelkVwYgHCkVlOIbGVYdKOns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i00tafQZhVAfqXlBHgbwWdMADjSMnGAhnFrqYe8Q7SQDNNH3k1OEd3d43DeT+IfM/ i/F1q6WirAj0v6wVlxJm1Ag+YVJeE/giPY3MWumG8y6ypAKakg/PToM9oDrqiMzA7P +fejyNACFB/UiLEHhrPD4TfVA/fsKWLU1nl218Mg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ding Hui , Mathias Nyman Subject: [PATCH 5.4 173/214] xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed Date: Tue, 1 Sep 2020 17:10:53 +0200 Message-Id: <20200901151001.266477923@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ding Hui commit f1ec7ae6c9f8c016db320e204cb519a1da1581b8 upstream. Some device drivers 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 xhci_endpoint_reset failed and left ep_state's EP_SOFT_CLEAR_TOGGLE bit still set So all the subsequent urb sumbits to the ep will fail with the warn log: Can't enqueue URB while manually clearing toggle We need to clear ep_state EP_SOFT_CLEAR_TOGGLE bit after xhci_endpoint_reset, even if it failed. Fixes: f5249461b504 ("xhci: Clear the host side toggle manually when endpoint is soft reset") Cc: stable # v4.17+ Signed-off-by: Ding Hui Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200821091549.20556-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct u 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,