Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2869772imu; Sun, 6 Jan 2019 12:04:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN7TzdhRTVSw6Jrm5/f3ddttFwLADfX/aQqkq9pqhlslO0TV/Pg+oqPQfwmNKbxDGsr9rRz9 X-Received: by 2002:a65:534b:: with SMTP id w11mr8700862pgr.125.1546805077674; Sun, 06 Jan 2019 12:04:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546805077; cv=none; d=google.com; s=arc-20160816; b=wFJTHlTV0OQou+bypwss+RaMAgV3bR+NJ8pZTnpbn2qBtcYFzU4qcS8gZ+bpCkepZU M8IPkmtF7EWHt/cquA/+cVp0eohARl04uqIK5SCVocQFSDVXB/E47+DI8M/KMZfy8XXC lSI86vN3DdUKT91svbW0Ww35OyMA8R61+iGD6Qfy038H25vQTL/0L/pOj4exMQZINbLm NE+2jGtsfN4iWclQ4Lx1bmmNeztlzNnelHZGoEsCufYOQpCPnPbZmGR4jMEavN6PUAFo ucaN/vMeVli1y0Aefr5S07Sl/aY/GnTJztI4lElj0DDL1mC3q6WwlVeffNrh+sTaEs31 76ow== 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=/TfnQnjpRs5LUBVjgLhrhWJtVRz85qrhGBSkHolrbzI=; b=WL0U6EMXSok1OmSem3ykaS4xxigadbZr/EpxGVVG81NHvG61yifap14oQjvTdI5A0P n0o50KnPW3Jpo3+5nIE8Eg4hWjR4++nOPfn8aTk1DJM+DYOWe53DRbmxt1cSLYqneH/0 wnbMDmLS6c1zT/jfSgF1HIQ/x1QTgUHgzbkDN5Q+SfBM6OdofN4JqlPdO8BtsoRZNN/3 141WkbgKMxYGg7mxLneKGKNLBsvUT5XBY4ukjK9RuDGO4l6Bu4/Rg8LZeTL2EOk6Kcmm WGUb2YE45RZhgFnklngFbphMBFEU92rIso9l9EKmSxUcmDg2IYGNuNkwkNP34cMbhQqt 0D8Q== 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 i129si67353864pfb.32.2019.01.06.12.04.20; Sun, 06 Jan 2019 12:04:37 -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 S1726089AbfAFUDL (ORCPT + 99 others); Sun, 6 Jan 2019 15:03:11 -0500 Received: from netrider.rowland.org ([192.131.102.5]:34037 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726060AbfAFUDK (ORCPT ); Sun, 6 Jan 2019 15:03:10 -0500 Received: (qmail 18969 invoked by uid 500); 6 Jan 2019 15:03:09 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 6 Jan 2019 15:03:09 -0500 Date: Sun, 6 Jan 2019 15:03:09 -0500 (EST) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Paul Elder cc: laurent.pinchart@ideasonboard.com, , , , , , , Subject: Re: [PATCH v4 5/6] usb: musb: gadget: implement optional explicit status stage In-Reply-To: <20190106160221.4480-6-paul.elder@ideasonboard.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 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. 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. Alan Stern