From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751992AbdB1SnM (ORCPT ); Tue, 28 Feb 2017 13:43:12 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:33946 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751511AbdB1SmY (ORCPT ); Tue, 28 Feb 2017 13:42:24 -0500 Date: Tue, 28 Feb 2017 13:34:05 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: Baolin Wang , Greg KH , USB , LKML , Linaro Kernel Mailman List , Mark Brown Subject: Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase In-Reply-To: <87tw7ettoo.fsf@linux.intel.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Feb 2017, Felipe Balbi wrote: > > Hi, > > Alan Stern writes: > >> So I am not sure how the Gadget driver can figure out that it needs to > >> usb_ep_queue() another request for status stage when handling the > >> no-data control? > > > > Gadget drivers already queue status-stage requests for no-data > > control-OUT requests. The difficulty comes when you want to handle an > > IN request or an OUT request with a data stage. > > I don't see a difficulty there. Gadget driver will see wLength and > notice it needs both data and status stages, then it does: > > usb_ep_queue(ep0, data_req, GFP_KERNEL); > usb_ep_queue(ep0, status_req, GFP_KERNEL); The main difficulty is that all the gadget/function drivers will have to be audited to add the status requests. > Just needs to prepare both requests and queue them both ahead of > time. UDC drivers should hold both requests in their own private list > and process one at a time. Or the gadget driver should queue the status request after the data stage has been fully processed, in the case of an OUT transfer. There is still a possible race. The host might send another SETUP packet before the status request has been queued, or after it has been queued but before the UDC driver has completed it. (Of course, that's already true now for the data request...) Alan Stern