Commit Graph

29 Commits

Author SHA1 Message Date
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
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 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 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 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 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 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
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
Nikunj A Dadhania 1b495eec59 usb-ohci: add Bulk transfer support
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
Nikunj A Dadhania da1c3fa98a USB generic hub device driver
Support for usb generic hub driver.

Todo: Detect disconnects and remove device

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
Nikunj A Dadhania 6eb646603d USB keyboard driver
Portions of keyboard driver(usb-key.h and usb-hid.c) inherited from
code originally written by former SLOF team

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
Nikunj A Dadhania 2deb222c4c usb-core: setup new device
* Configures the newly found usb devices.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Fixes-by: Avik Sil <aviksil@linux.vnet.ibm.com>
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
Nikunj A Dadhania 323108d792 usb-ohci: implement ohci send control
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
Nikunj A Dadhania 91826241af usb-core: usb send control
Introduce generice usb_send_control and implement correspoding stubs
in ohci and ehci

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
Nikunj A Dadhania 0376b7eb56 usb-core: implement usb_{get,put}_pipe routines
Generic routines to get pipe structure from controller.

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:22 +05:30
Nikunj A Dadhania 0b4a392b66 usb-ohci: allocate pipe pool
usb-core: usb_pipe structure, this structure will be embedded in
	  controller specific pipe structure and accessed using
	  container_of macro.

usb-ohci: allocate pipe pool and support routines

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:22 +05:30
Nikunj A Dadhania f9ad8f3cd5 usb-ohci: reset, init and check-ports
* Resets the controller
* Initializes controller
* Query ports for discovering devices

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:22 +05:30
Nikunj A Dadhania a4e14d308f usb-core: hcd registration and query routines
* usb-core: hcd registration
  	    query hcd operations structure
            hcd controller init routines
* usb-ohci: stub ochi controller init

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:22 +05:30
Nikunj A Dadhania c4ddc59f67 usb-core: registration and makefiles
* Introduce libusb
* USB core register routine and required forth changes
* USB OHCI skeleton file

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