Commit Graph

42 Commits

Author SHA1 Message Date
Warner Losh
2deae8fa2f More removing compatibility macros.
md5 still the same.

"Dave, stop.  I feel my mind slipping away." -- hal
2006-09-07 00:06:42 +00:00
Warner Losh
56635f6bd3 s/Static/static/g
s/device_ptr_t/device_t/g

No md5 changes in the .o's

# Note to the md5 tracking club: $FreeBSD$ changes md5 after every commit
# so you need to checkout -kk to get $FreeBSD$ instead of the actual value
# of the keyword.
2006-09-06 23:44:25 +00:00
Ian Dowse
368030a87a Use the limited scatter-gather capabilities of ehci, ohci and uhci
host controllers to avoid the need to allocate any multi-page
physically contiguous memory blocks. This makes it possible to use
USB devices reliably on low-memory systems or when memory is too
fragmented for contiguous allocations to succeed.

The USB subsystem now uses bus_dmamap_load() directly on the buffers
supplied by USB peripheral drivers, so this also avoids having to
copy data back and forth before and after transfers. The ehci and
ohci controllers support scatter/gather as long as the buffer is
contiguous in the virtual address space. For uhci the hardware
cannot handle a physical address discontinuity within a USB packet,
so it is necessary to copy small memory fragments at times.
2006-05-28 05:27:09 +00:00
Ian Dowse
a3d327674a It was possible to have two threads concurrently aborting the same
transfer, which lead to panics or page faults. For example if a
transfer timed out, another thread could come along and attempt to
abort the same transfer while the timeout task was sleeping in
the *_abort_xfer() function.

Add an "aborting" flag to the private transfer state in each host
controller driver and use this to ensure that the abort is only
executed once. Also prioritise normal abort requests over timeouts
so that the callback is always given a status of USB_CANCELLED even
if the timeout-initiated abort began first.

The crashes caused by this bug were mainly reported in connection
with lpd printing to a USB printer.

PR:	usb/78208, usb/78986
2005-03-19 19:08:46 +00:00
Warner Losh
ad3142eda4 MFp4:
sc_child isn't used on FreeBSD, so ifdef it out in a way that is
NetBSD mergeable.
2005-01-11 07:34:13 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Ian Dowse
f50033ff2e Make the USB subsystem unloadable and detachable, though currently
a significant amount of memory may be leaked each time a host
controller is detached.
2004-08-02 15:37:35 +00:00
John-Mark Gurney
57499a32b1 make allocation of the necessary data structures most efficent by using
a full page instead of only part of a page.

Reviewed by:	joe
2003-07-15 23:19:49 +00:00
John-Mark Gurney
c97325b0c8 WARNING: white space diff
This code reduces the number of trailing white space to be more in line
w/ NetBSD.  I don't regenerate usbdevs, saving that for when it really
changes.
2003-07-04 01:50:39 +00:00
Josef Karthauser
fe74650816 In rev 1.51 of usb_port.h I switched over to using the USB_USE_SOFTINTR
code path to fix a bug in the non USB_USE_SOFTINTR path that caused
the usb bus to hang and generally misbehave when devices were unplugged.
In the process though it also reduced the throughput of usb devices because
of a less than optimal implementation under FreeBSD.

This commit fixes the non USB_USE_SOFTINTR code in uhci and ohci
so that it works again, and switches back to using this code path.

The uhci code has been tested, but the ohci code hasn't.  It's
essentially the same anyway and so I don't envisage any difficulties.

Code for uhci submitted by:	Maksim Yevmenkin <myevmenk@exodus.net>
2002-09-30 17:50:18 +00:00
Josef Karthauser
b146ba499d MFNetBSD: uhcireg.h (1.15), uhcivar.h (1.33)
date: 2002/02/11 11:41:30;  author: augustss;
    Switch to new abort mechanism.
