History log of /drivers/usb/host/isp1760-hcd.c
Revision Date Author Comments
c64391f264b7658c00515173cca58f5b054af1a2 23-Nov-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix race condition memory leak

This fixes a memory leak reported by Catalin Marinas:

schedule_ptds() is called from isp1760_irq() and removes the qh from the
controlqhs queue but ep->hcpriv still points to the qh and therefore it is not
freed.

Shortly after this, the isp1760_endpoint_disable() function sets ep->hcpriv to
NULL and calls schedule_ptds() but since the corresponding qh is no longer in
the queue, it is simply forgotten and reported by kmemleak.

With this patch, the qh is always freed at endpoint_disable, instead, and the
corresponding entry removed from the queue head list.

While I was at it, I also replaced the lines in isp1760_endpoint_disable()
that removed remaining qtds from the qh with a WARN_ON check for non-empty qh,
in line with earlier comments from Alan Stern (linux-usb list, 2011-07-20).

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e08f6a2790aaf3563e7800399321c0fb9a6c6636 23-Nov-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Simpler queue head list code.

Small code refactoring to ease the real fix in patch #2.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3a7655fcb210b349111251689d0a56b7250885ea 19-Oct-2011 Joachim Foerster <joachim.foerster@missinglinkelectronics.com> usb/isp1760: Allow to optionally trigger low-level chip reset via GPIOLIB.

Properly triggering the reset wire is necessary with the ISP1761 used
on Terasic DE4 Altera-FPGA boards using a NIOS2 processor, for example.

This is an optional implementation for the OF binding only. The other
bindings just pass an invalid GPIO to the isp1760_register() routine.

Example, usage in DTS:
gpios = <&pio_isp1761rst_0 0 1>;
to point to a GPIO controller from within the ISP1761 node: GPIO 0, active low.

Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
74ad60292bf0108de9884c531d7ec3f65c206230 23-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Clear TT buffer on interrupted low & full speed transfers

When a low or full speed urb in progress is unlinked (or some other error
occurs), the buffer in the transaction translator (part of the hub) might end
up in an inconsistent state. This can make all further low and full speed
transactions fail, unless the buffer is cleared.

The bug can be seen when running the usbtest unlink tests as "set altsetting
to 0 failed, -110", and gets fixed by this patch.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6477acc0814fc7aadfe3d723d2596fb4eb6d1732 21-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix problems that trigger WARNING at line 1136.

1) A bug in the usage of time_after() in errata2_function().

2) Clear done_maps just prior to starting a new transfer in
start_bus_transfer(), instead of just after, when done_map bits might have
been validly set by the started transfer.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
38679b720014d89b192c38d4c604f5a718b9788d 21-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix missing endpoint unlink when no mem during enqueue

... and some small code style fixes.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6d50c60e6d169b04b0cf0b267eb14ab0839f9540 21-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Use polling instead of SOF interrupts to fix Errata 2

Errata 2 for the isp1760 explains that the chip sometimes does not issue
interrupts when an ATL (bulk or control) transfer is completed. There are
several issues with the current work-around (SOF interrupts) for this:

1) It seems the chip sometimes does not even set the done bit for a
completed transfer, in which case SOF interrupts does not solve
the problem since we still check the done map to find out which
transfer descriptors to handle.

2) The above point seems to happen only when ATL and SOF interrupts
are enabled at the same time. However, disabling ATL interrupts
increases the latency between transfer completion and handling.
This is very noticeable in the testusb suite, which take several
minutes more to run with ATL interrupts disabled.

This patch removes the code to switch on SOF interrupts, and instead
use a kernel timer to periodically check for "old" descriptors that
have their VALID and ACTIVE flags unset, indicating completion, thus
avoiding the dependency on the chip's done map (and SOF interrupts)
to find transfers affected by this HW bug.

[bigeasy@linutronix: 80 lines limit]

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0ba7905e030a409fd0bb92cb965e915c0cb01030 21-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Move isp1760_run within file (prepare for next patch)

Like the previous patch, this patch has been split from the next one
for clarity.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e25e0eb209bf945db554512430ee128e6bb7b291 21-Aug-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Move some code (prepare for next patch)

