From patchwork Sat Jan 14 08:40:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 91507 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp563822qgi; Sat, 14 Jan 2017 00:41:20 -0800 (PST) X-Received: by 10.98.71.3 with SMTP id u3mr26565514pfa.66.1484383280910; Sat, 14 Jan 2017 00:41:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si15118894pgn.3.2017.01.14.00.41.20; Sat, 14 Jan 2017 00:41:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbdANIlO (ORCPT + 4 others); Sat, 14 Jan 2017 03:41:14 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:34902 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbdANIlN (ORCPT ); Sat, 14 Jan 2017 03:41:13 -0500 Received: by mail-pg0-f42.google.com with SMTP id 194so1755374pgd.2 for ; Sat, 14 Jan 2017 00:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=C9J5QpS5II1xHx5XSQoIqTUruwOYziuTZzMdUDGBelE=; b=GzPBun+4rw6ahInqWE4LJwG7YaSfQya9Eze4ABWf4cbe43u1cscA2SnVN4grMT8od3 ubHF0ojdaXvC8J6L2fVEq8978U2ZEu935oDjMCB5dZJAboiQ71IDi7Dpt1pFafCtYEJF Plglym376KZXFpnp14OE6fa4CK96atu73qC1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=C9J5QpS5II1xHx5XSQoIqTUruwOYziuTZzMdUDGBelE=; b=tNFR4IZ28u/dDauCG30SpsUgUTqmVUKWNEbOLydbcnyYKYm8P/r46DyEJLNlUWbje2 JD29zDz6IDa1u6evbclyYtrvJ1Ne1hD8jtAKJaCjQa2Iy7NGJwogHn3MgP0lOVC+gnaQ kNZXgztiRcB3lcmX2Xy4NK1N+tPeYSmLzR7P2VYlkkNp1yVSofC+Tg1mC4HyxaPdvx6i 7WevHJfHn5jAygFVI0CpxRkXy2J/bIwxpndBkwFoCQYKpJojjXT+Hn9qA6LA+zE32L8P LHXf2G6IP9AujCBll504il6sKzEa8ahT1KlkZ3xET2ZYD3EfWC76s8VqbcwmGhMmPR59 7UoA== X-Gm-Message-State: AIkVDXJfcaFmwNBqIWZoamx2JsxCDgCu5SMArsMDDVU4isoY/ik+IQ9XlTiePkKyCIYRfI8f X-Received: by 10.84.211.137 with SMTP id c9mr34743285pli.8.1484383273228; Sat, 14 Jan 2017 00:41:13 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id s8sm33873248pfj.30.2017.01.14.00.41.10 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Jan 2017 00:41:12 -0800 (PST) From: Baolin Wang To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase Date: Sat, 14 Jan 2017 16:40:39 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When handing the SETUP packet by composite_setup(), we will release the dwc->lock. If we get the 'USB_GADGET_DELAYED_STATUS' result from setup function, which means we need to delay handling the STATUS phase. But during the lock release period, maybe the request for handling delay STATUS phase has been queued into list before we set 'dwc->delayed_status' flag or entering 'EP0_STATUS_PHASE' phase, then we will miss the chance to handle the STATUS phase. Thus we should check if the request for delay STATUS phase has been enqueued when entering 'EP0_STATUS_PHASE' phase in dwc3_ep0_xfernotready(), if so, we should handle it. Signed-off-by: Baolin Wang --- drivers/usb/dwc3/ep0.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 9bb1f85..e689ced 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -1123,7 +1123,21 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc, dwc->ep0state = EP0_STATUS_PHASE; if (dwc->delayed_status) { + struct dwc3_ep *dep = dwc->eps[0]; + WARN_ON_ONCE(event->endpoint_number != 1); + /* + * We should handle the delay STATUS phase here if the + * request for handling delay STATUS has been queued + * into the list. + */ + if (!list_empty(&dep->pending_list)) { + dwc->delayed_status = false; + usb_gadget_set_state(&dwc->gadget, + USB_STATE_CONFIGURED); + dwc3_ep0_do_control_status(dwc, event); + } + return; }