Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4359358imu; Mon, 7 Jan 2019 21:52:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN4waV5IHHgsedNLx/QqkZuDOVBtcqFepai0AaCXIevREHknj0FwNZw4eGJUVGECr+6CQ2RU X-Received: by 2002:a63:cd11:: with SMTP id i17mr363787pgg.345.1546926721727; Mon, 07 Jan 2019 21:52:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546926721; cv=none; d=google.com; s=arc-20160816; b=I5x+HAIrOS/aQ3jfTIBwUheZiu2q6WUryoU54z50mSfLhEvxZ/OffvYtYGNbNZcGk+ Pwh1RhLjFzDMLcQ4gV8Q/DzhWHbJ+OACnqsdOtDAjPDHOhSX/DITT6Ukr6z2IJecQOPU wee/jMoph9dwRcnf6Ww1jCdlKpW5PL/1vwTMpdZOUAsdiNSb0X5Wo1bb9pX1nVM2ievy SPSI5Dywb49akuhr05gR0SBWe/pXot2c9x5c4+9KeHv23ngUTPwdkFkaWiX+xiSud1Fz emkeCcH3APJUCdaXPVFprjheZrpfcoOBA0vIC1it26pWeq5Oi45Og5U5fryr0ZwVEbTo NFow== 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=nouVw1EW3A4Bv0xrIR8QqWzqI+/93jGUwwDEtK7XQuk=; b=KKy1nBSz+PmvKK/2OEjWPqTEll9g5BdcIW069Is6y2DUsgfNU9qVopNuQvJuXPYAN8 agyeBBmEoPhRLASvE5Q7IhEiJbOy9chlxuN8ANVqFy9Sl0f4I9zlMTtKuX1X2dAUEVGI M2yeuEIccKit+WikQB3UfFG7oXX8fuNn9qoe9guP9bDSsu4GGEL511EIAyfLt4uNyL9E v5gQiZMzMvumMJz9Uh+flwjyRG1mxLRygFEzQ9z7+XRtLpgxIgcJH26dJEdSqI8tT7Pv pIUnVDaOJ4+YlF14jI9LryhqnTgOHygadRCTstMvky0hV6QZNd05Xx06mxVCDSpp1RPQ 1iiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=vHz5qEHV; 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 s36si30453388pld.46.2019.01.07.21.51.46; Mon, 07 Jan 2019 21:52:01 -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=vHz5qEHV; 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 S1727625AbfAHFt3 (ORCPT + 99 others); Tue, 8 Jan 2019 00:49:29 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:50762 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727290AbfAHFt2 (ORCPT ); Tue, 8 Jan 2019 00:49:28 -0500 Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 097DE586; Tue, 8 Jan 2019 06:49:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546926566; bh=haDBg8FRrGdlSSiUJXlAfb0IkDX+97QtVOk53gCXxSQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vHz5qEHVgpTqkpZwhDUdMmFC8PIcR6P6CCy7xa2ci8/NVw6bDc1BMcJz0WUdieQ90 6OpeeQ0AY6URuu9mT2Vpem4L7N13bz44qqjjIekhCLJ3e1v+A3++H4HxvpsNISn8U/ 27uqamP6xGuzG5kWeEmkQk8phw5Q64PM25MRnikA= Date: Tue, 8 Jan 2019 00:49:18 -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 v4 5/6] usb: musb: gadget: implement optional explicit status stage Message-ID: <20190108054918.GB31873@localhost.localdomain> References: <20190106160221.4480-6-paul.elder@ideasonboard.com> 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 Sun, Jan 06, 2019 at 03:03:09PM -0500, Alan Stern wrote: > On Sun, 6 Jan 2019, Paul Elder wrote: > > > Implement the mechanism for optional explicit status stage for the MUSB > > driver. This allows a function driver to specify what to reply for the > > status stage. The functionality for an implicit status stage is > > retained. > > > > Signed-off-by: Paul Elder > > v1 Reviewed-by: Laurent Pinchart > > v1 Acked-by: Bin Liu > > --- > > No change from v3 > > > > Changes from v2: > > - update call to usb_gadget_control_complete to include status > > - since sending STALL from the function driver is now done with > > usb_ep_set_halt, there is no need for the internal ep0_send_response to > > take a stall/ack parameter; remove the parameter and make the function > > only send ack, and remove checking for the status reply in the > > usb_request for the status stage > > > > Changes from v1: > > - obvious change to implement v2 mechanism laid out by 4/6 of this > > series (send_response, and musb_g_ep0_send_response function has > > been removed, call to usb_gadget_control_complete has been added) > > - ep0_send_response's ack argument has been changed from stall > > - last_packet flag in ep0_rxstate has been removed, since it is equal to > > req != NULL > > > > drivers/usb/musb/musb_gadget.c | 2 ++ > > drivers/usb/musb/musb_gadget_ep0.c | 23 +++++++++++++++++++++++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c > > index d3f33f449445..a7a992ab0c9d 100644 > > --- a/drivers/usb/musb/musb_gadget.c > > +++ b/drivers/usb/musb/musb_gadget.c > > @@ -145,6 +145,8 @@ __acquires(ep->musb->lock) > > > > trace_musb_req_gb(req); > > usb_gadget_giveback_request(&req->ep->end_point, &req->request); > > + usb_gadget_control_complete(&musb->g, request->explicit_status, > > + request->status); > > I haven't paid much attention to this part of the patch series, not > knowing much about musb. Still, it's clear that > usb_gadget_control_complete should be called only for transfers on > ep0. You need to test the endpoint value. Oh oops, yeah, you're right. > Another problem: the completion handler may deallocate the request. > Dereferencing request->expicit_status and request->status would then > cause errors. Would it be preferable to call > usb_gadget_control_complete before usb_gadget_giveback_request? If > it gets done that way then the arguments could be simplified: we could > pass a pointer to the request instead of the separate explicit_status > and status values. I thought that usb_gadget_control_complete needs to check the status of the request that was given back. Doesn't that mean that usb_gadget_giveback_request must be called first? I was thinking that maybe we could save explicit_status before calling usb_gadget_giveback_request, and if request is still valid then we can pull status from it otherwise use 0, but then would that be considered adding complexity to UDCs that want to implement optional status stage delay? Or add a wrapper function? On the other hand, if we do put usb_gadget_control_complete before usb_gadget_giveback_request, then the control transfer would complete before the function driver has a chance to complete, but if the function driver wanted to intervene/determine the status stage then it would have gone through the new mechanism that we're making here. So it could be fine to switch the order. My tests for it work too, so I guess we'll go with usb_gadget_control_complete before usb_gadget_giveback_request then. In that case usb_gadget_control_complete doesn't need to check the status of the request, since there isn't any, right? Thanks, Paul Elder