Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp894883pxb; Tue, 1 Feb 2022 12:39:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE8D3MxFlQtLP4yYKAjcRgtLxjJyZiO9ndS/WXvxZlsq7/A372dJCKsCot2Zk2LboSSqw+ X-Received: by 2002:a63:5454:: with SMTP id e20mr21838042pgm.621.1643747947306; Tue, 01 Feb 2022 12:39:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643747947; cv=none; d=google.com; s=arc-20160816; b=wmW1yEqCmjVDgSKRtj7kZDkF3BOEGR+geN4zz5i75S3kEb34AUfAVMePh4yI3bwJ4Z t6aPBqP0T2wCwnTzNQ8pVfy1am++8/y1x8zFAyHFiRf6ynnPO+fHqG/ymsxMsKQVHdLU /k4QqB/uBF7alHrzkfkEi2cwZEudTAeLqeCkCIX1fGB07OucGZ1BJa/G9KTjBUnT+noq D5jiD2BI11o8dPv30kkKG6naxtvOhmSgP456xqp07chAvEXO2YigFZgSfx5hJnu1gjV/ ILDChAR2kenTGuLoaRWZ1XQ+niMB6rkevdXtZawG/1MG+EMdDbqIjzvRe1zXxStdH90/ 2UfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VCgP12SciOPycsXe9rZksnsfyeFgIdcL3SxJRJkFv6s=; b=CkLKzOIEQxqPP2dU2C7HZ7whVCDz0L7y5+TrWvMTPOYigkFYtxd1mMX/GJO3ffWaQx U9dGMIXcwsfFN0C1JQTm+PxOp1nG/hW0fZpILCzYXAN9Bei5swKg5Kj3TQuYjSPk+KSS MvOvKa9KQ2LQwxSE/ww29jHkqXX/DFv75ngpHDUWhyrwJXmlAfvw0VWRmaETgaoCR9UI af5Uk7BRDwd+fnYhFPh+xx5PI/ko+WbI/DufEOygMtmGlIZAhG9SKnHFDJI+bwRRylLW BeOXNQevtCUqtW8i+PYnEepzaOwQhTQ+kRgR8jggAKJn2PxlWoCN8tf4hVFqV/hFMb0Z g+lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hGd2izQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si19499727pgq.34.2022.02.01.12.38.53; Tue, 01 Feb 2022 12:39:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hGd2izQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377213AbiAaNUS (ORCPT + 99 others); Mon, 31 Jan 2022 08:20:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbiAaNUN (ORCPT ); Mon, 31 Jan 2022 08:20:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A790CC061714; Mon, 31 Jan 2022 05:20:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D3916B82AE1; Mon, 31 Jan 2022 13:20:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA3F5C340EE; Mon, 31 Jan 2022 13:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643635210; bh=qk/GzWF+PrZ1CJd+U4cjuHtK3Pd/DekAoW2KSXSyNPU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hGd2izQErHbOw9LEBcl3F1TlOXSeLwd/5wFFQJMYLIGUZLPFdN8/DINM+t5FybI2e t4QwGUA69EUrzH3GzfG9VB4I7xQHGXn8FF9C+jvPX/y3SsFA/aSkEuY34ydtarvJV/ 6fo4wCvtH2rvTCrWaWk3+xuTZGk8QGXKYtEwZ0WM= Date: Mon, 31 Jan 2022 14:20:07 +0100 From: Greg Kroah-Hartman To: Andrey Konovalov Cc: Felipe Balbi , USB list , LKML , Jann Horn , stable@vger.kernel.org Subject: Re: [PATCH] usb: raw-gadget: fix handling of dual-direction-capable endpoints Message-ID: References: <20220126205214.2149936-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 30, 2022 at 10:58:42PM +0100, Andrey Konovalov wrote: > On Wed, Jan 26, 2022 at 11:37 PM Andrey Konovalov wrote: > > > > On Wed, Jan 26, 2022 at 11:31 PM Jann Horn wrote: > > > > > > On Wed, Jan 26, 2022 at 11:12 PM Andrey Konovalov wrote: > > > > On Wed, Jan 26, 2022 at 9:52 PM Jann Horn wrote: > > > > > > > > > > Under dummy_hcd, every available endpoint is *either* IN or OUT capable. > > > > > But with some real hardware, there are endpoints that support both IN and > > > > > OUT. In particular, the PLX 2380 has four available endpoints that each > > > > > support both IN and OUT. > > > > > > > > > > raw-gadget currently gets confused and thinks that any endpoint that is > > > > > usable as an IN endpoint can never be used as an OUT endpoint. > > > > > > > > > > Fix it by looking at the direction in the configured endpoint descriptor > > > > > instead of looking at the hardware capabilities. > > > > > > > > > > With this change, I can use the PLX 2380 with raw-gadget. > > > > > > > > > > Fixes: f2c2e717642c ("usb: gadget: add raw-gadget interface") > > > > > Signed-off-by: Jann Horn > > > > > --- > > > > > drivers/usb/gadget/legacy/raw_gadget.c | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c > > > > > index c5a2c734234a..d86c3a36441e 100644 > > > > > --- a/drivers/usb/gadget/legacy/raw_gadget.c > > > > > +++ b/drivers/usb/gadget/legacy/raw_gadget.c > > > > > @@ -1004,7 +1004,7 @@ static int raw_process_ep_io(struct raw_dev *dev, struct usb_raw_ep_io *io, > > > > > ret = -EBUSY; > > > > > goto out_unlock; > > > > > } > > > > > - if ((in && !ep->ep->caps.dir_in) || (!in && ep->ep->caps.dir_in)) { > > > > > + if (in != usb_endpoint_dir_in(ep->ep->desc)) { > > > > > dev_dbg(&dev->gadget->dev, "fail, wrong direction\n"); > > > > > ret = -EINVAL; > > > > > goto out_unlock; > > > > > > > > > > base-commit: 0280e3c58f92b2fe0e8fbbdf8d386449168de4a8 > > > > > -- > > > > > 2.35.0.rc0.227.g00780c9af4-goog > > > > > > > > > Reviewed-by: Andrey Konovalov > > Tested-by: Andrey Konovalov > > Greg, could you PTAL and pick this up? > > It also makes sense to include this fix into stable kernels. > > Cc: Now picked up, thanks. greg k-h