Move the few lines of code in isp1760_enable_interrupts() and
isp1760_init_maps() into isp1760_run(). This makes the following patch
easier.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
17d3e145a4ad680b3d1b1c30d0696a5bbb2b65c4 20-Jul-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Added missing call to usb_hcd_check_unlink_urb() during unlink

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
8b1ab60c767f33d79894ef66037ef851a7a88fc8 17-Jun-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix bug preventing the unlinking of control urbs

Both control and bulk transfers use isp1760 slots of type ATL, but the
driver unlink code for ATL slots only acts on urbs describing a bulk
transfer, letting the code for INT slots take care of the unlink instead,
which often ended up removing the interrupt transfer for root hub events
instead. That's not good, and gets fixed by this patch.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d05b6ec01b8186f847ac9e41098e40858926db40 20-May-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix possible unlink problems

Use skip map to avoid spurious interrupts from unlinked transfers.
Also changes to urb_dequeue() and endpoint_disable() to avoid
release of spinlock in uncertain state.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
079cdb0947ce6ae7df0c73a1c82c14920a9b6b6d 20-May-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Move function isp1760_endpoint_disable() within file.

Preparation for patch #2. The function isp1760_endpoint_disable() does almost
the same thing as urb_dequeue(). In patch #2 I change these to use a common
helper function instead of calling each other - for clarity but also to
avoid releasing the spinlock while in a "questionable" state. It seemed
proper to have these functions close to each other in the code.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d93da492d9a8840a0bdda88e74df8d0f593f1977 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Report correct urb status after unlink

This fixes a bug in my previous (2.6.38) patch series which caused
urb->status value to be wrong after unlink (broke usbtest 11, 12).

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
71a9f9d268a5c2b0a80ae606cf8e502f3410a5df 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Improve urb queueing, get rid of BUG():s in normal code paths

This patch replaces the code that handles qtds. Intead of directly allocating
chip mem and chip slot, enqueue the transfer in a list of queue heads. Use
a centralized function enqueue_qtds() to prioritize and enqueue transfers.

This removes all of the interrupt context BUG() calls when out of chip
mem or transfer slots. It also makes it possible to efficiently use the
dual-port mem on the chip for double-buffered transfers, which improve
transfer times to/from/between usb sticks by about 40 % on my HW.

With this patch it should also be possible to handle qtd scheduling outside
of the interrupt handler, for significantly improved kernel latency. I have
not implemented this since there are some locking issues which I haven't
had time to look at.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
22bea9cef810ec54abdb057de46cea04c972dc64 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Report correct urb status after unlink

This fixes a bug in my previous (2.6.38) patch series which caused
urb->status value to be wrong after unlink (broke usbtest 11, 12).

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
eb1a796868effbf33ec2cfa3d15567d7e31f2ee2 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Remove unneeded OR map and HcBufferStatus code

Since we always set the OR flag for each transfer, we can just as well set all
these bits to 1 at init and be done with it. Also, HcBufferStatus can be set
at init as per the ISP1761 datasheet page 47 with no loss of performance.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
34537731d7f64d20116fbef4a665ec6a37195573 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Clean up urb enqueueing

This collects urb enqueue code that was spread out all over the place
into a couple of more readable functions.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
847ed3e8f18b9cc401677e6e14eb7c89c7b8dfb6 26-Apr-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Remove false error printout

This removes the "qh is 0" printout. qh == NULL if the urb has
been unlinked, so this condition is normal.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
753d8534cc190ed144caebc2ea49ab7a43dca662 14-Apr-2011 Greg Kroah-Hartman <gregkh@suse.de> Revert "USB: isp1760-hcd: move imask clear after pending work is done"

This reverts commit 5808544690300071f09eef9ab83a0fb1f60cf1cd.

To quote Richard:
I don't think this should be mainlined. It was a
misunderstanding on my part. If you see all the other hdc
drivers in the same location, they all do the same thing (i.e.
clear the interrupt status first, then do the work) that
"glitch" I think I saw was actually two back-to-back
interrupts.

