History log of /haiku/src/add-ons/kernel/busses/usb/ehci.cpp
Revision Date Author Comments
# 629f071b 27-Feb-2024 X512 <danger_mail@list.ru>

pci: extend MSI interrupt vector number to 32 bits

Also increase MSI message data size to 32 bits according to PCIe spec.

Remove 0xff check for MSI interrupts because it is potentially valid
interrupt vector number. Reject 0xff only for legacy pin interrupts.

- MSI-X supports up to 2048 interrupts per device that do not fit to
`uint8`.

- Non-x86 systems may use separate interrupt vector ranges for
hard-wired interrupts and MSI interrupts so `uint8` is not enough to
represent all of them.

Change-Id: Iaf9ffb197ec23db0f97ffe3ea756d28d7bfc8705
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7433
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# be3ce6d7 31-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

USB: Make "buffer error" reporting consistent.

This error means that the controller failed to read or write data
to/from system memory fast enough. As a result, we should report it
as READ_ERROR/WRITE_ERROR, rather than something that sounds like
an error with the device itself.

Then, make BABBLE reporting consistent: this is a data overrun/underrun
of the device itself, not the buffers passed to the controller.
This then leaves B_DEV_FIFO_OVERRUN/UNDERRUN unused, and thus usable
for reporting ring overrun/underrun on isochronous transfers.

The API documentation already described DATA_OVERRUN/UNDERRUN basically
like they were babble errors, while FIFO_OVERRUN/UNDERRUN are
currently described as "internal errors" at present. No driver actually
checked for these.


# 55a46882 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Support physical-vector bulk requests.

Introduce a new utility method, "generic_memcpy", which takes
generic_addr_t plus indications of whether these specify virtual or
physical addresses (and potentially user addresess) and calls the
appropriate memcpy variant depending.

All bus drivers adjusted to support this at once. We don't actually
take advantage of the physical addresses in any way (yet), as USB
controllers have some pretty specific requirements that would have
to be carefully validated to use these directly.

All bus drivers tested and confirmed to still be working.

Change-Id: I66326667e148091147bb2b3d0843a26fb7e5bda6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6479
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 99626c29 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Use generic_io_vec in Transfer.

Prepares the way for actual physical-address request support,
which is not yet wired up.

Change-Id: I1b2d04a31e334a79b8361280fa0f3a5fbdb43d2b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6478
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3b91d73b 16-Dec-2022 X512 <danger_mail@list.ru>

bus & drivers: drop PCI_x86

Change-Id: I494deaf24a4793a5e0fe9fa46ecdce32f65e616a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6226
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 215b685f 11-Dec-2022 X512 <danger_mail@list.ru>

kernel: Drop non-standard GNU inline assignment syntax

* We needed this previously due to our gcc2 compiled kernel.
* Now that our kernel is always latest gcc, we can move to the
c++20 syntax for inline assignment.
* Improves compatibility with clang, less GNU-specific stuff

Change-Id: Ib7272a0a52554a31e9a0e788fd3f031db9049795
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5898
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# d2875e7b 16-Nov-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: fix references on the module B_PCI_X86_MODULE_NAME

the dependency is optional, only the device modules depend on it.
should fix #18075

Change-Id: Ifddb9814ff5ff59ee7d80d06b14ba9fded04cd56
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5822
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e6ce95c5 10-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: register device nodes for hubs and devices

the device identifier is the USBID. no actual interface to be used by drivers.

Change-Id: I9fd1fdab0d02f1b82380c619b39bc3a12a9e2333
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5736
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 6652606f 05-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: remove debug leftover

Change-Id: Idba6eaecb2c5b5773cd61794ac62fac1f7e3c1f9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5715
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 15ebede2 01-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

ehci: switch to the new driver API

Change-Id: I9102a27fe8e536003a0ab09c9cca5a87e88c8092
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5709
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 07b1a217 14-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

EHCI: Do not ignore status of PrepareKernelAccess.

May help with #17799.


# ffc83aa2 28-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB bus drivers: Add missing iterator increments.

Should fix boot hang regressions introduced in hrev55455
in the fix for #17275.


# ae61e1b7 27-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB bus drivers: Return error when combining other transfers with a fragmented one.

The drivers do not support this properly at present, they would
run the other transfers interspersed with fragments from the fragemented one,
which is obviously the wrong thing to do.

No USB device drivers seem to do this at present (it would cause data
corruption if they had.)

Fixes #17275.


# bc7fd433 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rename Transfer::VectorLength to Transfer::FragmentLength.

It did not return the length of the vectors, but only the current
fragment's worth of vectors. It also modified the fFragmented flag,
which really should have been set in SetVectors in the first place.

As everything seemed to call IsFragmented after VectorLength,
this is not a behavioral change.


# 877c1b93 09-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

EHCI: Call InitKernelAccess at the top of SubmitTransfer functions.

I missed that this was not done before WriteDescriptor was called.
Fixes #14835 (again.)


# 07ec2cf0 08-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

EHCI: Call PrepareKernelAccess before writing descriptor chains.

Fixes #15653.


# 79ded8ca 04-Feb-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

Reduce polling interval for low-speed devices

Fixes #7651, my Logitech gamepad works.

Change-Id: Ia3f92ba817576946dabee262a2fd5af8102a109f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2198
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 9f7fb0e5 18-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

EHCI: Destroy the cleanup semaphore on teardown.

Otherwise, the wait_for_thread() of the fCleanupThread will block
forever, stalling the boot process.

Fixes another part of #15004.


# e8b2085d 18-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Print the PCI ID of the device with an invalid IRQ.


# 6be54385 13-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Handle getting/putting the PCI modules properly.

Previously it was possible that we put() them twice, leading to
assert-failure panics as their ref-counts would go below 0.
Now we get() them once for every bus object that we create, as
the destructors put() them.

Should fix the panic in #15004.


# 67b05100 12-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Don't reject devices with "invalid" IRQs immediately.

We may be able to allocate an MSI for them. This was done for XHCI
already in hrev52742.

Probably fixes #15004.


# 5c6d92d7 12-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

busses/usb: Move ::AddTo to be above the class constructors.

It is called before them (and is responsible for calling them),
so having it in the middle of the file does not make a lot of sense.

Already done for XHCI. Only one functional change -- removing the
set_dprintf_enabled call. Drivers probably shouldn't spuriously
re-enable that if it was specifically disabled.


# a182f193 19-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Properly assign IDs to USB Bus Managers (HCI drivers).

Previously they would just get -1, as the BusManager class
would request their ID before they had been added to the Stack.
Now we add them to the stack inside ::Start(), rather than letting
the individual drivers do that just after ::Start(), and then assign
the ID there directly.


# 21c87a5d 09-Sep-2018 Jérôme Duval <jerome.duval@gmail.com>

drivers: remove some non-haiku support code.

