linux/drivers/usb/core
Dan Williams 5c79a1e303 usb: introduce port status lock
In general we do not want khubd to act on port status changes that are
the result of in progress resets or USB runtime PM operations.
Specifically port power control testing has been able to trigger an
unintended disconnect in hub_port_connect_change(), paraphrasing:

	if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
	    udev->state != USB_STATE_NOTATTACHED) {
		if (portstatus & USB_PORT_STAT_ENABLE) {
			/* Nothing to do */
		} else if (udev->state == USB_STATE_SUSPENDED &&
				udev->persist_enabled) {
			...
		} else {
			/* Don't resuscitate */;
		}
	}

...by falling to the "Don't resuscitate" path or missing
USB_PORT_STAT_CONNECTION because usb_port_resume() was in the middle of
modifying the port status.

So, we want a new lock to hold off khubd for a given port while the
child device is being suspended, resumed, or reset.  The lock ordering
rules are now usb_lock_device() => usb_lock_port().  This is mandated by
the device core which may hold the device_lock on the usb_device before
invoking usb_port_{suspend|resume} which in turn take the status_lock on
the usb_port.  We attempt to hold the status_lock for the duration of a
port_event() run, and drop/re-acquire it when needing to take the
device_lock.  The lock is also dropped/re-acquired during
hub_port_reconnect().

This patch also deletes hub->busy_bits as all use cases are now covered
by port PM runtime synchronization or the port->status_lock and it
pushes down usb_device_lock() into usb_remote_wakeup().

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-27 16:51:50 -07:00
..
buffer.c USB: core: correct spelling mistakes in comments and warning 2014-01-07 16:17:40 -08:00
config.c Merge 3.14-rc6 into usb-next 2014-03-12 11:40:15 -07:00
devices.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-02-26 20:16:07 -08:00
devio.c USB patches for 3.15-rc1 2014-04-01 17:06:09 -07:00
driver.c USB: unbind all interfaces before rebinding any 2014-03-17 16:08:27 -07:00
endpoint.c USB: core: be specific about attribute permissions 2013-08-25 15:12:03 -07:00
file.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-11-13 15:34:18 +09:00
generic.c staging: usbip: convert usbip-host driver to usb_device_driver 2014-02-07 10:54:30 -08:00
hcd-pci.c usb: remove redundant D0 power state set 2014-05-27 15:18:48 -07:00
hcd.c usb: introduce port status lock 2014-05-27 16:51:50 -07:00
hub.c usb: introduce port status lock 2014-05-27 16:51:50 -07:00
hub.h usb: introduce port status lock 2014-05-27 16:51:50 -07:00
Kconfig usb: common: rename phy-fsm-usb.c to usb-otg-fsm.c 2014-05-27 15:29:44 -07:00
Makefile USB: core: remove CONFIG_USB_DEBUG usage 2013-12-21 16:01:00 -08:00
message.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-04-02 16:23:38 -07:00
notify.c
otg_whitelist.h
port.c usb: introduce port status lock 2014-05-27 16:51:50 -07:00
quirks.c usb: Add device quirk for Logitech HD Pro Webcams C920 and C930e 2014-03-07 11:46:51 -08:00
sysfs.c USB: core: correct spelling mistakes in comments and warning 2014-01-07 16:17:40 -08:00
urb.c Merge branch 'master' into for-next 2014-02-20 14:54:28 +01:00
usb-acpi.c usb: find internal hub tier mismatch via acpi 2014-05-27 16:38:52 -07:00
usb.c drivers: usb: core: {file,hub,sysfs,usb}.c: Whitespace fixes 2013-10-11 17:02:37 -07:00
usb.h usb: find internal hub tier mismatch via acpi 2014-05-27 16:38:52 -07:00