2009-12-11 21:27:44

by Greg KH

[permalink] [raw]
Subject: [GIT PATCH] USB patches for 2.6.33-git

Here is the big USB merge for the 2.6.33-git tree.

Lots of different things here, mostly all just driver updates and a few
new additions. There was some prep work for future power api changes
done as well. All of the details are in the shortlog below.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6.git/

All of these patches have been in the linux-next and mm trees for a
while.

The full patches will be sent to the linux-usb mailing list, if anyone
wants to see them.

thanks,

greg k-h

------------


Documentation/ABI/testing/sysfs-bus-usb | 13 +
.../ABI/testing/sysfs-class-uwb_rc-wusbhc | 13 +
Documentation/kernel-parameters.txt | 2 +
Documentation/powerpc/dts-bindings/xilinx.txt | 11 +
Documentation/usb/power-management.txt | 69 +-
MAINTAINERS | 4 +-
arch/arm/plat-mxc/Makefile | 1 +
arch/arm/plat-mxc/ehci.c | 92 +
arch/arm/plat-mxc/include/mach/mxc_ehci.h | 37 +
drivers/bluetooth/btusb.c | 2 +-
drivers/hid/usbhid/hid-core.c | 8 +-
drivers/net/wimax/i2400m/usb.c | 7 +-
drivers/usb/Kconfig | 2 +
drivers/usb/Makefile | 2 +
drivers/usb/class/cdc-acm.c | 58 +-
drivers/usb/class/usbtmc.c | 54 +-
drivers/usb/core/driver.c | 135 +-
drivers/usb/core/file.c | 1 +
drivers/usb/core/generic.c | 2 +-
drivers/usb/core/hcd.c | 82 +-
drivers/usb/core/hcd.h | 19 +-
drivers/usb/core/hub.c | 142 +-
drivers/usb/core/message.c | 82 +-
drivers/usb/core/sysfs.c | 61 +-
drivers/usb/core/urb.c | 22 +-
drivers/usb/core/usb.c | 69 +-
drivers/usb/core/usb.h | 1 +
drivers/usb/gadget/Kconfig | 60 +
drivers/usb/gadget/Makefile | 4 +
drivers/usb/gadget/at91_udc.c | 6 +-
drivers/usb/gadget/audio.c | 115 -
drivers/usb/gadget/composite.c | 59 +-
drivers/usb/gadget/ether.c | 16 +-
drivers/usb/gadget/f_acm.c | 28 +
drivers/usb/gadget/f_audio.c | 76 +-
drivers/usb/gadget/f_mass_storage.c | 3091 ++++++++++++++++++++
drivers/usb/gadget/f_rndis.c | 35 +-
drivers/usb/gadget/file_storage.c | 879 +-----
drivers/usb/gadget/mass_storage.c | 240 ++
drivers/usb/gadget/multi.c | 358 +++
drivers/usb/gadget/storage_common.c | 778 +++++
drivers/usb/gadget/u_ether.h | 2 +-
drivers/usb/host/Kconfig | 22 +-
drivers/usb/host/ehci-hcd.c | 19 +-
drivers/usb/host/ehci-hub.c | 2 +-
drivers/usb/host/ehci-mxc.c | 296 ++
drivers/usb/host/ehci-omap.c | 756 +++++
drivers/usb/host/ehci-q.c | 32 +-
drivers/usb/host/ehci-sched.c | 36 +-
drivers/usb/host/ehci-xilinx-of.c | 300 ++
drivers/usb/host/isp1362.h | 4 +-
drivers/usb/host/ohci-at91.c | 10 +-
drivers/usb/host/ohci-pnx4008.c | 8 +-
drivers/usb/host/r8a66597-hcd.c | 4 -
drivers/usb/host/whci/debug.c | 20 +-
drivers/usb/host/whci/hcd.c | 1 +
drivers/usb/host/whci/qset.c | 350 ++-
drivers/usb/host/whci/whcd.h | 9 +
drivers/usb/host/whci/whci-hc.h | 14 +-
drivers/usb/host/xhci-hcd.c | 139 +-
drivers/usb/host/xhci-mem.c | 255 ++-
drivers/usb/host/xhci-pci.c | 2 +
drivers/usb/host/xhci-ring.c | 343 ++-
drivers/usb/host/xhci.h | 37 +-
drivers/usb/misc/usbtest.c | 7 +-
drivers/usb/mon/mon_bin.c | 51 +-
drivers/usb/mon/mon_text.c | 23 +-
drivers/usb/musb/Kconfig | 5 +-
drivers/usb/musb/blackfin.c | 16 +-
drivers/usb/musb/blackfin.h | 37 +
drivers/usb/musb/musb_core.c | 10 +-
drivers/usb/musb/musb_core.h | 8 +
drivers/usb/musb/musb_dma.h | 11 +
drivers/usb/musb/musb_gadget.c | 196 +-
drivers/usb/musb/musb_gadget.h | 4 +-
drivers/usb/musb/musb_gadget_ep0.c | 70 +-
drivers/usb/musb/musb_host.c | 10 +-
drivers/usb/musb/musb_regs.h | 4 +-
drivers/usb/musb/musbhsdma.c | 12 +-
drivers/usb/musb/omap2430.c | 2 +-
drivers/usb/otg/Kconfig | 9 +
drivers/usb/otg/Makefile | 1 +
drivers/usb/otg/twl4030-usb.c | 4 +-
drivers/usb/otg/ulpi.c | 136 +
drivers/usb/serial/ark3116.c | 975 +++++--
drivers/usb/serial/ftdi_sio.c | 32 +-
drivers/usb/serial/ftdi_sio.h | 14 +
drivers/usb/serial/mos7840.c | 24 +-
drivers/usb/serial/option.c | 39 +-
drivers/usb/serial/sierra.c | 91 +-
drivers/usb/storage/scsiglue.c | 3 +-
drivers/usb/storage/transport.c | 17 +-
drivers/usb/storage/unusual_devs.h | 7 +
drivers/usb/storage/usb.c | 43 +-
drivers/usb/storage/usb.h | 1 +
drivers/usb/usb-skeleton.c | 4 +-
drivers/usb/wusbcore/devconnect.c | 7 +-
drivers/usb/wusbcore/security.c | 6 +-
drivers/usb/wusbcore/wusbhc.c | 32 +
drivers/usb/wusbcore/wusbhc.h | 1 +
include/linux/usb.h | 33 +-
include/linux/usb/composite.h | 1 +
include/linux/usb/otg.h | 68 +-
include/linux/usb/ulpi.h | 7 +
include/linux/usb_usual.h | 4 +-
scripts/mod/file2alias.c | 93 +-
106 files changed, 9634 insertions(+), 1881 deletions(-)
create mode 100644 arch/arm/plat-mxc/ehci.c
create mode 100644 arch/arm/plat-mxc/include/mach/mxc_ehci.h
create mode 100644 drivers/usb/gadget/f_mass_storage.c
create mode 100644 drivers/usb/gadget/mass_storage.c
create mode 100644 drivers/usb/gadget/multi.c
create mode 100644 drivers/usb/gadget/storage_common.c
create mode 100644 drivers/usb/host/ehci-mxc.c
create mode 100644 drivers/usb/host/ehci-omap.c
create mode 100644 drivers/usb/host/ehci-xilinx-of.c
create mode 100644 drivers/usb/otg/ulpi.c
create mode 100644 include/linux/usb/ulpi.h