Sebastian (the original author of isp1760) explained it to me a
few days after my submission.

sorry for the confusion

Cc: Richard Retanubun <RichardRetanubun@ruggedcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5808544690300071f09eef9ab83a0fb1f60cf1cd 17-Mar-2011 Richard Retanubun <RichardRetanubun@ruggedcom.com> USB: isp1760-hcd: move imask clear after pending work is done

This patch moves the HcInterrupt register write to clear the
pending interrupt to after the isr work is done, doing this removes
glitches in the irq line.

Signed-off-by: Richard Retanubun <richardretanubun@ruggedcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d06847fec256f4f902075ce5986e10f7c55fa250 16-Mar-2011 Randy Dunlap <randy.dunlap@oracle.com> usb: fix ips1760-hcd printk format warning

Fix printk format build warning and grammar typo on same line.

drivers/usb/host/isp1760-hcd.c:300: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'size_t'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
dbe79bbe9dcb22cb3651c46f18943477141ca452 17-Sep-2001 John Youn <John.Youn@synopsys.com> USB 3.0 Hub Changes

Update the USB core to deal with USB 3.0 hubs. These hubs have a slightly
different hub descriptor than USB 2.0 hubs, with a fixed (rather than
variable length) size. Change the USB core's hub descriptor to have a
union for the last fields that differ. Change the host controller drivers
that access those last fields (DeviceRemovable and PortPowerCtrlMask) to
use the union.

Translate the new version of the hub port status field into the old
version that khubd understands. (Note: we need to fix it to translate the
roothub's port status once we stop converting it to USB 2.0 hub status
internally.)

Add new code to handle link state change status. Send out new control
messages that are needed for USB 3.0 hubs, like Set Hub Depth.

This patch is a modified version of the original patch submitted by John
Youn. It's updated to reflect the removal of the "bitmap" #define, and
change the hub descriptor accesses of a couple new host controller
drivers.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Cc: Tony Olech <tony.olech@elandigitalsystems.com>
Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Max Vozeler <mvz@vozeler.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Anton Vorontsov <avorontsov@mvista.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Lothar Wassmann <LW@KARO-electronics.de>
Cc: Olav Kongas <ok@artecdesign.ee>
Cc: Martin Fuzzey <mfuzzey@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
da13051cc756756f10b2da8ea97b05bdf84bd7bb 01-Dec-2010 Sarah Sharp <sarah.a.sharp@linux.intel.com> USB: Remove bitmap #define from hcd.h

Using a #define to redefine a common variable name is a bad thing,
especially when the #define is in a header. include/linux/usb/hcd.h
redefined bitmap to DeviceRemovable to avoid typing a long field in the
hub descriptor. This has unintended side effects for files like
drivers/usb/core/devio.c that include that file, since another header
included after hcd.h has different variables named bitmap.

Remove the bitmap #define and replace instances of it in the host
controller code. Cleanup the spaces around function calls and square
brackets while we're at it.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Cc: Tony Olech <tony.olech@elandigitalsystems.com>
Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Max Vozeler <mvz@vozeler.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Anton Vorontsov <avorontsov@mvista.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Lothar Wassmann <LW@KARO-electronics.de>
Cc: Olav Kongas <ok@artecdesign.ee>
Cc: Martin Fuzzey <mfuzzey@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
d3cf2a8d4ddd121dbf4ad48c995648af04e0cfbf 07-Mar-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Fix crash when unplugging bug

This fixes a problem with my previous patch series where there's a great
risk that the kernel will crash when unplugging interrupt devices from
the USB port. These lines must have got missing when I rebased the
patches from the older kernel I was working with to 2.6.37 and 2.6-next:

This fixes a bug where the kernel may crash if you unplug a USB device
that has active interrupt transfers.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7adc14b14b43b6ca9f2f00ac7a4780577dbe883b 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Handle toggle bit in queue heads only

Remove redundant "toggle" member from struct isp1760_qtd, and store toggle
status in struct isp1760_qh only.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
65f1b5255ce0e657e4d8de92098837d36831320a 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Replace period calculation for INT packets with something readable

