Commit Graph

24 Commits

Author SHA1 Message Date
Thomas Huth 9ca6ebded5 usb: Set XHCI slot speed according to port status
So far, the code was always assuming SuperSpeed for all devices,
which seemed to work OK with QEMU ... but let's better play safe
instead and use the speed from the port status instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-08-03 13:48:18 +10:00
Thomas Huth b14743a8ff usb: Build correct route string for USB3 devices behind a hub
To support USB3 devices attached to a hub, we've got to set
the so-called "route string" in the slot context, which is
a concatenation of the hub port numbers that need to be
traversed between the root hub port and the destination device.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-08-03 13:48:18 +10:00
Thomas Huth cf7963a12c usb: Initialize USB3 devices on a hub and keep track of hub topology
USB3 devices need to be initialized with usb3_dev_init(), so that
they get assigned a proper slot ID. And for USB3 devices that are
attached to a (non-root) hub, we also need to keep track of the
hub topology, so a new field called "hub" is added to the struct
usb_dev which references the hub devices where the current USB
devices is attached to. The hub topology will be used later to
build the so-called "route string" for the USB3 devices.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-08-03 13:48:18 +10:00
Thomas Huth f1d7dc911c usb: Increase amount of maximum slot IDs and add a sanity check
SLOF should be able to support more than just four devices on
the four root hub ports. So we've got to increase the amount of
possible slot IDs. Since QEMU supports up to 44 devices (four
devices at the root ports + 5 tiers of hubs with 8 ports each),
this seems to be a good new value instead. And to make sure that
we do not accidentially get a buffer overflow when accessing the
xhcd->xdevs[slot_id] array, this patch also add a sanity check at
the beginning of the xhci_alloc_dev() function here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-08-03 13:48:18 +10:00
Thomas Huth 6ea7b81d16 usb: Move XHCI port state arrays from header to .c file
Arrays should not be declared in a header (to avoid that it gets
declared multiple times when the header is included more than once),
so the ps_array_usbX settings should reside in the .c file instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-08-03 13:48:17 +10:00
Nikunj A Dadhania 4202498ebf usb-xhci: assign field4 before conditional
Static analysis tool reported:

file	lib/libusb/usb-xhci.c
line	1022
uninitialized `field4'

file	lib/libusb/usb-xhci.c
line	1036
uninitialized `field4'

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-06-07 18:17:58 +10:00
Nikunj A Dadhania ca8fb51e05 xhci: fix missing keys from keyboard
Current handling of the keyboard polling was very slow and
keys were getting dropped. Done following for fixing this:

* Use multiple buffers per TRB
* Allocate buffers in xhci according to the number of TRBS.

This reduces the delay of key? processing by getting rid of wait in
the polling routine.

Reported-by: Dinar Valeev <k0da@opensuse.org>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Tested-by: Dinar Valeev <k0da@opensuse.org>
Tested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-05-02 16:45:05 +10:00
Nikunj A Dadhania 72f9ffdcc2 xhci: add memory barrier after filling the trb
A memory barrier was missing after updating the trb details.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-05-02 16:44:44 +10:00
Thomas Huth edd582383f Stack optimization in libusb: split up setup_new_device()
When scanning hubs, the code in libusb can be called recursively, for
example usb_hub_init() calls setup_new_device(), which then calls
slof_usb_handle() to execute Forth code for the next device.
If that next device is a hub, we end up recursively in usb_hub_init()
again.
Since stack space is limited in SLOF, we can optimize here a little
bit by splitting up the setup_new_device() function into the part
that retrieves the descriptors (which takes most of the stack space
in this code path since the descriptors are placed on the stack),
and the part that populates the the device tree node of the new
device (which is responsible for the recursion).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01 17:02:04 +11:00
Nikunj A Dadhania 2757414329 usb-xhci: add keyboard support
Add support for xhci interrupt pipes needed for keyboard handling

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:52:02 +11:00
Nikunj A Dadhania ec94b351f6 usb-xhci: ready the link trb early
The keyboard events being async, need to prepare the link when last but
one trb is queued.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:51:09 +11:00
Nikunj A Dadhania 35f9876b6a usb-xhci: scan usb high speed ports
Current code scanned only the super speed ports. Add support for
scanning high speed ports as well.

Also re-org code to reduce duplication of code.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:51:01 +11:00
Nikunj A Dadhania 94168f451f usb-xhci: bulk improve event handling loop
Since the controller was being used by single user, event poll loop
works without verifying what event returned. Now with usb-keyboard
addition where we will get keyboard events, this would not work.

Transfer bulk would only look for response from the trb queued and
ignore rest of the events. Moreover, while bulk transfer is going on,
there are no keyboard events in booting use case.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:50:50 +11:00
Nikunj A Dadhania 8d2f3ba631 usb-xhci: return on allocation failure
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:50:39 +11:00
Nikunj A Dadhania 2a37eb9a6a usb-xhci: add delay in shutdown path
QEMU implementation of XHCI doesn't implement halt properly. There might
be ongoing activities and active DMAs, introduce 50ms delay during
shutdown path.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:50:31 +11:00
Nikunj A Dadhania 41c2c5df4f usb-xhci: event trbs does not need link trb
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:50:23 +11:00
Nikunj A Dadhania 792984914c usb-xhci: support xhci extended capabilities
commit 706c69e4 "xhci: fix port assignment" partially fixed the
usb port numbering.

Adding parsing of xhci extended capabilities, we can parse the
overlapped ports accordingly and have proper port numbering.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-10-29 16:19:35 +05:30
Nikunj A Dadhania 706c69e46b xhci: fix port assignment
Port assignment logic was generating negative port number

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-07-17 12:43:29 +05:30
Nikunj A Dadhania 49976ab5e7 xhci: fix controller stop
A bit operation bug left the controller in the running state causing
PCI EEH in the host when using pci-passthru for USB3 device.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-25 15:40:13 +05:30
Nikunj A Dadhania 673997ee74 [oex]hci_exit: Check before freeing/unmapping memory
While doing cleanup of the allocated memory, make sure addresses being
unmapped/free were really allocated. During error conditions, some
address would not have been.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-01-20 17:19:47 +05:30
Nikunj A Dadhania 8281a9333c usb-xhci: memory freeing and using returns as bool uniformly
* Fix freeing of memory in error path
* Boolean and int were used interchangebly at various points,
  consolidate it to use boolean

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-16 15:40:04 +05:30
Nikunj A Dadhania 7bc3d6b7d7 Fix dprintf macros at various points
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-16 13:59:30 +05:30
Nikunj A Dadhania 32dcbfadcd usb-xhci: add xhci host controller support
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15 10:36:51 +05:30
Nikunj A Dadhania ce91e6a282 usb-xhci: add xhci support
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15 10:36:51 +05:30