---------------

Adrian Taylor (1):
USB: Exposing second ACM channel as tty for Nokia S60 phones.

Aguilar Pena, Leed (1):
USB: twl4030: Enable USB regulators before enabling USB charging

Alan Stern (9):
USB: don't use a fixed DMA mapping for hub status URBs
USB: add a "remove hardware" sysfs attribute
USB: fix a bug in the scatter-gather library
USB: EHCI: add native scatter-gather support
USB: add scatter-gather support to usbmon
USB: remove the auto_pm flag
USB: prepare for changover to Runtime PM framework
USB: usb-storage: add BAD_SENSE flag
USB: usb-storage: fix bug in fill_inquiry

Anand Gadiyar (2):
USB: ehci: Allow EHCI to be built on OMAP3
USB: MUSB: save hardware revision at init

Andre Herms (1):
USB: usbtmc: repeat usb_bulk_msg until whole message is transfered

Bryan Wu (3):
USB: musb: kill compile warning for Blackfin systems
USB: musb: kill some useless comments in Blackfin driver
USB: musb: fix musb_platform_set_mode() definition

CHENG Renquan (1):
USB: add remove_id sysfs attr for usb drivers

Cliff Brake (2):
USB: ftdi_sio: add USB device ID's for B&B Electronics line
USB: mos7840: add device IDs for B&B electronics devices

Cliff Cai (2):
USB: musb: clear the Blackfin interrupt pending bits early in the ISR
USB: musb: Blackfin code needs NOP_USB_XCEIV too

Dan Carpenter (2):
USB: r8a66597: clean up. remove unneeded null checks
USB: fix possible null deref in init_usb_class()

Daniel Mack (3):
USB OTG: add support for ulpi connected external transceivers
USB OTG: Add generic driver for ULPI OTG transceiver
USB: Add EHCI support for MX27 and MX31 based boards

David Vrabel (9):
USB: make urb scatter-gather support more generic
USB: whci-hcd: support urbs with scatter-gather lists
USB: allow interrupt transfers to WUSB devices
USB: whci-hcd: fix type and format warnings in sg code
usb: whci-hcd: decode more QHead fields in the debug files
USB: wusb: add wusb_phy_rate sysfs file to host controllers
USB: whci-hcd: correctly handle sg lists longer than QTD_MAX_XFER_SIZE.
USB: wusb: don't leak urb in certain error cases
USB: wusb: correctly check size of security descriptor.

Elina Pasheva (1):
USB: serial: sierra driver memory reduction