Replace the period calculation for INT packets with something readable. Seems
to fix a rare bug with quickly repeated insertion/removal of several USB
devices simultaneously (hub control INT packets).

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6bda21bc0941c11f07cbf436ff6ca85e7e6e47f0 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Consolidate printouts and remove unused code

Consolidate printouts to use dev_XXX functions instead of an assortment of
printks and driver specific macros. Remove some unused code snippets and struct
members. Remove some unused function parameters and #defines. Change the
"queue_entry" variable name which has different but related meanings in
different places and use "slot" only.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bbaa387674b65a2f784631cc4c87c77ec9d3374e 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Remove redundant "data_buffer" member from struct inter_packet_info

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a041d8e4375ee6d78409a721221878dcad5eff8a 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Clean up payload address handling

Encapsulate payload addresses within qtds.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fd436aee97d157ff6441e7aaff2a2dc802765b5b 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Remove redundant variables and defines

Removes the redundant hw_next list pointer from struct isp1760_qtd, removes some
unused #defines, removes redundant "urb" member from struct inter_packet_info.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bedc0c31ac3db828e6ade7a8c5cb708688f0a7e1 26-Feb-2011 Arvid Brodin <arvid.brodin@enea.com> usb/isp1760: Move to native-endian ptds

This helps users with platform-bus-connected isp176xs, big-endian cpu,
and missing byteswapping on the data bus. It does so by collecting all
SW byteswaps in one place and also fixes a bug with non-32-bit io
transfers on this hardware, where payload has to be byteswapped
instead of ptds.

Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b14e840d04dba211fbdc930247e379085623eacd 08-Feb-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> USB: isp1760: Implement solution for erratum 2

The document says:
|2.1 Problem description
| When at least two USB devices are simultaneously running, it is observed that
| sometimes the INT corresponding to one of the USB devices stops occurring. This may
| be observed sometimes with USB-to-serial or USB-to-network devices.
| The problem is not noticed when only USB mass storage devices are running.
|2.2 Implication
| This issue is because of the clearing of the respective Done Map bit on reading the ATL
| PTD Done Map register when an INT is generated by another PTD completion, but is not
| found set on that read access. In this situation, the respective Done Map bit will remain
| reset and no further INT will be asserted so the data transfer corresponding to that USB
| device will stop.
|2.3 Workaround
| An SOF INT can be used instead of an ATL INT with polling on Done bits. A time-out can
| be implemented and if a certain Done bit is never set, verification of the PTD completion
| can be done by reading PTD contents (valid bit).
| This is a proven workaround implemented in software.

Russell King run into this with an USB-to-serial converter. This patch
implements his suggestion to enable the high frequent SOF interrupt only
at the time we have ATL packages queued. It goes even one step further
and enables the SOF interrupt only if we have more than one ATL packet
queued at the same time.

Cc: <stable@kernel.org> # [2.6.35.x, 2.6.36.x, 2.6.37.x]
Tested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ebb8a4e48722c8f5e04a6490b197d2fbc894a0f6 05-Aug-2010 Michael Hennerich <michael.hennerich@analog.com> USB: isp1760: use a write barrier to ensure proper ndelay timing

The ISP1760 has some timing requirements where it has to delay a short
period after a write to a register has started. However, this delay is
from the time the write hits the USB chip (the ISP1760), not from the
time where the processor started processing the write. So on a quick
enough processor, it is sometimes possible for the write to not hit the
device before we start delaying, and we then violate the part's timing
requirements, so things stop working.

To avoid all this, insert a write barrier after the register write and
before the timing delay/register read so we can guarantee we only start
counting time after the write has hit the device.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
541c7d432f76771079e7c295d596ea47cc6a3030 22-Jun-2010 Alan Stern <stern@rowland.harvard.edu> USB: convert usb_hcd bitfields into atomic flags

This patch (as1393) converts several of the single-bit fields in
struct usb_hcd to atomic flags. This is for safety's sake; not all
CPUs can update bitfield values atomically, and these flags are used
in multiple contexts.

