linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@freescale.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Ruslan Bilovol <ruslan.bilovol@gmail.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH v6 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers
Date: Mon, 23 Nov 2015 15:40:31 +0800	[thread overview]
Message-ID: <20151123074030.GC16321@shlinux2> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1511201120290.1647-100000@iolanthe.rowland.org>

On Fri, Nov 20, 2015 at 11:27:36AM -0500, Alan Stern wrote:
> On Fri, 20 Nov 2015, Marek Szyprowski wrote:
> 
> > From: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> > 
> > 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 <maxime.ripard@free-electrons.com>
> > Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> > [simplified code as requested by Alan Stern and Felipe Balbi]
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> ...
> 
> > @@ -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

  reply	other threads:[~2015-11-23  7:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20  8:54 [PATCH v6 0/4] usb/gadget: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-20  8:54 ` [PATCH v6 1/4] usb: gadget: bind UDC by name passed via usb_gadget_driver structure Marek Szyprowski
2015-11-20  9:21   ` Peter Chen
2015-11-20  8:54 ` [PATCH v6 2/4] usb: gadget: configfs: pass UDC name via usb_gadget_driver struct Marek Szyprowski
2015-11-20  9:22   ` Peter Chen
2015-11-20  8:54 ` [PATCH v6 3/4] usb: gadget: udc-core: remove unused usb_udc_attach_driver() Marek Szyprowski
2015-11-20  8:54 ` [PATCH v6 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-20  9:26   ` Peter Chen
2015-11-20  9:45     ` Marek Szyprowski
2015-11-20  9:51       ` Peter Chen
2015-11-20 16:27   ` Alan Stern
2015-11-23  7:40     ` Peter Chen [this message]
2015-11-23  7:44   ` Peter Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151123074030.GC16321@shlinux2 \
    --to=peter.chen@freescale.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=ruslan.bilovol@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).