Change-Id: Ic55bb4832adabeb807f763c87ad938e74fb3a97d
Reviewed-on: https://review.haiku-os.org/520
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# c91002a1 12-Mar-2018 Jérôme Duval <jerome.duval@gmail.com>

Revert "EHCI USB: process the extended capabilities chain"

This reverts commit 137135a10dc6322773be9da67861c05f53b709a5.

Change-Id: I6e6ef1933b3b3f5eda7278d37b673eefe2867c2a


# 137135a1 13-Dec-2014 Jérôme Duval <jerome.duval@gmail.com>

EHCI USB: process the extended capabilities chain

...instead of the first one only.


# 05a859eb 14-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

usb: map registers or allocate area for the kernel only.


# 3da7be22 30-Jan-2016 Michael Lotz <mmlr@mlotz.ch>

EHCI: Current qtd field in qh overlay has no terminate bit.

Don't initialize the current qtd field with the terminate bit as it does
not exist in this field. While the lower 5 bits are documented as being
ignored anyway, this is more correct. Should cause no functional change.


# ad72f4ca 30-Jan-2016 Michael Lotz <mmlr@mlotz.ch>

EHCI: Fix alignment check, the mask wasn't wide enough.

As this is only an assert that shouldn't ever be triggered, this doesn't
change anything in normal operation.


# 3648dc87 30-Jan-2016 Michael Lotz <mmlr@mlotz.ch>

EHCI: Style cleanup only, no functional change.

Change < B_OK to != B_OK for status_t results and to < 0 for ids.


# 159aa93b 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 7cbae3c9 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Implement debug transfers.


# d7626f8d 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Move locking to be only around actually critical section.


# 63cf3cfa 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Simplify short packet logic to use alternate pointer.

The alternate pointer is the software equivalent of the alternate
physical address in the hardware queue head part. The controller
follows that path, so we can follow the alternate pointer as well.
Simplifies and generalizes the logic.


# 848bfaa6 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

More style fixes to ehci.


# a48beace 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

More style fixes.


# 2afa6a58 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style and 80-column fixes.


# b1c9a1a3 22-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

Fix Short Packet EHCI Transfers

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #10867.


# 578558b4 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# 010b06a1 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

EHCI USB: add MSI support

* similar to OHCI support by mmlr.
* interrupt handler is removed on destruction.


# 691f8e5a 26-Jun-2013 Jérôme Duval <jerome.duval@gmail.com>

ehci: initializes fItdEntries and fSitdEntries.


# c4dbefe0 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Fix build with tracing turned on.


# 2b883e19 06-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix compilation of OHCI on x86.

Fixes were needed to go with the USB stack changes. Haven't tested it
yet because I don't have a a machine with OHCI, but I doubt there
will be any problems.


# d8b4cfc9 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# ebdb8247 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Move mutex initialization earlier, analogous to hrev43320.

Avoids crashing if the bus manager init fails. Also fixes CID 10846.


# 04c14022 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Use the right form of delete. Fixes CID 11037.


# ef2eaedc 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Account for full-/lowspeed errors and ensure an error is set.

For full- and lowspeed devices the unused ping status bit works as an
additional error bit (albeit it's so generic that it isn't really
useful). Include that bit when the error counter counts down to zero.

Also ensure that an error is returned if the error counter reaches
zero, but print a warning if none of the describing bits are set.


# 345eb8c4 29-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Make two unexpected/error cases more visible with debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7ca82dc 30-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Read the previous descriptor pointer before freeing transfer and transfer descriptors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42701 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77660b03 23-Aug-2011 Jérôme Duval <korli@users.berlios.de>

* threshold higher bit means a full frame. Also use the threshold for micro frames instead of frames.
* introduces fNextStartingFrame to keep track of the next frame to use on next submit.
* set the IOC bit for the last ITD
* computes multiply field of the ITD based on the packed size (1, 2 or 3).
* use locking around linking of ITD
* free descriptors on errors
* on finishing, whenever a non success status is found, set actual length to zero
* on finishing, when copying data to the Transfer object, copy starting on packet boundaries (skipping unused bytes).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42679 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 425eff67 11-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Locking around descriptors list handling isn't enough, locking is also needed when traversing the list: we instead lock the whole traversing/handling loop.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0839540d 04-Aug-2011 Jérôme Duval <korli@users.berlios.de>

use locking when messing ITD and SITD queues. itd->prev was becoming NULL, thus leading to KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c05a3fa6 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

We obviously need to mask off the interrupt threshold value before overwriting
it with our new setting. Otherwise we might end up with an illegal value as the
interrupt threshold which might inhibit interrupt generation alltogether
depending on the controller implementation. This was the case for the ATI/AMD
SBx00 chipsets. Therefore fixes #5551.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ce44796e 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

Introduce simplistic poll mode for EHCI. If enabled a thread will run the
interrupt handler every millisecond so it can check for interrupts to handle.
While this is certainly not ideal, it allows EHCI to run (surprisingly well
even) on chipsets that experience interrupt routing issues.
It can be enabled with the safemode setting "ehci_polling on" that can either
be entered using the new advanced debug option entry in the bootloader and/or
in the kernel settings file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41688 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c0b58c07 22-May-2011 Jérôme Duval <korli@users.berlios.de>

* added some EHCI definitions (specification 1.1)
* enable per-port change events when available


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41661 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cca52e79 22-May-2011 Jérôme Duval <korli@users.berlios.de>

ehci usb driver:
* make sure the PortEnable bit is disabled (specification page 28)
* 250ms is too long: USB 2.0 specifies only 50ms. This prevented one of my devices to be detected.
+alpha


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 609f2f33 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

Check if PCI interrupts are disabled on the EHCI device. Rather unlikely to be
the case, but maybe there's some BIOSes that disable them? More or less poking
around for #5551, doesn't do any harm in any case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bb57042 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

Introduce workaround for the (documented) bug with ATI/AMD SB600 and early SB700
periodic list cache. This workaround is based on similar patches in NetBSD and
Linux and disables the (Advanced) Periodic List Cache on the affected devices
using ATI/AMD specifc registers (as documented in the corresponding AMD
register reference guide).
Also remove a ton of stray whitespace introduced by the isochronous patches.
Please take more care the next time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41512 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df33d91 10-May-2011 Jérôme Duval <korli@users.berlios.de>

* Implement inbound isochronous transfer for EHCI, based on UHCI implementation.
* changes next_log to their actual type instead of void*
* the field this_phy now includes the item type, it simplifies things.
* isochronous transfer descriptors are linked in the periodic frame list first,
and points to existing interrupt transfer descriptors.

This is still work in progress. Yet it's worth committing as it doesn't seem to
have impacts, and is required for the UVC SoC project. Tested basically with
usb_webcam to receive UVC stream headers.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf3381e7 19-Apr-2011 Jérôme Duval <korli@users.berlios.de>