The flag fields that are set only during registration or removal can
remain as they are, since non-atomic accesses at those times will not
cause any problems.

(Strictly speaking, the authorized_default flag should become atomic
as well. I didn't bother with it because it gets changed only via
sysfs. It can be done later, if anyone wants.)

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0954e1c258c4018bfd370da41fbb5deb34582976 06-May-2010 Anton Vorontsov <cbouatmailru@gmail.com> USB: isp1760: Soften DW3 X/transaction error bit handling

There were some reports[1] of isp1760 USB driver malfunctioning
with high speed devices, noticed on Blackfin and PowerPC targets.
These reports indicated that the original Philips 'pehcd'[2]
driver worked fine.

We've noticed the same issue with an ARM RealView platform. This
happens under load (with only some mass storage devices, not all,
just as in another report[3]):

error bit is set in DW3
error bit is set in DW3
error bit is set in DW3
usb 1-1.2: device descriptor read/64, error -32

It appears that the 'pehcd' driver checks the X bit only if the
transaction is halted (H bit), otherwise the error is so far
insignificant.

The ISP176x chips were modeled after EHCI, and EHCI spec says
(thanks to Alan Stern for pointing out):

"Transaction errors cause the status field to be updated to reflect
the type of error, but the transaction continues to be retried until
the Active bit is set to 0. When the error counter reaches 0, the
Halt bit is set and the Active bit is cleared."

So, just as the original Philips driver, isp1760 must report the
error only if the transaction error and the halt bits are set.

[1] http://markmail.org/message/lx4qrlbrs2uhcnly
[2] svn co svn://sources.blackfin.uclinux.org/linux-kernel/trunk/drivers/usb/host -r 5494
See pehci.c:pehci_hcd_update_error_status().
[3] http://blackfin.uclinux.org/gf/tracker/5148

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
749da5f82fe33ff68dd4aa1a5e35cd9aa6246dab 04-Mar-2010 Alan Stern <stern@rowland.harvard.edu> USB: straighten out port feature vs. port status usage

This patch (as1349b) clears up the confusion in many USB host
controller drivers between port features and port statuses. In mosty
cases it's true that the status bit is in the position given by the
corresponding feature value, but that's not always true and it's not
guaranteed in the USB spec.

There's no functional change, just replacing expressions of the form
(1 << USB_PORT_FEAT_x) with USB_PORT_STAT_x, which has the same value.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
288ead45fa6637e959015d055304f521cbbc0575 04-Mar-2010 Alan Stern <stern@rowland.harvard.edu> USB: remove bogus USB_PORT_FEAT_*_SPEED symbols

This patch (as1348) removes the bogus
USB_PORT_FEAT_{HIGHSPEED,SUPERSPEED} symbols from ch11.h. No such
features are defined by the USB spec. (There is a PORT_LOWSPEED
feature, but the spec doesn't mention it except to say that host
software should never use it.) The speed indicators are port
statuses, not port features.

As a temporary workaround for the xhci-hcd driver, a fictional
USB_PORT_STAT_SUPER_SPEED symbol is added.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27729aadd31dafddaaf64c24f8ef6d0ff750f3aa 24-Apr-2010 Eric Lescouet <Eric.Lescouet@virtuallogix.com> USB: make hcd.h public (drivers dependency)

The usbcore headers: hcd.h and hub.h are shared between usbcore,
HCDs and a couple of other drivers (e.g. USBIP modules).
So, it makes sense to move them into a more public location and
to cleanup dependency of those modules on kernel internal headers.
This patch moves hcd.h from drivers/usb/core into include/linux/usb/

Signed-of-by: Eric Lescouet <eric@lescouet.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
db8516f61b481e82cec398474ed716d926de7f94 02-Feb-2010 Catalin Marinas <catalin.marinas@arm.com> USB: isp1760: Flush the D-cache for the pipe-in transfer buffers

