From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Nazarewicz Subject: Re: USB gadgets with configfs hang reboot Date: Fri, 01 Apr 2016 19:02:47 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Alan Stern , Ivaylo Dimitrov Cc: Felipe Balbi , Tony Lindgren , Bin Liu , pali =?utf-8?Q?Roh=C3=A1r?= , USB list , linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Greg Kroah-Hartman , Robert Baldyga , Andrzej Pietrasiewicz List-Id: linux-omap@vger.kernel.org On Thu, Mar 31 2016, Alan Stern wrote: > Michal, I'm not sure how you intended to handle this. =46or legacy/nokia setting no_configfs should be a valid solution: ---- >8 ---------------------------------------------------------------= - diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/leg= acy/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_configurati= on *c) } =20 fsg_opts =3D fsg_opts_from_func_inst(fi_msg); + fsg_opts->no_configfs =3D true; =20 status =3D fsg_common_run_thread(fsg_opts->common); if (status) ---- >8 ---------------------------------------------------------------= - This is what other legacy gadgets do after all. =46or 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 *com= mon) common->thread_task =3D kthread_create(fsg_main_thread, common, "file-storage")= ; if (IS_ERR(common->thread_task)) { + int ret =3D PTR_ERR(common->thread_task); + common->thread_task =3D NULL; common->state =3D FSG_STATE_TERMINATED; - return PTR_ERR(common->thread_task); + return ret; } =20 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 !=3D FSG_STATE_TERMINATED) { raise_exception(common, FSG_STATE_EXIT); wait_for_completion(&common->thread_notifier); + common->thread_task =3D NULL; } =20 for (i =3D 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 =3D fsg_common_run_thread(fsg->common); - if (ret) - return ret; + if (common->thread_task) { + ret =3D fsg_common_run_thread(fsg->common); + if (ret) + return ret; + } } =20 fsg->gadget =3D gadget; ---- >8 ---------------------------------------------------------------=