activate some traces for EHCI bus driver (see bug #4718)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41270 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7411ad2 07-Apr-2011 Jérôme Duval <korli@users.berlios.de>

added traces for unimplemented isochronous transfers for ehci and ohci


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41194 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 64d79eff 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2cf04ca7 07-Mar-2010 Michael Lotz <mmlr@mlotz.ch>

Don't take ownership by writing the OS-owned semaphore when the BIOS-owned flag
isn't set. I'd tend to say that's a rather odd interpretation of the specified
protocol if a BIOS goes mad if the sem is written to while it doesn't actually
own the controller (it should just be a no-op in that case and directly set the
sem state). But it seems this is what others do as well (FreeBSD, Linux) so we
follow. Thanks to vegardw in #2083 for researching into this and proposing this
fix. Minor other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35780 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1393394b 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

We need to guarantee that when cancel returns that the callback won't be called
anymore. It could happen that the transfer was already in the process of being
finished, so wasn't in the list of pending transfers anymore. Cancel would then
return even though the callback wasn't called yet. This could lead to a callback
being called after a driver was already unloaded (even after it cleaned up the
pipes it used).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33239 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eb01fb72 08-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

* Add the kernel debugger extensions only for the haiku target.
* Acknowledge non-enabled interrupts in UHCI as done in EHCI as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30063 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c43b2568 05-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

It turns out that on some BIOSes even if the handover is signaled as successful,
the BIOS doesn't remove it's SMIs. When then initializing the controller this
would trigger all sorts of stuff and for example freeze the system. We therefore
always force off the SMIs, even if the handover didn't fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29931 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4085ff6f 28-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Check for and discard not enabled interrupts in EHCI.
* Simplify acknowledging interrupts a bit.

Might help with bug #2083 in case the controller would interrupt on a port
change or frame list rollover even though those aren't enabled by us.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29354 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14fe767 23-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Rework the USB tracing mechanism. Cleaned it up and make it more convenient to
use. It will now print out the usb_ids of the objects that generate the trace
messages. These IDs are unique compared to the device address used previously,
because device addresses are per bus while usb_ids are global. This makes
trace output from devices across multiple controllers distinguishable.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 508dd5f9 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Output some more debug output in case of port reset failure.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2fc7e292 19-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

When calculating the actual length for requests, we don't want to include the
8 byte request header. It was included in the case of outgoing request
transfers before. In fact we always just want the length of the data phase,
which for non-requests just happens to be the whole transfer.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a0ace2df 10-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

If the BIOS doesn't give up ownership of an EHCI controller, simply clear the
BIOS owned flag and clear all possibly enabled SMIs. It seems to be common
practice to just ignore this error case, probably because there are enough
broken BIOSs out there that do not correctly hand over the controller.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25918 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ca87670 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

When canceling transfers, do not call the callbacks with the lock held. This
prevents deadlocks in cases where a new transfer is scheduled from within the
cancel callback. This is an edge case, as generally you don't want to schedule
anything when explicitly canceling transfers, but there are a valid use cases
when you cancel because of a timeout and then have to reset the device for
example. Note that this hides bug #2353, where the cancel case is probably
not handled correctly.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25861 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 856c49e6 06-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Only check the explicitly enabled interrupts in EHCI. Otherwise we might steal
a shared interrupt from someone else.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c8de858 01-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added optional spinlock contention measurement feature. Enabled when
B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a
structure (thus breaking BeOS binary compatibility), containing a
counter which is incremented whenever a thread has to wait for the
spinlock.
* Added macros for spinlock initialization and access and changed
code using spinlocks accordingly. This breaks compilation for BeOS --
the macros should be defined in the respective compatibility wrappers.
* Added generic syscall to get the spinlock counters for the thread and
the team spinlocks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25752 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3283bfa 16-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Increase the amount of tries in the EHCI BIOS handover so it lasts for up to
1 second instead of half a second. Might help with slow BIOSes.
* Disable EHCI interrupts if the BIOS handover fails so that we do not flood
the system with interrupts if the BIOS later on decides to still comply with
our handover request.
* Add an unconditional success message to EHCI and UHCI to better see if
controllers are present/initialized correctly at all.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24980 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33574eaf 14-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Exclude the frame list rollover interrupt from the interrupts we are interested
in. We do not enable this interrupt and if we still "handle" it in our
interrupt handler we might prevent the interrupt from reaching the real intended
handler in a shared interrupt setup. Not sure if this could have happend at
all, but this is more correct in any case.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 93209d82 13-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Fully clear the EHCI members too, so an incompletely constructed object can be
safely deleted.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24957 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e959baed 12-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Set the interrupt threshold of the controller when doing the rest of the
initialization as suggested by the EHCI spec and do not touch it again
once the controller is running. Doing so would result in undefined behaviour
according to EHCI specs.
* Set the port routing policy after the controller has started and not before
as suggested by the EHCI specs.
* Explicitly set the segment register after resetting the host controller and
not before, as this likely has no real effect ;-)

Might help with some legacy support or UHCI/OHCI to EHCI handover problems.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ff902d0 09-Apr-2008 François Revol <revol@free.fr>

Fix building usb busses with tracing on.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24880 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8024db25 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Change just host_controller_info to usb_host_controller_info for the sake of
clearity as suggested by Philippe Houdoin once and brought to my attention by
Slavatore. As this definition is completely private to the USB stack it would
not have caused any conflicts though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24828 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a763522d 26-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

We are not supposed to overwrite the full capability register when setting our
OS-owned bit. Otherwise we overwrite exactly the bit we later have to wait for.
Could theoretically help on legacy support issues, but I doubt it since most
hardware probably does not even use EHCI legacy support as it's normally not
needed to support full/low-speed input devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 252fa0fc 25-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Unconditionally output when giving up port ownership and taking over host
controller ownership in EHCI to aid debugging USB legacy support issues.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23735 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 26f2e4a0 24-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Notify the finisher thread after canceling transfers. It was possible that freeing the allocated
transfer resources would be delayed unnecessarily until some other transfer completed and woke up
the finisher thread. Found by Salvatore Benedetto, thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b6cdc4c 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* fixed memory leak: if InitKernelAccess failed data was not deleted



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 20c43b02 10-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

* Add support for low/full speed interrupt transfers over USB 2.0 hubs
* Actually enable the periodic schedule so that any interrupts work over EHCI

