Commit Graph

72 Commits

Author SHA1 Message Date
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 568fb49625 Fix format strings in usb-ohci.c
When compiling with OHCI_DEBUG enabled, gcc complains about a
lot of bad format strings. So let's use more appropriate format
modifiers to fix these warnings.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-01-11 12:00:05 +11:00
Nikunj A Dadhania b25d5796db usb: print unhandled descriptor in debug mode
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-09 15:52:15 +11: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
Dinar Valeev 67422f9371 Fix special keys on USB
This patch fixing HOME, INS, END and DEL keys in Grub, when USB
keyboard is used. Those keys are useful in faster grub interaction in
automated tests.

Signed-off-by: Dinar Valeev <dvaleev@suse.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-22 12:06:16 +11:00
Dinar Valeev 43c9abfd81 Fix function keys on USB
This is fixing F1-F12 keys in grub2.

Sequence was grabbed by running cat in xterm and pressing relative
function key.

Signed-off-by: Dinar Valeev <dvaleev@suse.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-22 12:05:57 +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 f591c5d7a2 usb-hid: refactor usb key reading
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06 12:50:12 +11:00
Dinar Valeev c8bd0cdce2 usb-hid: Caps is not always shift
Caps behaves like shift only for latin characters.
In case we're typing - for example with caps enabled, SLOF picks _ char
from shifted table.

Treat caps as shift only for letters.

Signed-off-by: Dinar Valeev <dvaleev@suse.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-07-20 21:04:26 +10:00
Thomas Huth 2ece1754f7 Fix "key?" Forth word when using USB keyboards
The "key?" Forth word did not work when being used for polling keyboard
events from USB keyboards since the usb_key_available() function never
triggered any USB transfers. Fix it by also refactoring usb_read_keyb()
a little bit so that both functions now use the same code for checking
for new keyboard events.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-23 11:43:35 +11:00
Thomas Huth 5f79afca64 Include make.rules in the library Makefiles
Make sure to include make.rules from the Makefiles in the common
lib folder to get some more sane console output during the build
process.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-23 11:43:20 +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 c365fe0393 virtio-blk: support variable block size
Current code only works with 512 bytes read.

Moreover, Qemu ignores the guest set features request. In the set
features request SLOF indicates to qemu that it is not support
VIRTIO_BLK_F_BLK_SIZE feature. Code in qemu suggests that virtio-blk
is not implementing set_guest_feature.

Tested-by: Bharata B Rao <bharata@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-25 15:40:13 +05:30
Nikunj A Dadhania a6c2d4cfd2 usb-core: adjust port numbers in set_address
There is a mismatch between the port number between qemu and slof. Was
unearthed while using bootindex.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-03-26 10:10:48 +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 32c448bfaf usb-ohci: fix warnings
usb-ohci.c: In function ‘ohci_process_done_head’:
usb-ohci.c:458:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘struct ohci_td *’ [-Wformat]
usb-ohci.c:417:20: warning: variable ‘start_frame’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-17 16:34:50 +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 7470b17ac4 usb-ohci: rewrite done_head processing code
The routine had got complicated and source of few bugs while using in
pci-passthru and js2x

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15 15:00:04 +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
Nikunj A Dadhania 22c4d4b3ae usb-core: disable xhci
Code still does not support xhci, disable creation of xhci node, as it
was causing crash in the quiesce path.

Also check if ops pointer is verified before accessing function
pointers during usb_hcd_exit.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-15 22:23:28 +05:30
Nikunj A Dadhania 5962dbf56d usb-ohci: preserve the toggleCarry bit in ED
Endpoint descriptors toggleCarry bit needs to be preserved when using
DataToggle bit in transfer descriptor is set to 0.

