History log of /netbsd-current/sys/dev/usb/xhcivar.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.24 09-Apr-2023 riastradh

xhci(4): Avoid crash in suspend/resume/resume if first resume fails.

Rather than try to recover from this, just make new commands fail so
at least we don't deadlock.

XXX pullup-9
XXX pullup-10


# 1.23 07-Apr-2023 riastradh

xhci(4): Defer root intr xfers while polling.

Root intr xfers require taking adaptive locks, which is forbidden
while polling.

This is not great -- any USB transfer completion callbacks might try
to take adaptive locks, not just uhub_intr, and that will always
causes trouble. We get lucky with ukbd_intr because it's not
MP-safe, so it relies only on the kernel lock (a spin lock) anyway.
But this change brings xhci in line with ehci.

PR kern/57326

XXX pullup-8
XXX pullup-9
XXX pullup-10


Revision tags: netbsd-10-base
# 1.22 11-Oct-2022 msaitoh

There is an xHCI device which has USB 2 port only. Support it.

- Example:

xhci4 at pci17 dev 0 function 0: AMD product 15b8 (rev. 0x00)
xhci4: 64-bit DMA
allocated pic msix10 type edge pin 0 level 6 to cpu0 slot 32 idt entry 107
xhci4: interrupting at msix10 vec 0
xhci4: xHCI version 1.20
xhci4: hcs1=1000840 hcs2=140000f1 hcs3=7000a
xhci4: hcc=0x110ffc5<XECP=0x110,MAXPSA=0xf,CFC,SEC,SPC,PAE,NSS,LTC,CSZ,AC64>
xhci4: xECP 440
xhci4: hcc2=0x3f<CIC,LEC,CTC,FSC,CMC,U3C>
xhci4: ECR: 0x00000401
xhci4: ECR: 0x02000402
xhci4: SP: 0x02000402 0x20425355 0x00180101 0x00000000
xhci4: hs ports 1 - 1
xhci4: ECR: 0x000f000a
xhci4: PAGESIZE 0x00000001
xhci4: sc_pgsz 0x00001000
xhci4: sc_maxslots 0x00000040
xhci4: sc_maxports 1
xhci4: sc_maxspbuf 2
xhci4: eventst: 0x000000013ee60fc0 0xffffb08826f5afc0 1000
xhci4: dcbaa: 0x000000013ee63000 0xffffb08826f5b000 1000
xhci4: current IMOD 0
(snip)
usb8 at xhci4: USB revision 3.1
usb9 at xhci4: USB revision 2.0
uhub8 at usb8: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 3.00/1.00, addr 0
uhub8: 0 ports with 0 removable, self powered
uhub8: no ports, hub ignored
uhub8: WARNING: power management not supported
autoconfiguration error: usb8: root device is not a hub
usb8: WARNING: power management not supported
uhub9 at usb9: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 2.00/1.00, addr 0
uhub9: 1 port with 1 removable, self powered

- To resolve this problem, keep number of ports of SS and HS and use
it to attach child device(s).
- Tested on ASUS TUF GAMING X670E-PLUS.
- OK'd by skrll@.


Revision tags: bouyer-sunxi-drm-base
# 1.21 13-Mar-2022 riastradh

xhci(4): Serialize access to portsc registers.

Both xhci_roothub_ctrl and xhci_suspend/resume do r/m/w on them, so
use a mutex to serialize access to avoid stomping on each other.


# 1.20 03-Mar-2022 riastradh

xhci(4): Add missing includes to xhcivar.h.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 1.19 23-May-2021 riastradh

xhci(4): Block commands and issue Stop Endpoint on suspend.


# 1.18 23-May-2021 riastradh

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:

- if we don't have any pending USB activity whether we need to issue
the Stop Endpoints or quiesce the command ring; but

- if we do have any pending USB activity whether issuing Stop
Endpoint is enough or whether we also need to do anything to
synchronize with other software logic to quiesce it too.


