Commit Graph

228 Commits

Author SHA1 Message Date
martin 1e54487f2a Correct previous: detaching uhubN makes the bus pointer NULL 2009-05-02 22:28:41 +00:00
martin 9b2932709e If we are unlucky, during detach of child devices, after a uhub has detached,
our uhci_poll_hub callout might strike. The detaching of the uhub has left
the device member in the pipe NULL, so make sure we do not dereference it.

We could halt the callout before detaching child devices, but it this
would likely interfere with proper servicing the child devices while
they are still around.
2009-05-02 22:09:39 +00:00
ad e2c5e0a204 In this case "XXX free other data structures XXX" includes stopping and
destroying the callout.
2009-04-19 12:32:52 +00:00
bouyer dbac012ecf Make it safe to call uhci_init() from a kernel thread with interrupts
enabled:
- don't enable interrupts before calling uhci_run()
- check if the controller's interrupt is enabled in uhci_intr()
The issue is that uhci_run() may tsleep(), uhci_intr1() may be called before
uhci_run() is complete and disable it because it found it halted.

Now a uhci controller can be successfully exported to a NetBSD Xen domU :)
2009-03-06 23:40:50 +00:00
christos 9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00
bouyer efe8b350b3 Add appropriate bus_dmamap_sync() calls to uhci(4), ohci(4) and ehci(4),
as proposed on tech-kern@.
While all DMA memory used in the USB framework is mapped BUS_DMAMAP_COHERENT
(including data memory, which is memcpy'd from/to USB-private buffers),
the CPU can reorder loads or stores from/to main memory, causing the
controller to have an incoherent view of the DMA descriptors lists for a
short time. bus_dmamap_sync() should contain memory barriers that prevents
the CPU from reordering load/store. Note that BUS_DMAMAP_COHERENT is
still required for the DMA descriptor lists - these can't work properly
with software cache coherency.
This fixes "host controller process error/host controller halted" errors
I'm occasionally seeing with a umodem device on uhci on x86.
Thanks to Michael Lorenz for testing it on his O2, and Izumi Tsutsui on
his Cobalt Qube 2700.
2008-06-28 17:42:53 +00:00
drochner 94d328c85c fix selective port resume signaling (not used in normal operation,
just for correctness)
2008-06-16 10:29:41 +00:00
jmcneill 06fd33749e uhci_device_intr_done: when re-queueing, pass pipe direction to
uhci_alloc_std_chain instead of always 1 (read). ok drochner
2008-06-06 11:21:16 +00:00
bouyer 17471e2294 Fix probable cut-n-paste error: make the virtual QH link match the physical
one. The effect of this was just that the virtual list missed the
chsqh entry, it only shows up when looking at debug outputs.
2008-06-02 20:53:29 +00:00
jmcneill e09ade91de Set sc_suspend properly so we can avoid a potential HCH on resume. 2008-06-02 01:02:21 +00:00
drochner 26a4d5b843 fix argument to usb_setup_reserve() (called from USB host adapter drivers)
to be device_t consistently, from Quentin Garnier
2008-05-21 17:19:44 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
drochner fd0ded75ed split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
2008-03-28 17:14:45 +00:00
dyoung cd44c43b28 Add a method to detach child.
Cosmetic: use device_t and accessors.  Use aprint_*_dev().  Use
PMF_FN_{ARGS,CALL,PROTO}.
2008-02-22 23:04:52 +00:00
smb 585d42043e Patch from Jared McNeill to prevent USB interrupt storms on resume on
Thinkpad T61.  (Note: to prevent a very similar-seeming problem, T61
users should also install firmware 2.06 or later, according to thinkwiki.)
2008-02-13 00:52:44 +00:00
drochner d9459c5f21 share some code for USB root hub emulation which is common in the 3
host controller implementations, start with two little functions
which fake up string descriptors (which were inconststent, language
table fetching didn't interoperate with other code in the tree)
2008-02-03 10:57:11 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
kiyohara 2db72b9118 * splsoftusb, IPL_SOFTUSB, and IPL_HARDUSB defines in usbdi.h
-> the current names are confusing (didn't change other drivers)
* fix invalid memory access in usbd_transfer (kern/24636)
-> needed for this driver
* fix USB HC detach race condition (kern/32011)
-> main patch needed for this driver, sc_dying changes in other drivers
not necessary but seem right to me

Patch from Matthew Orgass.
  http://mail-index.netbsd.org/tech-kern/2007/06/26/0001.html
2007-08-15 04:00:33 +00:00
jmcneill 2a8951f91f Clear the run flag in the command register when powering down, from
FreeBSD. Makes my laptop, and hopefully others, successfully sleep. Waking
up is a different story...
2007-08-01 22:40:16 +00:00
drochner 8fd98300b1 -in root hub emulation, return a sane value as language code
-constify "methods" tables and (partly) descriptor templates
2007-02-26 13:26:45 +00:00
mlelstv 1fb16b2557 The diagnostic code doesn't track busy_free correctly when a
device gets removed. However, when the diagnostic check fails,
it is much better to complete the free operation than to abort
it, because this just causes an infinite loop.
2007-02-10 07:52:29 +00:00
drochner 60e1a2a1cb Kill the "bus powered" bit in the configuration descriptor. This doesn't
exist in newer spec revisions, and is recommended to be set to 1.
So call it _MBO and also use it in the fake root hub descriptors, just
for sanity, even if nothing ever looks at it.
2007-01-19 22:46:21 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
joerg 8934eeb830 Split the USB task queue into two parts, one for normal device tasks and
one for tasks of the host controllers. This is needed for drivers like
ural(4) that want to do synchronous USB transfers from the task handler.
Before the split timeouts could not be handled correctly as the task
thread was still blocked. From FreeBSD.
2006-10-31 20:43:31 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos 894062c90e Coverity CID 3061: Add KASSERT (from Arnaud Lacombe) 2006-10-03 18:21:53 +00:00
jmcneill ce9801710e Only display "interrupt while not running ignored" if DIAGNOSTIC is set, as
whenever this happens, so many messages are spewed to the screen from the
kernel that the system is effectively useless. Hardly ignored :-)
2006-09-25 22:15:15 +00:00
jmcneill f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +00:00
christos 40be650c67 add missing initializers. 2006-09-03 21:05:01 +00:00
christos 224c7c746b add missing initializer. 2006-09-03 21:03:11 +00:00
gdamore a5c89047c0 Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.)  This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.
2006-06-19 15:44:33 +00:00
mrg 0337fbac37 make [OU]READ[124]() real inline functions instead of macros. 2006-05-12 01:25:00 +00:00
christos 2fa8f13ac7 Coverity CID 1133: Abort quickly if we don't have a buffer in all the cases. 2006-04-14 16:31:27 +00:00
christos c7ffec83be Only do the software reset if we are dying, like we do in ohci and ehci.
Pointed out by SAITOH Masanobu
2006-03-31 17:31:13 +00:00
augustss 94cd2a4171 Use polling while shutting down the host controller since interrupts
cannot be trusted at this point.  From Iain Hibbert <plunky@rya-online.net>.
2006-03-05 23:12:58 +00:00
perry 3d4ed1fbc7 __inline__ -> inline 2005-12-24 23:41:33 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
augustss 7dd02394b7 Make sure we don't enable host controller interrupts until all
initialization is finished.
2005-07-18 11:08:00 +00:00
christos a9cf21849d - const poisoning
- eliminate variable shadowing
2005-05-30 04:21:39 +00:00
augustss 5b3acf742e Fix a race condition in xfer abort. Derived from a FreeBSD patch.
An xfer could be aborted twice (which means that the second abort might
access deallocated memory).  This happened when an xfer timed out and
the timeout started an abort.  While that abort was taking place the
xfer could be cancelled (usually by closing the pipe), causing a second
abort to begin.
This is now handled by having flags indicating the abort state of an xfer.

Hopefully this will fix the occasional crashes when printing.
2005-04-30 14:38:40 +00:00
skrll e71eebcad0 Complete the interrupt output transfer support copy from FreeBSD, but
remove the incorrect access to the bulk part of the union.

Reviewed and OK'ed by Lennart.
2005-04-29 19:15:13 +00:00
skrll 5597345e50 KNF and s/a an/an/ 2005-04-27 07:47:25 +00:00
mycroft 2d562a01e2 Copyright maintenance. 2005-03-02 11:37:27 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
fvdl a3cea30b50 Implement an USB memory reserve. Allocate some memory per host controller
in the wanted bus_dma space. If an allocation fails during operation
(i.e. when hotplugging an umass device), fall back to using the reserve.

The amount can be configured as USB_MEM_RESERVE. The default value is
256k.

Ideally, there would be a way to steal pages in the desired area from
UVM, but that's far more complicated, and this is not intrusive, plus
it works.
2004-12-21 16:41:24 +00:00
augustss d32a749096 Allow strings descriptor 0 to be fetched. It's the default language index. 2004-10-26 20:46:16 +00:00
drochner 7f3933adae typo in comment 2004-07-22 18:45:40 +00:00
mycroft c206d4cf15 hcpriv is not actually used here. Remove references to it. 2004-07-17 20:12:02 +00:00
mycroft ac575d2a58 Make one message dependent on ohcidebug, so it doesn't interfere with polled
operation; e.g. when entering a root device or in DDB.
2004-06-29 03:56:04 +00:00