Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031806AbbKFDHS (ORCPT ); Thu, 5 Nov 2015 22:07:18 -0500 Received: from mail-by2on0139.outbound.protection.outlook.com ([207.46.100.139]:43616 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031061AbbKFDHO (ORCPT ); Thu, 5 Nov 2015 22:07:14 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; Date: Fri, 6 Nov 2015 11:05:07 +0800 From: Peter Chen To: Robert Baldyga CC: , , , , , , Subject: Re: [PATCH 01/23] usb: gadget: f_sourcesink: make ISO altset user-selectable Message-ID: <20151106030506.GB12560@shlinux2> References: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> <1446555242-3733-2-git-send-email-r.baldyga@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1446555242-3733-2-git-send-email-r.baldyga@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD050;1:LUOT0co6RY4m/B1yW2IGePCNqJX7QVvlXkuiFcT6afa03EA6Je+grZ5Yunbf+dK6vjbADmksuZQdWcOX2CdbPfC3wZ74vDUaWiJq7fa57EmEsWphV1ejtN45PlUlXU89t/Lak610WlZlt9PhoABaCofPD95OX5muFZmIioGc4gzA0KLOpwQ2yWSt59C0uzqttLGul2LHvJALnc7trrdvUkRswqt06mxLgo/qr5xYLPtIggtBLe+mgtPhNhFDZ6PaOnV4tZ4byDi29kebHBU+mPE5miEJLnwB1hP+7XPRobrdwDigVP/H++OiO6OdViWcaVbOkkaGv78FmBBBwSj5+0IJy7rJch6zCHEmg1468RWwg21sPkC23/g2mVq63U5/ X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(24454002)(87936001)(104016004)(86362001)(4001350100001)(81156007)(83506001)(2950100001)(77096005)(15975445007)(189998001)(54356999)(76176999)(23726002)(50986999)(92566002)(46406003)(33656002)(33716001)(5008740100001)(19580395003)(5007970100001)(110136002)(47776003)(5001960100002)(105606002)(19580405001)(97756001)(106466001)(6806005)(50466002)(85426001)(5001920100001)(97736004)(11100500001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0301MB2003;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2003;2:Fw8z/6mZUeh/kDBGMd+uebQXmLwqxL6Su8L6zHv/wTtkQ0WsRnfXDPli+dezV+nHmBSEaw/xcoBrwJqA+/8wkW56lVHn86DtnNq5U44KFR3HbfZRmNW2g71iZIJScyFhWCLpe+ydwgA5z80rt/Agod8YJu5NYOfcAcZEMauSyYw=;3:soB0Sfi+7fgQ71Ri/qaHONjCHZGXWYNH/i6qZ/DQkgDKC+HPVAhdRubdQNNMtcufwWom7LIDnkBPDtjiEDbcI53DLq/2sWBMbWgVEuqln6Kc/vgdy5sjtJzBbU5SDKuxRJzMZ8JNtNplAOodj7cpW0dwCjqNzWByZUXGELjBHdA6yRbj6GCidC/h+f5fgL6D+6/1sc5oAYK0zAcBGczXlmq8htHdt/GZo5ZKbXA6OkmHYFXs9AlpOi9M3qR1FktoVlrLlbFxVEERDhhre2QZUg==;25:zSS898TUjCxt69ZDBvPK/IFbWyJ7sXX5QzNAIe46u6F0JQUZxwDhJ2K8R6HUC/63nfjbmFsJ+zUbgH4h57dHtaOS/dq5UAbQh5MwksFea9uTxbNtJARAcnuSpK9nVkYZJc/yqm/CPbEOUSFMQZLswop1VOCA6cjZOnbATsak42NrG0mzQ7z4+YLC5FktqfvBUWtYFndazU7Mp/dZXQotc7era4+ozRWnt3/BGDAD74SjU8R0aLneDiumQFi8doqaUrtzq4vO/OX7SfbmZ77WQA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(42134001)(42139001);SRVR:BLUPR0301MB2003; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2003;20:NlQWwOfQ6HtjoQnHMHnpGpGqI04T0FxWxfMeOQAoODDP08A7gpewVkCxTNbtvvVa30lf0+ZL7QI3KiK8ye2Vwrzx/OymAbS9qAHCbFfYk/Wei7o6hiFCSaQ7PDjyg8S+K8DFZh6Qd2AMPfuHUQBYUstf+VJ38T9hl6jTbsFh//5aBe3Gp7tcwnU2DSS9fQlUPxOb2jcp9NOs654+hZkB7/PBRPzGsXXtqAbE16oEvuJOI+zQliGjLQq7W07pepZQjYbqZ41UirNejIcLcBM1x2plbIpsTWIxM0uipSZu+FATS4W+A++ITxXGfoRKrqYyu+aOfExDaJOndpTmPHBIwIIHoH3zn5d9p4mTZNFAFdA=;4:kPAfpIymMtS2acRfIPSOxKEfoiOd/m9MdXK7hNa7eHLMeyvM8oi0RSzGZmph/S0dzmhh3TGmDQ2+WL9hiJco1YIzRY3MaWw0s8aOiAULaumx2+TuyZMpxE9G56k4P63r4e+wO/iPuqc/qGzHytYK5401lg66uNMJhFzpK4PIaqTo7bEvpR1PGHu2hlfqG+sYyWhEM7eEj3qRHzmkntd6ZTrZLSfl+nnxkoz/lgYRo4Vn0qViI05BiXGPSiXxGdW4/mCSprdxDTgVerZB2vklTovEn3ycTo0upAqUVZbzIeiKa1S2MPxEq4Gs/WYnKEhRchzNWhnKfetPUUCcfk2TKU+xTZAXjL4tUnOJ/XVSm48lOcsQ1GtXqmLouM6VNJQb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001);SRVR:BLUPR0301MB2003;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2003; X-Forefront-PRVS: 07521929C1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0301MB2003;23:Y7YSvn2GqqxQoytmjh8XMTSHRFu2cxhMDhQheiM?= =?us-ascii?Q?Fif56/vRuE+ZAlVKIoSmlEstzcBMFDdLT838KsafXc3d5AIGyedmOawzW4cI?= =?us-ascii?Q?cbsP2AM3lmSNvMABVAJOKnOVgUe8yDDbGiZksj5f0cQzh9ppGdLLFdW0oHf6?= =?us-ascii?Q?gQnPNQtgN6c6RhnKeO+LFqMIIEH3ThVVUDyWmuuCPQU83mEp1TTgPAkWASRr?= =?us-ascii?Q?MiQWQPiwcgSZA+dp0Y+7Fuv11d1w+HYFj+zduLztRFEwLTkOs4wTqQ7VOkDe?= =?us-ascii?Q?DYUfJtVoUovNb9UsdyDnGrY17bwN6WoeN000tK9chC28k9BNSqcj4TZ6nBOB?= =?us-ascii?Q?EAKWClFIguMgDRoSZ5aBkySFftk1u0qIkQkiv8iFfrU4I+ko15ifpU8UHx3T?= =?us-ascii?Q?cGX9rmSdS0WlZ1tmseyYJ5G3yOPXgQDvbKtAH4TnTmU9nk0PvD31YtwXSKhd?= =?us-ascii?Q?HhmFa8dujvZQ5HwMO6numxbtWOzpeLCOwaCM95Vrh2fmpqhB4waB0KJEIfco?= =?us-ascii?Q?XQQA06pELRMv6kTe6MSzMrEqSnCGz7lrwatVEYIZXwN1PvpjMD+UL2l5sS12?= =?us-ascii?Q?vn5P6Eg3kX+b7c748oWG2vcnJyBLTfvzIgTZPZ83sWvP8NKOHnahknurv1K7?= =?us-ascii?Q?Ustjs0WMwd6OrslA0MeUwt7ZuHqBURV+J/20DMTB9LeORNcKKC10RmrXpwEI?= =?us-ascii?Q?zMjTHmA0i/+3ALliUCnvQnsI3oUhHXO7Sp1ZtijIejIfn5WmSNDjCSs3X+tp?= =?us-ascii?Q?rDpNK+dzPxDK4Ez6/kBuJbJdsIHTKDT+7k9BgTS3n3M9PUUmAXvtaXhPcU3m?= =?us-ascii?Q?2IzedqZHD7kzgA+Tm9GsKQzU6bgC0qGRRxBA1G8URWEtIpcOKxiz/W+UCkx3?= =?us-ascii?Q?lbl6ujZa9jThifKls/qloDHYG/L2XCNjgvg469Eve3gFly20yLiQ2YUCT1AK?= =?us-ascii?Q?OMlOw0Sau2VxiwdsCHH86WWYOpFXg/iBpxUbnk2JTEquxT4ZozL4GhU4HMN8?= =?us-ascii?Q?W0hhEZucoKOB6F5z7ZppwOmyWuG9cG1mlN3SGw9GmEaHka1PdS/Hlm65kQW7?= =?us-ascii?Q?9fEYF+Ihag18awFJA5yGlDxkc1koinJl4d+RC/+8APCOYWHAp6D5u+FHpcf2?= =?us-ascii?Q?km+tFeQlwom1kbf6uc1F7T2PozlrBDjB8?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2003;5:S+EMMdMRvCPptZYyI+pTn6v9B06UHjczeqoyYK24Fl9Mo2w6aeG8L1hbMkUJroJ0F7XxLFtCnKRhKS9IB/eLmeMwq/afJeTmiurTbb7TUx7PIGlZB8uXdb/+dQX0jy/JLyGPg13hQ1+s2XvSqCp3CQ==;24:J+KIGTqnJw8ZhQnwGAF+pjDlSCWv6YOy7sY2309uiZ2XYB0hUF4rJWD23nCfHLjTh7EujhghoWyOuX6+SnrFqse9Ww1Iwcsz3b2EnDIiHng=;20:mqjCfaeU79O0DnllNgq1GgLQnOunbKs5jxYuauZ3kaGxbHIRLh9+OWyrp/N+fLHxbLtFXE9xxpvtJw4TPxQjww== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2015 03:07:10.8612 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB2003 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9806 Lines: 287 On Tue, Nov 03, 2015 at 01:53:40PM +0100, Robert Baldyga wrote: > So far it was decided during the bind process whether is iso altsetting > included to f_sourcesink function or not. This decision was based on > availability of isochronous endpoints. > > Since we can assemble gadget driver using composite framework and configfs > from many different functions, availability of given type of endpoint > can depend on selected components or even on their order in given > configuration. > > This can result with non-obvious behavior - even small, seemingly unrelated > change in gadget configuration can decide if we have second altsetting with > iso endpoints in given sourcesink function instance or not. > > Because of this it's way better to have additional parameter allowing user > to decide if he/she wants to have iso altsetting, and if iso altsetting is > included, and there are no iso endpoints available, function bind will fail > instead of silently allowing to have non-complete function bound. Hi Robert, Why another isoc_enabled parameter is needed instead of judging if it is supported through gadget framework? Any use cases can't be supported by current way? Peter > > Signed-off-by: Robert Baldyga > --- > drivers/usb/gadget/function/f_sourcesink.c | 99 ++++++++++++++++++++---------- > drivers/usb/gadget/function/g_zero.h | 3 + > drivers/usb/gadget/legacy/zero.c | 6 ++ > 3 files changed, 77 insertions(+), 31 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c > index d7646d3..1d6ec88 100644 > --- a/drivers/usb/gadget/function/f_sourcesink.c > +++ b/drivers/usb/gadget/function/f_sourcesink.c > @@ -56,6 +56,7 @@ struct f_sourcesink { > unsigned isoc_maxpacket; > unsigned isoc_mult; > unsigned isoc_maxburst; > + unsigned isoc_enabled; > unsigned buflen; > }; > > @@ -347,17 +348,28 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) > > /* allocate bulk endpoints */ > ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); > - if (!ss->in_ep) { > -autoconf_fail: > - ERROR(cdev, "%s: can't autoconfigure on %s\n", > - f->name, cdev->gadget->name); > - return -ENODEV; > - } > + if (!ss->in_ep) > + goto autoconf_fail; > > ss->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); > if (!ss->out_ep) > goto autoconf_fail; > > + /* support high speed hardware */ > + hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; > + hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; > + > + /* support super speed hardware */ > + ss_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; > + ss_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; > + > + if (!ss->isoc_enabled) { > + fs_source_sink_descs[FS_ALT_IFC_1_OFFSET] = NULL; > + hs_source_sink_descs[HS_ALT_IFC_1_OFFSET] = NULL; > + ss_source_sink_descs[SS_ALT_IFC_1_OFFSET] = NULL; > + goto no_iso; > + } > + > /* sanity check the isoc module parameters */ > if (ss->isoc_interval < 1) > ss->isoc_interval = 1; > @@ -379,30 +391,14 @@ autoconf_fail: > /* allocate iso endpoints */ > ss->iso_in_ep = usb_ep_autoconfig(cdev->gadget, &fs_iso_source_desc); > if (!ss->iso_in_ep) > - goto no_iso; > + goto autoconf_fail; > > ss->iso_out_ep = usb_ep_autoconfig(cdev->gadget, &fs_iso_sink_desc); > - if (!ss->iso_out_ep) { > - usb_ep_autoconfig_release(ss->iso_in_ep); > - ss->iso_in_ep = NULL; > -no_iso: > - /* > - * We still want to work even if the UDC doesn't have isoc > - * endpoints, so null out the alt interface that contains > - * them and continue. > - */ > - fs_source_sink_descs[FS_ALT_IFC_1_OFFSET] = NULL; > - hs_source_sink_descs[HS_ALT_IFC_1_OFFSET] = NULL; > - ss_source_sink_descs[SS_ALT_IFC_1_OFFSET] = NULL; > - } > + if (!ss->iso_out_ep) > + goto autoconf_fail; > > if (ss->isoc_maxpacket > 1024) > ss->isoc_maxpacket = 1024; > - > - /* support high speed hardware */ > - hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; > - hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; > - > /* > * Fill in the HS isoc descriptors from the module parameters. > * We assume that the user knows what they are doing and won't > @@ -419,12 +415,6 @@ no_iso: > hs_iso_sink_desc.bInterval = ss->isoc_interval; > hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; > > - /* support super speed hardware */ > - ss_source_desc.bEndpointAddress = > - fs_source_desc.bEndpointAddress; > - ss_sink_desc.bEndpointAddress = > - fs_sink_desc.bEndpointAddress; > - > /* > * Fill in the SS isoc descriptors from the module parameters. > * We assume that the user knows what they are doing and won't > @@ -447,6 +437,7 @@ no_iso: > (ss->isoc_mult + 1) * (ss->isoc_maxburst + 1); > ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; > > +no_iso: > ret = usb_assign_descriptors(f, fs_source_sink_descs, > hs_source_sink_descs, ss_source_sink_descs); > if (ret) > @@ -459,6 +450,11 @@ no_iso: > ss->iso_in_ep ? ss->iso_in_ep->name : "", > ss->iso_out_ep ? ss->iso_out_ep->name : ""); > return 0; > + > +autoconf_fail: > + ERROR(cdev, "%s: can't autoconfigure on %s\n", > + f->name, cdev->gadget->name); > + return -ENODEV; > } > > static void > @@ -868,6 +864,7 @@ static struct usb_function *source_sink_alloc_func( > ss->isoc_maxpacket = ss_opts->isoc_maxpacket; > ss->isoc_mult = ss_opts->isoc_mult; > ss->isoc_maxburst = ss_opts->isoc_maxburst; > + ss->isoc_enabled = ss_opts->isoc_enabled; > ss->buflen = ss_opts->bulk_buflen; > > ss->function.name = "source/sink"; > @@ -1125,6 +1122,45 @@ static struct f_ss_opts_attribute f_ss_opts_isoc_maxburst = > f_ss_opts_isoc_maxburst_show, > f_ss_opts_isoc_maxburst_store); > > +static ssize_t f_ss_opts_isoc_enabled_show(struct f_ss_opts *opts, char *page) > +{ > + int result; > + > + mutex_lock(&opts->lock); > + result = sprintf(page, "%u\n", opts->isoc_enabled); > + mutex_unlock(&opts->lock); > + > + return result; > +} > + > +static ssize_t f_ss_opts_isoc_enabled_store(struct f_ss_opts *opts, > + const char *page, size_t len) > +{ > + int ret; > + bool enabled; > + > + mutex_lock(&opts->lock); > + if (opts->refcnt) { > + ret = -EBUSY; > + goto end; > + } > + > + ret = strtobool(page, &enabled); > + if (ret) > + goto end; > + > + opts->isoc_enabled = enabled; > + ret = len; > +end: > + mutex_unlock(&opts->lock); > + return ret; > +} > + > +static struct f_ss_opts_attribute f_ss_opts_isoc_enabled = > + __CONFIGFS_ATTR(isoc_enabled, S_IRUGO | S_IWUSR, > + f_ss_opts_isoc_enabled_show, > + f_ss_opts_isoc_enabled_store); > + > static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page) > { > int result; > @@ -1170,6 +1206,7 @@ static struct configfs_attribute *ss_attrs[] = { > &f_ss_opts_isoc_maxpacket.attr, > &f_ss_opts_isoc_mult.attr, > &f_ss_opts_isoc_maxburst.attr, > + &f_ss_opts_isoc_enabled.attr, > &f_ss_opts_bulk_buflen.attr, > NULL, > }; > diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/function/g_zero.h > index 15f1809..8a99071 100644 > --- a/drivers/usb/gadget/function/g_zero.h > +++ b/drivers/usb/gadget/function/g_zero.h > @@ -10,6 +10,7 @@ > #define GZERO_QLEN 32 > #define GZERO_ISOC_INTERVAL 4 > #define GZERO_ISOC_MAXPACKET 1024 > +#define GZERO_ISOC_ENABLED 1 > > struct usb_zero_options { > unsigned pattern; > @@ -17,6 +18,7 @@ struct usb_zero_options { > unsigned isoc_maxpacket; > unsigned isoc_mult; > unsigned isoc_maxburst; > + unsigned isoc_enabled; > unsigned bulk_buflen; > unsigned qlen; > }; > @@ -28,6 +30,7 @@ struct f_ss_opts { > unsigned isoc_maxpacket; > unsigned isoc_mult; > unsigned isoc_maxburst; > + unsigned isoc_enabled; > unsigned bulk_buflen; > > /* > diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c > index 37a4100..3579310 100644 > --- a/drivers/usb/gadget/legacy/zero.c > +++ b/drivers/usb/gadget/legacy/zero.c > @@ -66,6 +66,7 @@ module_param(loopdefault, bool, S_IRUGO|S_IWUSR); > static struct usb_zero_options gzero_options = { > .isoc_interval = GZERO_ISOC_INTERVAL, > .isoc_maxpacket = GZERO_ISOC_MAXPACKET, > + .isoc_enabled = GZERO_ISOC_ENABLED, > .bulk_buflen = GZERO_BULK_BUFLEN, > .qlen = GZERO_QLEN, > }; > @@ -249,6 +250,10 @@ module_param_named(isoc_maxburst, gzero_options.isoc_maxburst, uint, > S_IRUGO|S_IWUSR); > MODULE_PARM_DESC(isoc_maxburst, "0 - 15 (ss only)"); > > +module_param_named(isoc_enabled, gzero_options.isoc_enabled, uint, > + S_IRUGO|S_IWUSR); > +MODULE_PARM_DESC(isoc_enabled, "0 - disabled, 1 - enabled"); > + > static struct usb_function *func_lb; > static struct usb_function_instance *func_inst_lb; > > @@ -284,6 +289,7 @@ static int zero_bind(struct usb_composite_dev *cdev) > ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket; > ss_opts->isoc_mult = gzero_options.isoc_mult; > ss_opts->isoc_maxburst = gzero_options.isoc_maxburst; > + ss_opts->isoc_enabled = gzero_options.isoc_enabled; > ss_opts->bulk_buflen = gzero_options.bulk_buflen; > > func_ss = usb_get_function(func_inst_ss); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/