History log of /netbsd-current/sys/dev/usb/ugen.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.177 29-Mar-2024 thorpej

ugen and ugenif share the same /dev/ugenN.xx namespace in such a way
that the device unit number does not necessarily match the /dev/ugenN.xx
unit number (N). If you ONLY have ugen devices, it happens to work out
and devpubd scripts can be extremely naive. If you ONLY have ugenif
devices, it also happens to work out, but your devpubd scripts have to
slightly more informed. If you have a mix of ugen AND ugenif devices,
though, you're pretty much out of luck.

So, this change adds a "ugen-unit" device property which devpubd scripts
can query to determine which /dev/ugenN.xx nodes a given ugen or ugenif
device is using.


# 1.176 26-Mar-2024 thorpej

Define a "flags 1" config directive for ugenif, which is similar to ugen's,
but rather forces the ugenif to match at the *lowest* match priority rather
than the highest. This allows ugenif to claim only otherwise unclaimed
interfaces.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.175 06-Nov-2023 hannken

Undo the DPRINTFN part of the last commit. It breaks i386 at least
when KERNHIST_LOG casts the pointer to uintmax_t.

Kernel ALL/i386 compiles again.


# 1.174 10-Oct-2023 simonb

Debug printf tidy up, KNF comma,space nits.


# 1.173 31-Jul-2023 christos

Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.176 26-Mar-2024 thorpej

Define a "flags 1" config directive for ugenif, which is similar to ugen's,
but rather forces the ugenif to match at the *lowest* match priority rather
than the highest. This allows ugenif to claim only otherwise unclaimed
interfaces.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.175 06-Nov-2023 hannken

Undo the DPRINTFN part of the last commit. It breaks i386 at least
when KERNHIST_LOG casts the pointer to uintmax_t.

Kernel ALL/i386 compiles again.


# 1.174 10-Oct-2023 simonb

Debug printf tidy up, KNF comma,space nits.


# 1.173 31-Jul-2023 christos

Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.175 06-Nov-2023 hannken

Undo the DPRINTFN part of the last commit. It breaks i386 at least
when KERNHIST_LOG casts the pointer to uintmax_t.

Kernel ALL/i386 compiles again.


# 1.174 10-Oct-2023 simonb

Debug printf tidy up, KNF comma,space nits.


# 1.173 31-Jul-2023 christos

Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-0-RC1 netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.174 10-Oct-2023 simonb

Debug printf tidy up, KNF comma,space nits.


# 1.173 31-Jul-2023 christos

Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.173 31-Jul-2023 christos

Don't call versioned stuff "old". Follow the naming convention for versioning
and name them after the last version of the OS they appeared on.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.172 20-Jul-2023 mrg

various debug updates for some usb drivers

- several new *_DEBUG_DEFAULT options that allow usb debug values to
be set to a default that is non-zero:
EHCI_DEBUG_DEFAULT, UGEN_DEBUG_DEFAULT, URTWN_DEBUG_DEFAULT,
UMS_DEBUG_DEFAULT, and USB_DEBUG_DEFAULT
- ugen debug uses fewer usbhist lines for the same info
- ums.c converted from printf() to usbhist


Revision tags: netbsd-10-base
# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.171 23-Oct-2022 riastradh

ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


# 1.170 23-Oct-2022 skrll

Fix USBDEBUG build on ILP32


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.169 21-Oct-2022 mrg

ugen(4): convert to USBHIST style debugging.


Revision tags: bouyer-sunxi-drm-base
# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.168 26-Sep-2021 thorpej

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.167 07-Sep-2021 riastradh

ugen(4): Keep fields null when not allocated; kassert on close.

This avoids silent leaks in DIAGNOSTIC kernels.


# 1.166 07-Sep-2021 riastradh

ugen(4): Use cv_wait loop for draining reference count on detach.

- Should be no need to use cv_timedwait because all users have now
been given a wakeup (previously writers were not, so we relied on
the timeouts to work out).