2002-04-07 18:06:34 +00:00
Josef Karthauser
a011c2e7a8 MFNetBSD: Update many URLs. 2002-04-01 21:13:22 +00:00
Josef Karthauser
174ea84839 Use ANSI prototypes and declarations.
Update $NetBSD$ idents to better reflect reality.
2002-04-01 19:01:09 +00:00
Josef Karthauser
3ede2e88ea Merge from NetBSD:
ohcivar.h (1.22), uhcivar.h (1.29):
	============================================================
	date: 2000/04/25 09:20:55;  author: augustss;
	Move the size of the mapped bus_space region into the bus
	independent softc.
	============================================================

ohci.c (1.88), uhci.c (1.112):
	============================================================
	date: 2000/04/25 14:28:13;  author: augustss;
	Insert (very conservative!) bus_space_barrier() calls at
	all register accesses.
	The bus_space(9) man page says you've gotta have them...
	============================================================
2002-03-16 12:44:21 +00:00
Josef Karthauser
cdd493aa00 Bump some $NetBSD$ idents for patches that have already been previously
ported.
2002-03-16 12:24:00 +00:00
Josef Karthauser
5a11d73afa Huge merge from NetBSD:
usbdi.c (1.61):
	===================================================================
	revision 1.61
	date: 2000/01/31 20:13:07;  author: augustss;  lines: +20 -4
	Change the way the HC done method is invoked a little.
	===================================================================

usbdi.c (1.65):
	===================================================================
	revision 1.65
	date: 2000/03/08 15:34:10;  author: augustss;  lines: +4 -2
	Get the status right when a polled transfer times out.
	===================================================================

ohci.c (1.79), uhci.c (1.89), uhcivar.h (1.24), usb_port.h (1.22),
usbdivar.h (1.48):
	===================================================================
	date: 2000/03/23 07:01:46;  author: thorpej;
	New callout mechanism with two major improvements over the old
	timeout()/untimeout() API:
	- Clients supply callout handle storage, thus eliminating problems of
	  resource allocation.
	- Insertion and removal of callouts is constant time, important as
	  this facility is used quite a lot in the kernel.

	The old timeout()/untimeout() API has been removed from the kernel.
	===================================================================

uhci.c (1.80), usbdi.c (1.66):
	===================================================================
	date: 2000/03/23 18:59:10;  author: thorpej;
	Shake out some bugs from the callout changes.
	===================================================================

ohci.c (1.80), uhci.c (1.91), uhcivar.h (1.25), usb_port.h (1.23),
usbdi.c (1.67), usbdivar.h (1.49):
	===================================================================
	date: 2000/03/24 22:03:30;  author: augustss;
	Some cleanup and renaming of the callouts used in USB drivers.
	===================================================================

uhci.c (1.92), uhcivar.h (1.26):
	===================================================================
	date: 2000/03/24 22:57:58;  author: augustss;
	Two major changes:

	  Make each xfer have its own intr_info.  This is necessary if we want
	  to queue multiple xfers on an endpoint.  This should get rid of the
	  (mostly harmless) DIAGNOSTICs about intr_infos (not) being done.

	  Change (again!) how xfers are aborted.  Aborting a TD is a nightmare
	  on the braindead UHCI controller.  (Unless you stop the HC, thereby
	  losing isoc traffic.)  Hopefully I got it right this time.
	===================================================================

usbdivar.h (1.50):
	===================================================================
	revision 1.50
	date: 2000/03/25 00:10:19;  author: augustss;  lines: +4 -2
	GC an unsued field and add some DIAGNOSTIC in xfer.
	===================================================================

ums.c: Use the callout functions instead of the timeout ones.

uhci.c (1.93):
	===================================================================
	revision 1.93
	date: 2000/03/25 00:11:21;  author: augustss;
	lines: +26 -1
	Add more DIAGNOSTIC when aborting isoc.
	===================================================================

uhci.c (1.94), usbdivar.h (1.51):
	===================================================================
	date: 2000/03/25 07:13:05;  author: augustss;
	More DIAGNOSTIC.
	Initialize a callout handle I forgot.
	===================================================================