Felipe Balbi (7):
USB: host: ehci: introduce omap ehci-hcd driver
USB: core: fix sparse warning for static function
USB: core: hub: fix sparse warning
USB: core: message: fix sparse warning
USB: musb: omap2430: fix sparse warning
USB: musb: musb_gadget: fix sparse warning
USB: musb: musb_host: fix sparse warning

Greg Kroah-Hartman (1):
USB: add devpath sysfs attribute

H Hartley Sweeten (1):
USB: hcd.c: quiet NULL pointer sparse noise

Hong Xu (1):
USB: modifications for at91sam9g10

Jason Wessel (1):
USB: ehci-hub: Remove redundant ehci->debug check

Jean Delvare (1):
USB: Add missing static markers to ohci-pnx4008

Julia Lawall (3):
USB: skeleton: Correct use of ! and &
USB: xhci-mem.c: introduce missing kfree
USB: ehci-omap.c: introduce missing kfree

Julie Zhu (1):
USB: Add support for Xilinx USB host controller

Larry Finger (1):
USB: Check results of dma_map_single

Laurent Pinchart (2):
USB gadget: Handle endpoint requests at the function level
USB audio gadget: handle endpoint control requests at the function level

Matthew Wilcox (3):
USB: Convert a dev_info to a dev_dbg
USB: usb-storage: Associate the name of the interface with the scsi host
USB Storage: Make driver less chatty when it finds a new device

Michal Nazarewicz (19):
USB: g_file_storage: parts of file_storage.c moved to separate file
USB: g_file_storage: "fsg_" prefix added to some identifiers
USB: g_file_storage: per-LUN ro, removable and cdrom flags handling changed
USB: g_file_storage: more code from file_storage.c moved to storage_common.c
USB: g_mass_storage: template f_mass_storage.c file created
USB: g_mass_storage: testing code from f_mass_storage.c removed
USB: g_mass_storage: parts of fsg_dev moved to fsg_common structure
USB: g_mass_storage: constant length buffers used
USB: g_mass_storage: fsg_common_init() created
USB: Interface Association Descriptors added to CDC & RNDIS
USB: g_mass_storage: Mass Storage Function created
USB: g_mass_storage: fsg_config added & module params handlig changed
USB: g_mass_storage: lun_name_format and thread_name added
USB: g_mass_storage: code cleaned up and comments updated
USB: g_mass_storage: most data moved to fsg_common
USB: composite: usb_composite_unregister() no longer __exit
USB: g_mass_storage: thread_exits callback added
USB: g_multi: Multifunction Composite Gadget added
USB: Added USB_ETH_RNDIS to use instead of CONFIG_USB_ETH_RNDIS

Mike Frysinger (2):
USB: musb: tweak musb_read_fifo() to avoid unused warnings
USB: musb: fix printf warning in debug code

Nathaniel McCallum (2):
USB: add hex/bcd detection to usb modalias generation
USB: handle bcd incrementation in usb modalias generation

Oliver Neukum (2):
USB: usbtmc: minor formatting cleanups
USB: improved error handling in usb_port_suspend()

Randy Dunlap (1):
USB: g_multi kconfig: fix depends and help text

Roel Kluin (1):
USB: FIX bitfield istl_flip:1, make it unsigned.

Roland Koebler (1):
USB: serial: ftdi_sio: add space/mark parity

Russ Dill (1):
USB: Close usb_find_interface race

Sarah Sharp (17):
USB: xhci: Handle URB cancel, complete and resubmit race.
USB: xhci: Re-purpose xhci_quiesce().
USB: xhci: Add watchdog timer for URB cancellation.
USB: xhci: Remove unused HCD statistics code.
USB: ehci: Minor constant fix for SCHEDULE_SLOP.
USB: ehci: Respect IST when scheduling new split iTDs.
USB: xhci: Add tests for TRB address translation.
USB: xhci: Set transfer descriptor size field correctly.
USB: xhci: Return -EPROTO on a split transaction error.
USB: xhci: Return success for vendor-specific info codes.
USB: xhci: Handle errors that cause endpoint halts.
USB: xhci: Add correct email and files to MAINTAINERS entry.
USB: usbtmc: Use usb_clear_halt() instead of custom code.
USB: xhci: Make reverting an alt setting "unfailable".
USB: xhci: Fix command completion after a drop endpoint.
USB: Refactor code to find alternate interface settings.
USB: Check bandwidth when switching alt settings.

Sergei Shtylyov (4):
USB: musb_gadget_ep0: fix unhandled endpoint 0 IRQs, again
USB: musb_gadget: implement set_wedge() method
USB: musb_gadget_ep0: stop abusing musb_gadget_set_halt()
USB: musb_gadget: remove pointless loop

Sonic Zhang (4):
USB: musb: update Blackfin processor dependency
USB: musb: add notes for Blackfin anomalies
USB: musb: add work around for Blackfin anomaly 05000456
USB: musb: error out when anomaly 05000380 is applicable

Vikram Pandita (1):
usbtest: make module param pattern writeable

Zhang Le (1):
USB: option.c: add support for D-Link DWM-162-U5

