Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758864AbcDESHw (ORCPT ); Tue, 5 Apr 2016 14:07:52 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35712 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbcDESHt convert rfc822-to-8bit (ORCPT ); Tue, 5 Apr 2016 14:07:49 -0400 From: Michal Nazarewicz To: Alan Stern Cc: Ivaylo Dimitrov , Tony Lindgren , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Felipe Balbi , Bin Liu , pali.rohar@gmail.com Subject: Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another In-Reply-To: Organization: http://mina86.com/ References: User-Agent: Notmuch/0.19+53~g2e63a09 (http://notmuchmail.org) Emacs/25.1.50.1 (x86_64-unknown-linux-gnu) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACP0lEQVQ4T23Sv2vbQBQHcBk1xE6WyALX107VUEgmn6+ouUwpEQQ6uRjttkWP4CkBg2M0BQLBdPFZYPsyFYo7qEtKDQ7on+t7+nF2Ux8ahD587717OmNYrOvycHsZ+o2r051wHTHysAvGb8ygvgu4QWT0sCmkgZCIEnlV2X8BtyraazFGDuxhmKSQJMlwHQ7v5MHSNxmz78rfElwAa3ieVD9e+hBhjaPDDG6NgFo2f4wBMNIo5YmRtF0RyDgFjJjlMIWbnuM4x9MMfABGTlN4qgIQB4A1DEyA1BHWtfeWNUMwiVJKoqh97KrkOO+qzgluVYLvFCUKAX73nONeBr7BGMdM6Sg0kuep03VywLaIzRiVr+GAzKlpQIsAFnWAG2e6DT5WmWDiudZMIc6hYrMOmeMQK9WX0B+/RfjzL9DI7Y9/Iayn29Ci0r2i4f9gMimMSZLCDMalgQGU5hnUtqAN0OGvEmO1Wnl0C0wWSCEHnuHBqmygxdxA8oWXwbipoc1EoNR9DqOpBpOJrnr0criQab9ZT4LL+wI+K7GBQH30CrhUruilgP9DRTrhVWZCiAyILP+wiuLeCKGTD6r/nc8LOJcAwR6IBTUs+7CASw3QFZ0MdA2PI3zNziH4ZKVhXCRMBjeZ1DWMekKwDCASwExy+NQ86TaykaDAFHO4aP48y4fIcDM5yOG8GcTLbOyp8A8azjJI93JFd1EA6yN8sSxMQJWoABqniRZVykYgRXErzrdqExAoUrRb0xfRp8p2A/4XmfilTtkDZ4cAAAAASUVORK5CYII= X-Face: -TR8(rDTHy/(xl?SfWd1|3:TTgDIatE^t'vop%*gVg[kn$t{EpK(P"VQ=~T2#ysNmJKN$"yTRLB4YQs$4{[.]Fc1)*O]3+XO^oXM>Q#b^ix,O)Zbn)q[y06$`e3?C)`CwR9y5riE=fv^X@x$y?D:XO6L&x4f-}}I4=VRNwiA^t1-ZrVK^07.Pi/57c_du'& X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:160405:linux-kernel@vger.kernel.org::lmacVTyIPOEq+4/q:0000000000000000000000000000000000heH X-Hashcash: 1:20:160405:linux-usb@vger.kernel.org::0Ozft6wQ6Zfi+INM:0000000000000000000000000000000000000sJS X-Hashcash: 1:20:160405:ivo.g.dimitrov.75@gmail.com::zXcpLtCaT9SGc+nS:00000000000000000000000000000000001oyA X-Hashcash: 1:20:160405:tony@atomide.com::K53X+Iw+mJgfPSRl:02YHl X-Hashcash: 1:20:160405:pali.rohar@gmail.com::4MScin1aIbUlgV6g:000000000000000000000000000000000000000005Iru X-Hashcash: 1:20:160405:stern@rowland.harvard.edu::Vm46c6aZY0yn9PYW:0000000000000000000000000000000000005y5A X-Hashcash: 1:20:160405:b-liu@ti.com::7eMTxwSOd29B2jpC:0000049u9 X-Hashcash: 1:20:160405:felipe.balbi@linux.intel.com::HbU1/MhLyWy+za7t:0000000000000000000000000000000006PCH Date: Tue, 05 Apr 2016 20:07:45 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1754 Lines: 38 > On Tue, 5 Apr 2016, Michal Nazarewicz wrote: >> When binding the function to usb_configuration, check whether the thread >> is running before starting another one. Without that, when function >> instance is added to multiple configurations, fsg_bing starts multiple >> threads with all but the latest one being forgotten by the driver. This >> leads to obvious thread leaks, possible lockups when trying to halt the >> machine and possible more issues. >> >> This fixes issues with legacy/multi¹ gadget as well as configfs gadgets >> when mass_storage function is added to multiple configurations. >> >> This change also simplifies API since the legacy gadgets no longer need >> to worry about starting the thread by themselves (which was where bug >> in legacy/multi was in the first place). >> >> ¹ I have no example failure though. Conclusion that legacy/multi has >> a bug is based purely on me reading the code. >> >> Signed-off-by: Michal Nazarewicz On Tue, Apr 05 2016, Alan Stern wrote: > This doesn't address the problem I raised in a previous email. > Sharing one thread among several function instances in the same config > will not work if one of them encounters an error. Each usb_function_instance has its own fsg_common and its own thread. This was true in the past and is true with this patch as well. And unless I’m missing something, sharing a thread among multiple usb_function’s does not prevent the driver from working correctly. Having the thread run even when it’s not used may be considered wasteful but that’s an orthogonal issue to the configfs failure. -- Best regards ミハウ “????????????????86” ナザレヴイツ «If at first you don’t succeed, give up skydiving»