uhci.c (1.95):
	===================================================================
	revision 1.95
	date: 2000/03/25 07:23:12;  author: augustss;
	Exp;  lines: +24 -7
	Improve uhci_dump_ii().
	===================================================================

ohci.c (1.81), uhci.c (1.96), uhcivar.h (1.27), usb_subr.c (1.68),
usbdi.c (1.68), usbdivar.h (1.52):
	===================================================================
	date: 2000/03/25 18:02:33;  author: augustss;
	Rename and move around callout handles to make it more sane.
	Add some DIAGNOSTIC.
	Fix buglet in isoc abort on UHCI.
	===================================================================

uhci.c (1.98):
	===================================================================
	revision 1.98
	date: 2000/03/27 07:39:48;  author: augustss;  lines: +12 -4
	Make it compile without DIAGNOSTIC.
	===================================================================

uhci.c (1.99):
	===================================================================
	revision 1.99
	date: 2000/03/27 08:01:09;  author: augustss;  lines: +1 -5
	Remove some debug nonsense.
	===================================================================

uhci.c (1.100):
	===================================================================
	revision 1.100
	date: 2000/03/27 09:41:36;  author: augustss;  lines: +13 -3
	Don't mess with QH in bulk abort for the moment.
	===================================================================

uhci.c (1.102):
	===================================================================
	revision 1.102
	date: 2000/03/27 22:42:57;  author: augustss;  lines: +66 -26
	Be a little more careful when aborting.
	Preallocate some TDs for large buffers.
	===================================================================

uhci.c (1.103):
	===================================================================
	date: 2000/03/28 09:47:10;  author: augustss;  lines: +11 -1
	Another patch for xfer abort...
	XXX The current xfer queueing and aborting semantics should really
	XXX be changed.  It cannot be implemented in a sane way on UHCI.
	XXX One day when I have lots of time I'll redesign it...
	===================================================================

uhci.c (1.104): Correct a debug message.
uhci.c (1.105): Be more defensive in a DIAGNOSTIC test.

uhci.c (1.106):
	===================================================================
	revision 1.106
	date: 2000/03/29 01:49:13;  author: augustss;  lines: +14 -309
	*SIGH*  Revert back to the old method of aborting xfers.
	I had tested the new stuff for two months now, but as soon as I commited
	it the problems started to appear.  Murphy, no doubt...
	===================================================================

usb_subr.c (1.70), usbdi.c (1.71), usbdivar.h (1.53):
	===================================================================
	revision 1.70
	date: 2000/03/29 01:45:20;  author: augustss;  lines: +2 -1
	Do not accept new xfers for queuing while a pipe is aborting.
	===================================================================
2002-03-16 12:06:01 +00:00
Josef Karthauser
baf3f0817e Reduce the diffs between NetBSD and our version where appropriate
(comments, etc.)
2002-01-26 13:08:57 +00:00
Josef Karthauser
ed98caba5f Merge from NetBSD:
uhci.c:	-r1.82
    uhcivar.h:	-r1.22

	date: 2000/01/26 10:04:39;  author: augustss;  state: Exp;
	Try to avoid accessing the HC if it is dead.  Suggested by mycroft.
2002-01-21 03:35:55 +00:00
Josef Karthauser
8e65c31988 Merge from NetBSD:
uhci.c:	-r1.123 (and a tiny bit of -r1.92)
    uhcivar.h:	-r1.32

	date: 2000/08/13 16:18:09;  author: augustss;  state: Exp;
	Implement what in Intel-speech is known as "bandwidth
	reclamation".  It means that we continously poll USB devices
	that have a pending transfer instead of polling just once
	every ms.  This speeds up some transfers at the expense of
	using more PCI bandwidth.
2002-01-20 20:12:25 +00:00
Nick Hibma
9bd863570a Save and restore the registers SOF and FRAMENUMBER on suspend. In some
cases the registers are not correctly set on resume.

