tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Patch: xhci controller driver improvements



On 08/10/14 04:27, Takahiro HAYASHI wrote:
Hello,

(05/11/14 02:57), Rajasekhar Pulluru wrote:
Hi,

The attached patch addresses following points.

- With some usb devices, often some endpoints gets stalled. Resetting the
endpoint helps recover usb transactions.

- When a usb device is removed while data is being copied to/from, all the
queued transfer requests needs to be aborted gracefully so that transfer
status is reported up to the application.

- Some boards require an additional interrupt acknowledgement specific to the architecture. Added a function pointer that needs to be set during that
board arch-specific initialization. If this is not required, function
pointer needs to be set to NULL.

- Added debug functions to dump xhci registers that could help us in case
of any issue.

Note: I have manually patched the code changes from my older
version(verified) of code to the latest as of today in MAIN branch. And the code is not compiled either, sorry about that. If anyone is interested to
patch this and verify, it would be really helpful.

I reformatted whitespace and made several changes:

- avoid lock error when calling xhci_do_command from
  xhci_stop_endpoint
- assume usb_uncallout(a,b,c) is callout_stop(&a)
- comment out checking xfer->device->bus->intr_context
- declare gsc used in debug code (would be set in ddb?)

It should build at least, but still experimental.



Some comments...

--- src/sys/dev/usb/xhci.c.orig 2014-08-05 22:24:27.000000000 +0900
+++ src/sys/dev/usb/xhci.c      2014-08-07 17:35:16.000000000 +0900
@@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.2
  #include <dev/usb/xhcivar.h>
  #include <dev/usb/usbroothub_subr.h>
+#include <uvm/uvm.h> /* for vtophys on arm */
+

Shouldn't be needed at all - the hexdump use is questionable.


@@ -1127,6 +1165,81 @@ xhci_open(usbd_pipe_handle pipe)
  }
static void
+xhci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)

This function needs usbmp-ifiction, i.e. updating for -current by removing spl, tsleep, wakeup, etc.

@@ -2889,6 +3028,7 @@ xhci_timeout(void *addr)
        struct xhci_softc * const sc = xfer->pipe->device->bus->hci_private;
if (sc->sc_dying) {
+               xhci_abort_xfer(xfer, USBD_TIMEOUT);
                return;
        }

This looks very strange.

The driver makes far too much use of device_printf and all USB should move to KERNHIST.

Nick


Home | Main Index | Thread Index | Old Index