mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.cz>
To: Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tejun Heo <tj@kernel.org>,
	Joe Lawrence <joe.lawrence@stratus.com>,
	Jiri Kosina <jkosina@suse.cz>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Petr Mladek <pmladek@suse.cz>
Subject: [PATCH v3 6/6] usb: hub: allow to process more usb hub events in parallel
Date: Fri, 19 Sep 2014 17:32:24 +0200	[thread overview]
Message-ID: <1411140744-21424-7-git-send-email-pmladek@suse.cz> (raw)
In-Reply-To: <1411140744-21424-1-git-send-email-pmladek@suse.cz>

It seems that only choose_devnum() was not ready to process more hub
events at the same time.

All should be fine if we take bus->usb_address0_mutex there. It will
make sure that more devnums will not be chosen for the given bus and
the related devices at the same time.

Signed-off-by: Petr Mladek <pmladek@suse.cz>
---
 drivers/usb/core/hub.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6c1a79a50576..69f9f1c1d9c1 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2042,7 +2042,8 @@ static void choose_devnum(struct usb_device *udev)
 	int		devnum;
 	struct usb_bus	*bus = udev->bus;
 
-	/* If hub_wq ever becomes multithreaded, this will need a lock */
+	/* be safe when more hub events are proceed in parallel */
+	mutex_lock(&bus->usb_address0_mutex);
 	if (udev->wusb) {
 		devnum = udev->portnum + 1;
 		BUG_ON(test_bit(devnum, bus->devmap.devicemap));
@@ -2060,6 +2061,7 @@ static void choose_devnum(struct usb_device *udev)
 		set_bit(devnum, bus->devmap.devicemap);
 		udev->devnum = devnum;
 	}
+	mutex_unlock(&bus->usb_address0_mutex);
 }
 
 static void release_devnum(struct usb_device *udev)
@@ -5162,11 +5164,8 @@ int usb_hub_init(void)
 	 * USB-PERSIST port handover. Otherwise it might see that a full-speed
 	 * device was gone before the EHCI controller had handed its port
 	 * over to the companion full-speed controller.
-	 *
-	 * Also we use ordered workqueue because the code is not ready
-	 * for parallel execution of hub events, see choose_devnum().
 	 */
-	hub_wq = alloc_ordered_workqueue("usb_hub_wq", WQ_FREEZABLE);
+	hub_wq = alloc_workqueue("usb_hub_wq", WQ_FREEZABLE, 0);
 	if (hub_wq)
 		return 0;
 
-- 
1.8.4


  parent reply	other threads:[~2014-09-19 15:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 15:32 [PATCH v3 0/6] usb: hub: convert khubd into workqueue Petr Mladek
2014-09-19 15:32 ` [PATCH v3 1/6] usb: hub: keep hub->dev reference all the time when struct usb_hub lives Petr Mladek
2014-09-19 15:32 ` [PATCH v3 2/6] usb: hub: rename hub_events() to hub_event() and handle only one event there Petr Mladek
2014-09-19 15:32 ` [PATCH v3 3/6] usb: hub: convert khubd into workqueue Petr Mladek
2014-09-19 15:32 ` [PATCH v3 4/6] usb: hub: rename usb_kick_khubd() to usb_kick_hub_wq() Petr Mladek
2014-09-19 15:32 ` [PATCH v3 5/6] usb: hub: rename khubd to hub_wq in documentation and comments Petr Mladek
2014-09-19 15:32 ` Petr Mladek [this message]
2014-09-19 19:38 ` [PATCH v3 0/6] usb: hub: convert khubd into workqueue Alan Stern
2014-09-20 20:41   ` Paul Zimmerman
2014-09-24  5:19     ` Greg Kroah-Hartman

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=1411140744-21424-7-git-send-email-pmladek@suse.cz \
    --to=pmladek@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=joe.lawrence@stratus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    /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

all inboxes | Powered by JetHome®