For those who wait for OHCI: You can now attach your USB 1.1 mouse or keyboard
to a USB 2.0 hub and it should work.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bd7e77c 01-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Messed up those numbers. The interval can range from 0 to 16 and we can use 0 to 10 with the 1024 frame list. So it's obviously 11 entries and not 10. Fixes the wrong tree layout and the doubled polling intervals of interrupts.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23035 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4ef0f13 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Since the interval is now part of the general pipe info we don't have to cast the pipe to an interrupt one anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22976 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b06464 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented split transactions for control and bulk pipes in EHCI.
With this it is possible to use low/fullspeed (USB 1.1) devices below USB 2.0 Hubs.
Note though that you cannot yet use mice or keyboards attached to USB 2.0 Hubs as split transactions for interrupt pipes are still missing.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22973 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f074829 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Removed the two extra submit functions and combined them directly into SubmitTransfer()
* The sparation based on async and periodic schedule made no sense as it is a question of queued/non-queued
* Therefore removed the near complete code duplication for adding interrupt transfers (that are also queued)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22943 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed1eff2f 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Implement interrupt transfers in EHCI
* Uses a "collapsed binary tree" (for lack of a better name) to support the different intervals
* Remove a leftover variable declaration that was hiding error conditions away...
* Some cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22942 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13508e8b 14-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Completely redesign the USB explore process. Replaces the scary race conditions of the previous locking mechanism and simplifies handling of device changes by a more centralized approach.
Changes are now collected during explore and notifications as well as rescans are done at once. Through this a driver is also not rescanned multiple times anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c954d334 11-Aug-2007 Michael Lotz <mmlr@mlotz.ch>

* Apply more sane canceling logic to EHCI too
* Remove the leftover user_area - this is handeled inside the Transfer class by now

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0341b28 25-May-2007 François Revol <revol@free.fr>

Revert r21231 as it's supposedly not possible. Someone implement OHCI then pleazzze!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21241 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d5bdb86 24-May-2007 François Revol <revol@free.fr>

Added a keep_port_ownership driver setting for EHCI, to allow keeping devices on EHCI instead of giving them up to the 1.0 controller.
Hopefully this will get things working here until OHCI is implemented.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21231 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34cbbba7 07-May-2007 Michael Lotz <mmlr@mlotz.ch>

* Reworked userland buffer access functionality into two functions in the Transfer class to not duplicate code in each HCD
* Use these functions in UHCI and EHCI which greatly reduces overhead on fragmented transfers as the vector conversion and area cloning is only done once
* Use the PrepareKernelAccess() function before submitting fragments which fixes the crash when trying to access the next fragments buffer in user memory from the kernel thread

This should fix bug #1167 which could be encountered when sending data to a mass storage device with an application that uses a large enough transfer buffer size.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 562328e7 07-May-2007 Michael Lotz <mmlr@mlotz.ch>

Fixed wrong cancelling algorithm. This is what you get when you "rework" an existing function without thinking it through again... Thanks J Jerome for noticing\!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b3d0fcf 06-May-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented transfer cancelling for EHCI by reworking the previously unused CancelPendingTransfer() into CancelQueuedTransfers() with the pipe based semantic.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21044 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 145461d5 25-Mar-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented fragmented USB transfers. The transfer length will max out at a certain point to not overflow the allocator. The fragmented transfers are resubmitted until all fragments are sent / received.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 955dc88f 06-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Fixed spinlock usage in EHCI and UHCI drivers
* Fixed UHCI to allow for empty transfer buffers
* Extended the check for still linked transfer descriptors when removing a chain

There remain UHCI bugs that will cause transfers outgoing transfers to fail. I'll have to review / rewrite the UHCI driver.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00f6fab9 26-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented a notification method for BusManagers so that they can be notified of pipe changes (creation, destruction, changed settings).
This is necessary in OHCI and will probably be used in EHCI also to keep one endpoint construct for each pipe open instead on creating and deleting it for each transfer.
* Pseudo implemented set_pipe_policy for isochronous pipes that makes use of the new notification system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18945 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4330ef22 25-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Added retries to the PhysicalMemoryAllocator. Memory is allocated and freed at a very high frequency, so low memory conditions shouldn't last very long.
* Added a separate thread for cleaning up EHCI transfers. This makes it possible to actually always wait for the async advance interrupt without hindering execution of transfers.
This pushes performance again and fixes the bug I introduced in the last change, that we could free yet cached descriptors when a previous async advance timed out.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17f83b21 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Switched from the old v2 callback status codes to the new v3 codes
This means that the usb_callback_func now takes a status_t instead of a uint32 status.
Also the error codes are now different. I don't see this as a real problem in binary compatibility, as the status codes were never really documented and most drivers just assumed that a nonzero status meant an error.
Source compatibility breaks for callback functions and error defines. I fixed (hopefully) all places in the tree that are currenty included in the image and affected by the change.
* Corrected error reporting in UHCI and EHCI using the new status codes.
* Fixed a memory leak in EHCI where the async advance interrupt was not triggered in time.
* Fixed another race condition in usb_raw that could cause a crash when a device is removed while a transfer is pending.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18916 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a278a1b 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixing my previous attempt at fixing cookie handling. Device addresses cannot be used, since there may be devices with the same address across different busses. A linked list of usb_driver_cookies is maintained now that relates devices and cookies.
* Fixed endpoint halt clearing. The data toggle has to be reset when we clear a stall.
* Now using up to B_PAGE_SIZE * 4 sized buffers in EHCI. They are split automatically by the host controller. This further pushes throughput.
* Optimize memory allocator settings for the above case. Enlarging it's managed space to 1MB
* Ignore the transaction error bit in EHCI. It is only of informational character as it also idicates errors that were recovered automatically. If an unrecoverable error occures, other bits will indicate this.
* Fixed some more print formats in debug output.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7145ff17 20-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented compatibility workaround for BeOS to be able to write user memory from the kernel finisher thread

This fixes crashing of the USB Mass Storage driver under R5. It is fully working there now.
I hope to be able to do this more cleanly under Haiku though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcc2d1b6 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented usable thread synchronisation for UHCI and EHCI.
* Cleaned interrupt handlers for both busses, too.
* Fixed memory leak of the queue head stray descriptors in EHCI.
* Fixed warnings about assigning NULL to the module flags field.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18857 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dff0c634 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented transfer finishing in EHCI
* Implemented actual length calculation in EHCI
* Implemented bulk transfers in EHCI
* Implemented queue freeing in EHCI
* Added extended buffer pointers to the EHCI structs, necessary when the controller supports 64bit
* Fixed debug output and removed warnings due to wrong print format

Control and bulk transfers are now working nicely for EHCI. This means that I can now get pictures from my camera with USB 2.0 speed. Note though that many things still are unimplemented (isochronous transfers, split transactions, interrupt transfers, queue chaches per pipe, ...). But it's certainly a nice step forward :-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18855 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f452f9dc 14-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most qTD and qH functions for EHCI async transfers.
* Implementing control and bulk (async) transfers. They don't work yet though.
* Corrected the legacy support handling in EHCI
* Fixed the bit mask for total bytes in qTDs and added the data toggle bit
* Changed the boolean low speed flags to usb_speed enum that allows for low, full and highspeed