- Need to run this in a loop or else a spurious wakeup could cause us
to free data structures before the users have actually drained.


# 1.165 07-Sep-2021 riastradh

ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer. So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


# 1.164 07-Sep-2021 riastradh

ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification. We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.


# 1.163 07-Sep-2021 riastradh

ugen(4): Ensure we close pipes on detach.

Calling vdevgone has the effect of VOP_REVOKE -> spec_node_revoke ->
VOP_CLOSE -> spec_close -> cdev_close -> ugenclose, but:

(a) the flags passed to VOP_CLOSE don't have FREAD or FWRITE, and
(b) ugenclose has no effect when sc_dying is set anyway.

So create another path into the close logic, ugen_do_close. We have
to do this in detach _after_ the references have drained because we
may free buffers that other users are still using while the reference
count is nonzero.


# 1.162 07-Sep-2021 riastradh

ugen(4): Refuse non-forced detach with EBUSY if endpoints are open.

Sprinkle some comments.


# 1.161 07-Sep-2021 riastradh

ugen(4): Prevent ugenopen while ugen_set_config is in progress.

(except on the control endpoint)

Although we hold the kernel lock (which we should eventually change),
we may sleep in usbd_set_config_no at which point ugenopen might
happen and start making use of endpoint state which we'll stomp all
over once usbd_set_config_no returns. Setting sc_is_open[endpt]
while we wait prevents this.


# 1.160 07-Sep-2021 riastradh

ugen(4): Fix race of ugenopen against itself.

Even though we have the kernel lock held, a sleep during kmem_alloc
or usbd_open_pipe could allow another ugenopen to run concurrently
before we have marked the endpoint opened.

To avoid this, mark the endpoint open immediately (while we still
have the kernel lock held and before any sleeps, so there is no
TOCTOU error here), and then revert on unwind in the event of
failure.


# 1.159 07-Sep-2021 riastradh

ugen(4): Sprinkle KERNEL_LOCKED_P assertions around sc_is_open.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


# 1.157 18-Aug-2020 riastradh

branches: 1.157.2;
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.158 18-Dec-2020 thorpej

Use sel{record,remove}_knote().


Revision tags: thorpej-futex-base
# 1.157 18-Aug-2020 riastradh

Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.157 18-Aug-2020 riastradh

Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77259@syzkaller.appspotmail.com


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.156 16-Aug-2020 riastradh

Fix sloppy mistakes in previous.

1. Give the offset of the rbnode, not some other random members to
overwrite with garbage.

2. Don't try to unlock a mutex at NULL.

3. Make sure all paths out after ugenif_acquire go via
ugenif_release.


# 1.155 16-Aug-2020 riastradh

Share unit numbering for ugen and ugenif.

This way putting ugenif in kernel config actually works to wire it to
the /dev/ugenN.MM device nodes in userland.

Not a fully fleshed out solution to the ugen problem -- there's no
way for a userland driver to kick out a kernel driver and take over,
but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2
but ugen(4), with pcscd(8), for Yubikey CCID.

Fix various MP-safety issues while here (still not MPSAFE, but more
progress).


# 1.154 16-Aug-2020 riastradh

Convert DIAGNOSTIC prints to KASSERTs.


# 1.153 16-Aug-2020 riastradh

Hold the lock over access to the data structures it covers.

Still not MPSAFE, but progress.


# 1.152 16-Aug-2020 riastradh

Remove UGEN_ASLP microoptimization.

cv_signal already has this microoptimization.

While here, make the lock cover the relevant things we're issuing
cv_signal about -- progress toward real MP-safety.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.151 21-Mar-2020 skrll

KNG


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.150 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.149 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

branches: 1.146.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.148 11-Dec-2019 bouyer

reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[ 303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.147 01-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.146 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2; 1.139.4;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.146 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


Revision tags: isaki-audio2-base
# 1.145 01-Mar-2019 pgoyette

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.


# 1.144 07-Feb-2019 skrll

Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}