[email protected] (6):
USB: ark3116: Setup some basic infrastructure for new ark3116 driver.
USB: ark3116: Make existing functions 16450-aware and add close and release functions.
USB: ark3116: Replace cmget
USB: ark3116: Add cmset and break
USB: ark3116: Callbacks for interrupt and bulk read
USB: ark3116: Cleanup of now unneeded functions

[email protected] (1):
USB: option: add pid for ZTE


2009-12-12 06:59:33

by Ingo Molnar

[permalink] [raw]
Subject: [build failure] Re: [GIT PATCH] USB patches for 2.6.33-git


FYI, there's a new build breakage on latest upstream, on allyesconfig
x86:

drivers/net/usb/kaweth.c: In function kaweth_open:
drivers/net/usb/kaweth.c:719: error: implicit declaration of function usb_autopm_enable

The problem appears to be that usb_autopm_enable() is obsolete and got
eliminated recently via:

| commit 8e4ceb38eb5bbaef22fc00abe9bc11e26bea2ab5
| Author: Alan Stern <[email protected]>
| Date: Mon Dec 7 13:01:37 2009 -0500
|
| USB: prepare for changover to Runtime PM framework

Ingo

2009-12-12 07:00:34

by David Miller

[permalink] [raw]
Subject: Re: [build failure] Re: [GIT PATCH] USB patches for 2.6.33-git

From: Ingo Molnar <[email protected]>
Date: Sat, 12 Dec 2009 07:59:23 +0100

>
> FYI, there's a new build breakage on latest upstream, on allyesconfig
> x86:
>
> drivers/net/usb/kaweth.c: In function kaweth_open:
> drivers/net/usb/kaweth.c:719: error: implicit declaration of function usb_autopm_enable
>
> The problem appears to be that usb_autopm_enable() is obsolete and got
> eliminated recently via:

I posted about this a few hours ago, it's been resolved and a fix
is in net-2.6 and will be pushed out soon.

2009-12-12 07:15:46

by Ingo Molnar

[permalink] [raw]
Subject: [PATCH] kaweth: Replace runtime power management primitives


* David Miller <[email protected]> wrote:

> From: Ingo Molnar <[email protected]>
> Date: Sat, 12 Dec 2009 07:59:23 +0100
>
> >
> > FYI, there's a new build breakage on latest upstream, on allyesconfig
> > x86:
> >
> > drivers/net/usb/kaweth.c: In function kaweth_open:
> > drivers/net/usb/kaweth.c:719: error: implicit declaration of function usb_autopm_enable
> >
> > The problem appears to be that usb_autopm_enable() is obsolete and got
> > eliminated recently via:
>
> I posted about this a few hours ago, it's been resolved and a fix
> is in net-2.6 and will be pushed out soon.

thanks, i found the patch on netdev - attached below, should anyone only
subscribed to lkml run into this problem.

Ingo

-------------------->
>From cf549e36d31c8f12da1fe9aaa44702b60d967aac Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Wed, 19 Aug 2009 21:35:01 +0200
Subject: [PATCH] kaweth: Replace runtime power management primitives

This patch removes a rare use of the USB power management API
which won't be supported after the conversion to the new generic
runtime power management framework. Functionality is not
altered.

Signed-off-by: Oliver Neukum <[email protected]>
Cc: Alan Stern <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
drivers/net/usb/kaweth.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 3b80e8d..f1d64ef 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -716,7 +716,7 @@ static int kaweth_open(struct net_device *net)
return 0;

err_out:
- usb_autopm_enable(kaweth->intf);
+ usb_autopm_put_interface(kaweth->intf);
return -EIO;
}

@@ -753,7 +753,7 @@ static int kaweth_close(struct net_device *net)

kaweth->status &= ~KAWETH_STATUS_CLOSING;

- usb_autopm_enable(kaweth->intf);
+ usb_autopm_put_interface(kaweth->intf);

return 0;
}

2009-12-15 00:40:14

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Fri, 11 Dec 2009, Greg KH wrote:
>
> Here is the big USB merge for the 2.6.33-git tree.

I haven't bisected this yet, but something bad has happened to the USB
printer connected to Tove's computer since 2.6.32. Current -git doesn't
work, 2.6.32 works fine.

The USB pull is obviously an easy suspect, but on the other hand the code
still sees the printer - but for some reason Fedora-11 print manager still
complains about it perhaps being unconnected (and is unable to see any
printer if I try to go into "Printer admin" and remove and add the
printer)..

Booting back into 2.6.32 gets me a fine working printer again.

Does this ring a bell for anybody? The bisect is ongoing, but it will take
some time (at least 12 more compiles and reboots - I just started).

Linus

2009-12-15 00:52:43

by Greg KH

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git