Also wrote a memory allocator that takes over memory management from the stack. It is similar to a buddy allocator. This does on the one hand remove some ugly code from the stack and is on the other hand far more scalable than the previous free list approach. This scalability is needed for proper EHCI support where buffers can go up to a size of 5 pages. The allocator is not perfect and it's memory overhead is quite high compared to the managed memory (depends on the managed block sizes), but it's quik and works well so far.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8fedfdfc 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Rewrote some stack internals (again). Everything is now created using a parent object that shares the BusManager and Stack information to reduce individual constructors.
* Don't inherit Device and Interface from pipes anymore. The device has a default pipe member now.
* Since the parent of each Object is now known, we can send control messages using the default pipe of the device from all attached elements (pipes and interfaces).
* Fixed the generic {Set|Clear}Feature() and GetStatus() calls to include the endpoint address for pipe specific requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18710 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2761c5ae 30-Aug-2006 Jérôme Duval <korli@users.berlios.de>

replaced with PCI.h definitions, added PCI_usb_ehci


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ffe3f107 27-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Redisigned some of the USB Stack. Unified constructors, removed redundant functions and moved some other functions around
* Implemented the EHCIRootHub
* Reworked UHCIRootHub to be more of a utility class and moved the actual work into the UHCI BusManager
* Implemented port reset in EHCI. Ports with low and fullspeed devices are now correctly handed over to the companion host controller.

Attachs and detachs as well as port resetting / enabling works now in EHCI. Only the actual data transfers are missing thereafter ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01595708 26-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Changed EHCI register access from port to memory mapped io (which is required)
* Added individual register operations for operational and capability registers
* Added resetting the host controller which appearantly actually works

Note that you shouldn't install the ehci module if you want uhci to work.
It disables the companion host controller drivers (uhci and ohci) because it takes port ownership and does not yet give it back for low and fullspeed devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e857d24 25-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Adding skeleton EHCI driver. Some parts filled from the specs and the UHCI driver.
* Corrected some errors I found while reading UHCI.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18626 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 159aa93b31cb5d926ef4939a16419e7d02979b1c 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 7cbae3c96949ea78ad796ce86ef1c6a46ad213f2 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Implement debug transfers.


# d7626f8db366dc2806e82b1c424e805dc14971ba 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Move locking to be only around actually critical section.


# 63cf3cfa115b97cebcef542609aaa4e13dfc151b 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

EHCI: Simplify short packet logic to use alternate pointer.

The alternate pointer is the software equivalent of the alternate
physical address in the hardware queue head part. The controller
follows that path, so we can follow the alternate pointer as well.
Simplifies and generalizes the logic.


# 848bfaa602d9bcd8976d0c83ce649686f1d09760 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

More style fixes to ehci.


# a48beaced052d8a01c2b3b6d02c6e5b88bdcb032 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

More style fixes.


# 2afa6a58e18e1b3603841e8efa8f2ad005b81b18 07-Aug-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style and 80-column fixes.


# b1c9a1a31d030bbe501deca5f110ffc60359ba13 22-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

Fix Short Packet EHCI Transfers

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #10867.


# 578558b439867f563d44d168a29223f76d6bb23e 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# 010b06a16e6bb1c84a92ed34dd410b5769a0b430 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

EHCI USB: add MSI support

* similar to OHCI support by mmlr.
* interrupt handler is removed on destruction.


# 691f8e5a27889ba011e7577180d4c7b15c28b776 26-Jun-2013 Jérôme Duval <jerome.duval@gmail.com>

ehci: initializes fItdEntries and fSitdEntries.


# c4dbefe0b4597740fcae84fc088e4d4159a59b13 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Fix build with tracing turned on.


# 2b883e1977b1c420935c80b6fb9eb0067f112301 06-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix compilation of OHCI on x86.

Fixes were needed to go with the USB stack changes. Haven't tested it
yet because I don't have a a machine with OHCI, but I doubt there
will be any problems.


# d8b4cfc9829119291e68cfe0152c239fd8850b3d 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# ebdb8247fd2618970201748cf021846882a05a6b 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Move mutex initialization earlier, analogous to hrev43320.

Avoids crashing if the bus manager init fails. Also fixes CID 10846.


# 04c140226cc085987a99ec2d430c5dd498fc0311 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Use the right form of delete. Fixes CID 11037.


# ef2eaedc2ec5332905a4784a38283a2d83234f3a 04-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Account for full-/lowspeed errors and ensure an error is set.

For full- and lowspeed devices the unused ping status bit works as an
additional error bit (albeit it's so generic that it isn't really
useful). Include that bit when the error counter counts down to zero.

Also ensure that an error is returned if the error counter reaches
zero, but print a warning if none of the describing bits are set.


# 345eb8c4fea85cef0339c919468716f9611798d8 29-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Make two unexpected/error cases more visible with debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7ca82dc00e7f2c657b00d8b0da15429344ea177 30-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Read the previous descriptor pointer before freeing transfer and transfer descriptors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42701 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77660b03e844ff20dc766a3033f4ee0d776983fb 23-Aug-2011 Jérôme Duval <korli@users.berlios.de>

* threshold higher bit means a full frame. Also use the threshold for micro frames instead of frames.
* introduces fNextStartingFrame to keep track of the next frame to use on next submit.
* set the IOC bit for the last ITD
* computes multiply field of the ITD based on the packed size (1, 2 or 3).
* use locking around linking of ITD
* free descriptors on errors
* on finishing, whenever a non success status is found, set actual length to zero
* on finishing, when copying data to the Transfer object, copy starting on packet boundaries (skipping unused bytes).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42679 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 425eff67d65263031010581ba0f332bceb56a9f8 11-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Locking around descriptors list handling isn't enough, locking is also needed when traversing the list: we instead lock the whole traversing/handling loop.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0839540d1e84ff4829960f08c9d3025987a5ca04 04-Aug-2011 Jérôme Duval <korli@users.berlios.de>

use locking when messing ITD and SITD queues. itd->prev was becoming NULL, thus leading to KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c05a3fa6a7bbc6928d0fe4987cfa5ef1d9b9f481 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

We obviously need to mask off the interrupt threshold value before overwriting
it with our new setting. Otherwise we might end up with an illegal value as the
interrupt threshold which might inhibit interrupt generation alltogether
depending on the controller implementation. This was the case for the ATI/AMD
SBx00 chipsets. Therefore fixes #5551.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ce44796e34f049cc20fb8a522c81f05c325b69a5 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

Introduce simplistic poll mode for EHCI. If enabled a thread will run the
interrupt handler every millisecond so it can check for interrupts to handle.
While this is certainly not ideal, it allows EHCI to run (surprisingly well
even) on chipsets that experience interrupt routing issues.
It can be enabled with the safemode setting "ehci_polling on" that can either
be entered using the new advanced debug option entry in the bootloader and/or
in the kernel settings file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41688 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c0b58c071f690fd5f5bbcb20a4b54853a624b575 22-May-2011 Jérôme Duval <korli@users.berlios.de>