When the HDC driver writes the data to the transfer buffers it pollutes
the D-cache (unlike DMA drivers where the device writes the data). If
the corresponding pages get mapped into user space, there are no
additional cache flushing operations performed and this causes random
user space faults on architectures with separate I and D caches
(Harvard) or those with aliasing D-cache.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Matthew Dharm <mdharm-kernel@one-eyed-alien.net>
Cc: Greg KH <greg@kroah.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c0d74142531c7ec23bb29885aec8f924ee4c1a46 07-Jan-2010 Colin Tuckley <colin.tuckley@arm.com> USB: Fix level of isp1760 Reloading ptd error message

This error message is not actually an error, it's an information
message. It is triggered when a transfer which ended in a NAQ is
retried successfully by the hardware.

Signed-off-by: Colin Tuckley <colin.tuckley@arm.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9da69c604d87afea37b5411867bb76e3c624cc92 16-Jul-2009 Michael Hennerich <michael.hennerich@analog.com> USB: isp1760: allow platform devices to customize devflags

Platform device support was merged earlier, but support for boards to
customize the devflags aspect of the controller was not. We want this on
Blackfin systems to control the bus width, but might as well expose all of
the fields while we're at it.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0afb20e00b5053170c85298fed842b32d20b4ea9 08-May-2009 Warren Free <wfree@ipmn.com> USB: isp1760: urb_dequeue doesn't always find the urbs

The option driver (and presumably others) allocates several URBs when it
opens and tries to free them when it closes. The isp1760_urb_dequeue
function gets called, but the packet being dequeued is not necessarily at
the
front of one of the 32 queues. If not, the isp1760_urb_done function doesn't
get called for the URB and the process trying to free it hangs forever on a
wait_queue. This patch does two things. If the URB being dequeued has others
queued behind it, it re-queues them. And it searches the queues looking for
the URB being dequeued rather than just looking at the one at the front of
the queue.

[bigeasy@linutronix] whitespace fixes, reformating

Cc: stable <stable@kernel.org>
Signed-off-by: Warren Free <wfree@ipmn.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e6bdfe36e52f0e552b50acf49a82851eeb122fde 23-Mar-2009 Catalin Marinas <catalin.marinas@arm.com> USB: isp1760: Add a delay before reading the SKIPMAP registers in isp1760-hcd.c

The data read from the SKIPMAP registers is not immediately available
after writing and the driver panics when a packet is enqueued from the
interrupt handler. This patch adds an ndelay(195) before these registers
are read (delay value mentioned in section 15.1.1.3 of the ISP1760 data
sheet).

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
551509d267905705f6d723e51ec706916f06b859 11-Feb-2009 Harvey Harrison <harvey.harrison@gmail.com> USB: replace uses of __constant_{endian}

The base versions handle constant folding now.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f9031f2c4237abfe75d9ad33f5c0f0dde96f7d09 10-Feb-2009 Catalin Marinas <catalin.marinas@arm.com> USB: Make the isp1760_register function prototype more generic

The patch changes the prototype of the isp1760_register() function to use
predefined types like phys_addr_t and resource_size_t rather than u64

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
42c65396d4f10f25bdab13f8e2f33fe63fa94418 18-Dec-2008 Thomas Hommel <Thomas.Hommel@gefanuc.com> USB: isp1760: don't auto disable Port1 on ISP1761

There is no need to disable port 1 on ISP1761. That port could
be used as an OTG port which would require a different init
sequence. However we don't have OTG support (yet) so we can use
it as a normal USB port.
This patch allows port 1 to be used a normal Port on the ISP1761.

Signed-off-by: Thomas Hommel <Thomas.Hommel@gefanuc.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
380ec6780a0461bb4a4592484d6fe75aa096edeb 20-Aug-2008 Enrico Scholz <enrico.scholz@sigma-chemnitz.de> USB: ISP1760: fixed trivial math in comment

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Acked-by: Sebastian Siewior <sebastian@breakpoint.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7839b5162d7d6c100f70a036be1e1f2b072857bc 17-Jul-2008 Sebastian Siewior <sebastian@breakpoint.cc> usb: isp1760: don't be noisy about short packets.

