Alan Stern [Mon, 20 Nov 2006 16:14:30 +0000 (11:14 -0500)]
USB hub: simplify remote-wakeup handling
This patch (as817) simplifies the remote-wakeup processing in the hub
driver. Now instead of using a specialized code path, it relies on
the standard USB resume routines. The hub_port_resume() function does
an initial get_port_status() to see whether the port has already
resumed itself (as it does when a remote-wakeup request is sent).
This will slow down handling of other resume events slightly, but not
enough to matter.
The patch also changes the hub_port_status() routine, making it return
an error if a short reply is received.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Mon, 20 Nov 2006 16:06:59 +0000 (11:06 -0500)]
OHCI: make autostop conditional on CONFIG_PM
Unlike UHCI, OHCI does not exert any DMA load on the system when no
devices are connected. Consequently there is no advantage to doing
an autostop other than the power savings, so we shouldn't compile the
necessary code unless CONFIG_PM is enabled.
This patch (as820) makes the root-hub suspend and resume routines
conditional on CONFIG_PM. It also prevents autostop from activating
if the device_may_wakeup flag isn't set; some people use this flag to
alert the driver about Resume-Detect bugs in the hardware.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Thu, 9 Nov 2006 19:44:33 +0000 (14:44 -0500)]
USB: Add autosuspend support to the hub driver
This patch (as742b) adds autosuspend/autoresume support to the USB hub
driver. The largest aspect of the change is that we no longer need a
special flag for root hubs that want to be resumed. Now every hub is
autoresumed whenever khubd needs to access it.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Thu, 9 Nov 2006 19:42:16 +0000 (14:42 -0500)]
EHCI: Fix root-hub and port suspend/resume problems
This patch (as738b) fixes numerous problems in the controller/root-hub
suspend/resume/remote-wakeup support in ehci-hcd:
The bus_resume() routine should wake up only the ports that
were suspended by bus_suspend(). Ports that were already
suspended should remain that way.
The interrupt mask is used to detect loss of power in the
bus_resume() routine (if the mask is 0 then power was lost).
However bus_suspend() always sets the mask to 0. Instead the
mask should retain its normal value, with port-change-detect
interrupts disabled if remote wakeup is turned off.
The interrupt mask should be reset to its correct value at the
end of bus_resume() regardless of whether power was lost.
bus_resume() reinitializes the operational registers if power
was lost. However those registers are not in the aux power
well, hence they can lose their values whenever the controller
is put into D3. They should always be reinitialized.
When a port-change interrupt occurs and the root hub is
suspended, the interrupt handler should request a root-hub
resume instead of starting up the controller all by itself.
There's no need for the interrupt handler to request a
root-hub resume every time a suspended port sends a
remote-wakeup request.
The pci_resume() method doesn't need to check for connected
ports when deciding whether or not to reset the controller.
It can make that decision based on whether Vaux power was
maintained.
Even when the controller does not need to be reset,
pci_resume() must undo the effect of pci_suspend() by
re-enabling the interrupt mask.
If power was lost, pci_resume() must not call ehci_run().
At this point the root hub is still supposed to be suspended,
not running. It's enough to rewrite the command register and
set the configured_flag.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Adrian Bunk [Mon, 20 Nov 2006 02:24:44 +0000 (03:24 +0100)]
USB: ftdi-elan.c: fixes and cleanups
This patch contains the following possible cleanups:
- make the needlessly global ftdi_release_platform_dev() static
- remove the unused usb_ftdi_elan_read_reg()
- proper prototypes for the following functions:
- usb_ftdi_elan_read_pcimem()
- usb_ftdi_elan_write_pcimem()
Note that the misplaced prototypes for the latter ones in
drivers/usb/host/u132-hcd.c were buggy. Depending on the calling
convention of the architecture calling one of them could have turned
your stack into garbage.
Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
David Brownell [Fri, 17 Nov 2006 07:34:58 +0000 (23:34 -0800)]
USB: add ehci_hcd.ignore_oc parameter
Certain boards seem to like to issue false overcurrent notifications, for
example on ports that don't have anything connected to them. This looks
like a hardware error, at the level of noise to those ports' overcurrent
input signals (or non-debounced VBUS comparators). This surfaces to users
as truly massive amounts of syslog spam from khubd (which is appropriate
for real hardware problems, except for the volume from multiple ports).
Using this new "ignore_oc" flag helps such systems work more sanely, by
preventing such indications from getting to khubd (and spam syslog). The
downside is of course that true overcurrent errors will be masked; they'll
appear as spontaneous disconnects, without the diagnostics that will let
users troubleshoot issues like short circuited cables.
Note that the bulk of these reports seem to be with VIA southbridges, but
I think some were with Intel ones.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
David Brownell [Fri, 17 Nov 2006 07:56:15 +0000 (23:56 -0800)]
USB: EHCI hooks for high speed electrical tests
EHCI hooks for high speed electrical tests of the root hub ports.
The expectation is that a usermode program actually triggers the test,
making the same control request it would make for an external hub.
Tests for peripheral upstream ports would issue a different request.
In all cases, the hardware needs re-initialization before it could
be used "normally" again (e.g. unplug/replug, rmmod/modprobe).
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The net2280 driver is too eager to send zero-length packets when
IN tokens are received on ep0. No such packet should be sent (the
driver should NAK) before the gadget driver has queued the proper
response. Otherwise deferred responses are impossible.
This patch (as823) makes net2280 avoid sending ZLPs for IN transfers
on ep0 until a response has been submitted, and avoids stalling when an
OUT packet is received before a request has been submitted for an OUT
transfer on ep0.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Jaco Kroon [Wed, 15 Nov 2006 09:02:08 +0000 (01:02 -0800)]
USB: add Digitech USB-Storage to unusual_devs.h
The mass storage device from Digitech designed for Flash Cards, as found
on (for example) the GNX4 device has issues with residue, similar to the
bug report at http://kerneltrap.org/node/6297. This patch adds the
faulty storage device to unusual_devs.h, this not only reduces the noise
in dmesg but also increases the transfer speeds by a factor of 7x for me
(89kB/s -> 637kB/s).
> 2006/11/11, Adrian Bunk <bunk@stusta.de>:
> > The Coverity checker spotted the following in
> > drivers/usb/serial/aircable.c:
> >
> > <-- snip -->
> >
> > ...
> > static void aircable_read(void *params)
> > {
> > ...
Hi everyone,
Sorry for the long time response but here is the patch, I think this way should
work, if anyone has any suggestion let me know. What I do now is, in case I
don't have the tty available I reschedule the work, I have tried it and it
works with no problem, I even tried removing the device, and didn't find
anything strange.
Signed-off-by: Naranjo Manuel <naranjo.manuel@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Mon, 6 Nov 2006 17:05:00 +0000 (12:05 -0500)]
OHCI: change priority level of resume log message
All the other root-hub suspend or resume log messages, in ohci-hcd or
any of the other host controller drivers, use the debug priority
level. This patch (as815) makes the one single exception behave like
all the rest.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Allright. As Greg KH suggested I split this big patch into smaller ones to
make the changes easier to review. Having no better idea how to split that I
split it on a 'patch per file' basis. All those patches clean redundant 'if' before
usb_unlink/free/kill_urb():
if (urb)
usb_free_urb(urb); /* unlink / free / kill */
I decided not to touch bigger 'if's like
if (urb) {
usb_kill_urb(urb);
usb_free_urb(urb);
urb = NULL;
}
as that would be probably too intrusive. One of patches also fixes
drivers/usb/misc/auerswald.c memleak I found when digging the code. All those
patches are against 2.6.19-rc4.
Several functions in USB core overlap with global functions.
The linker appears to do the right thing, but it is bad practice and makes
debugging harder.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Mon, 6 Nov 2006 16:56:13 +0000 (11:56 -0500)]
USB: Move private hub declarations out of public header file
This patch (as809b) moves the declaration of the hub driver's private
data structure from hub.h into the hub.c source file. Lots of other
files import hub.h; they have no need to know about the details of the
hub driver's private data.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Mon, 30 Oct 2006 22:07:51 +0000 (17:07 -0500)]
USB: expand autosuspend/autoresume API
This patch (as814) adds usb_autopm_set_interface() to the autosuspend
API. It also provides convenient wrapper routines,
usb_autopm_enable() and usb_autopm_disable(), for drivers that want
to specify directly whether autosuspend should be allowed.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Mon, 30 Oct 2006 22:06:45 +0000 (17:06 -0500)]
USB: autosuspend code consolidation
This patch (as813) gathers together common code for USB interface
autosuspend/autoresume.
It also adds some simple checking at the time an autosuspend request
is made, to see whether the request will fail. This way we don't
add a workqueue entry when it would end up doing nothing.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This is the result of a 2.6.19-rc3 kernel compiled with GCC 4.1.1 without
CONFIG_MODULES, CONFIG_CC_OPTIMIZE_FOR_SIZE, CONFIG_REGPARM options set.
USB support is fully enabled (while most of the other drivers are not),
and that kernel has most of the USB code ported to use the endpoint
functions.
That happens because a call to those functions are expensive (in terms
of bytes), while the function's size is smaller or have the same 'size' of
the call.
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 27 Oct 2006 14:35:01 +0000 (10:35 -0400)]
USB: OHCI: remove stale testing code from root-hub resume
This patch (as811) removes some stale testing code from the root-hub
resume routine in ohci-hcd. It also adds a spin_lock_irq() call that
inadvertently got left out of an error pathway.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 27 Oct 2006 14:33:11 +0000 (10:33 -0400)]
USB: OHCI: disable RHSC inside interrupt handler
This patch (as808b) moves the Root Hub Status Change interrupt-disable
code in ohci-hcd back into the interrupt handler proper, to avoid the
chance of adverse interactions with mediocre hardware implementations.
It also deletes the root-hub status timer from within the interrupt-enable
routine. There's no need to poll for status any more once interrupts are
re-enabled.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Wed, 18 Oct 2006 20:41:51 +0000 (16:41 -0400)]
USB core: don't match interface descriptors for vendor-specific devices
This patch (as804) makes USB driver matching ignore the interface
class, subclass, and protocol if the device class is Vendor Specific.
Drivers can override this policy by specifying a Vendor ID as part
of the match; then vendor-specific matches are allowed.
Linus Walleij has reported a problem this patch fixes. When a
particular mass-storage device is switched from mass-storage mode to
Media Transfer Protocol, the interface class remains set to mass-storage
and usb-storage binds to it erroneously, even though the device class
changes to Vendor-Specific.
This may cause a problem for some drivers until their match records can
be updated to include Vendor IDs. But if it does, then those records
were broken to begin with.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Wed, 18 Oct 2006 16:35:24 +0000 (12:35 -0400)]
USB HID: Handle STALL on interrupt endpoint
The USB HID driver doesn't include any code to handle a STALL on the
interrupt endpoint. While this may be uncommon, it does happen
sometimes. This patch (as805) adds a fix.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usb hub: fix root hub code so it takes more than 15 devices per root hub
Wireless USB Host Controllers accept a large number of devices per
host, which shows up as a large number of ports in its root hub.
When the number of ports in a hub device goes over 16, the activation
of the hub fails with the cryptic message in klogd.
hub 2-0:1.0: activate --> -22
Following this further, it was seen that:
hub_probe()
hub_configure()
generates pipe number
pseudo allocates buffer 'maxp' bytes in size using usb_maxpacket()
The endpoint descriptor for a root hub interrupt endpoint is
declared in
drivers/usb/core/hcd.c:hs_rh_config_descriptor and declares it
to be size two (supporting 15 devices max).
hub_activate()
usb_hcd_submit_urb()
rh_urb_enqueue()
urb->pipe is neither int nor ctl, so it errors out
rh_queue_status()
Returns -EINVAL because the buffer length is smaller
than the minimum needed to report all the hub port
bits as in accordance with USB2.0[11.12.3]. There has
to be trunc((PORTS + 1 + 7) / 8) bytes of space at
least.
Alan Stern confirmed that the reason for reading maxpktsize and not
the right amount is because some hubs are known to return more data
and thus cause overflow.
So this patch simply changes the code to make the interrupt endpoint's
max packet size be at least the minimum required by USB_MAXCHILDREN
(instead of a fixed magic number) and add documentation for that. This
way we are always ahead of the limit.