Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667AbbKWHng (ORCPT ); Mon, 23 Nov 2015 02:43:36 -0500 Received: from mail-bn1bn0102.outbound.protection.outlook.com ([157.56.110.102]:8807 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750724AbbKWHne (ORCPT ); Mon, 23 Nov 2015 02:43:34 -0500 X-Greylist: delayed 19777 seconds by postgrey-1.27 at vger.kernel.org; Mon, 23 Nov 2015 02:43:33 EST Authentication-Results: spf=permerror (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; samsung.com; dkim=none (message not signed) header.d=none;samsung.com; dmarc=none action=none header.from=freescale.com; Date: Mon, 23 Nov 2015 15:40:31 +0800 From: Peter Chen To: Alan Stern CC: Marek Szyprowski , , , Ruslan Bilovol , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v6 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Message-ID: <20151123074030.GC16321@shlinux2> References: <1448009652-14716-5-git-send-email-m.szyprowski@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD042;1:6kORimgZK00W+SxYQciNFq+2dQl09coSx60Bn4s+23w464TYa44Sfqdkp0lvwM435mb8rtQ2KR92dNCYOXXjZAAbV5abKyGRG9EhoKooabh/bd2SAVZnTmrTtkmNvnIam/VvifUNQr4oDIcIw6OjludoUz0WwKjymbgmL9afzjJp81FbmRa+LSQJjPPDgkRR6a32gXhY5AEIu77rPlMb7MYyjp1itOT6aWtr794CSJxrJayqUckqDznzZWx9mwo+LAPb4NFXc29BmK/0SCvk/rNTjwh5jphARlA5Bj+CHInWt8lPu8QeiSbYhsWr8i2KJSfeV8rntFej2dKOG9nF68N3xU1mm2zZP+w3ERyoOYm90hThoBmPVYwYsx22usTesw3I7oupDfUAsI7Jc/pYkX5+y1Zpk4NF25BIWBYIecubfvV6U6reVIYQoKK8c+JK X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(979002)(6009001)(1060300003)(2980300002)(448002)(199003)(24454002)(189002)(5008740100001)(2950100001)(77096005)(47776003)(6806005)(2171001)(11100500001)(110136002)(5001960100002)(23726003)(4001350100001)(104016004)(606003)(81156007)(46406003)(97736004)(106466001)(110436001)(87936001)(85326001)(83506001)(54356999)(97756001)(33716001)(86362001)(50466002)(92566002)(33656002)(19580395003)(5007970100001)(69596002)(4290100001)(50986999)(19580405001)(76176999)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0301MB1221;H:az84smr01.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1221;2:v8WBKLiLaXZNBxPgoK2GfqiIPq+E3vDCAjpioLRcyjPoZaRVsLlrPU7QtMXh1opidHTcJZ5BGzQe0iRknG+qIpNqbyl8W2F8+HTroTnX7Nl0mfGwvTrHa65GMymhUps72ZGM64SK4hnkExiqTbX2Tw==;3:2LmwvGnkGU9vagz5SVjBw6HfSqf9IIXqTTQri7iKg4BJlX0QwmFvv3pz/toeoZblA2p0xsqz+GXoxGJPl3fohgqEcVg4ckRxGydNr2gmBuUbf83OXBobyzbnhK6F01iI7ogBLOjNV8s2oE2RzO0hodz39ZdsfGJOCNYmqg+aFq4cej6qYdQ3+A5+I/d7Za9WBotCIKTP/N5UGi7Aqkt90oZmM5NmojkBHjtYnT8C8bQ=;25:OVKgHsRiniewKykibtIbd3s09d8ZQmSFU9XG+ylAr0RrFRFoRFiazJvKPl7TxzhkAArRle28FhaPxdp+EIYPEFfYzGkMUA6edRkMHHe1g/WZqlCZ2pCj155C9d9G9lTdklTvEK+3CgiChXmQRkBF/dwJXMUCt6zZl+gpZbhA3UkqpN9mFRxo87KtTrT4+tLqd1DZhGV9+TTIE+gMXWk2oyor4D87SygPZv6KxJ/ZrkckZXhgTG+xC/DkKAKv+i6fz85oUNnkTpUkJk0MVElK+g== X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:BY1PR0301MB1221; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1221;20:63m+vl7dgBj2L/p6SywFJq0c5TrmCUY6fVtw8fug8pMp6oYf4SbsEPTe9ZG6X3gFi2ACooGWgfvpOYg+inalFKSo2PozF65wczkrVsyVN45/ku+yF5RFYjCsNseTq7Ry042ZIMMnl+x8i62cKhUMi9ambT1KieIhJiBvtghyU1raGZVuoD5hZFIA/+2640j5YYOq89PJIfu6DLZka5dMqS6q38a54Ve3CcyVH4xefN76RVrYKf1XZe3qKIfLAQKXbpIJWj0tuZOjie3W6Dqjrs4XZj6MymLriv4Snt24BYJTkiCwGyrKpzH3dtprIrlEJH/sDDKxgTI5VON+/1vH76yKxEn7eoiXTe9OLP2alAM=;4:VJr08jopbjM03xRt+1Bv0upsmBmO+0PZYk6hSf5OOyT3p8brUkAWTVQn8wqCvGRDGqYbLtHjqxp//XzSylUegozRKS99J7Ko7EAZkO88xLaIIAEOdIHTPmZ/Jckg6EWvPukZZS9wjmWB+TiVJffXNL21ak0tV+BwZW7If1Ch7/44RJ/RdkU0sXi7nRZWQVHiWwTBNIMoQcw2iSX7AjWYT86P8Yp6Zv9oq67e3vhXY7xEyhaa4JguHMjDN1MPabSmUaXnWxQUR7+BgMrHj53ZMuZr+/uovi5iK8rY0E0HGxOdaRyEQ8sZIcdi52mHtaMfAOi+sB9Sg5lvAOmfekm0nRcnbxft3sYCvknIUYNCH9Ft2DWMjKNZsM59mM5UqJqexLOUv3e0R85BeqKHnpUqrw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1;PCL:0;RULEID:(601004)(2401047)(1201001)(8121501046)(5005006)(520078)(10201501046)(3002001);SRVR:BY1PR0301MB1221;BCL:1;PCL:0;RULEID:;SRVR:BY1PR0301MB1221; X-Forefront-PRVS: 07697999E6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB1221;23:XBbf24c9NnFpBEkImrjz/FYM8KVW2H0UszP3XmA?= =?us-ascii?Q?dgX1Nr0xM07tB41fgtvxrDOBesjSzOnMCqsbdXyLPqOi/WkhT74uq/d4giqP?= =?us-ascii?Q?KA/erKFCh7677eNiqeJZoVvfzOa7HQ+Od/57QNQcm4vjHmXpGcntNqusLXua?= =?us-ascii?Q?cuPVUvOyd7XwTl3eZboqjJSL2Yq0NYNO/Z0+Bp4NT42K/riC21uvMrKdRZH8?= =?us-ascii?Q?orbjLxfALPU7KNRAh9sZSMLUAJK84R7gSM5sbmfPJdmksGwDh/5ykyjW4mOt?= =?us-ascii?Q?FtNrVyVcciEKRVfyuwzN1eE7Fi7GHA2VPqnN4cut5uSnpBJ9Ngo4PKbCSeZK?= =?us-ascii?Q?LKp+4WY5PGdNiR0WLDZHO+ua9bJJhW3EGqM8eWBI34b8o/8QwvDUJmBFflbl?= =?us-ascii?Q?jhl+H9Ji0GdPJ1WPWTPQsKpqSKdkX++LvNiPgPrGav7eJ47CwBkVmJq6Yuse?= =?us-ascii?Q?P1DugbRnZf0nYel5rJTxVd1lV3tP5EOYN1bWlTQspsFcZUZk9xzUF32+qJsU?= =?us-ascii?Q?9FmfK3AyQiz13X7qFgHVMsQrO2tKgG5KHqr1Wuh9ik7/0HoaXgffAp08SkWu?= =?us-ascii?Q?zEsXjWbPZ352TYoGC3oGKpu7hi7gO8j5Mi21YPlubh6rNS4K1tjXK6ByjB3P?= =?us-ascii?Q?HhYexF2/uSr+ZVnUF4Q06nfEWmoGTIjCN8+8hBFQYTesWnY3S9uVnlsUDxNL?= =?us-ascii?Q?RfGUjk+IpzlPaEx5t+I6AIhTdyauNgoJpfXdg5lOnOdyYTjUOkZ/q6DysdAQ?= =?us-ascii?Q?nZIGsKwu45o7SOyBXkCi4I0wkuVZT203NQ/lpjSX9gFPEKrmPRNyyjbL7Sde?= =?us-ascii?Q?oNsQpXKj5xxoyrKuX7Y5MuGJeUMQtdadpcMj+XuexALLUxhC/arFtGUnw//C?= =?us-ascii?Q?aOkj8TmoetqdQ5733O6RLrtCzIN8oorWlDqZVEaz/5ckNRelqst41qrpgWog?= =?us-ascii?Q?VNkdvoZsEvECHVl0Sn/OyWW3vaSRQzdtmx13P7uZWHNYj3iMOl4oFf8y1zb4?= =?us-ascii?Q?Kvja/SowgbfgvpMFAE2d3uOtVoCRpM6wCyEA0TDWGkBZeaADr+jYuwq1NrpE?= =?us-ascii?Q?DFd2jXY/ltZ21zYb91BgeOhM9uV45VCpaZMx/8WJKN0M0niED7k5C5KzXvqh?= =?us-ascii?Q?B1qG7acj6fUPy/1mAt4Fize7qGBV31hn/4TXoHxd9tqpj5P5hQ54UQQvpjrm?= =?us-ascii?Q?zdimz3htZsnZX2VDwDLplLzv8DVyjSYGtPxmC7qdT/bAcDeGXUzhfgw+v0g?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1221;5:sLEG9mGE4CKxvQoDdw4ehNQRB3Ct0BhkHs45JLqQuNYzTDdgSGFOQ4SqnuIq8FRFvs3hBVEZE/Sy+9wRw3ltotRlCzfI6qATYfs1oxMrHmCh6Kxx8eWaemVnJEq50wzWtqY/jauHjo7fdo8GdPkfRw==;24:57BKB3pFt7oqTu6M5q5ZDaa7c/AWomvLbWcyxySGvYGGHw4P79UVtdgffKgWHWfjAOInT5Ogkq327Cb3c6aOE54xRwl+8Fe6bwnU9MBtxcg= SpamDiagnosticOutput: 1:5 SpamDiagnosticMetadata: 00000000%2D0000%2D0000%2D0000%2D000000000000 SpamDiagnosticMetadata: 1 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2015 07:43:30.0117 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1221 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2202 Lines: 62 On Fri, Nov 20, 2015 at 11:27:36AM -0500, Alan Stern wrote: > On Fri, 20 Nov 2015, Marek Szyprowski wrote: > > > From: Ruslan Bilovol > > > > Change behavior during registration of gadgets and > > gadget drivers in udc-core. Instead of previous > > approach when for successful probe of usb gadget driver > > at least one usb gadget should be already registered > > use another one where gadget drivers and gadgets > > can be registered in udc-core independently. > > > > Independent registration of gadgets and gadget drivers > > is useful for built-in into kernel gadget and gadget > > driver case - because it's possible that gadget is > > really probed only on late_init stage (due to deferred > > probe) whereas gadget driver's probe is silently failed > > on module_init stage due to no any UDC added. > > > > Also it is useful for modules case - now there is no > > difference what module to insert first: gadget module > > or gadget driver one. > > > > Tested-by: Maxime Ripard > > Signed-off-by: Ruslan Bilovol > > [simplified code as requested by Alan Stern and Felipe Balbi] > > Signed-off-by: Marek Szyprowski > > ... > > > @@ -475,9 +492,16 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) > > list_del(&udc->list); > > mutex_unlock(&udc_lock); > > > > - if (udc->driver) > > + if (udc->driver) { > > + struct usb_gadget_driver *driver = udc->driver; > > + > > usb_gadget_remove_driver(udc); > > > > + mutex_lock(&udc_lock); > > + list_add(&driver->pending, &gadget_driver_pending_list); > > + mutex_unlock(&udc_lock); > > + } > > It looks like there is a race here with usb_gadget_unregister_driver(). > Would it be okay to hold the udc_lock mutex throughout the whole "if" > statement? > +1 In fact, only one mutex_lock/mutex_unlock is needed at this function. -- 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/