Really should loop on conditon.


# 1.143 29-Jan-2019 pgoyette

Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.


# 1.142 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.141 08-Nov-2018 manu

Enfore USB timeout on ugen(4) write operations


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.140 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.139 05-Mar-2018 ws

branches: 1.139.2;
Fix last:

Since config(1) could not distinguish between device and
interface attachments, it was generating only the latter.
Thus devices without their own driver wouldn't match the
ugen driver anymore.

Fix this by using a different device name for interface attachments.


# 1.138 20-Feb-2018 ws

Attach uftdi to each interface found in the device separately.
This allows for other drivers (e.g. ugen) to attach to some of
the other interfaces.

Allow ugen to attach only to some of the interfaces found in a device.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

branches: 1.134.10;
KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.137 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202
# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.136 25-Oct-2017 maya

Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


# 1.135 05-Sep-2017 mrg

remove redundant checks against sc and sc->sc_dying.
check sc_dying in more places.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.134 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.133 23-Apr-2016 skrll

Merge nick-nhusb

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


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.132 13-Mar-2016 skrll

KNF


# 1.131 22-Feb-2016 skrll

Provide a ugen_clear_endpoints declaration


# 1.130 22-Feb-2016 skrll

Only clear the endpoint information in ugen_set_interface only if setting
the new altno suceeds.

Avoids the null de-ref in PR/50597 and PR/50810


# 1.129 21-Feb-2016 skrll

Remove always true conditional


# 1.128 20-Feb-2016 skrll

One more s/0/NULL/


# 1.127 20-Feb-2016 skrll

s/0/NULL/


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.126 20-Sep-2014 gson

branches: 1.126.2;
Include opt_usb.h to make "options UGEN_DEBUG" work.


# 1.125 05-Sep-2014 matt

Don't nest structure definitions.


Revision tags: netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.124 25-Jul-2014 dholland

branches: 1.124.2; 1.124.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.123 16-Mar-2014 dholland

branches: 1.123.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.122 05-Jan-2013 christos

branches: 1.122.2;
- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7
# 1.121 04-Dec-2012 riastradh

Fix some error branches in ugen.

There remains some cruft that should perhaps be better organized, but
at least this should reduce some memory leaks in screw cases, and at
least this does fix panics when plugging in and unplugging a USB
device with a botched configuration (a beaglebone with a hosed sd
card).


Revision tags: yamt-pagecache-base6
# 1.120 10-Jun-2012 mrg

branches: 1.120.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.119 25-Apr-2012 dholland

Remove duplicate break. PR 46368 from Henning Petersen.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6
# 1.118 06-Mar-2012 mrg

pull down from usbmp branch:

- rename usb_detach_{wake,waitup}() to usb_detach_{wake,waitup}old()
- use some c99 struct .initialisers


Revision tags: jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.117 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base2 netbsd-6-base
# 1.116 23-Dec-2011 jakllsch

Revert previous due to active usbmp branch(es).


# 1.115 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base
# 1.114 01-Dec-2011 jakllsch

branches: 1.114.2;
Don't double clfree() when closing an interrupt endpoint.
From Geoff C. Wing in PR#37934.


# 1.113 25-Nov-2011 jakllsch

Prevent poll and kqueue on the control endpoint.
Addresses PR#33352.