Revision tags: cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.17 21-Aug-2020 jakllsch

branches: 1.17.6; 1.17.8;
xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

branches: 1.11.4;
Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.22 11-Oct-2022 msaitoh

There is an xHCI device which has USB 2 port only. Support it.

- Example:

xhci4 at pci17 dev 0 function 0: AMD product 15b8 (rev. 0x00)
xhci4: 64-bit DMA
allocated pic msix10 type edge pin 0 level 6 to cpu0 slot 32 idt entry 107
xhci4: interrupting at msix10 vec 0
xhci4: xHCI version 1.20
xhci4: hcs1=1000840 hcs2=140000f1 hcs3=7000a
xhci4: hcc=0x110ffc5<XECP=0x110,MAXPSA=0xf,CFC,SEC,SPC,PAE,NSS,LTC,CSZ,AC64>
xhci4: xECP 440
xhci4: hcc2=0x3f<CIC,LEC,CTC,FSC,CMC,U3C>
xhci4: ECR: 0x00000401
xhci4: ECR: 0x02000402
xhci4: SP: 0x02000402 0x20425355 0x00180101 0x00000000
xhci4: hs ports 1 - 1
xhci4: ECR: 0x000f000a
xhci4: PAGESIZE 0x00000001
xhci4: sc_pgsz 0x00001000
xhci4: sc_maxslots 0x00000040
xhci4: sc_maxports 1
xhci4: sc_maxspbuf 2
xhci4: eventst: 0x000000013ee60fc0 0xffffb08826f5afc0 1000
xhci4: dcbaa: 0x000000013ee63000 0xffffb08826f5b000 1000
xhci4: current IMOD 0
(snip)
usb8 at xhci4: USB revision 3.1
usb9 at xhci4: USB revision 2.0
uhub8 at usb8: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 3.00/1.00, addr 0
uhub8: 0 ports with 0 removable, self powered
uhub8: no ports, hub ignored
uhub8: WARNING: power management not supported
autoconfiguration error: usb8: root device is not a hub
usb8: WARNING: power management not supported
uhub9 at usb9: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 2.00/1.00, addr 0
uhub9: 1 port with 1 removable, self powered

- To resolve this problem, keep number of ports of SS and HS and use
it to attach child device(s).
- Tested on ASUS TUF GAMING X670E-PLUS.
- OK'd by skrll@.


Revision tags: bouyer-sunxi-drm-base
# 1.21 13-Mar-2022 riastradh

xhci(4): Serialize access to portsc registers.

Both xhci_roothub_ctrl and xhci_suspend/resume do r/m/w on them, so
use a mutex to serialize access to avoid stomping on each other.


# 1.20 03-Mar-2022 riastradh

xhci(4): Add missing includes to xhcivar.h.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 1.19 23-May-2021 riastradh

xhci(4): Block commands and issue Stop Endpoint on suspend.


# 1.18 23-May-2021 riastradh

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:

- if we don't have any pending USB activity whether we need to issue
the Stop Endpoints or quiesce the command ring; but

- if we do have any pending USB activity whether issuing Stop
Endpoint is enough or whether we also need to do anything to
synchronize with other software logic to quiesce it too.


Revision tags: cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.17 21-Aug-2020 jakllsch

branches: 1.17.6; 1.17.8;
xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

branches: 1.11.4;
Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.21 13-Mar-2022 riastradh

xhci(4): Serialize access to portsc registers.

Both xhci_roothub_ctrl and xhci_suspend/resume do r/m/w on them, so
use a mutex to serialize access to avoid stomping on each other.


# 1.20 03-Mar-2022 riastradh

xhci(4): Add missing includes to xhcivar.h.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 1.19 23-May-2021 riastradh

xhci(4): Block commands and issue Stop Endpoint on suspend.


# 1.18 23-May-2021 riastradh

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:

