aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb
AgeCommit message (Collapse)AuthorFilesLines
2021-02-12usb: Compile with -WextraAlexey Kardashevskiy5-19/+19
-Wextra enables a bunch of rather useful checks which this fixes with one exception of -Wunused-parameter - this fixes it for debug macros only and leave the rest for the future as more functional change is needed. Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * updated debug macros to fix -Wunused-parameter --- These are not fixed: ====== Building common libraries ====== [CC] usb-core.o [CC] usb-ohci.o [CC] usb-hid.o [CC] usb-xhci.o /home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_set_address’: /home/aik/p/slof/lib/libusb/usb-core.c:244:58: warning: unused parameter ‘port’ [-Wunused-parameter] static int usb_set_address(struct usb_dev *dev, uint32_t port) ^~~~ /home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_send_enable_slot’: /home/aik/p/slof/lib/libusb/usb-xhci.c:353:67: warning: unused parameter ‘port’ [-Wunused-parameter] static void xhci_send_enable_slot(struct xhci_hcd *xhcd, uint32_t port) ^~~~ /home/aik/p/slof/lib/libusb/usb-ohci.c: In function ‘ohci_dump_regs’: /home/aik/p/slof/lib/libusb/usb-ohci.c:42:46: warning: unused parameter ‘regs’ [-Wunused-parameter] static void ohci_dump_regs(struct ohci_regs *regs) ^~~~ /home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_handle_device’: /home/aik/p/slof/lib/libusb/usb-core.c:444:80: warning: unused parameter ‘cfg’ [-Wunused-parameter] static int usb_handle_device(struct usb_dev *dev, struct usb_dev_config_descr *cfg, ^~~ /home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘fill_setup_trb’: /home/aik/p/slof/lib/libusb/usb-xhci.c:1026:13: warning: unused parameter ‘size’ [-Wunused-parameter] uint32_t size) ^~~~ /home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_transfer_bulk’: /home/aik/p/slof/lib/libusb/usb-xhci.c:1217:60: warning: unused parameter ‘td’ [-Wunused-parameter] static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys, ^~ /home/aik/p/slof/lib/libusb/usb-xhci.c:1217:70: warning: unused parameter ‘td_phys’ [-Wunused-parameter] static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys, ^~~~~~~ /home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_get_pipe_intr’: /home/aik/p/slof/lib/libusb/usb-xhci.c:1364:22: warning: unused parameter ‘len’ [-Wunused-parameter] char *buf, size_t len) ^~~
2019-10-22libusb: Fix compiler warnings with gcc9Alexey Kardashevskiy4-11/+11
gcc9 enforces -Waddress-of-packed-member, fix this. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-09-12usb-xhci: Reset ERSTSZ together with ERSTBAAlexey Kardashevskiy1-0/+2
When shutting down the adapter, SLOF writes 0 to the Event Ring Segment Table Base Address Register (ERSTBA) but does not reset the Event Ring Segment Table Size Register (ERSTSZ) which makes QEMU do DMA access at zero address which fails in unassigned_mem_accepts. This resets ERSTSZ right before resetting ERSTBA so these 2 registers can stay in sync. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2016-08-03usb: Set XHCI slot speed according to port statusThomas Huth3-7/+22
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-03usb: Build correct route string for USB3 devices behind a hubThomas Huth1-4/+10
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-03usb: Initialize USB3 devices on a hub and keep track of hub topologyThomas Huth4-11/+39
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-03usb: Increase amount of maximum slot IDs and add a sanity checkThomas Huth2-1/+7
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-03usb: Move XHCI port state arrays from header to .c fileThomas Huth2-18/+17
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-07-25usb-hid: Fix non-working comma keyThomas Huth1-7/+0
Commit c8bd0cdce2bd ("Caps is not always shift") introduced a global "ctrl" variable and two new cases to handle the shift key in check_key_code() in usb-hid.c. However, one of these cases uses the key code for the "," key and thus prevents that key from working in the VGA console. The global ctrl variable that is set by these two cases is never read again, so this is apparently completely useless code, likely just an accidential leftover from debugging the original issue. So let's simply remove that bad code to get the comma key working again. Fixes: c8bd0cdce2bd7c4498d61079553c89747656614d Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-06-07usb-xhci: assign field4 before conditionalNikunj A Dadhania1-5/+4
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-05-02xhci: fix missing keys from keyboardNikunj A Dadhania2-12/+41
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-02xhci: add memory barrier after filling the trbNikunj A Dadhania1-0/+1
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-01-11Fix format strings in usb-ohci.cThomas Huth1-6/+6
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>
2015-12-09usb: print unhandled descriptor in debug modeNikunj A Dadhania1-1/+1
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-01Stack optimization in libusb: split up setup_new_device()Thomas Huth7-40/+52
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-10-22Fix special keys on USBDinar Valeev1-9/+7
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-22Fix function keys on USBDinar Valeev1-16/+12
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-06usb-xhci: add keyboard supportNikunj A Dadhania2-1/+120
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-06usb-xhci: ready the link trb earlyNikunj A Dadhania1-7/+6
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-06usb-xhci: scan usb high speed portsNikunj A Dadhania1-9/+30
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-06usb-xhci: bulk improve event handling loopNikunj A Dadhania1-9/+32
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-06usb-xhci: return on allocation failureNikunj A Dadhania1-1/+2
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: add delay in shutdown pathNikunj A Dadhania1-0/+12
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-06usb-xhci: event trbs does not need link trbNikunj A Dadhania1-4/+6
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-hid: refactor usb key readingNikunj A Dadhania1-7/+4
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-07-20usb-hid: Caps is not always shiftDinar Valeev1-3/+27
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-03-23Fix "key?" Forth word when using USB keyboardsThomas Huth1-9/+21
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-23Include make.rules in the library MakefilesThomas Huth1-0/+2
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>
2014-10-29usb-xhci: support xhci extended capabilitiesNikunj A Dadhania2-6/+41
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-07-17xhci: fix port assignmentNikunj A Dadhania1-1/+1
Port assignment logic was generating negative port number Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-25xhci: fix controller stopNikunj A Dadhania1-1/+1
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-25virtio-blk: support variable block sizeNikunj A Dadhania1-5/+0
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-03-26usb-core: adjust port numbers in set_addressNikunj A Dadhania1-1/+8
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-01-20[oex]hci_exit: Check before freeing/unmapping memoryNikunj A Dadhania3-16/+38
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>
2013-12-16usb-xhci: memory freeing and using returns as bool uniformlyNikunj A Dadhania2-26/+41
* 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-11-17usb-ohci: fix warningsNikunj A Dadhania1-3/+2
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-16Fix dprintf macros at various pointsNikunj A Dadhania6-7/+7
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15usb-ohci: rewrite done_head processing codeNikunj A Dadhania1-55/+59
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-15usb-xhci: add xhci host controller supportNikunj A Dadhania4-9/+1453
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15usb-xhci: add xhci supportNikunj A Dadhania7-2/+230
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-15usb-core: disable xhciNikunj A Dadhania1-1/+1
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-04usb-ohci: preserve the toggleCarry bit in EDNikunj A Dadhania1-1/+2
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-04usb-ohci: done_head processing fixesNikunj A Dadhania2-36/+42
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-04usb-ohci: update init and rationalize timingsNikunj A Dadhania2-13/+17
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-04usb-msc: handle stall and other fixesNikunj A Dadhania2-2/+16
* 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-04usb-core: Add CLEAR FEATURE apiNikunj A Dadhania2-0/+22
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-23usb-ohci: Convert td-phys every time to td-virtqemu-slof-20130827Nikunj A Dadhania1-1/+4
next_td is phys pointer as well, convert that to virt Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-21usb: fix various issues found with js2xNikunj A Dadhania4-36/+125
* 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-21usb: Use separate in-memory endian swapNikunj A Dadhania3-32/+33
Convert pending in-memory byteswaps to accessors Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-08-21usb-ohci: collect TDs from done listNikunj A Dadhania2-14/+133
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>