This solves the problem of USB failing after resuming a machine.

Submitted by:	mike+fbsd@medianstrip.net
PR:		18261
2000-08-07 00:04:53 +00:00
Nick Hibma
4f04f78215 Remove __P prototypes to reduce diffs between the NetBSD and FreeBSD
versions.
2000-07-17 18:41:20 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Nick Hibma
128aa3af3c Change Lennart's e-mail address. 2000-05-14 16:43:10 +00:00
Nick Hibma
8feb725eb1 Add the fields needed to store the cookies. 2000-05-07 20:17:30 +00:00
Nick Hibma
31bfa89e41 Get rid of the last remnants of powerhook abuse. 2000-03-18 14:54:54 +00:00
Nick Hibma
330dc9152d powerhooks no longer used 2000-03-15 22:15:21 +00:00
Nick Hibma
341777d004 Add support for DEVICE_SUSPEND, DEVICE_RESUME and DEVICE_SHUTDOWN
methods for USB devices.

However: with none of the devices I have here suspend seems to work
properly.  This is probably a bug in uhci_power which I still have to
look at.

Prodded and pushed by:  Christopher Masto <chris@netmonger.net>
2000-01-20 22:24:35 +00:00
Bill Paul
a6d9a40e81 More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
  following improvements:
        o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
          quirk. This allows drivers to specify busy waiting only for
          certain transfers (namely control transfers for reading/writing
          registers and stuff).
        o New USBD_FORCE_SHORT_XFER flag can be used to deal with
          devices like the ADMtek Pegasus that sense the end of bulk OUT
          transfers in a special way (if a transfer is exactly a multiple
          of 64 bytes in size, you need to send an extra empty packet
          to terminate the transfer).
        o usbd_open_pipe_intr() now accepts an interval argument which
          can be used to change the rate at which the interrupt callback
          routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
          value specified in the device's config data, but drivers can
          override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
  control transfers. We no longer force the non-tsleep hack for
  bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
  need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
  usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
  when a device has been detached, and use this flag to perform
  tests to prevent the drivers from trying to do control transfers
  if this is the case. This is necessary because calling if_detach()
  with INET6 enabled will eventually result in a call to the driver's
  ioctl() routine to delete the multicast groups on the interface,
  which will result in attempts to perform control transfers. (It's
  possible this also happens even without INET6 support enabled.) This
  is pointless since we know that if the detach method has been called,
  the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
  to initialize the device states without trying to close and re-open the
  pipes. This is partly because we don't want to frob things at interrupt
  context, but also because this doesn't seem to work right and I don't
  want to panic the system just because a USB device may have stopped
  responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
  transfer is needed. Unfortunately, the design of the chip makes it hard
  to get this exactly right. Hopefully, this will go away once either
  Nick or Lennart finds the bug in the uhci driver that makes this ugly
  hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
Nick Hibma
3241be7550 Synchronisation with NetBSD as of 1999/11/16:
Cleaning up the code:
- Declare many functions static
- Change variable names to make them more self explanatory
- Change usbd_request_handle -> usbd_xfer_handle
- Syntactical changes
- Remove some unused code
- Other KNF changes

Interrupt context handling
- Change delay to usbd_delay_ms were possible (takes polling mode into
  account)
- Change detection mechanism for interrupt context

Add support for pre-allocation DMA-able memory by device driver

Add preliminary support for isochronous to the UHCI driver (not for OHCI
yet).

usb.c, uhci.c, ohci.c
- Initial attempt at detachable USB host controllers
- Handle the use_polling flag with a lttle more care and only set it if
we are cold booting.

usb.c, uhci.c ohci.c, usbdi.c usbdi_util.c usb_subr.c
- Make sure an aborted pipe is marked as not running.
- Start queued request in the right order.
- Insert some more DIAGNOSTIC sanity checks.
- Remove (almost) unused definitions USBD_XFER_OUT and USBD_XFER_IN.

