Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1490221imu; Wed, 23 Jan 2019 18:48:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN7cuLPs0BiOJtJU88ZBfIsIvz1SsPdB1zXeUDO9rgbEMj2TpW4iMCG7zFpvJDo0Dc8oKbwX X-Received: by 2002:a62:7a8b:: with SMTP id v133mr4703075pfc.159.1548298129411; Wed, 23 Jan 2019 18:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548298129; cv=none; d=google.com; s=arc-20160816; b=w7FGEAUKG4Jgr6tmtFsEneDQsnkosiF+MBtarsNaYJccIFzE5qIfp1ENc3z64TbBTK MyGWC8b2EyAif4NfqxHAlCLU2mvRJ9hSpY4oE7Rh6IdkiBh+0utGqPVkuQIAqmcoUOf7 KAapSmnaUjV/dTXMmRqtX9PS/PhesJNulNpPnl2AwbAf2e6BYfxMBi5QqHdrtONJ+IXo 2Xk/trAk24JX73I5n+k4zuArfRgnHNIDodW2wAsk2ebSNG1DHF0aFbLG6znLwOW/0cZK keZCYQhxxnOQeXtu1GnSfSUYPoAOLDUftvN2EhpBEd8Kr9bH6i11ixlv7I1OemuwrZJB xhjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WuKDPQQ5LCMNQzBfPO1dPw0JUumxc3MZb9hEDWJhstU=; b=xlgomceeuaxtMhHMuLnVGSGpyV6Mh4gXOv7FSGvpHmjQY4rzGgqbrXGUidHtsdYV8Y yugGPiNV0rsqN5NAiLSGjNkPf3U5oGR7cqUGYRLZdG6Sh0TvqtrqI2tMVN05TrFXjAyM 7H+Wgs2HiRk5ss0JPDZv+DCbogzF1DikiYgK8BC/HFA9rJDS8zVYm5Rj+327sDe8zIJE yhGE6pnvP4CXW9iUc6xWpK5DawQoo1L3HMnWP2vmSsIgIz8ZwrNiqCQqIu4WjAPAxxqT d8Vx8jZfVLG5D9R/58/1eRbfQxdtnENKllN/B47nh4DyVrPTMAhJZn6lVq+Nd3+BcEPO cUOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SG6mzxld; 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 e3si21068619pfe.203.2019.01.23.18.48.31; Wed, 23 Jan 2019 18:48:49 -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; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SG6mzxld; 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 S1727159AbfAXCs1 (ORCPT + 99 others); Wed, 23 Jan 2019 21:48:27 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:52726 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfAXCs1 (ORCPT ); Wed, 23 Jan 2019 21:48:27 -0500 Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EEE8B23D; Thu, 24 Jan 2019 03:48:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548298104; bh=3h+uxe2sAA9BCJmU9gFmlyspGVcHAmaKH4MwAt4++Ms=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SG6mzxld8CtthHEL7dSRRg2ZlmAsRvpix0AeMLEPtPPossxmhgs4PeuzI1ibyDDvk ixG+L8EXrmdMDwoj7J2/RmqJ4gvZ6uTlhPga9CTWvPGAGX+IMIlPeDoz5aAnEWaGB7 t2aWAvzoVMZT8nvwWEUkqV/s47149RSGPAf9aBpg= Date: Wed, 23 Jan 2019 21:48:16 -0500 From: Paul Elder To: Alan Stern Cc: laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, b-liu@ti.com, rogerq@ti.com, balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 4/6] usb: gadget: add mechanism to specify an explicit status stage Message-ID: <20190124024816.GG7331@localhost.localdomain> References: <20190114051113.GD32268@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 04:10:12PM -0500, Alan Stern wrote: > On Mon, 14 Jan 2019, Paul Elder wrote: > > > On Fri, Jan 11, 2019 at 10:50:11AM -0500, Alan Stern wrote: > > > On Fri, 11 Jan 2019, Paul Elder wrote: > > > > > > > On Wed, Jan 09, 2019 at 02:06:31PM -0500, Alan Stern wrote: > > > > > On Wed, 9 Jan 2019, Paul Elder wrote: > > > > > > > > > > > A usb gadget function driver may or may not want to delay the status > > > > > > stage of a control OUT request. An instance where it might want to is to > > > > > > asynchronously validate the data of a class-specific request. > > > > > > > > > > > > A function driver that wants an explicit status stage should set the > > > > > > newly added explicit_status flag of the usb_request corresponding to the > > > > > > data stage. Later on, the function driver can explicitly complete the > > > > > > status stage by enqueueing a usb_request for ACK, or calling > > > > > > usb_ep_set_halt() for STALL. > > > > > > > > > > > > To support both explicit and implicit status stages, a UDC driver must > > > > > > call the newly added usb_gadget_control_complete function right before > > > > > > calling usb_gadget_giveback_request. To support the explicit status > > > > > > stage, it might then check what stage the usb_request was queued in, and > > > > > > for control IN ACK the host's zero-length data packet, or for control > > > > > > OUT send a zero-length DATA1 ACK packet. > > > > > > > > > > > > Signed-off-by: Paul Elder > > > > > > v4 Acked-by: Alan Stern > > > > > > v1 Reviewed-by: Laurent Pinchart > > > > > > > > > > This looks good and has passed my tests so far. > > > > > > > > Good! Thank you :) > > > > > > > > > Can you check your uvc > > > > > changes using dummy_hcd with the patch below? > > > > > > > > I'm not sure what to make of the test results. I get the same results > > > > with or without the patch. Which I guess makes sense... in dummy_queue, > > > > this is getting hit when the uvc function driver tries to complete the > > > > delayed status: > > > > > > > > req = usb_request_to_dummy_request(_req); > > > > if (!_req || !list_empty(&req->queue) || !_req->complete) > > > > return -EINVAL; > > > > > > > > So the delayed/explicit status stage is never completed, afaict. > > > > > > I presume you are hitting the !list_empty(&req->queue) test, yes? The > > > other two tests are trivial. > > > > Yes, that is what's happening. > > > > > Triggering the !list_empty() test means the request has already been > > > submitted and not yet completed. This probably indicates there is a > > > bug in the uvc function driver code. > > > > The uvc function driver works with musb, though :/ > > Did you ever figure out the reason for the "!list_empty(&req->queue)" > error with dummy_hcd? Was it related to the confusion about completion > callbacks for status requests? Yeah, I'm pretty sure that's what was happening. With what I previously had the uvc function driver wasn't expecting a completion callback for the status stage but the OUT request flag was set so it just kept sending the data stage data to userspace and userspace kept calling the ioctl to send the status stage which kept calling the completion callback and so on, until the dummy_hcd timer triggered and the next request came in. > Interesting new question: How does your code in musb tell the > difference between a 0-length data-stage reply to a control-IN > transfer, and a status-stage request? Both would appear to the UDC > driver as 0-length request submissions for ep0. > Do you explicitly keep track of whether the data stage is pending? musb has a state machine to keep track of which stage it's in, so I just count whatever is queued during the status-IN stage as a status-stage request for control OUT requests. Now that you mention it, I don't actually check that the queued request's length is zero there... gotta fix that. Paul