From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965606AbcBDVBT (ORCPT ); Thu, 4 Feb 2016 16:01:19 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:38222 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1757141AbcBDVAx (ORCPT ); Thu, 4 Feb 2016 16:00:53 -0500 Date: Thu, 4 Feb 2016 16:00:51 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Chris Bainbridge cc: mathias.nyman@linux.intel.com, , , Subject: Re: [PATCH] usb: host: xhci: Replace bus lock with host controller lock In-Reply-To: <1454615189-6862-1-git-send-email-chris.bainbridge@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Feb 2016, Chris Bainbridge wrote: > The XHCI controller presents two USB buses to the system - one for USB 2 > and one for USB 3. When only one bus is locked there is a race condition > during hub init that results in errors like: > > [ 13.183701] usb 3-3: device descriptor read/all, error -110 What exactly is the race condition? Why does locking both buses fix it? > @@ -4312,7 +4312,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, > if (oldspeed == USB_SPEED_LOW) > delay = HUB_LONG_RESET_TIME; > > - mutex_lock(&hdev->bus->usb_address0_mutex); > + mutex_lock(&hdev->bus->controller->mutex); > > /* Reset the device; full speed may morph to high speed */ > /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */ > @@ -4588,7 +4588,7 @@ fail: > hub_port_disable(hub, port1, 0); > update_devnum(udev, devnum); /* for disconnect processing */ > } > - mutex_unlock(&hdev->bus->usb_address0_mutex); > + mutex_unlock(&hdev->bus->controller->mutex); > return retval; > } I don't think this is a good idea. The driver core needs to be able to access the controller while this function is running. You can introduce a new mutex if you want, perhaps in the primary hcd structure, but don't use bus->controller->mutex. Alan Stern