On Mon, Dec 14, 2009 at 04:39:37PM -0800, Linus Torvalds wrote:
>
>
> On Fri, 11 Dec 2009, Greg KH wrote:
> >
> > Here is the big USB merge for the 2.6.33-git tree.
>
> I haven't bisected this yet, but something bad has happened to the USB
> printer connected to Tove's computer since 2.6.32. Current -git doesn't
> work, 2.6.32 works fine.
>
> The USB pull is obviously an easy suspect, but on the other hand the code
> still sees the printer - but for some reason Fedora-11 print manager still
> complains about it perhaps being unconnected (and is unable to see any
> printer if I try to go into "Printer admin" and remove and add the
> printer)..

Any kind of kernel log messages? This would be a USB 2.0 device, right?

> Booting back into 2.6.32 gets me a fine working printer again.
>
> Does this ring a bell for anybody? The bisect is ongoing, but it will take
> some time (at least 12 more compiles and reboots - I just started).

Hm, I just tried to print from mine on your latest tree, and I have a
stream of:
[440651.362550] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440656.363409] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440661.364296] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440666.365009] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440677.692298] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440682.693080] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440687.697054] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440692.697784] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[440697.698653] usb 4-1.2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1

messages in the log, which doesn't seem good.

Alan, any ideas?

thanks,

greg k-h

2009-12-15 01:00:27

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Greg KH wrote:
>
> Any kind of kernel log messages? This would be a USB 2.0 device, right?

There's no odd messages. I see the regular connect and disconnect
messages, so I know the USB layer _saw_ the printer. But apart from that,
nothing actually happens. And no printout.

> Hm, I just tried to print from mine on your latest tree, and I have a
> stream of:

Ahha. So I'm not the only one.

Will continue to bisect.

Linus

2009-12-15 01:47:35

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Linus Torvalds wrote:
>
> Will continue to bisect.

So far:

Good: d71cb81af3817193bc605de061da0499934263a6
Bad: 6bd03e7b9d0f70928f9cd793326c28e4e08ffc96

so it's definitely from that USB merge (unless it comes and goes
intermittently and my bisect is not reliable, but the
fact that I've bisected down to the USB merge makes it at least _look_
plausible).

Not surprising, and there's 85 commits in between those points, so I'll
have to do 7 more bisection points.

Linus

2009-12-15 02:31:52

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Linus Torvalds wrote:
>
> Not surprising, and there's 85 commits in between those points, so I'll
> have to do 7 more bisection points.

It bisected down to this:

commit a2582bd478c13c574d4c16ef1209d333f2a25935
Author: Russ Dill <[email protected]>
Date: Wed Nov 18 11:02:13 2009 -0700

USB: Close usb_find_interface race

USB drivers that create character devices call usb_register_dev in their
probe function. This associates the usb_interface device with that minor
number and creates the character device and announces it to the world.
However, the driver's probe function is called before the new
usb_interface is added to the driver's klist_devices.
...

and what's even scarier is that that commit is marked for stable too. Did
it already make it?

I'll double-check by reverting it from current -tip, but if you don't hear
anything different from me, you can assume that that double-check
succeeded and confirms that that commit really is the cause of my printer
no longer working.

Linus

2009-12-15 03:09:52

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Linus Torvalds wrote:
>
> I'll double-check by reverting it from current -tip, but if you don't hear
> anything different from me, you can assume that that double-check
> succeeded and confirms that that commit really is the cause of my printer
> no longer working.

Confirmed.

With that commit reverted, everything works fine again. So it's definitely
a2582bd478c13c574d4c16ef1209d333f2a25935, although I have no idea _why_ it
causes problems.

One thing I note is that it literally changed semantics, as per the
comment in there. It used to be:

This walks the driver device list and returns a pointer to the interface
with the matching minor.

and after that it is

This walks the bus device list and returns a pointer to the interface
with the matching minor.

Notice the "driver device list" -> "bus device list" change.

Also notice that the minor number of my 'lp0' device is zero, so I could
easily imagine that some device without a driver at all or whatever will
have a zero there, and then it would return the wrong device entirely.

So I really think that commit is very suspect. Not matching against the
driver that we passed in looks like some total screwup.

But I don't know the code or the use. I do know that reverting it fixes
it.

Linus

2009-12-15 03:18:13

by Russ Dill

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, Dec 14, 2009 at 8:09 PM, Linus Torvalds <[email protected]> wrote:
>
>
> On Mon, 14 Dec 2009, Linus Torvalds wrote:
>>
>> I'll double-check by reverting it from current -tip, but if you don't hear
>> anything different from me, you can assume that that double-check
>> succeeded and confirms that that commit really is the cause of my printer
>> no longer working.
>
> Confirmed.
>
> With that commit reverted, everything works fine again. So it's definitely
> a2582bd478c13c574d4c16ef1209d333f2a25935, although I have no idea _why_ it
> causes problems.
>
> One thing I note is that it literally changed semantics, as per the
> comment in there. It used to be:
>
>        This walks the driver device list and returns a pointer to the interface
>        with the matching minor.
>
> and after that it is
>
>        This walks the bus device list and returns a pointer to the interface
>        with the matching minor.
>
> Notice the "driver device list" -> "bus device list" change.
>
> Also notice that the minor number of my 'lp0' device is zero, so I could
> easily imagine that some device without a driver at all or whatever will
> have a zero there, and then it would return the wrong device entirely.
>
> So I really think that commit is very suspect. Not matching against the
> driver that we passed in looks like some total screwup.
>
> But I don't know the code or the use. I do know that reverting it fixes
> it.