Also zero the bulk_curr_ed

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04 12:01:21 +05:30
Nikunj A Dadhania 80ba6519d8 usb-ohci: done_head processing fixes
Return error code like STALL back, so it can be handled effectively.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04 12:01:21 +05:30
Nikunj A Dadhania a351fc0cbc usb-ohci: update init and rationalize timings
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04 12:01:21 +05:30
Nikunj A Dadhania 2b14fb9a9e usb-msc: handle stall and other fixes
* Add Reset Recovery procedure
* Zero cbw and csw memory everytime
* Add delays during cbw, data and csw stage
* Increment tag after every command

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04 12:01:21 +05:30
Nikunj A Dadhania 50302c3eb9 usb-core: Add CLEAR FEATURE api
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04 12:01:20 +05:30
Nikunj A Dadhania a523d1b0cd usb-ohci: Convert td-phys every time to td-virt
next_td is phys pointer as well, convert that to virt

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-23 16:25:49 +05:30
Nikunj A Dadhania 1abf624dfb usb: fix various issues found with js2x
* JS20 exposed various timing related issues that were not apparent in
  the emulated environment.
* Reset the USB Bus
* JS20 overrides the frame_interval and periodic_start on setting the
  controller to USB operational. Reprogram them.
* ohci fix the data-toggle bits.
* Robust error handling

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-21 10:50:02 +05:30
Nikunj A Dadhania 5a75cd882e usb: Use separate in-memory endian swap
Convert pending in-memory byteswaps to accessors

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-21 10:49:41 +05:30
Nikunj A Dadhania 8092c2e3e3 usb-ohci: collect TDs from done list
OHCI HC after using the TDs queues them back to hccaDoneHead. Until
this event the TDs cannot be reused, as there might be references in
the host controller still pending. Recycle all the TDs from the queue
and acknowledge it by clearing the WD bit in interrupt status
register.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-21 10:49:36 +05:30
Benjamin Herrenschmidt 77107650e8 usb-ohci: Use proper memory barriers always
Compiler barriers are not useful for ordering memory
accesses.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-08-06 16:05:38 +10:00
Benjamin Herrenschmidt fa6de662a9 usb: Fix a couple of warnings
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-08-06 16:03:55 +10:00
Nikunj A Dadhania 2ecfaa4a86 usb-ehci: Add ehci handshake
After removal of the QTD, the device driver needs to make sure that
the host controller is really done with this QTD, and does not have
any local/cached copy of this. This is achieved by employing a 3-bit
handshake as explained in the echi spec 4.8.2 and Fig 4-10

Also add missing memory barrier.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-06 16:00:30 +10:00
Nikunj A Dadhania 69772c33c2 usb: add mb for write accessors
Introduce mb() in all the variants of write_reg* before the hcall

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-06 16:00:29 +10:00
Nikunj A Dadhania 3a83de22be usb-ohci: add missing memory barriers
* Start the control/bulk processing after ed is written
* Clear the content of control_head_ed and bulk_head_ed
  once done using them.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-06 16:00:29 +10:00
Nikunj A Dadhania 67dafd87d2 usb-ohci: suspend the controller in exit code path
Moreover ehci already suspends the controller in the hcd_exit path. So
we can remove hc-suspend from the cleanup path.

Also, count mechanism is not needed anymore, as quiesce is called only
once.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-06 16:00:29 +10:00
Benjamin Herrenschmidt 225b8b0e3a usb-ohci: Add a reset when closing the OHCI
Or it will continue DMA'ing which is not a good idea. On recent qemu's
that add proper DMA error handling, it will get into error state.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-08-06 16:00:29 +10:00
Benjamin Herrenschmidt 14bca6ff9a usb: Use proper accessors for MMIO and separate in-memory endian swap
We cannot just access MMIO like that. On KVM for example, this has
to be hypercalls. On js2x, we need to use special cache-inhibited
loads and stores.

We have accessors in cache.h, we just need to use them. However that
means that read/write_reg() are no longer suitable for in-memory
byteswaps. We need to use the accessors in byteorder.h for that

While at it, we also fix the code to use mb() instead of barrier()
as a full memory barrier is needed to actually order things.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-08-06 16:00:29 +10:00
Nikunj A Dadhania d7354e2724 usb: unmap buffers
Clean up all the dma allocated buffers and remove their mappings.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2013-07-24 14:46:23 +05:30