- if we don't have any pending USB activity whether we need to issue
the Stop Endpoints or quiesce the command ring; but

- if we do have any pending USB activity whether issuing Stop
Endpoint is enough or whether we also need to do anything to
synchronize with other software logic to quiesce it too.


Revision tags: cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.17 21-Aug-2020 jakllsch

branches: 1.17.6; 1.17.8;
xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

branches: 1.11.4;
Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.20 03-Mar-2022 riastradh

xhci(4): Add missing includes to xhcivar.h.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 thorpej-i2c-spi-conf-base
# 1.19 23-May-2021 riastradh

xhci(4): Block commands and issue Stop Endpoint on suspend.


# 1.18 23-May-2021 riastradh

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:

- if we don't have any pending USB activity whether we need to issue
the Stop Endpoints or quiesce the command ring; but

- if we do have any pending USB activity whether issuing Stop
Endpoint is enough or whether we also need to do anything to
synchronize with other software logic to quiesce it too.


Revision tags: cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.17 21-Aug-2020 jakllsch

branches: 1.17.6; 1.17.8;
xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

branches: 1.11.4;
Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.19 23-May-2021 riastradh

xhci(4): Block commands and issue Stop Endpoint on suspend.


# 1.18 23-May-2021 riastradh

xhci(4): Draft suspend/resume.

Work almost entirely done and tested by maya@ based on xhci 1.2 spec;
tidied up and tweaked by me.

Not sure about issuing Stop Endpoint commands or ensuring the Command
Ring is in the Stopped or Idle state, but this seems to work as is,
so it's already an improvement over what we had before which was no
xhci suspend/resume at all.

In particular, it's not clear to us:

- if we don't have any pending USB activity whether we need to issue
the Stop Endpoints or quiesce the command ring; but

- if we do have any pending USB activity whether issuing Stop
Endpoint is enough or whether we also need to do anything to
synchronize with other software logic to quiesce it too.


Revision tags: cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.17 21-Aug-2020 jakllsch

xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.17 21-Aug-2020 jakllsch

xhci(4): initial support for Isochronous pipes

Needs more cleanup, and more work, particularly transaction scheduling
may need to be examined with bus analyzer (to check if too frequent/
infrequent) or various isoc pipe consumers (to check if too infrequent)
and fixed if incorrect.

Begins to address PR kern/55574.


# 1.16 21-Aug-2020 jakllsch

xhci(4): copy HCCPARAMS regs to softc, use when needed

We'll need more than just the AC64 bit for the Isoc support coming up;
and we don't need to keep all the bits as bools in the softc.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.15 21-May-2020 jakllsch

xhci(4): dynamically allocate xhci_xfer->xx_trb buffer

Allocation size remains the same for now.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.14 19-May-2020 jakllsch

Remove definition of unused struct xhci_endpoint.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.13 02-Apr-2020 skrll

Tweak a comment in previous


# 1.12 02-Apr-2020 skrll

Reduce the memory footprint by allocating a ring per endpoint/pipe on
pipe open.

From sc.dying on tech-kern


Revision tags: ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

branches: 1.9.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.11 07-Jan-2019 jakllsch