* added some EHCI definitions (specification 1.1)
* enable per-port change events when available


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41661 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cca52e798798962b4a733a1afc8925dae8ff5729 22-May-2011 Jérôme Duval <korli@users.berlios.de>

ehci usb driver:
* make sure the PortEnable bit is disabled (specification page 28)
* 250ms is too long: USB 2.0 specifies only 50ms. This prevented one of my devices to be detected.
+alpha


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 609f2f339355713b8c70e0053cdcf40b2c0b4c5d 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

Check if PCI interrupts are disabled on the EHCI device. Rather unlikely to be
the case, but maybe there's some BIOSes that disable them? More or less poking
around for #5551, doesn't do any harm in any case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bb5704280cf288802cde939808949eb5ed6479e 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

Introduce workaround for the (documented) bug with ATI/AMD SB600 and early SB700
periodic list cache. This workaround is based on similar patches in NetBSD and
Linux and disables the (Advanced) Periodic List Cache on the affected devices
using ATI/AMD specifc registers (as documented in the corresponding AMD
register reference guide).
Also remove a ton of stray whitespace introduced by the isochronous patches.
Please take more care the next time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41512 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df33d912b05c8d986287bec208df68c595c24a8 10-May-2011 Jérôme Duval <korli@users.berlios.de>

* Implement inbound isochronous transfer for EHCI, based on UHCI implementation.
* changes next_log to their actual type instead of void*
* the field this_phy now includes the item type, it simplifies things.
* isochronous transfer descriptors are linked in the periodic frame list first,
and points to existing interrupt transfer descriptors.

This is still work in progress. Yet it's worth committing as it doesn't seem to
have impacts, and is required for the UVC SoC project. Tested basically with
usb_webcam to receive UVC stream headers.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf3381e7711994e02004e8689e8976e09fab4179 19-Apr-2011 Jérôme Duval <korli@users.berlios.de>

activate some traces for EHCI bus driver (see bug #4718)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41270 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7411ad2ec16e5fd1b8eefa975119cf3045f5fbd 07-Apr-2011 Jérôme Duval <korli@users.berlios.de>

added traces for unimplemented isochronous transfers for ehci and ohci


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41194 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 64d79eff7290437d24b1a420537c3ed5c144ab96 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36960 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2cf04ca7280a51addb83525c1a00166d77cba0e9 07-Mar-2010 Michael Lotz <mmlr@mlotz.ch>

Don't take ownership by writing the OS-owned semaphore when the BIOS-owned flag
isn't set. I'd tend to say that's a rather odd interpretation of the specified
protocol if a BIOS goes mad if the sem is written to while it doesn't actually
own the controller (it should just be a no-op in that case and directly set the
sem state). But it seems this is what others do as well (FreeBSD, Linux) so we
follow. Thanks to vegardw in #2083 for researching into this and proposing this
fix. Minor other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35780 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1393394ba6adde434020a48e5d9b7b22822150b0 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

We need to guarantee that when cancel returns that the callback won't be called
anymore. It could happen that the transfer was already in the process of being
finished, so wasn't in the list of pending transfers anymore. Cancel would then
return even though the callback wasn't called yet. This could lead to a callback
being called after a driver was already unloaded (even after it cleaned up the
pipes it used).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33239 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eb01fb72f6d90bf6a083941ace087bdd6803a516 08-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

* Add the kernel debugger extensions only for the haiku target.
* Acknowledge non-enabled interrupts in UHCI as done in EHCI as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30063 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c43b256828601f49e88f648edce39b59eff307c3 05-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

It turns out that on some BIOSes even if the handover is signaled as successful,
the BIOS doesn't remove it's SMIs. When then initializing the controller this
would trigger all sorts of stuff and for example freeze the system. We therefore
always force off the SMIs, even if the handover didn't fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29931 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4085ff6fcfa78eae897d339e97a2956de475a3f7 28-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Check for and discard not enabled interrupts in EHCI.
* Simplify acknowledging interrupts a bit.

Might help with bug #2083 in case the controller would interrupt on a port
change or frame list rollover even though those aren't enabled by us.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29354 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14fe767bf568186bbd0678e35b03c99d8a264c6 23-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Rework the USB tracing mechanism. Cleaned it up and make it more convenient to
use. It will now print out the usb_ids of the objects that generate the trace
messages. These IDs are unique compared to the device address used previously,
because device addresses are per bus while usb_ids are global. This makes
trace output from devices across multiple controllers distinguishable.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 508dd5f91db9f11d5522b1050558c1a0ecc42726 21-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Output some more debug output in case of port reset failure.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2fc7e292e5c277938b10d50f99e8fd531fe2e8ed 19-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

When calculating the actual length for requests, we don't want to include the
8 byte request header. It was included in the case of outgoing request
transfers before. In fact we always just want the length of the data phase,
which for non-requests just happens to be the whole transfer.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a0ace2dff6fd640baea8259a91f5a53ba757ed0c 10-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

If the BIOS doesn't give up ownership of an EHCI controller, simply clear the
BIOS owned flag and clear all possibly enabled SMIs. It seems to be common
practice to just ignore this error case, probably because there are enough
broken BIOSs out there that do not correctly hand over the controller.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25918 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ca876701dbe6b2676f81902186fabe67b8ad956 08-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

When canceling transfers, do not call the callbacks with the lock held. This
prevents deadlocks in cases where a new transfer is scheduled from within the
cancel callback. This is an edge case, as generally you don't want to schedule
anything when explicitly canceling transfers, but there are a valid use cases
when you cancel because of a timeout and then have to reset the device for
example. Note that this hides bug #2353, where the cancel case is probably
not handled correctly.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25861 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 856c49e614420148f8fe9471e33baf1e97cf6a9e 06-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Only check the explicitly enabled interrupts in EHCI. Otherwise we might steal
a shared interrupt from someone else.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c8de8581b66c14ea94bccd7ddcea99291955796 01-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added optional spinlock contention measurement feature. Enabled when
B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a
structure (thus breaking BeOS binary compatibility), containing a
counter which is incremented whenever a thread has to wait for the
spinlock.
* Added macros for spinlock initialization and access and changed
code using spinlocks accordingly. This breaks compilation for BeOS --
the macros should be defined in the respective compatibility wrappers.
* Added generic syscall to get the spinlock counters for the thread and
the team spinlocks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25752 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3283bfa83c385bf47492439a2ba5985ec24a1bb 16-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Increase the amount of tries in the EHCI BIOS handover so it lasts for up to
1 second instead of half a second. Might help with slow BIOSes.
* Disable EHCI interrupts if the BIOS handover fails so that we do not flood
the system with interrupts if the BIOS later on decides to still comply with
our handover request.
* Add an unconditional success message to EHCI and UHCI to better see if
controllers are present/initialized correctly at all.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24980 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33574eaf6e1efe1f43a89fdbfc94ff5293869187 14-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Exclude the frame list rollover interrupt from the interrupts we are interested
in. We do not enable this interrupt and if we still "handle" it in our
interrupt handler we might prevent the interrupt from reaching the real intended
handler in a shared interrupt setup. Not sure if this could have happend at
all, but this is more correct in any case.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 93209d82e21e40417b69629a5693bf2a7e6cf1e9 13-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Fully clear the EHCI members too, so an incompletely constructed object can be
safely deleted.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24957 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e959baed586471dc0a718d46b20e1a865148230e 12-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Set the interrupt threshold of the controller when doing the rest of the
initialization as suggested by the EHCI spec and do not touch it again
once the controller is running. Doing so would result in undefined behaviour
according to EHCI specs.
* Set the port routing policy after the controller has started and not before
as suggested by the EHCI specs.
* Explicitly set the segment register after resetting the host controller and
not before, as this likely has no real effect ;-)