Yes, you are right. Sorry for breaking your printer. There is both USB_MAJOR and USB_DEVICE_MAJOR. I haven't investigated it in great detail yet, but that seems likely to be the issue. I'll clean up the patch. And yes, it should definitely not be going into stable yet. Revert for now and I'll resubmit.


Attachments:
signature.asc (271.00 B)
OpenPGP digital signature

2009-12-15 04:01:12

by Russ Dill

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git

On Mon, 2009-12-14 at 20:17 -0700, [email protected] wrote:
>
> On Mon, Dec 14, 2009 at 8:09 PM, Linus Torvalds <[email protected]> wrote:
> >
> >
> > On Mon, 14 Dec 2009, Linus Torvalds wrote:
> >>
> >> I'll double-check by reverting it from current -tip, but if you don't hear
> >> anything different from me, you can assume that that double-check
> >> succeeded and confirms that that commit really is the cause of my printer
> >> no longer working.
> >
> > Confirmed.
> >
> > With that commit reverted, everything works fine again. So it's definitely
> > a2582bd478c13c574d4c16ef1209d333f2a25935, although I have no idea _why_ it
> > causes problems.
> >
> > One thing I note is that it literally changed semantics, as per the
> > comment in there. It used to be:
> >
> > This walks the driver device list and returns a pointer to the interface
> > with the matching minor.
> >
> > and after that it is
> >
> > This walks the bus device list and returns a pointer to the interface
> > with the matching minor.
> >
> > Notice the "driver device list" -> "bus device list" change.
> >
> > Also notice that the minor number of my 'lp0' device is zero, so I could
> > easily imagine that some device without a driver at all or whatever will
> > have a zero there, and then it would return the wrong device entirely.
> >
> > So I really think that commit is very suspect. Not matching against the
> > driver that we passed in looks like some total screwup.
> >
> > But I don't know the code or the use. I do know that reverting it fixes
> > it.
>
> Yes, you are right. Sorry for breaking your printer. There is both USB_MAJOR and USB_DEVICE_MAJOR. I haven't investigated it in great detail yet, but that seems likely to be the issue. I'll clean up the patch. And yes, it should definitely not be going into stable yet. Revert for now and I'll resubmit.


Here is a cleaned up patch that matches against minor and driver, not
just minor. I'll haven't test it yet, but will get a chance to tomorrow.

From 4441c99c80d8298a99b6f2fbd4ece9d3cfe7fd4d Mon Sep 17 00:00:00 2001
From: Russ Dill <[email protected]>
Date: Wed, 18 Nov 2009 10:31:27 -0700
Subject: [PATCH] Close usb_find_interface race v2

USB drivers that create character devices call usb_register_dev in their
probe function. This associates the usb_interface device with that minor
number and creates the character device and announces it to the world.
However, the driver's probe function is called before the new
usb_interface is added to the driver's klist_devices.

This is a problem because userspace will respond to the character device
creation announcement by opening the character device. The driver's open
function will the call usb_find_interface to find the usb_interface
associated with that minor number. usb_find_interface will walk the
driver's list of devices and find the usb_interface with the matching
minor number.

Because the announcement happens before the usb_interface is added to the
driver's klist_devices, a race condition exists. A straightforward fix
is to walk the list of devices on usb_bus_type instead since the device
is added to that list before the announcement occurs.

bus_find_device calls get_device to bump the reference count on the found
device. It is arguable that the reference count should be dropped by the
caller of usb_find_interface instead of usb_find_interface, however,
the current users of usb_find_interface do not expect this.

The original version of this patch only matched against minor number
instead of driver and minor number. This version matches against both.

Signed-off-by: Russ Dill <[email protected]>
---
drivers/usb/core/usb.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index b1b85ab..2091fac 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -132,7 +132,7 @@ EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);

struct find_interface_arg {
int minor;
- struct usb_interface *interface;
+ struct device_driver *drv;
};

static int __find_interface(struct device *dev, void *data)
@@ -144,10 +144,9 @@ static int __find_interface(struct device *dev, void *data)
return 0;

intf = to_usb_interface(dev);
- if (intf->minor != -1 && intf->minor == arg->minor) {
- arg->interface = intf;
+ if (intf->minor != -1 && intf->minor == arg->minor &&
+ dev->driver == arg->drv)
return 1;
- }
return 0;
}

