Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3199481pxb; Mon, 9 Nov 2020 05:25:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTUIOBQ2AMHd8qJQOKLf4QKZhRkEp9MPrV10kEUnfEmOUGB8ULoA6Kqr4SOKYoIbnFIU07 X-Received: by 2002:a17:906:2444:: with SMTP id a4mr15556756ejb.415.1604928345441; Mon, 09 Nov 2020 05:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928345; cv=none; d=google.com; s=arc-20160816; b=yOTFxq3wDgtrng6seOI9JyOp9NeWP26BivRIvBzBIPhGuHqDTyFhhTUupXeFGBVoFH j5hTs4wB+v6LSr90OiRvceKHCQApp37PtOmbCrgc66mI5OvlL/+wsNiCMSnae/B0qRYK DI/VDJUfO5WCVY/7i675KGlsBQJgsM8ghw2Gtt7YWgRk7meFF46QCHntkiqEu2+/kBy/ GYYwbZkosfESj70W/NWZ9J9XeNCLyA7A7a/PIFYfN/wiB9ztqP/nNcspSeiutLRieD2i gjO+k0A9yrliIMMzZH2lVenTpZhy4aSU49ghzP6NYP7/eu3quu3JOQ7R3cWprGhqbThR 09aw== 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=FIdqnljvYrDW6zPuUX77FXfWOfOD0vHW+lhP63GEhqvARe/Q3nedBlUExKuCmzBiuS Jxs1smeOfMy8PAd4KfPUGjHiC35Mef4fD+Q+hhxTXJ2kC313/FavF+2wkFoQVahJ0LG9 LPkpMrWtP3PXzYbI3qFBnhg0MyMCaHtLAIq3bnlMYaLa64Gteu2/3WtNa8IYREz9mmQ/ uw9q6SFp8Vab5IbPK6+76YCwZR02L41MYKqACyPkAglcm8mZ3RGanV/HlQfEOD01/Ve/ tGtDqzcTYd1zRb9gwGEkSk5ZL24RAD2iUrhSoxOcniLqzXm8Dzu5bmqGj+YwjxZ59M+a X5+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="N29mL0v/"; 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 ds19si7360228ejc.306.2020.11.09.05.25.21; Mon, 09 Nov 2020 05:25:45 -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="N29mL0v/"; 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 S1731445AbgKINVY (ORCPT + 99 others); Mon, 9 Nov 2020 08:21:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388046AbgKINVX (ORCPT ); Mon, 9 Nov 2020 08:21:23 -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 2C8CA2065D; Mon, 9 Nov 2020 13:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604928082; bh=rLhjXJeRAW8D0097gZ8jQCcXv8gLYuj/zeHcbNeT4lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N29mL0v/6PRLdTDVZYYvgCmMTFskaV8kYOryouZgCGxpSa0HfdzsFxc/RsX1xCFwV 2lDuGEjAaStJvw/ExoHMJ0EAjZ5Qmi9AF7ZMxp8M50THirHdFaR3nqMeKUGLsPBW4e kB0G02Vg63vGtaMufVtY+xUfbBXRSxeNqSEEvnAc= 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.9 121/133] usb: dwc3: ep0: Fix delay status handling Date: Mon, 9 Nov 2020 13:56:23 +0100 Message-Id: <20201109125036.509191184@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@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]); }