Might help with some legacy support or UHCI/OHCI to EHCI handover problems.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ff902d0bdbca23a39e31ec8b3810e9a10dd05ad 09-Apr-2008 François Revol <revol@free.fr>

Fix building usb busses with tracing on.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24880 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8024db25a8b9a380d73fd0198f4203f514f4b5dd 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Change just host_controller_info to usb_host_controller_info for the sake of
clearity as suggested by Philippe Houdoin once and brought to my attention by
Slavatore. As this definition is completely private to the USB stack it would
not have caused any conflicts though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24828 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a763522da618955410fb301b97bb99eac5823ed7 26-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

We are not supposed to overwrite the full capability register when setting our
OS-owned bit. Otherwise we overwrite exactly the bit we later have to wait for.
Could theoretically help on legacy support issues, but I doubt it since most
hardware probably does not even use EHCI legacy support as it's normally not
needed to support full/low-speed input devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 252fa0fc83e4f7e2a50c9191ab136d0a6a1e9f18 25-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Unconditionally output when giving up port ownership and taking over host
controller ownership in EHCI to aid debugging USB legacy support issues.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23735 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 26f2e4a061d1751a5d155b7f920a51e0af2af808 24-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Notify the finisher thread after canceling transfers. It was possible that freeing the allocated
transfer resources would be delayed unnecessarily until some other transfer completed and woke up
the finisher thread. Found by Salvatore Benedetto, thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b6cdc4c7b36a945c960f2808a47579b5ddf0593 22-Jan-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* fixed memory leak: if InitKernelAccess failed data was not deleted



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 20c43b026dda2fc83698ccd5d073ab7037abd1fb 10-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

* Add support for low/full speed interrupt transfers over USB 2.0 hubs
* Actually enable the periodic schedule so that any interrupts work over EHCI

For those who wait for OHCI: You can now attach your USB 1.1 mouse or keyboard
to a USB 2.0 hub and it should work.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23382 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bd7e77cfa160772648f4aa708f487695406302d 01-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Messed up those numbers. The interval can range from 0 to 16 and we can use 0 to 10 with the 1024 frame list. So it's obviously 11 entries and not 10. Fixes the wrong tree layout and the doubled polling intervals of interrupts.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23035 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4ef0f13b7c1b9427b05b083beb31d1d1309537f 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Since the interval is now part of the general pipe info we don't have to cast the pipe to an interrupt one anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22976 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b06464222e1b41e95bcd0c8476b8677aa91a23 21-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented split transactions for control and bulk pipes in EHCI.
With this it is possible to use low/fullspeed (USB 1.1) devices below USB 2.0 Hubs.
Note though that you cannot yet use mice or keyboards attached to USB 2.0 Hubs as split transactions for interrupt pipes are still missing.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22973 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f074829886403b0e04406ed47f0fbe5ae2f5655 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Removed the two extra submit functions and combined them directly into SubmitTransfer()
* The sparation based on async and periodic schedule made no sense as it is a question of queued/non-queued
* Therefore removed the near complete code duplication for adding interrupt transfers (that are also queued)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22943 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed1eff2fec7b126e8032ef19357cb7aceda2c388 17-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

* Implement interrupt transfers in EHCI
* Uses a "collapsed binary tree" (for lack of a better name) to support the different intervals
* Remove a leftover variable declaration that was hiding error conditions away...
* Some cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22942 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13508e8bd034aac27c2e3271aefa04e255520d99 14-Nov-2007 Michael Lotz <mmlr@mlotz.ch>

Completely redesign the USB explore process. Replaces the scary race conditions of the previous locking mechanism and simplifies handling of device changes by a more centralized approach.
Changes are now collected during explore and notifications as well as rescans are done at once. Through this a driver is also not rescanned multiple times anymore.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c954d334059dce539eea9c07d6fe46b307c7edab 11-Aug-2007 Michael Lotz <mmlr@mlotz.ch>

* Apply more sane canceling logic to EHCI too
* Remove the leftover user_area - this is handeled inside the Transfer class by now

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0341b286b2c30281e6bcb83aad6aa963b102cbe 25-May-2007 François Revol <revol@free.fr>

Revert r21231 as it's supposedly not possible. Someone implement OHCI then pleazzze!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21241 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d5bdb86881b8cf275576b1c11fcc92c0cfeae8a 24-May-2007 François Revol <revol@free.fr>

Added a keep_port_ownership driver setting for EHCI, to allow keeping devices on EHCI instead of giving them up to the 1.0 controller.
Hopefully this will get things working here until OHCI is implemented.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21231 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34cbbba798a50322040ad88254293063d5117fe5 07-May-2007 Michael Lotz <mmlr@mlotz.ch>

* Reworked userland buffer access functionality into two functions in the Transfer class to not duplicate code in each HCD
* Use these functions in UHCI and EHCI which greatly reduces overhead on fragmented transfers as the vector conversion and area cloning is only done once
* Use the PrepareKernelAccess() function before submitting fragments which fixes the crash when trying to access the next fragments buffer in user memory from the kernel thread

This should fix bug #1167 which could be encountered when sending data to a mass storage device with an application that uses a large enough transfer buffer size.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 562328e70a80b4f6807ed9be81e101ae82ded619 07-May-2007 Michael Lotz <mmlr@mlotz.ch>

Fixed wrong cancelling algorithm. This is what you get when you "rework" an existing function without thinking it through again... Thanks J Jerome for noticing\!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b3d0fcfda9e442ef8c4c8b6c44f8dc581d3ccbb 06-May-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented transfer cancelling for EHCI by reworking the previously unused CancelPendingTransfer() into CancelQueuedTransfers() with the pipe based semantic.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21044 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 145461d547a8e5e1be7ad8b31cc974caf893b884 25-Mar-2007 Michael Lotz <mmlr@mlotz.ch>

