From patchwork Fri Apr 1 17:02:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Nazarewicz?= X-Patchwork-Id: 8726821 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4F2D09F39A for ; Fri, 1 Apr 2016 17:02:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65B29203AE for ; Fri, 1 Apr 2016 17:02:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59B0C2012D for ; Fri, 1 Apr 2016 17:02:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752298AbcDARCz (ORCPT ); Fri, 1 Apr 2016 13:02:55 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:38491 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbcDARCw convert rfc822-to-8bit (ORCPT ); Fri, 1 Apr 2016 13:02:52 -0400 Received: by mail-wm0-f44.google.com with SMTP id 20so30503654wmh.1 for ; Fri, 01 Apr 2016 10:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version :content-transfer-encoding; bh=0KrTFd7Ox0vCNORKNadBTaKA/I1Emlwkvk4XXs4Dw38=; b=m0GcMaayt5G3/hGf6v9K/eSiAPJnjhyGVC9LeKO7UUvitwen2h619sIdzqQjAT+hBi UhF+ANuNJZpUQaM0ttLMqNt+0qqjZ/C9ycAzLoID1wTBMYZ0lsITQQCTmSLg7APIYfzy RDQ5SzOslg2klbOJ44cAzIM3IZdu3C0oM12m/q3FMy3QxQ8n4LXiQ0z1L05PNCvq59PR 7hd/3W1M57Rlg9OvOg7pIKXhpbF1G4dGZqslwLCwYi7c/T7SEf3KH9iAu2paYgPpooV/ 32BLYxgicPkOuJHzocAtbuLRBUcFUoPVnKWmdbO/K6/05wu2sP6jvglvMv5mxC8Miey6 6n2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-transfer-encoding; bh=0KrTFd7Ox0vCNORKNadBTaKA/I1Emlwkvk4XXs4Dw38=; b=Wm9UEDEVAeJ4L2ojdho6sL8O3/dZEla8f8oi+gKrwnzrI+GTclXzVVjSWeHjwmRdKV TjBOUYPpNkFhIQS3Rl/4yloW8BbmZsvvuRr1Ojxa11m0LRkodP4hS67CjZpa4R6ZVvBH DCCilIhuCl0jXfrkZZ8y2RtOeH8Mml7r6f7kODXuElz9MFYaegofFeBbwnhcfc0U3gbv nNEVfMTrceRzqwi8O59KYJ4p48j/WOXy8QyiymCfDPc+2xSxfliwAmxraoU3oGPVviT2 ez1Se2aXIJfOksv2+X9W5hLYvNO6qkHWNwvBTpmC+4Po4kjbfbDpqFN3aCnZUzQz6Wm8 3NPg== X-Gm-Message-State: AD7BkJKhomQC7YxIbS9Fn7E6bDxDR+qOuFJg1qLVzi3Kbu4mWtoJeSo7UiIY6XZvPdtWkWQP X-Received: by 10.28.141.141 with SMTP id p135mr4975586wmd.8.1459530170356; Fri, 01 Apr 2016 10:02:50 -0700 (PDT) Received: from mpn-glaptop ([2620:0:105f:310:e9f3:7caf:638f:c016]) by smtp.gmail.com with ESMTPSA id by7sm14848152wjc.18.2016.04.01.10.02.47 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 01 Apr 2016 10:02:48 -0700 (PDT) From: Michal Nazarewicz To: Alan Stern , Ivaylo Dimitrov Cc: Felipe Balbi , Tony Lindgren , Bin Liu , pali =?utf-8?Q?Roh=C3=A1r?= , USB list , linux-omap@vger.kernel.org, Greg Kroah-Hartman , Robert Baldyga , Andrzej Pietrasiewicz Subject: Re: USB gadgets with configfs hang reboot 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:160401:stern@rowland.harvard.edu::u68MUu0aaPR2sR6m:0000000000000000000000000000000000000eBC X-Hashcash: 1:20:160401:pali.rohar@gmail.com::MVdVwnaOZVxEOqSC:000000000000000000000000000000000000000000QsI X-Hashcash: 1:20:160401:gregkh@linuxfoundation.org::P2hcIlJXXUVuwAD0:000000000000000000000000000000000000UW7 X-Hashcash: 1:20:160401:ivo.g.dimitrov.75@gmail.com::ehKdtvujeTzdmw5p:00000000000000000000000000000000000yyv X-Hashcash: 1:20:160401:felipe.balbi@linux.intel.com::00wiiimnVyeJpePH:0000000000000000000000000000000002AzO X-Hashcash: 1:20:160401:tony@atomide.com::8kyw9ve7emxfjMkV:01Spb X-Hashcash: 1:20:160401:linux-omap@vger.kernel.org::UCi5Vh1Y1ybSuUag:000000000000000000000000000000000001m0W X-Hashcash: 1:20:160401:b-liu@ti.com::WBV5GBrX+DdwEawI:000002Ps8 X-Hashcash: 1:20:160401:r.baldyga@samsung.com::SFKDilVU3F6i8Q8D:000000000000000000000000000000000000000037Qg X-Hashcash: 1:20:160401:andrzej.p@samsung.com::XxhZseacMeRFEi4e:00000000000000000000000000000000000000004FxR X-Hashcash: 1:20:160401:linux-usb@vger.kernel.org::2PVFvZkA0hgYiW85:00000000000000000000000000000000000081jI Date: Fri, 01 Apr 2016 19:02:47 +0200 Message-ID: MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Mar 31 2016, Alan Stern wrote: > Michal, I'm not sure how you intended to handle this. For legacy/nokia setting no_configfs should be a valid solution: ---- >8 ---------------------------------------------------------------- ---- >8 ---------------------------------------------------------------- With that, the whole fsg_common_run_thread call should be moved outside of the if (!no_configfs) and legacy should no longer call it IMO. diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c index 0997504..e4bc607 100644 --- a/drivers/usb/gadget/legacy/nokia.c +++ b/drivers/usb/gadget/legacy/nokia.c @@ -223,6 +223,7 @@ static int nokia_bind_config(struct usb_configuration *c) } fsg_opts = fsg_opts_from_func_inst(fi_msg); + fsg_opts->no_configfs = true; status = fsg_common_run_thread(fsg_opts->common); if (status) ---- >8 ---------------------------------------------------------------- This is what other legacy gadgets do after all. For configfs, why not simply check if the thread has already been started: ---- >8 ---------------------------------------------------------------- diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index acf210f..62854b6 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2984,8 +2984,10 @@ int fsg_common_run_thread(struct fsg_common *common) common->thread_task = kthread_create(fsg_main_thread, common, "file-storage"); if (IS_ERR(common->thread_task)) { + int ret = PTR_ERR(common->thread_task); + common->thread_task = NULL; common->state = FSG_STATE_TERMINATED; - return PTR_ERR(common->thread_task); + return ret; } DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task)); @@ -3005,6 +3007,7 @@ static void fsg_common_release(struct kref *ref) if (common->state != FSG_STATE_TERMINATED) { raise_exception(common, FSG_STATE_EXIT); wait_for_completion(&common->thread_notifier); + common->thread_task = NULL; } for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { @@ -3050,9 +3053,11 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) if (ret) return ret; fsg_common_set_inquiry_string(fsg->common, NULL, NULL); - ret = fsg_common_run_thread(fsg->common); - if (ret) - return ret; + if (common->thread_task) { + ret = fsg_common_run_thread(fsg->common); + if (ret) + return ret; + } } fsg->gadget = gadget;