From patchwork Mon Nov 9 12:56:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 322748 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=-9.8 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 9103FC2D0A3 for ; Mon, 9 Nov 2020 13:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36EE5208FE for ; Mon, 9 Nov 2020 13:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927697; bh=rLhjXJeRAW8D0097gZ8jQCcXv8gLYuj/zeHcbNeT4lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JZDXoIBoKCUEaJTYvYoBALxqSLH7EzCPa49xT2EMOA8D5uW14D4RpkwIFalmEGL6F J33UjUuuFlpRbVO+/4CUIqSd53hYKAXXUCgNDhtvfUWcxiWjmAX9RzpsjmWKLG0Oq6 7g4yS9la/dGUiRyuuGiYayCdP9U5NVYaxPaQ0Kak= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733212AbgKINOz (ORCPT ); Mon, 9 Nov 2020 08:14:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:41356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733241AbgKINOv (ORCPT ); Mon, 9 Nov 2020 08:14:51 -0500 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 E0C6120663; Mon, 9 Nov 2020 13:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927691; bh=rLhjXJeRAW8D0097gZ8jQCcXv8gLYuj/zeHcbNeT4lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xF29v1Dr2Pup66Q0egzcVCH1CBoS0XgyLVpcKC0gPEDRVeg7l2hfnFqoQ681B4z5S L+rzfEClx+l6KVzsKb1wIt+MJ37jfK8XQtef9KtUVCVAtaDajuCBbS/t9dgpfO6Dbj S5Y9YhVKvQO9LQxSrSo6THrsAZwxJUH4QuUeUP7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 5.4 75/85] usb: dwc3: ep0: Fix delay status handling Date: Mon, 9 Nov 2020 13:56:12 +0100 Message-Id: <20201109125026.180567725@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125022.614792961@linuxfoundation.org> References: <20201109125022.614792961@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thinh Nguyen commit fa27e2f6c5e674f3f1225f9ca7a7821faaf393bb upstream. If we want to send a control status on our own time (through delayed_status), make sure to handle a case where we may queue the delayed status before the host requesting for it (when XferNotReady is generated). Otherwise, the driver won't send anything because it's not EP0_STATUS_PHASE yet. To resolve this, regardless whether dwc->ep0state is EP0_STATUS_PHASE, make sure to clear the dwc->delayed_status flag if dwc3_ep0_send_delayed_status() is called. The control status can be sent when the host requests it later. Cc: Fixes: d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/ep0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -1058,10 +1058,11 @@ void dwc3_ep0_send_delayed_status(struct { unsigned int direction = !dwc->ep0_expect_in; + dwc->delayed_status = false; + if (dwc->ep0state != EP0_STATUS_PHASE) return; - dwc->delayed_status = false; __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); }