@@ -156,21 +155,24 @@ static int __find_interface(struct device *dev, void *data)
* @drv: the driver whose current configuration is considered
* @minor: the minor number of the desired device
*
- * This walks the driver device list and returns a pointer to the interface
- * with the matching minor. Note, this only works for devices that share the
- * USB major number.
+ * This walks the bus device list and returns a pointer to the interface
+ * with the matching minor and driver. Note, this only works for devices
+ * that share the USB major number.
*/
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
{
struct find_interface_arg argb;
- int retval;
+ struct device *dev;

argb.minor = minor;
- argb.interface = NULL;
- /* eat the error, it will be in argb.interface */
- retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
- __find_interface);
- return argb.interface;
+ argb.drv = &drv->drvwrap.driver;
+
+ dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
+
+ /* Drop reference count from bus_find_device */
+ put_device(dev);
+
+ return dev ? to_usb_interface(dev) : NULL;
}
EXPORT_SYMBOL_GPL(usb_find_interface);

--
1.6.5



Attachments:
signature.asc (197.00 B)
This is a digitally signed message part

2009-12-15 04:28:46

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Russ Dill wrote:
>
> Here is a cleaned up patch that matches against minor and driver, not
> just minor. I'll haven't test it yet, but will get a chance to tomorrow.

Ok, this looks sane. I'll test it on the machine that had trouble.

Linus

2009-12-15 04:36:51

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Russ Dill wrote:
> @@ -144,10 +144,9 @@ static int __find_interface(struct device *dev, void *data)
> return 0;
>
> intf = to_usb_interface(dev);
> - if (intf->minor != -1 && intf->minor == arg->minor) {
> - arg->interface = intf;
> + if (intf->minor != -1 && intf->minor == arg->minor &&
> + dev->driver == arg->drv)
> return 1;
> - }
> return 0;
> }

Btw, can we please write this somewhat more readably, and just do

if (dev->driver != arg->drv)
return 0;
intf = to_usb_interface(dev);
return intf->minor == arg->minor;

because the whole "intf->minor != -1" thing is pointless (we're going to
test it against 'arg->minor', and if that is -1, then the caller damn well
gets what he deserves anyway).

This way there are no complex multi-line crud expressions, and it all
looks simpler. No?

Linus

2009-12-15 04:44:48

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Linus Torvalds wrote:
>
> Ok, this looks sane. I'll test it on the machine that had trouble.

Tests fine. I'd still like the trivial cleanup, but at least this confirms
that the problem was that the original patch matches the wrong device due
to not matching on the driver field.

Greg, do you want me to do this (revert+fixed patch), or are you going to
send me a pull request with it all sorted out?

Linus

2009-12-15 04:45:52

by Russ Dill

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git

On Mon, 2009-12-14 at 20:36 -0800, Linus Torvalds wrote:
>
> On Mon, 14 Dec 2009, Russ Dill wrote:
> > @@ -144,10 +144,9 @@ static int __find_interface(struct device *dev, void *data)
> > return 0;
> >
> > intf = to_usb_interface(dev);
> > - if (intf->minor != -1 && intf->minor == arg->minor) {
> > - arg->interface = intf;
> > + if (intf->minor != -1 && intf->minor == arg->minor &&
> > + dev->driver == arg->drv)
> > return 1;
> > - }
> > return 0;
> > }
>
> Btw, can we please write this somewhat more readably, and just do
>
> if (dev->driver != arg->drv)
> return 0;
> intf = to_usb_interface(dev);
> return intf->minor == arg->minor;
>
> because the whole "intf->minor != -1" thing is pointless (we're going to
> test it against 'arg->minor', and if that is -1, then the caller damn well
> gets what he deserves anyway).
>
> This way there are no complex multi-line crud expressions, and it all
> looks simpler. No?

Yup.

From 41e394bc38b9d5224cc5e8013f45e769910a114e Mon Sep 17 00:00:00 2001
From: Russ Dill <[email protected]>
Date: Wed, 18 Nov 2009 10:31:27 -0700
Subject: [PATCH] Close usb_find_interface race v3

USB drivers that create character devices call usb_register_dev in their
probe function. This associates the usb_interface device with that minor
number and creates the character device and announces it to the world.
However, the driver's probe function is called before the new
usb_interface is added to the driver's klist_devices.

This is a problem because userspace will respond to the character device
creation announcement by opening the character device. The driver's open
function will the call usb_find_interface to find the usb_interface
associated with that minor number. usb_find_interface will walk the
driver's list of devices and find the usb_interface with the matching
minor number.

Because the announcement happens before the usb_interface is added to the
driver's klist_devices, a race condition exists. A straightforward fix
is to walk the list of devices on usb_bus_type instead since the device
is added to that list before the announcement occurs.

bus_find_device calls get_device to bump the reference count on the found
device. It is arguable that the reference count should be dropped by the
caller of usb_find_interface instead of usb_find_interface, however,
the current users of usb_find_interface do not expect this.

The original version of this patch only matched against minor number
instead of driver and minor number. This version matches against both.

Signed-off-by: Russ Dill <[email protected]>
---
drivers/usb/core/usb.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index b1b85ab..52e5e31 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -132,7 +132,7 @@ EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);

struct find_interface_arg {
int minor;
- struct usb_interface *interface;
+ struct device_driver *drv;
};

static int __find_interface(struct device *dev, void *data)
@@ -143,12 +143,10 @@ static int __find_interface(struct device *dev, void *data)
if (!is_usb_interface(dev))
return 0;

