public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Éric Piel" <E.A.B.Piel@tudelft.nl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@suse.de>,
	Arkadiusz Miskiewicz <a.miskiewicz@gmail.com>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	USB list <linux-usb@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH] USB: additional regression fix for device removal
Date: Thu, 07 Jul 2011 10:36:05 +0200	[thread overview]
Message-ID: <4E156FF5.9070203@tudelft.nl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1107061658180.1995-100000@iolanthe.rowland.org>

Op 06-07-11 23:03, Alan Stern schreef:
> Commit e534c5b831c8b8e9f5edee5c8a37753c808b80dc (USB: fix regression
> occurring during device removal) didn't go far enough.  It failed to
> take into account that when a driver claims multiple interfaces, it may
> release them all at the same time.  As a result, some interfaces can
> get released before they are unregistered, and we deadlock trying to
> acquire the bandwidth_mutex that we already own.
>
> This patch (asl478) handles this case by setting the "unregistering"
> flag on all the interfaces before removing any of them.
>
> Signed-off-by: Alan Stern<stern@rowland.harvard.edu>
> CC:<stable@kernel.org>

Great, it works here :-)
Tested-by: Éric Piel <eric.piel@tremplin-utc.net>

Thanks,
Éric
>
> ---
>
> This should take care of Eric's problem as well as Arkadiusz, since
> they seemed to be hitting the same thing (cdc_ether claiming multiple
> interfaces and hanging while releasing them).
>
> Still, we need to rewrite this stuff.  A possible race remains, because
> a driver may try to change an altsetting at the same time as the device
> is removed.  Either the driver's disconnect routine would hang waiting
> for the altsetting change (which is waiting to acquire the
> bandwidth_mutex) or else the altsetting change would go through after
> the driver was unbound from the device.  Neither alternative is good.
>
> Alan Stern
>
>
>
>   drivers/usb/core/message.c |    9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> Index: usb-3.0/drivers/usb/core/message.c
> ===================================================================
> --- usb-3.0.orig/drivers/usb/core/message.c
> +++ usb-3.0/drivers/usb/core/message.c
> @@ -1147,6 +1147,14 @@ void usb_disable_device(struct usb_devic
>   	 * any drivers bound to them (a key side effect)
>   	 */
>   	if (dev->actconfig) {
> +		/*
> +		 * FIXME: In order to avoid self-deadlock involving the
> +		 * bandwidth_mutex, we have to mark all the interfaces
> +		 * before unregistering any of them.
> +		 */
> +		for (i = 0; i<  dev->actconfig->desc.bNumInterfaces; i++)
> +			dev->actconfig->interface[i]->unregistering = 1;
> +
>   		for (i = 0; i<  dev->actconfig->desc.bNumInterfaces; i++) {
>   			struct usb_interface	*interface;
>
> @@ -1156,7 +1164,6 @@ void usb_disable_device(struct usb_devic
>   				continue;
>   			dev_dbg(&dev->dev, "unregistering interface %s\n",
>   				dev_name(&interface->dev));
> -			interface->unregistering = 1;
>   			remove_intf_ep_devs(interface);
>   			device_del(&interface->dev);
>   		}
>


      reply	other threads:[~2011-07-07  8:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06 15:41 Regression 3.0-rc6+ : khubd blocked (usbnet_cdc_unbind) Éric Piel
2011-07-06 16:14 ` Alan Stern
2011-07-06 16:44   ` Arkadiusz Miskiewicz
2011-07-06 20:46     ` Greg KH
2011-07-06 21:03       ` [PATCH] USB: additional regression fix for device removal Alan Stern
2011-07-07  8:36         ` Éric Piel [this message]

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=4E156FF5.9070203@tudelft.nl \
    --to=e.a.b.piel@tudelft.nl \
    --cc=a.miskiewicz@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=sarah.a.sharp@linux.intel.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