usb.c, usb_subr.c
- Add an event mechanism so that a userland process can watch devices
  come and go.

ohci.c
- Handle the case when a USB transfer is so long that it crosses two
  page (4K) boundaries.  OHCI cannot do that with a single TD so we make
  a chain.

ulpt.c
- Use a bigger buffer when transferring data.
- Pre-allocate the DMA buffer.  This makes the driver slightly more
  efficient.
- Comment out the GET_DEVICE_ID code, because for some unknown reason it
  causes printing to fail sometimes.

usb.h
- Add a macro to extract the isoc type.
- Add a macro to check whether the routine has been entered after splusb
  and if not, complain.

usbdi.c
- Fix a glitch in dequeueing and aborting requests on interrupt pipes.
- Add a flag in the request to determine if the data copying is done by
  the driver or the usbdi layer.
1999-11-17 22:33:51 +00:00
Nick Hibma
8c895d718b Major synchronisation with the NetBSD USB stack:
- Some cleanup and improvements in the uhci and ohci drivers
- Support for plugging and unplugging devices improved
- Now available is bulk transport over OHCI controllers
- Resume and suspend have been temporarily been disabled again.  Proper
  support for it is available in the uhci.c and ohci.c files but I have
  not yet spent the brain cycles to use it.
- OpenBSD now uses the USB stack as well
- Add FreeBSD tags
1999-10-07 19:26:38 +00:00
Nick Hibma
0b77022752 Reset the UHCI controller when the device comes back from suspend.
This should be replaced by proper support for suspend one day (global
suspend).

Submitted-by:   Christopher Masto <chris@netmonger.net>
1999-08-23 21:00:08 +00:00
Nick Hibma
6d38342e16 Add comments, change variable names to make them consistent (r -> err,
timo_handle -> timeout_handle, p -> pipe, *pipe -> *rpipe, etc.)
1999-07-25 18:54:22 +00:00
Nick Hibma
f018dbb4d9 Clean up parts of struct shared between NetBSD and FreeBSD 1999-05-03 23:12:49 +00:00
Peter Wemm
6182fdbda8 Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic.
Most old drivers compile and run without modification via 'compatability
shims' to enable a smoother transition.  eisa, isapnp and pccard* are
not yet using the new resource manager.  Once fully converted, all drivers
will be loadable, including PCI and ISA.

(Some other changes appear to have snuck in, including a port of Soren's
 ATA driver to the Alpha.  Soren, back this out if you need to.)

This is a checkpoint of work-in-progress, but is quite functional.

The bulk of the work was done over the last few years by Doug Rabson and
Garrett Wollman.

Approved by:	core
1999-04-16 21:22:55 +00:00
Nick Hibma
67aa00a71b 1) Make debugging more selective.
2) create function usbd_errstr which turns a usbd_status into a sensible
   error message
3) Change the printf in DPRINTF to logprintf which is a define for
   log(KERN_DEBUG, x)
1999-04-11 20:50:33 +00:00
Nick Hibma
2115c3404f Remove unit from struct. Not used anymore. 1999-04-11 16:22:57 +00:00
Nick Hibma
235dddd4ea Textual changes 1999-01-22 00:51:12 +00:00
Nick Hibma
a73f7cf01f Major synchronisation with NetBSD USB code 1999-01-07 23:07:57 +00:00
Nick Hibma
6fef2c2c27 Added Id to all files 1998-12-14 09:32:25 +00:00
Nick Hibma
97797dc959 Various bug fixes:
1) Removed 'emulation' of bitmaps in printfs, FreeBSD seems to have caught
  up on that one
2) Fixed a few bugs in the timeout/timo timeout variables
3) First attempt at fixing a bug mentioned by Kazu: uhci_run is not able
  start/stop his USB host on his motherboard.
1998-12-09 23:36:15 +00:00
Nick Hibma
0cec007c5f Initial commit of ported NetBSD USB stack 1998-11-26 23:13:13 +00:00