Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp997141imu; Fri, 11 Jan 2019 12:59:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN5TQLHUbRHflBWzK1U8elEnj6MUQGOmKNKcV9FNV81e8EWM8OYAqd5Cg138VwrkQAQ/tB4t X-Received: by 2002:a63:2222:: with SMTP id i34mr11588822pgi.83.1547240378445; Fri, 11 Jan 2019 12:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547240378; cv=none; d=google.com; s=arc-20160816; b=Ll9cCQvEl1spZYQ/y8mfH15z6BBQEX4PIWyGiCOV/RgMU6lsvrzmaVWzXe39cSJpsw lGlUv8GMnMIgwRv64Ag4zM2rND78NhetM5Dl+TiAFiGE/+fEExalPFD9PANkVgERfXw2 r/NIHdso7Q2pFwOPKBEqCMm7wsrmg3BVh54dD24Nt+fOsQoe7JxvSJrDccqpihRom/GM owl4DQlU2M/vfIDaCtfq6JvtvJjZWw+1SAoBN8I+W/RI1xTohulLiYUeZLd3Q99+2K76 76YSqvUBjioLhtRKX0XI4N9zyoCNJCRWVQSVNJg+SpqovosrFcTlZSC/t7la/S72p0JR s1vg== 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=4sa+1j2fHWDRrEZUXQPAPS8PNzqhUccvpY+N1VEvrTQ=; b=h3Ie++s+X6Tdw3xCb7qgzEuzasAgElo5i4/EDSZDMXtnz5ovAtr258QLOZAKAOh/kh WVmsKX3GybBB7B/uuAzgC5NCffdJMXOpsB0047+qU7wTrRbOXEgSpIZHLPXOaakZ2eCw 1/tEWpCtOPI1b7KaILmKoEygeruT0kPqXPaB3iS0YB1LU+L+qPbA4A0Vu/EfCOueKk3/ 7KGxFjXP9Gu06nSTgGCJ49XNaQK6q1tEIr06lXetFs+EcOh4YINDIrZ0I3He77s2SoaA kNdy+VGZXcqqFCZ2/uda8MXfBU2wpZn60Z2zfS/wfINBMu3ONT93wbs6MK8i1oU6O5hB B0/Q== 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 68si15745740pgh.320.2019.01.11.12.59.23; Fri, 11 Jan 2019 12:59:38 -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 S2389343AbfAKSc5 (ORCPT + 99 others); Fri, 11 Jan 2019 13:32:57 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:44562 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1733084AbfAKSc4 (ORCPT ); Fri, 11 Jan 2019 13:32:56 -0500 Received: (qmail 5483 invoked by uid 2102); 11 Jan 2019 13:32:56 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 11 Jan 2019 13:32:56 -0500 Date: Fri, 11 Jan 2019 13:32:55 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Paul Elder cc: laurent.pinchart@ideasonboard.com, , , , , , USB list , Kernel development list Subject: Re: [PATCH v5 0/6] usb: gadget: add mechanism to asynchronously validate data stage of ctrl out request In-Reply-To: <20190111084346.GC32268@localhost.localdomain> 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 Fri, 11 Jan 2019, Paul Elder wrote: > On Thu, Jan 10, 2019 at 03:39:25PM -0500, Alan Stern wrote: > > On Wed, 9 Jan 2019, Paul Elder wrote: > > > > > This patch series adds a mechanism to allow asynchronously validating > > > the data stage of a control OUT request, and for stalling or suceeding > > > the request accordingly. > > > > One thing we haven't mentioned explicitly: What should happen when the > > time for the status stage rolls around if the gadget driver queues a > > non-zero length request? > > Ah, yeah, I missed that. > > > This can happen in a few different ways. One obvious possibility is > > that the gadget driver sets the explicit_status flag and then submits a > > non-zero length request. Another is that the gadget driver submits > > _two_ requests during the data stage (the second would be interpreted > > as the status-stage request). A third is that the gadget driver > > submits a data-stage request that is too long and the excess portion is > > used for the status stage. > > > > My feeling is that the behavior in these cases should officially be > > undefined. Almost anything could happen: the status stage could STALL, > > it could succeed, it could NAK, or it could send a non-zero packet to > > the host. The request could return with 0 status or an error status, > > and req->actual could take on any reasonable value. > > > > Alternatively, the UDC driver could detect these errors and report them > > somehow. Maybe STALL the status stage and complete the request with > > -EPIPE status or some such thing. > > > > Any preferences or other ideas? > > I think error detection and reporting would be useful. The question is > what action to take after that; either leave it undefined or STALL. I > think STALL would be fine, since if a non-zero length request is > submitted for a status stage, intentionally or not, it isn't part of > proper behavior and should count as an error. Okay; I will have to change the code in dummy-hcd to do this. You might need to update musb as well. > > One other thing: Some UDC drivers may assume that the data stage of a > > control transfer never spans more than a single usb_request. Should > > this become an official requirement? > > Would the data stage of a control transfer ever need more space than a > single usb_request can contain? I know UVC doesn't; that's why we pack > it together with the setup stage data in 3/6. If so, I would think we > can make it a requirement. The data stage of a control transfer cannot be larger than 64 KB. Certainly a single usb_request can handle that; the question concerns whether a function driver might want to split the data up among several different requests just for convenience. Felipe, any thoughts? Alan Stern