Implemented fragmented USB transfers. The transfer length will max out at a certain point to not overflow the allocator. The fragmented transfers are resubmitted until all fragments are sent / received.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 955dc88f0c0225985a695689d675e0c119a1bdc4 06-Jan-2007 Michael Lotz <mmlr@mlotz.ch>

* Fixed spinlock usage in EHCI and UHCI drivers
* Fixed UHCI to allow for empty transfer buffers
* Extended the check for still linked transfer descriptors when removing a chain

There remain UHCI bugs that will cause transfers outgoing transfers to fail. I'll have to review / rewrite the UHCI driver.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00f6fab9315c42c68c336f31f6061ba6faa17c27 26-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented a notification method for BusManagers so that they can be notified of pipe changes (creation, destruction, changed settings).
This is necessary in OHCI and will probably be used in EHCI also to keep one endpoint construct for each pipe open instead on creating and deleting it for each transfer.
* Pseudo implemented set_pipe_policy for isochronous pipes that makes use of the new notification system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18945 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4330ef22d5cffd443a7af847124557a803d15327 25-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Added retries to the PhysicalMemoryAllocator. Memory is allocated and freed at a very high frequency, so low memory conditions shouldn't last very long.
* Added a separate thread for cleaning up EHCI transfers. This makes it possible to actually always wait for the async advance interrupt without hindering execution of transfers.
This pushes performance again and fixes the bug I introduced in the last change, that we could free yet cached descriptors when a previous async advance timed out.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17f83b219d63eae4de462d6868e7d26ad6c3949e 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Switched from the old v2 callback status codes to the new v3 codes
This means that the usb_callback_func now takes a status_t instead of a uint32 status.
Also the error codes are now different. I don't see this as a real problem in binary compatibility, as the status codes were never really documented and most drivers just assumed that a nonzero status meant an error.
Source compatibility breaks for callback functions and error defines. I fixed (hopefully) all places in the tree that are currenty included in the image and affected by the change.
* Corrected error reporting in UHCI and EHCI using the new status codes.
* Fixed a memory leak in EHCI where the async advance interrupt was not triggered in time.
* Fixed another race condition in usb_raw that could cause a crash when a device is removed while a transfer is pending.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18916 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a278a1bb7c57c701210c7ded6b5b8dca82e293f 24-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixing my previous attempt at fixing cookie handling. Device addresses cannot be used, since there may be devices with the same address across different busses. A linked list of usb_driver_cookies is maintained now that relates devices and cookies.
* Fixed endpoint halt clearing. The data toggle has to be reset when we clear a stall.
* Now using up to B_PAGE_SIZE * 4 sized buffers in EHCI. They are split automatically by the host controller. This further pushes throughput.
* Optimize memory allocator settings for the above case. Enlarging it's managed space to 1MB
* Ignore the transaction error bit in EHCI. It is only of informational character as it also idicates errors that were recovered automatically. If an unrecoverable error occures, other bits will indicate this.
* Fixed some more print formats in debug output.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7145ff1705037d7310ea0d608484279c1dabfa64 20-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented compatibility workaround for BeOS to be able to write user memory from the kernel finisher thread

This fixes crashing of the USB Mass Storage driver under R5. It is fully working there now.
I hope to be able to do this more cleanly under Haiku though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcc2d1b69a3c9b2a7951b894ad3e5579dcbaffa1 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented usable thread synchronisation for UHCI and EHCI.
* Cleaned interrupt handlers for both busses, too.
* Fixed memory leak of the queue head stray descriptors in EHCI.
* Fixed warnings about assigning NULL to the module flags field.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18857 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dff0c634db8e3d8210c08419fa2795a355352714 15-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented transfer finishing in EHCI
* Implemented actual length calculation in EHCI
* Implemented bulk transfers in EHCI
* Implemented queue freeing in EHCI
* Added extended buffer pointers to the EHCI structs, necessary when the controller supports 64bit
* Fixed debug output and removed warnings due to wrong print format

Control and bulk transfers are now working nicely for EHCI. This means that I can now get pictures from my camera with USB 2.0 speed. Note though that many things still are unimplemented (isochronous transfers, split transactions, interrupt transfers, queue chaches per pipe, ...). But it's certainly a nice step forward :-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18855 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f452f9dc783e647ece105a379564d9ce6a05de2b 14-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Implemented most qTD and qH functions for EHCI async transfers.
* Implementing control and bulk (async) transfers. They don't work yet though.
* Corrected the legacy support handling in EHCI
* Fixed the bit mask for total bytes in qTDs and added the data toggle bit
* Changed the boolean low speed flags to usb_speed enum that allows for low, full and highspeed

Also wrote a memory allocator that takes over memory management from the stack. It is similar to a buddy allocator. This does on the one hand remove some ugly code from the stack and is on the other hand far more scalable than the previous free list approach. This scalability is needed for proper EHCI support where buffers can go up to a size of 5 pages. The allocator is not perfect and it's memory overhead is quite high compared to the managed memory (depends on the managed block sizes), but it's quik and works well so far.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8fedfdfcf8f931cd52a6e934a5b4e0aca565cf99 30-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Rewrote some stack internals (again). Everything is now created using a parent object that shares the BusManager and Stack information to reduce individual constructors.
* Don't inherit Device and Interface from pipes anymore. The device has a default pipe member now.
* Since the parent of each Object is now known, we can send control messages using the default pipe of the device from all attached elements (pipes and interfaces).
* Fixed the generic {Set|Clear}Feature() and GetStatus() calls to include the endpoint address for pipe specific requests.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18710 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2761c5ae558dccbeb2f9f088ca1011824c823612 30-Aug-2006 Jérôme Duval <korli@users.berlios.de>

replaced with PCI.h definitions, added PCI_usb_ehci


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18704 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ffe3f107c4ae65ec52128bb36115779fe07a01c0 27-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Redisigned some of the USB Stack. Unified constructors, removed redundant functions and moved some other functions around
* Implemented the EHCIRootHub
* Reworked UHCIRootHub to be more of a utility class and moved the actual work into the UHCI BusManager
* Implemented port reset in EHCI. Ports with low and fullspeed devices are now correctly handed over to the companion host controller.

Attachs and detachs as well as port resetting / enabling works now in EHCI. Only the actual data transfers are missing thereafter ;-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01595708f3ff37e1c86f32548fc48a7a6a5d4be7 26-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Changed EHCI register access from port to memory mapped io (which is required)
* Added individual register operations for operational and capability registers
* Added resetting the host controller which appearantly actually works

Note that you shouldn't install the ehci module if you want uhci to work.
It disables the companion host controller drivers (uhci and ohci) because it takes port ownership and does not yet give it back for low and fullspeed devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e857d24ca41743874f6b3c08bb0c35f53df5763 25-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

* Adding skeleton EHCI driver. Some parts filled from the specs and the UHCI driver.
* Corrected some errors I found while reading UHCI.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18626 a95241bf-73f2-0310-859d-f6bbb57e9c96