+ if (dev->driver != arg->drv)
+ return 0;
intf = to_usb_interface(dev);
- if (intf->minor != -1 && intf->minor == arg->minor) {
- arg->interface = intf;
- return 1;
- }
- return 0;
+ return intf->minor == arg->minor;
}

/**
@@ -156,21 +154,24 @@ static int __find_interface(struct device *dev, void *data)
* @drv: the driver whose current configuration is considered
* @minor: the minor number of the desired device
*
- * This walks the driver device list and returns a pointer to the interface
- * with the matching minor. Note, this only works for devices that share the
- * USB major number.
+ * This walks the bus device list and returns a pointer to the interface
+ * with the matching minor and driver. Note, this only works for devices
+ * that share the USB major number.
*/
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
{
struct find_interface_arg argb;
- int retval;
+ struct device *dev;

argb.minor = minor;
- argb.interface = NULL;
- /* eat the error, it will be in argb.interface */
- retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
- __find_interface);
- return argb.interface;
+ argb.drv = &drv->drvwrap.driver;
+
+ dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
+
+ /* Drop reference count from bus_find_device */
+ put_device(dev);
+
+ return dev ? to_usb_interface(dev) : NULL;
}
EXPORT_SYMBOL_GPL(usb_find_interface);

--
1.6.5





Attachments:
signature.asc (197.00 B)
This is a digitally signed message part

2009-12-15 06:03:36

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Russ Dill wrote:
>
> From: Russ Dill <[email protected]>
> Date: Wed, 18 Nov 2009 10:31:27 -0700
> Subject: [PATCH] Close usb_find_interface race v3
[...]

Ok, patch looks good to me.

However, now I just wonder whether this re-introduces the original race.

In the original race description:

> USB drivers that create character devices call usb_register_dev in their
> probe function. This associates the usb_interface device with that minor
> number and creates the character device and announces it to the world.
> However, the driver's probe function is called before the new
> usb_interface is added to the driver's klist_devices.

and now we obviously no longer care about that klist_devices thing any
more, but we _do_ care about 'dev->driver'.

Has that been set by the time the driver's probe function is called? Or
are we now going to have the same situation as before the original patch?

[ That obviously always worked for my printer situation, but I'm just
wondering if this patch actually now helps whatever problem the original
patch was supposed to help? ]

Somebody who knows the USB driver binding code better than I do should
look at this. Greg?

Linus

2009-12-15 06:12:04

by Russ Dill

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git

Linus Torvalds wrote:
>
> On Mon, 14 Dec 2009, Russ Dill wrote:
>> From: Russ Dill <[email protected]>
>> Date: Wed, 18 Nov 2009 10:31:27 -0700
>> Subject: [PATCH] Close usb_find_interface race v3
> [...]
>
> Ok, patch looks good to me.
>
> However, now I just wonder whether this re-introduces the original race.
>
> In the original race description:
>
>> USB drivers that create character devices call usb_register_dev in their
>> probe function. This associates the usb_interface device with that minor
>> number and creates the character device and announces it to the world.
>> However, the driver's probe function is called before the new
>> usb_interface is added to the driver's klist_devices.
>
> and now we obviously no longer care about that klist_devices thing any
> more, but we _do_ care about 'dev->driver'.
>
> Has that been set by the time the driver's probe function is called? Or
> are we now going to have the same situation as before the original patch?
>
> [ That obviously always worked for my printer situation, but I'm just
> wondering if this patch actually now helps whatever problem the original
> patch was supposed to help? ]
>
> Somebody who knows the USB driver binding code better than I do should
> look at this. Greg?
>

I'll test tomorrow be sure, but It seems fine. really_probe in
drivers/base/dd.c is setting dev->driver before calling drv->probe.
driver_bound is called after drv->prove which adds the device to the
driver klist_devices.


Attachments:
signature.asc (260.00 B)
OpenPGP digital signature

2009-12-15 06:20:31

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git



On Mon, 14 Dec 2009, Russ Dill wrote:
>
> I'll test tomorrow be sure, but It seems fine. really_probe in
> drivers/base/dd.c is setting dev->driver before calling drv->probe.
> driver_bound is called after drv->prove which adds the device to the
> driver klist_devices.

Ok, sounds good. Just checking.

Linus

2009-12-15 14:36:24

by Greg KH

[permalink] [raw]
Subject: Re: [GIT PATCH] USB patches for 2.6.33-git

On Mon, Dec 14, 2009 at 08:44:33PM -0800, Linus Torvalds wrote:
>
>
> On Mon, 14 Dec 2009, Linus Torvalds wrote:
> >
> > Ok, this looks sane. I'll test it on the machine that had trouble.
>
> Tests fine. I'd still like the trivial cleanup, but at least this confirms
> that the problem was that the original patch matches the wrong device due
> to not matching on the driver field.
>
> Greg, do you want me to do this (revert+fixed patch), or are you going to
> send me a pull request with it all sorted out?

I will provide a tree with a revert and addition of the new patch in a
few hours.

thanks,

greg k-h