Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1960256imu; Tue, 6 Nov 2018 07:02:19 -0800 (PST) X-Google-Smtp-Source: AJdET5cjZqxorla/SulHHjFGh+vsXt4mzEQCQGrUhDejkV+EPCtYAH2aal8el8YL2xBMOhz2Dxev X-Received: by 2002:a63:4c6:: with SMTP id 189mr24345027pge.391.1541516539171; Tue, 06 Nov 2018 07:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541516539; cv=none; d=google.com; s=arc-20160816; b=fO8k9H3zl2MW1pYEcsjRtujavZbDFs0YaRsBr03G/JOLbl/4UyRMrjTHFqxMB6Q8+5 bJMZifydSQeTp+2oCMQNowh0DBlawPF22U3fiTsXj81+KygcAiuQjDO/YnxxClGVo0/q QCewGTRcCDzb/1GdXA68XYGmaYj4ym77JIJmbeLHBVuh1jxjKeiMfVj4lT0CRyKIh+4T ySFQqmdj9dZaqZ3R8Jxe7Vne1JsoqkmE+sGCYxA1gtl//Mn+GFKU09ydQOUZo8EeTXu0 t/52TiqmsYogeKhVOL7kjP2YRyvnX/xq6VX0lqOhy8pVWoaDtGXaMWGxOB7eiJYPkClJ 3+OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=aMykDl6q5ntX94it/HC/6wk2CBRbFGrHvOx+Zc+4fNg=; b=oQsGGnY7SWB0gkEXbYbteFFruk7UN1cNKBKpLBvNKgElONkIFAnt6isTnLp4/2RFcZ TuTI44eC+NfDXBcS3z6LrrBLmp8KpC0YMILkaSPADPvwzxCy+HGTE0ffK3GrplkV2lmZ Nedc+9E22uge40Dc+m4sTZMDclTBO/nWplSG0acMMfdRnEsCjiH2Sa3axoCQh7d80xJ3 PUtVMJVGzceRuBflvPIxiL8ARQHiPYDjBkv6tN28H0bR9SxWJTaKZYq3JwtZblNlU6Hk jp/HFtVbDvtSjCItp7AGR4vTbMHSCXeIQxO10LyMLeJxlqpOArnREejz9o7WP1NOwzGg I/gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4-v6si30238002pla.203.2018.11.06.07.01.59; Tue, 06 Nov 2018 07:02:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730670AbeKGA0w (ORCPT + 99 others); Tue, 6 Nov 2018 19:26:52 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:36650 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729642AbeKGA0w (ORCPT ); Tue, 6 Nov 2018 19:26:52 -0500 Received: (qmail 2409 invoked by uid 2102); 6 Nov 2018 10:01:14 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 6 Nov 2018 10:01:14 -0500 Date: Tue, 6 Nov 2018 10:01:14 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: Laurent Pinchart , Paul Elder , Bin Liu , , , USB list , Kernel development list , Subject: Re: [PATCH 4/6] usb: gadget: add functions to signal udc driver to delay status stage In-Reply-To: <87a7mmv46v.fsf@linux.intel.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 6 Nov 2018, Felipe Balbi wrote: > > Hi, > > Alan Stern writes: > > There's a similar race at the hardware level. What happens if the > > controller receives a new SETUP packet and concurrently the driver is > > setting up the controller registers for a response to an earlier > > SETUP? I don't know how real controllers handle this. > > That's HW implementation detail. DWC3, for instance, will ignore the > TRBs and return me the status "setup packet pending". Then I just start > a new SETUP TRB. You mean the UDC hardware sets a "setup pending" flag in some register, and then ignores any attempts to do anything with ep0 until the driver clears this flag? We could do something similar at the software level. In fact, that would be one of the two proposals I outlined in an earlier email. > > You mean, should we allow function drivers to queue the data-stage > > request after the setup handler has returned? I don't see any reason > > that's already done: > > static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, > const struct dwc3_event_depevt *event) > { > struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; > > dep->flags &= ~DWC3_EP_TRANSFER_STARTED; > dep->resource_index = 0; > dwc->setup_packet_pending = false; > > switch (dwc->ep0state) { > case EP0_SETUP_PHASE: > dwc3_ep0_inspect_setup(dwc, event); > break; > [...] > } ... You mean, it's already done in DWC3. What about other UDC drivers? > > why not. After all, some drivers may require this. Likewise for the > > data stage of a control-IN. > > > > Another thing we should do is give function drivers a way to send a > > STALL response for the status stage. Currently there's no way to do > > it, if a data stage is present. > > Status stage can only be stalled if host tries to move data on the wrong > direction. The USB-2 spec disagrees. See Table 8-7 in section 8.5.3.1 and the following paragraphs. (Although, I can't see why a function would ever fail to complete the command sequence for a control-IN transfer after the data had already been sent.) Alan Stern