Seperate xHCI and xhci(4) TRB structs so as to avoid some of them
(the ones that the hardware doesn't touch) ending up less-aligned
than the compiler assumed.

Additionally, fix the most obvious problems that xhci(4) had on
big endian systems.

Briefly tested on a Jetson TK1 in LE and BE w/ evbarm GENERIC kernel.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.10 09-Aug-2018 mrg

pull across abort fixes from nick-nhusb. add more abort fixes, using
ideas from Taylor and Nick, and myself. special thanks to both who
inspired much of the code here, if not wrote it directly.

among other problems, this assert should no longer trigger:

panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914

using usbhist i was able to track down my instance of it being related
to userland close() beginning, dropping the sc_lock, and then the usb
softintr completes the transfer normally, and when it is done, the
abort path attempts to re-complete the transfer, and the above assert
is tripped.


changes from nhusb were commited with these logs:
--
Move the struct usb_task to struct usbd_xfer for everyone to use.
--
Set device transfer status to USBD_IN_PROGRESS if start methods succeeds
--
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying
--
Don't supply the lock to callout_halt when polling as it won't be held
--
Improve transfer abort
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--
#ifdef DIAGNOSTIC -> KASSERT and add another KASSERT
--
Mark device transfers as USBD_IN_PROGRESS appropriately and improve
abort handling
--

additional changes include:
- initialise the usb abort task in the HCI allocx routine, so that it
can be safely usb_rem_task()'d.
- rework the handling of softintr vs cancellation vs timeout abort based
upon a scheme from Taylor:
when completing a transfer normally:
- if the status is not in progress, it must be cancelled or timed out,
and we should not process this xfer.
- set the status as normal.
- unconditionallly callout_stop() and usb_rem_task(). they're safe and
either aren't running, or will run and do nothing.
- finally call usb_transfer_complete().
when aborting a transfer:
- status should be cancelled or timed out.
- if cancelling, callout_halt and usb_rem_task_wait() to make sure the
timer is either done or cancelled.
- at this point, the ux_status must not be cancelled or timed out, and
if it is not in progress we're done.
- set the status.
- if the controller is dying, just return.
- perform HCI-specific tasks to abort this xfer.
- finally call usb_transfer_complete().
for the timeout and timeout task:
- if the HCI is not dying, and the ux_status is in progress, then
trigger the usb abort task.
- remove UXFER_ABORTWAIT and UXFER_ABORTING.

tested on:
- multiple PC systems with several types of devices: ugen/UPS, ucom,
umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci
and xhci.
- erlite3: sd@umass on dwc2.
- sunblade2000: kbd/ms and umass disk on ohci.

untested:
- motg, slhci and ahci. motg has some portion of the new scheme
applied, but slhci and ahci require more study.

future work includes pushing a lot of the common abort handling into
usbdi.c and leaving upm_abort() for HC specific tasks, but this change
is pullup-able to netbsd-7 and netbsd-8 as it does not change any
external API, as well as removing over 100 lines of code while adding
over 30 new asserts.

XXX: pullup-7, pullup-8.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
# 1.9 09-Apr-2018 jakllsch

Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.8 25-Sep-2017 jmcneill

branches: 1.8.2;
If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

branches: 1.7.6;
Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.8 25-Sep-2017 jmcneill

If the bus glue calls xhci_init with interrupts enabled, there is a window
between when xhci interrupts are enabled and the usb bus driver is
attached. If an irq occurs in this window, xhci will attempt to schedule
a softint with an invalid softint handle.

Add a quirk flag, XHCI_DEFERRED_START, that when set skips starting the
controller at the end of xhci_init. Bus glue that sets this is responsible
to call xhci_start after attaching the child usb devices.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.7 19-Jan-2017 skrll

Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

branches: 1.6.2; 1.6.4;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


# 1.7 19-Jan-2017 skrll

Pull across xhci(4) improvemnts from nick-nhusb


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.6 03-May-2016 skrll

Kill XHCI_QUIRK_FORCE_INTR and surrounding code


# 1.5 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base tls-maxphys-base netbsd-7-base rmind-smpnet-base rmind-smpnet-nbase yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.4 10-Mar-2014 skrll

branches: 1.4.4; 1.4.6; 1.4.10; 1.4.12; 1.4.16;
Whtiespace.


# 1.3 10-Mar-2014 skrll

Don't abuse usbd_status in xhci_init


# 1.2 28-Oct-2013 matt

branches: 1.2.2;
Add support for scratchpad buffers (required for some XHCI devices).
Fix an endian issue.


# 1.1 14-Sep-2013 jakllsch

Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.