According to Alan Stern, short packets are quite normal under
certain circumstances. This printk was triggered by usb to
serial converters on every packet and some usb sticks triggered
a few of those while plugging the stick.
This printks are now hidden unless USB debug mode is activated.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3f02a957d5eb0eeb01207a799086f2b347077f71 17-Jul-2008 Enrico Scholz <enrico.scholz@sigma-chemnitz.de> usb: ISP1760: improve pre-fetch timing

ISP1760 requires a delay of 90ns between programming the address and
reading the data. Current driver solves this by a mdelay(1) which is
very heavy weighted and slow. This patch applies the workaround from
the ISP1760 FAQ by using two different banks for PTD and payload data
and using a common wait for them. This wait is done by an additional
ISP1760 access (whose timing constraints guarantee the 90ns delay).
This improves speed when reading from an USB stick from:

$ time dd if=/dev/sda of=/dev/zero bs=65536 count=1638
real 1m 15.43s
user 0m 0.44s
sys 0m 39.46s

to

$ time dd if=/dev/sda of=/dev/zero bs=65536 count=1638
real 0m 18.53s
user 0m 0.16s
sys 0m 12.97s

[bigeasy@linutronix.de: fixed comment formating, moved define into
header file, obey 80 char rule]

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a36c27dfd1003e6d6842fe77faaf868e3e6e9062 17-Jul-2008 Sebastian Siewior <sebastian@breakpoint.cc> usb: return error code instead of 0 in the enqueue function.

if the enqueue function returns -ESHUTDOWN or -ENOMEM then
we return 0 instead of an error. This leads to a timeout and
then to a dequeue request of an not enqueued urb.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3faefc88c1a32b0b4a00b9089fab5d917996b16c 17-Jun-2008 Nate Case <ncase@xes-inc.com> USB: isp1760: Support board-specific hardware configurations

This adds support for hardware configurations that don't match the
chip default register settings (e.g., 16-bit data bus, DACK and
DREQ pulled up instead of down, analog overcurrent mode).

These settings are passed in via the OF device tree. The PCI
interface still assumes the same default values.

Signed-off-by: Nate Case <ncase@xes-inc.com>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d249afddffda695a20afe5270cbbfa242969d6e1 10-Jun-2008 Andrew Morton <akpm@linux-foundation.org> USB: drivers/usb/host/isp1760-hcd.c: processor flags have type `unsigned long'

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
473bca94ba432b3c194e6fa315d81d8ac7670a4f 05-May-2008 Adrian Bunk <bunk@kernel.org> USB: isp1760-hcd.c: make 2 functions static

This patch makes the following needlessly global functions static:
- enqueue_an_ATL_packet()
- enqueue_an_INT_packet()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0031a06e2f07ab0d1bc98c31dbb6801f95f4bf01 02-May-2008 Kay Sievers <kay.sievers@vrfy.org> USB: usb dev_set_name() instead of dev->bus_id

The bus_id field is going away, use the dev_set_name() function
to set it properly.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e6942d633be61f1638e08c56ab8244fc9f1c61e3 21-May-2008 Nate Case <ncase@xes-inc.com> USB: isp1760: Assign resource fields before adding hcd

This fixes the bogus "io mem 0x00000000" message printed
during driver init due to hcd->rsrc_start being assigned after
the call to usb_add_hcd().

Signed-off-by: Nate Case <ncase@xes-inc.com>
Acked-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
220264733d3fb126c5ffd71ce897d918ce491c62 30-Apr-2008 Randy Dunlap <randy.dunlap@oracle.com> USB: isp1760: fix printk format

Fix printk format warnings in isp1760 (in linux-next):

next-20080430/drivers/usb/host/isp1760-hcd.c:994: warning: format '%d' expects type 'int', but argument 6 has type 'size_t'
next-20080430/drivers/usb/host/isp1760-hcd.c:1092: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
db11e47dd7b09b7f76c7eaa236277f23391331e7 24-Apr-2008 Sebastian Siewior <bigeasy@linutronix.de> USB: ISP1760 HCD driver

This driver has been written from scratch and supports the ISP1760. ISP1761
might (should) work as well but the OTG isn't supported. Also ISO packets are
not. However, it works on my little PowerPC board.

Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>