Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3193602pxb; Mon, 9 Nov 2020 05:17:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaLJfJXGY+9KG1seVMW15CcIFpWgjI8UzEqop6xwiT1XQjVgPH1sra0DgRuceKORgOA+MN X-Received: by 2002:a17:907:42cf:: with SMTP id nz23mr14751918ejb.138.1604927857424; Mon, 09 Nov 2020 05:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604927857; cv=none; d=google.com; s=arc-20160816; b=mdv7SThbcQo/mPcOgyOspMzfxg3W0hjm+10I16MkqVoQXLJDpgfSXPdmv6Di+ollfx OyFb9cIbyBBg9WHuiOQBA0CzM1DTo9u0vkn4MVdSknjYtLecxSsAPVd5RcQAxLR/CUlg RRhrUiF+4icuDPmSl97yxuAevLLbTWckjHI8OfLlxjVmDq81KWhLCa25ABj+SGE8y3XG 1cy1i5gU586WmZ9fKk8IEBBSc5zXv7AK/aj0EvRB6jdADP7bcM1nadrJpATFPAUX/wsb ofuvriBI4puwuQKrZKRA+yL6F+Jiygffj1BK1iMyUTAmQtfu+wTzZhFbltzbH593k3Oc 3o3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T5FebSj+HwtDqLdM8NxPZpBShAJ9wzW5jbo3c6ertBE=; b=h4Z4Nr8rHoChh8mRQi1Z6EmX7UvzHGomL2X0kAwGXQuKZPmweRwZGSq0j1y08ENjRO 0pjfIzL7mVQpUVpUJcF3eNMrZj36H2T2FbiOv60LBXQz0YIxrH7zBqR9AgywgV4D1kw7 aK7bdLORUGLxTElESD3lyQx5exFvPTD5bVUlZVkxKBCi29MUgGbIQNCC9fZkbzkCBD74 Mp3+l7Rn8+g4wZ0KkFm1VgYSV7qEQGpmgx1DRI8vTuf25BpfsJDa9aWTj9TPIEaiBi9P rDPabA7Mppb0ijNlqGE4V8rJlRWqQwYuOONPehYHx66/GgcsOWR2aLevQr3WOFVqGylx 3UCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xF29v1Dr; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si6963018edq.426.2020.11.09.05.17.14; Mon, 09 Nov 2020 05:17:37 -0800 (PST) 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=@kernel.org header.s=default header.b=xF29v1Dr; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731329AbgKINO4 (ORCPT + 99 others); Mon, 9 Nov 2020 08:14:56 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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]); }