(The control endpoint doesn't support pipes, so this would be of dubious
usefulness even if it didn't expose bugs.)


# 1.112 20-Nov-2011 gavan

Implement timeouts when blocking the calling process with tsleep.

Fixes PR kern/33452


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 rmind-uvmplock-base
# 1.111 03-Nov-2010 dyoung

branches: 1.111.8;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.110 27-Jul-2010 jakllsch

Tune ugen(4) isochronous parameters to better support high speed pipes.

Fixes PR#43159.

Justification:

UGEN_NISORFRMS, previously 4, is now 8 because that's the number of
microframes per frame on a high speed bus. This allows data to be
transfered every microframe if necessary.

UGEN_NISOREQS, previously 6, is now 4. This is harder to justify,
but I didn't think the total number of buffer frames needed to be
much more than it was.

UGEN_NISOFRAMES, previously 500, is now (UGEN_NISORFRMS * UGEN_NISOREQS)
(32 with values as above). This is all the more we've actually used.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.109 19-Feb-2010 pooka

branches: 1.109.2;
Replace USB_GET_SC() instances with USB_GET_SC_OPEN(). The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it. Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic. I have no idea what the "whatever reason"
might be.


Revision tags: uebayasi-xip-base
# 1.108 24-Dec-2009 jakllsch

branches: 1.108.2;
defflag UGEN_BULK_RA_WB is no more.
Hi pooka


# 1.107 23-Dec-2009 pooka

unifdef -D UGEN_BULK_RA_WB

Default behaviour unchanged, the feature must still be explicitly
enabled for a ugen fd.


Revision tags: matt-premerge-20091211
# 1.106 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.105 24-Sep-2009 pooka

Add a simple kvm integer toggle to control ugen priority and override
the autoconf flags value. This helps to change the priority at
runtime. (XXX: is there a better way to do this?)


# 1.104 24-Sep-2009 pooka

ugen_get_cdesc() can return NULL. When this happens, return the
karmic EINVAL error instead of crashing.


# 1.103 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 20-Mar-2009 drochner

Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


Revision tags: nick-hppapmap-base2
# 1.101 20-Jan-2009 drochner

branches: 1.101.2;
Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.


Revision tags: mjf-devfs2-base
# 1.100 11-Jan-2009 cegger

make this compile


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.99 24-May-2008 cube

branches: 1.99.6; 1.99.8;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.98 28-Apr-2008 martin

branches: 1.98.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.97 01-Mar-2008 rmind

branches: 1.97.2; 1.97.4;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.96 24-Dec-2007 smb

branches: 1.96.2; 1.96.6;
Add missing call to pmf_deregister() in the USB_DETACH routine.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.95 09-Dec-2007 jmcneill

branches: 1.95.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.94 05-Dec-2007 pooka

branches: 1.94.2;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.


Revision tags: vmlocking2-base1 vmlocking-nbase
# 1.93 01-Dec-2007 jmcneill

branches: 1.93.2;
aprintify


Revision tags: nick-csl-alignment-base5 matt-armv6-prevmlocking jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base
# 1.92 04-Mar-2007 christos

branches: 1.92.14; 1.92.16; 1.92.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.91 26-Feb-2007 drochner

branches: 1.91.4;
The manpage promises not to touch the device on USB_GET_DEVICEINFO.
Make it so.


# 1.90 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base
# 1.89 03-Dec-2006 pavel

branches: 1.89.2;
Restore compatibility of USB_DEVICEINFO ioctl and reads from /dev/usb with
NetBSD 3.x. Patch from Stephan Thesing provided in
http://mail-index.netbsd.org/current-users/2006/03/21/0002.html, with some
modifications by me.
See also
http://mail-index.netbsd.org/current-users/2006/08/29/0017.html

The code is conditionally compiled depending on COMPAT_30.

Also fix a leak of struct usb_event in usbread() introduced while converting
on-stack variables to dynamic allocation.

Reviewed by martin@.


Revision tags: netbsd-4-base
# 1.88 16-Nov-2006 christos

branches: 1.88.2;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.87 12-Oct-2006 xtraeme

sigh, another missing __unused.


# 1.86 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.85 03-Sep-2006 christos

branches: 1.85.2; 1.85.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.84 24-Jul-2006 gdt

Add UGEN_BULK_RA_WB, which allows users of ugen(4) to request read
ahead and write behind, improving performance for the Universal
Software Radio Peripheral (USRP) used with GNU Radio.

Enable UGEN_BULK_RA_WB in GENERIC and GENERIC_LAPTOP; behavior is
unchanged unless the new ioctl is called.

This code was written by Joanne Mikkelson under funding from DARPA's
ACERT program.

ok'd by christos@, tested by Berndt Josef Wulf


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.83 09-Jun-2006 christos

stack police: Don't allocate large buffers on the stack for I/O. Put the
buffer in the softc instead.


Revision tags: yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.82 14-Apr-2006 christos

branches: 1.82.2;
Coverity CID 1354: Add a KASSERT to convince coverity that there is no NULL
pointer dereference.


# 1.81 14-Apr-2006 christos

Coverity CID 1355: Add a KASSERT to convince coverity that this is not NULL.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3
# 1.80 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base
# 1.79 01-Mar-2006 yamt

branches: 1.79.2; 1.79.4; 1.79.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.


Revision tags: yamt-uio_vmspace-base5
# 1.78 11-Dec-2005 christos

branches: 1.78.2; 1.78.4; 1.78.6;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 28-Nov-2005 augustss

Add a new match level, UMATCH_HIGHEST.


# 1.76 23-Nov-2005 augustss

Normally a ugen device only attaches if no other driver wants the device.
Add the ability to force ugen to attach with very high priority if "flags 1"
is specified. This can be used with the vendor and product locators to
force ugen to be used for certain devices.
Similarly, uhid only attaches if no other HID driver (ums or ukbd) wants it.
Again, "flags 1" will force uhid to attach anyway.


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.75 21-Jun-2005 ws

branches: 1.75.2; 1.75.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.


# 1.74 30-May-2005 christos

- const poisoning
- eliminate variable shadowing


# 1.73 17-May-2005 augustss

Allow multiple opens of the control endpoint. This is unproblematic since
the control endpoint is in some sense always open to the device.

From wulf@ping.net.au.


# 1.72 11-May-2005 augustss

Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.71 02-Mar-2005 mycroft

Copyright maintenance.


# 1.70 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Dec-2004 augustss

branches: 1.69.4; 1.69.6;
Allow interrupt output devices. From FreeBSD.


# 1.68 23-Jun-2004 mycroft

Yes, some devices return incorrect lengths in their string descriptors. Rather
than losing, do what Windows does: just request the maximum size, and allow a
shorter response. Obsoletes the need for UQ_NO_STRINGS, and therefore these
"quirks" are removed.


# 1.67 23-Apr-2004 itojun

use bounded string ops (snprintf, strl*)


Revision tags: netbsd-2-0-base
# 1.66 04-Sep-2003 mycroft

branches: 1.66.2;
Cast a printf() arg so that USB_DEBUG compiles on multiple platforms.


# 1.65 29-Jun-2003 fvdl

branches: 1.65.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.64 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.63 26-Nov-2002 christos

si_ -> sel_


Revision tags: kqueue-aftermerge
# 1.62 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.61 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


# 1.60 06-Sep-2002 gehenna

Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.


Revision tags: gehenna-devsw-base
# 1.59 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base
# 1.58 20-Feb-2002 christos

branches: 1.58.8;
Prefix structure members to protect them against clashes with eg. c++ keywords.
Suggested by Alfred Perlstein, from FreeBSD, ok'd by augustss


# 1.57 11-Feb-2002 augustss

Give usbd_do_request_flags() an extra argument for the timeout.


# 1.56 02-Jan-2002 augustss

More whitespace fixes from FreeBSD.


# 1.55 31-Dec-2001 augustss

Whitespace fixes (from FreeBSD).


# 1.54 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.53 31-Dec-2001 augustss

Don't allow setting the configuration when an endpoint is open. From
FreeBSD.


# 1.52 31-Dec-2001 augustss

Only clear stall if endpoint is stalled. From FreeBSD.


# 1.51 13-Nov-2001 augustss

More test for NULL pipes.


# 1.50 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.49 24-Oct-2001 augustss

Add commented out match level feature.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.48 16-Sep-2001 yamt

branches: 1.48.2;
make ugen use updated frlengths.


# 1.47 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf
# 1.46 15-Sep-2001 yamt

correct debug messages.


Revision tags: thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.45 13-Dec-2000 augustss

branches: 1.45.2; 1.45.4; 1.45.6;
Don't try to access a device that is being disconnected when generating
the detach event. Fixes (I hope) PR 11713 from itohy@netbsd.org (ITOH Yasufumi).


# 1.44 26-Nov-2000 augustss

Improve a debug message.


# 1.43 24-Oct-2000 augustss

Tell usbd_set_config_no() to be verbose. It's nice to know whyit fails.


# 1.42 08-Sep-2000 augustss

ANSIfy last patch.


# 1.41 08-Sep-2000 augustss

Add isoc support. From FreeBSD via Berndt Josef Wulf <wulf@ping.net.au>


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.40 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


# 1.39 31-May-2000 augustss

Add a comment.


Revision tags: minoura-xpg4dl-base
# 1.38 27-Apr-2000 augustss

branches: 1.38.2;
Change my email address.


# 1.37 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.36 06-Mar-2000 augustss

Generate better error codes on bulk write.


# 1.35 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.34 08-Feb-2000 augustss

Use NULL instead of 0.


# 1.33 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.32 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.31 18-Dec-1999 augustss

Change the way the initial configuration value is picked.
Idea from Matthias Drochner <M.Drochner@fz-juelich.de>


# 1.30 18-Nov-1999 augustss

Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.


# 1.29 17-Nov-1999 augustss

A few more purely stylistic changes that I missed in the last round.


Revision tags: fvdl-softdep-base
# 1.28 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.27 28-Oct-1999 augustss

Add a few more tests for safety.


# 1.26 28-Oct-1999 augustss

Make sure read() and write() fails on the control pipe.


# 1.25 13-Oct-1999 augustss

branches: 1.25.2; 1.25.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.24 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.23 09-Sep-1999 augustss

branches: 1.23.2;
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

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


# 1.22 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.21 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.20 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.19 28-Aug-1999 augustss

Change a type name.


# 1.18 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.17 22-Aug-1999 augustss

Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.


# 1.16 19-Aug-1999 augustss

Use the right type for the size argument when calling usbd_bulk_transfer().


# 1.15 17-Aug-1999 augustss

Make some small changes to make it compile on OpenBSD.


# 1.14 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


# 1.13 02-Aug-1999 augustss

Change it so that a pipe can be open RW instead of just R or W.
This makes close() work properly, but it is still not ideal. Perhaps
there should be different device nodes for input and output on to
and endpoint with the same number?
Pay attention to the SHORT_XFER_OK ioctl().


Revision tags: chs-ubc2-base
# 1.12 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.11 08-Jan-1999 augustss

branches: 1.11.4;
Various little fixes from the FreeBSD version.


# 1.10 07-Jan-1999 augustss

Fix some pastos.


# 1.9 03-Jan-1999 augustss

Add an ugly workaround for a bug (feature) in the NetBSD open()/close()
protocol.


# 1.8 01-Jan-1999 augustss

Fix bug in reading from interrupt pipe.
Make read and write on bulk pipes interruptible.


# 1.7 29-Dec-1998 augustss

Don't set configuration unnecessarily, some (broken) devices seem to break
if you do.


# 1.6 29-Dec-1998 augustss

Make it possible to specify the request flags when issuing a raw USB request.


# 1.5 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.4 12-Dec-1998 augustss

Move initialization of sce around.


# 1.3 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.2 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.1 08-Dec-1998 augustss

Add a generic USB driver. It allows easy access to descriptors, the
control pipe via ioctl() and read() and write() access to bulk and
interrupt pipes.