Up to [DragonFly] / src / sys / bus / usb
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Remove some useless variables and assignments from USB code. Found-by: LLVM/Clang Static Analyzer
Remove the code which disables port status change interrupts for 1 second when one occured. It meant that event get lost or delayed until the next change leaving the port dead under some circumstances. Obtained-from: NetBSD
Expand delay macro into DELAY.
kprintf to device_printf conversion.
Nuke usb_ callout macros.
Nuke SIMPLEQ_* and logprintf.
Nuke device_ptr_t, USBBASEDEVICE, USBDEVNAME(), USBDEVUNIT(), USBGETSOFTC(), USBDEVPTRNAME() and Static with help from sed(1).
Nuke the code specific to NetBSD/OpenBSD/FreeBSD at first. I doubt anyone will update these pieces and I don't intend to review macros for all platforms. There is the chance though that I might kill something which should stay in the code in form "TODO: port it to DF". So, please review and kick me.
Rename printf -> kprintf in sys/ and add some defines where necessary (files which are used in userland, too).
Rename sprintf -> ksprintf Rename snprintf -> knsprintf Make allowances for source files that are compiled for both userland and the kernel.
Sync USB support (host controller part) with FreeBSD6. Following changes on FreeBSD-CURRENT(by firstname.lastname@example.org) are merged: ehci.c rev 1.52 ohci.c rev 1.167 uhci.c rev 1.172 usb.c rev 1.111 usbdi.h rev 1.61 "Use a different task queue for host controller and peripheral driver tasks. Since the host controllers rely on tasks to process transfer timeouts, if a synchronous transfer from a driver was invoked from a task and timed out, it would never complete because the single task thread was stuck performing the synchronous transfer so couldn't process the timeout." As of this commit, only following kernel APIs are changed: - usbd_get_string_desc() takes one more argument which returns the actual size of the string description. - usb_add_task() takes one more argument. The extra arguemnt is used to specify to which task queue the task should be added. There is two task queues defined, one for peripheral driver (USB_TASKQ_DRIVER), one for host controller (USB_TASKQ_HC). ugen(4) is adapted according to the above kernel API changes. Thank all of the folks for their work on the USB support. Tested-by: swildner@, vbd@, joerg@(1.6 backport), Max Herrgard <email@example.com> # Though VT6202 is supported by ehci(4), I still have problems with this # chip, even with the updated ehci(4).
Do a major clean-up of the BUSDMA architecture. A large number of essentially machine-independant drivers use the structures and definitions in machine-dependant directories that are really machine-independant in nature. Split <machine/bus_dma.h> into machine-depdendant and machine-independant parts and make the primary access run through <sys/bus_dma.h>. Remove <machine/bus.h>, <machine/bus_memio.h> and <machine/bus_pio.h>. The optimizations related to bus_memio.h and bus_pio.h made a huge mess, introduced machine-specific knowledge into essentially machine-independant drivers, and required specific #include file orderings to do their job. They may be reintroduced in some other form later on. Move <machine/resource.h> to <sys/bus_resource.h>. The contents of the file is machine-independant or can be made a superset across many platforms. Make <sys/bus.h> include <sys/bus_dma.h> and <sys/bus_resource.h> and include <sys/bus.h> where necessary. Remove all #include's of <machine/resource.h> and <machine/bus.h>. That is, make the BUSDMA infrastructure integral to I/O-mapped and memory-mapped accesses to devices and remove a large chunk of machine-specific dependancies from drivers. bus_if.h and device_if.h are now required to be present when using <sys/bus.h>.
Rename malloc->kmalloc, free->kfree, and realloc->krealloc. Pass 1
Remove all occurences of double semicolons at the end of a line by single ones. Submitted-by: Bill Marquette <firstname.lastname@example.org>
Remove an inappropriate crit_exit() in ehci.c and add a missing crit_exit() in kern/vfs_subr.c. Specify string IDs in vfsync_bp() so we don't get complaints on the console when the kernel is compiled with DEBUG_CRIT_SECTIONS. The missing crit_exit() in kern/vfs_subr.c was causing the kernel to leave threads in a critical section, causing interrupts to stop operating and cpu-bound userland programs to lock up the rest of the system. Reported-by: Sascha Wildner <email@example.com>, others.
Remove the thread pointer argument to lockmgr(). All lockmgr() ops use the current thread. Move the lockmgr code in BUF_KERNPROC to lockmgr_kernproc(). This code allows the lock owner to be set to a special value so any thread can unlock the lock and is required for B_ASYNC I/O so biodone() can release the lock.
- Add workarounds for dropped interrupts on VIA and ATI controllers. - Include more vendor IDs. Submitted-by: Gary <firstname.lastname@example.org> Taken-from: FreeBSD/NetBSD
Bring in some fixes from NetBSD: - Avoid NULL pointer dereference (ehci.c) - Abort quickly if we don't have a buffer in all the cases. (uhci.c) - Only do the software reset if we are dying, like we do in ohci and ehci (uhci.c) Submitted-by: Gary <email@example.com> Taken-from: NetBSD
Remove the now unused interlock argument to the lockmgr() procedure. This argument has been abused over the years by kernel programmers attempting to optimize certain locking and data modification sequences, resulting in a virtually unreadable code in some cases. The interlock also made porting between BSDs difficult as each BSD implemented their interlock differently. DragonFly has slowly removed use of the interlock argument and we can now finally be rid of it entirely.
Pass LK_PCATCH instead of trying to store tsleep flags in the lock structure, so multiple entities competing for the same lock do not use unexpected flags when sleeping. Only NFS really uses PCATCH with lockmgr locks.
* Move function types to a separate line. * Ansify function definitions. * Remove (void) casts for discarded return values. In collaboration with: Alexey Slynko <firstname.lastname@example.org>
1.101 Update code comments. 1.100 Update code comments. 1.99 DEFERRED 1.98 DEFERRED 1.97 Timeout while polling is in ms not ticks. [This should be computationally equivalent to the code that was there before, but is far simpler]. 1.96 DEFERRED - Abort race. It is unclear whether an xfer can be aborted multiple times. 1.95 DEFERRED (interrupt fixes that may still be buggy) 1.94 DEFERRED (interrupt fixes that may still be buggy) 1.93 DEFERRED (interrupt fixes that may still be buggy) 1.92 DEFERRED (interrupt fixes that may still be buggy) 1.91 NOT APPLICABLE (whitespace cleanup) 1.90 WILL NOT BE APPLIED - This rev tries to setup some sort of memory reserve but doesn't really solve any problems. A reserve is useless if it is not operated as a circular resource-limited pipeline. 1.89 Don't error out if the number of companion controllers is wrong, just complain and go ahead.
Merge the following revs from NetBSD (in an attempt to bring new material in in a more piecemeal fashion): 1.105 NOT APPLICABLE TO DRAGONFLY. This rev moved interrupt enablement to near the end of the init. DragonFly already goes even further and moves interrupt enablement into the PCI module. 1.104 Constification and variable naming cleanup. 1.103 Make sure all physical addresses are filled in the qTD even when we have a page offset. 1.102 Make sure to honor the USBD_FORCE_SHORT_XFER flag and generate an empty transfer when necessary.
Revert the very last commit to ehci.c (1.12). It was locking the system up on boot. The other portions of the Jeroen's patch set remain intact.
Synchronise with NetBSD: ehci.c: v1.74: Add suspend/resume support. v1.75: Fix typo: compolicated. v1.76: A little portability stuff (lockmgr -> usb_lockmgr) v1.78: add interrupt transfers v1.79: use DPRINTF instead of a printf ehcireg.h: 1.18: Fix EHCI_HCS_P_INDICATOR usb_port.h: NetBSD/OpenBSD specific things, lockmgr->usb_lockmgr..
Synchronise with NetBSD (some come from OpenBSD): v1.68: Adjust some silliness that was causing us to do extra work for "frame list rollover" interrupts, which we pretty much ignore. v1.69: hcpriv is not actually used here. Remove references to it. v1.71: ANSIfy. v1.72: Update printfs with accurate function names. Convert EHCI_LINK_TERMINATE using htole32(). v1.73: Fix spelling of intterupt. Use do .. while wrappers for debug print.
Place && at the right place.
Sync with NetBSD: PR/23128: Although the dma descriptors are limited to any 4G address range, the data is not, using extra area in the dma descriptors to define a 64 bit address. This is described in appendix B of the EHCI 1.0 spec from the URL in the file dev/usb/ehci.c. With a 64 bit address capable controller these upper address values must be set, the current driver does not do this.
Attempt to avoid a livelocked USB interrupt during boot by not enabling the EHCI interrupt until after all the companion controllers have been attached.
Remove spl*() calls from the bus/ infrastructure, replacing them with critical sections. Remove splusb() from everywhere, replacing it with critical sections.
Bring EHCI up-to-date with NetBSD. The most serious fixes are 1.53, 1.55, 1.56, and 1.64. revision 1.67 Fix a byte order error. (note: was already previously ported to DFly) revision 1.66 Fix an endianness problem (EHCI_NULL was being double-swapped). revision 1.65 Make one message dependent on ohcidebug, so it doesn't interfere with polled operation; e.g. when entering a root device or in DDB. revision 1.64 Further cleanup of toggle handling. Now that we use EHCI_QH_DTC, we don't need to fiddle with the TOGGLE bit in the overlay descriptor, so minimize how much we fuss with it. revision 1.63 Fix an error in a debug printf(). revision 1.62 Adjust a couple of comments to make it clear WTF is going on. revision 1.61 revision 1.60 Remove comment about the data toggle being borked. revision 1.59 As the ehci_idone() now uses the variable `epipe' unconditionally, always declare it (in other words, make this file compile w/o EHCI_DEBUG). revision 1.58 Fix a stupid bug in ehci_check_intr() that caused use to try to complete a transaction that was still running. Now ehci can handle multiple devices being active at once. revision 1.57 Oops. Remove a couple of printf()s. revision 1.56 Failure to properly mask off UE_DIR_IN from the endpoint address was causing OHCI_ED_FORMAT_ISO and EHCI_QH_HRECL to get set spuriously, causing rather interesting lossage. Suddenly I get MUCH better performance with ehci... revision 1.55 Set the data toggle correctly, and use EHCI_QTD_DTC. This fixes problems with my ALi-based drive enclosure (it works now, rather than failing to attach). Also seems to work with a GL811-based enclosure and an ASUS enclosure with a CD-RW, on both Intel and NEC controllers. Note: The ALi enclosure is currently very SLOW, due to some issue with taking too long to notice that the QTD is complete. This requires more investigation. revision 1.54 branches: 1.54.2; Michael van Elst reports his USB2 disk works stable after latest Chuck's ehci.c changes, so remove the item from TODO. revision 1.53 in ehci_softintr() when looping over the active xfers, save the next pointer before calling ehci_check_intr(), since that will free the xfer structure if the xfer is complete. revision 1.52 add list of known issues, from Lennart Augustsson and Michael van Elst revision 1.51 Use the correct wValue to get hub desriptors. Also, make wValue checks of root hub codes less strict.
Use M_INTWAIT and M_WAITOK instead of M_NOWAIT within the USB bus infrastructure. For the system to operate as expected, allocations done in this layer have to be reliable.
Add defined(__FreeBSD__) and defined(__DragonFly__) where appropriate
Get rid of PZERO. This was removed about the first of August. It probably compiled due to the preprocessor defining code out.
Get EHCI to compile. This will make USB2.0 work when 'device ehci' is specified. Note that USB2.0 support is not as good as USB1.x support, but it does appear to work with my USB2.0 external hard drive.
Bring in the entire FreeBSD-5 USB infrastructure. As of this commit my USB camera, Hard Drive, Mouse, and Sony memory key all work and I can even unplug and replug them in without crashing the port. Not all drivers and subsystems compile as of this commit, but the ones that do not are very close.