Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/subr_devsw.c
RevisionDateAuthorComments
 1.53  13-Oct-2024  chs avoid spurious warning about uninitialized "bi" here just as we do for "ci".
 1.52  16-Aug-2024  riastradh devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held
 1.51  15-Feb-2023  riastradh kern/subr_devsw.c: Nix trailing whitespace.

No functional change intended.

Please do (setq show-trailing-whitespace t) if you use Emacs!

Maybe someone should teach nvi to do something similar.
 1.50  13-Feb-2023  buhrow When a device driver calls devsw_attach() it has the option of attaching a block device
structure and a character device structure, or, just the character device structure.
With the existing code, if a driver elects not to attach a block device structure and if it
asks for a major number to be dynamically assigned to its character interface,
that driver will not be able to detach and reattach its character driver interface. This is a very
long standing bug which didn't come to light until we began using loadable kernel modules more
heavily. this patch fixes this problem. With this patch in place, drivers that implement only
a character device interface may detach and reattach that character interface as often as they
need to.

Fixes PR kern/57229
 1.49  29-Oct-2022  riastradh branches: 1.49.2;
devsw(9): Sprinkle dtrace probes on bdevsw, cdevsw calls.

This is better than fbt-tracing the bdev_* and cdev_* functions
because this way we can reliably get at the struct bdevsw/cdevsw
pointer after lookup and get at return values.
 1.48  28-Aug-2022  riastradh devsw(9): Clarify to match loop condition. NFCI.
 1.47  28-Aug-2022  riastradh devsw(9): Fix case of existing conv in devsw_attach.

- Fix sense of conditional: if we found a conv, i < max_devsw_convs.
- Make sure to initialize error on the way out.

PR kern/56962: Incorrect behavior of the devsw_attach function
 1.46  09-Jul-2022  riastradh devsw(9): Forbid extant linked autoconf instances in devsw_detach.
 1.45  28-Mar-2022  riastradh subr_devsw.c: KNF and style nits.

No functional change intended.
 1.44  28-Mar-2022  riastradh driver(9): New devsw d_cancel op to interrupt I/O before close.

If specified, when revoking a device node or closing its last open
node, specfs will:

1. Call d_cancel, which should return promptly without blocking.
2. Wait for all concurrent d_read/write/ioctl/&c. to drain.
3. Call d_close.

Otherwise, specfs will:

1. Call d_close.
2. Wait for all concurrent d_read/write/ioctl/&c. to drain.

This fallback is problematic because often parts of d_close rely on
concurrent devsw operations to have completed already, so it is up to
each driver to have its own mechanism for waiting, and the extra step
in (2) is almost redundant. But it is still important to ensure that
devsw operations are not active by the time a module tries to invoke
devsw_detach, because only d_open is protected against that.

The signature of d_cancel matches d_close, mostly so we don't raise
questions about `why is this different?'; the lwp argument is not
useful but we should remove it from open/cancel/close all at the same
time.

The only way d_cancel should fail, if it does at all, is with ENODEV,
meaning the driver doesn't support cancelling outstanding I/O, and
will take responsibility for that in d_close. I would make it return
void and only have bdev_cancel and cdev_cancel possibly return ENODEV
so specfs can detect whether a driver supports it, but this would
break the pattern around devsw operation types.

Drivers are allowed to omit it from struct bdevsw, struct cdevsw --
if so, it is as if they used a function that just returns ENODEV.

XXX kernel ABI change to struct bdevsw/cdevsw requires bump
 1.43  28-Mar-2022  riastradh driver(9): Make vdevgone call config_detach_commit if appropriate.

Make sure to do this before spec_node_lookup_by_dev -- that might wait
for a concurrent revoke to complete, which in turn might wait for a
concurrent open to complete, which in turn might be waiting for the
device to commit to detaching.
 1.42  28-Mar-2022  riastradh driver(9): New function dev_minor_unit.
 1.41  28-Mar-2022  riastradh driver(9): New devsw members d_cfdriver, d_devtounit.

If set, then bdev_open/cdev_open will use d_devtounit to map the
dev_t to an autoconf instance (e.g., /dev/wd0a -> wd0) and hold a
reference with device_lookup_acquire across the call to d_open.

This guarantees that the autoconf instance cannot be detached while
the devsw's d_open function is trying to open it (and also that the
autoconf instance has finished *_attach before anyone can open it).

Of course, if the underlying hardware has gone away, there will be
I/O errors, but this avoids software synchronization bugs between
open and detach for drivers that opt into it. It's up to the driver
and bus to figure out how to deal with I/O errors from operations on
hardware that has gone away while the software hasn't finished
notifying everything that it's gone yet.

XXX kernel ABI change to struct bdevsw/cdevsw requires bump
 1.40  28-Mar-2022  riastradh driver(9): Fix synchronization of devsw_attach/lookup/detach.

(`dev' means either `bdev' or `cdev' for brevity here, e.g. in
`devsw_lookup' (bdevsw_lookup, cdevsw_lookup), `dev_open' (bdev_open,
cdev_open), `maxdevsws', &c., except for `devsw_attach' and
`devsw_detach' which are taken literally.)

- Use atomic_store_release and atomic_load_consume for devsw and
tables and their entries, which are read unlocked and thus require
memory barriers to ensure ordering between initialization in
devsw_attach and use in dev_lookup.

- Use pserialize(9) and localcount(9) to synchronize dev_open and
devsw_detach.

=> Driver must ensure d_open fails and all open instances have been
closed by the time it calls devsw_detach.

=> Bonus: dev_open is no longer globally serialized through
device_lock.

- Use atomic_store_release and atomic_load_acquire for max_devsws,
which is used in conditionals in the new devsw_lookup_acquire.

=> It is safe to use atomic_load_relaxed in devsw_lookup because
the caller must guarantee the entry is stable, so any increase
of max_devsws must have already happened.

=> devsw_lookup and devsw_lookup_acquire assume that max_devsws
never goes down. If you change this you must find some way to
adapt the users, preferably without adding much overhead so that
devsw operations are cheap.

This change introduces an auxiliary table devswref mapping device
majors to localcounts of opens in progress. The auxiliary table only
occupies one pointer's worth of memory in a monolithic kernel, and is
allocated on the fly for dynamically loaded modules. We could ask
the module itself to reserve storage for it, but I don't see much
value in that, and it would require some changes to the ABI and to
config(8).

- Omit needless boolean indirection.
 1.39  28-Mar-2022  riastradh driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this. (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back. To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
 1.38  07-Nov-2017  christos branches: 1.38.8;
Add two utility functions to help use kmem with strings: kmem_strdupsize,
kmem_strfree.
 1.37  25-Apr-2017  pgoyette branches: 1.37.2;
Use __func__ for routine name in printf() calls. NFC intended.
 1.36  16-Dec-2016  riastradh Fix return value of nommap.
 1.35  09-Dec-2016  nat Add functions to access device flags. This restores simultaneous audio
open/close.

OK hannken@ christos@
 1.34  01-Feb-2016  riz branches: 1.34.2;
Implement the 'io' provider for DTrace. From riastradh@, with
fixes from me.
 1.33  05-Sep-2014  matt branches: 1.33.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.
 1.32  25-Jul-2014  dholland Add d_discard to struct bdevsw/cdevsw, and the plumbing to access it.

Unfortunately we need d_discard in both since we need to be able to
discard from both the block and character forms of disks. I'm
increasingly thinking it would be better to restructure the ops
dispatching so each type of device (ttys, disks, tapes, etc.) has its
own function table. Then we wouldn't need to change every tty driver
to add a disk op.
 1.31  25-May-2014  pooka Call biodone() in the bdev_strategy() error via a pointer. Decouples
subr_devsw from VFS -- not that I/O buffers are _VFS_ entities -- and
eliminates the last weak alias from librump, which means things now
fully work on glibc (w/o LD_DYNAMIC_WEAK) and musl.

The whole code path is suspect anyway, since nothing prevents the device
from escaping after the lookup, suggesting that the whole error path
should be handled by the caller, but oh well.
 1.30  18-Feb-2012  mrg branches: 1.30.2; 1.30.12;
add an XXX comment i meant to include with the original change.
 1.29  12-Dec-2011  mrg implement bdev_size(9) wrapper around d_psize() routine, so we can take
the device lock in relevant places. avoid doing so while actually dumping.

tested i386 crash dumps still work, and that all touched files compile.

fixes PR#45705.
 1.28  03-Sep-2009  jmcneill branches: 1.28.12; 1.28.16;
In bdev_strategy, return ENXIO instead of panicing if the block device has
disappeared. ok pooka@
 1.27  18-Aug-2009  yamt whitespace fixes. no functional changes.
 1.26  02-Feb-2009  haad Add support for loading pseudo-device drivers. Try to autoload modules from
specs_open routine. If devsw_open fail, get driver name with devsw_getname
routine and autoload module.

For now only dm drivervcan be loaded, other pseudo drivers needs more work.

Ok by ad@.
 1.25  02-Feb-2009  enami - An errno is missed in rev. 1.11 while converting return statement to
goto statement.
- A local variable still in use is intercepted in rev. 1.6. Define and
use variable of its own.
 1.24  20-Jan-2009  drochner 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.
 1.23  29-Dec-2008  pooka Rename specfs_lock as device_lock and move it from specfs to devsw.
Relaxes kernel dependency on vfs.
 1.22  08-Jun-2008  ad branches: 1.22.6; 1.22.8;
Correct previous.
 1.21  08-Jun-2008  ad cdev_tty: don't acquire kernel lock, as we may need to call this with
tty_lock already held (and it would reverse the usual lock order).
 1.20  31-May-2008  ad Kill devsw_lock and just use specfs_lock. The two would need merging
in order to prevent unload of modules when a device that they provide
is still open.
 1.19  19-May-2008  ad Give devsw_detach() a dummy error return.
 1.18  28-Apr-2008  martin branches: 1.18.2;
Remove clause 3 and 4 from TNF licenses
 1.17  06-Apr-2008  ad branches: 1.17.2; 1.17.4;
When accessing a block/char device, cache the D_MPSAFE flag on initial
access, in case the devsw record is modified.
 1.16  21-Mar-2008  plunky add devsw_name2chr() function to look up character devices
 1.15  13-Feb-2008  matt branches: 1.15.6;
#include <sys/cpu.h> for curlwp
 1.14  20-Nov-2007  pooka Don't pass devname to {b,c}devsw_attach(), it's not used.
 1.13  07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.12  08-Oct-2007  ad branches: 1.12.2; 1.12.4;
Merge from vmlocking: in cdev_tty() check d_tty != NULL.
 1.11  09-Jul-2007  ad branches: 1.11.6; 1.11.8; 1.11.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.10  01-Nov-2006  yamt branches: 1.10.8; 1.10.10;
remove some __unused from function parameters.
 1.9  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8  11-Dec-2005  christos branches: 1.8.22;
merge ktrace-lwp.
 1.7  14-Jul-2003  lukem branches: 1.7.16;
add missing __KERNEL_RCSID()
 1.6  16-May-2003  itojun branches: 1.6.2;
use strlcpy. [fixed off-by-one in subr_prop.c]
 1.5  01-Feb-2003  mrg in devsw_name2blk(), as we use strncmp(), make sure the next character
in the device is either nul or a digit. this avoids "raid0" being
matched as the "ra" device (and thus failing to find anything at all
causing my raid0 root to fail) on my vax.
 1.4  15-Sep-2002  tsutsui branches: 1.4.2; 1.4.4;
Fix devsw_name2blk() to return the correct device name for devname arg.
Ok'ed by gehenna.
 1.3  11-Sep-2002  gehenna fix that no major numbers is assigned dynamically if the
not-listed-in-majors device switch is loaded.
 1.2  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.
 1.1  16-May-2002  gehenna branches: 1.1.2;
file subr_devsw.c was initially added on branch gehenna-devsw.
 1.1.2.7  06-Jun-2002  gehenna fix typo.
pointed out by YAMAMOTO Takashi.
 1.1.2.6  05-Jun-2002  gehenna If majors are not specified, use majors listed up in majors.<arch>.
 1.1.2.5  22-May-2002  gehenna Fix to recycle block/character majors.
Pointed out by yamt in local Japanese ML.
 1.1.2.4  19-May-2002  gehenna Fix the rule to assign the majors dynamically, if not listed up in majors.<arch>.
 1.1.2.3  19-May-2002  gehenna If the device switch is known (i.e. listed up majors.<arch>) or it has
been attached in the past, assign known block/character major.
 1.1.2.2  19-May-2002  gehenna fix typo
 1.1.2.1  16-May-2002  gehenna Add devsw APIs:

int devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
const struct cdevsw *cdev, int *cmajor);
void devsw_detach(const struct bdevsw *bdev, const struct cdevsw *cdev);

const struct bdevsw *bdevsw_lookup(dev_t dev);
const struct cdevsw *cdevsw_lookup(dev_t dev);
int bdevsw_lookup_major(const struct bdevsw *bdev);
int cdevsw_lookup_major(const struct cdevsw *cdev);

const char *devsw_blk2name(int bmajor);
int devsw_name2blk(const char *name, char *devname, size_t devnamelen);
dev_t devsw_chr2blk(dev_t cdev);
dev_t devsw_blk2chr(dev_t bdev);
 1.4.4.2  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.1  15-Sep-2002  jdolecek file subr_devsw.c was added on branch kqueue on 2002-10-10 18:43:13 +0000
 1.4.2.2  17-Sep-2002  nathanw Catch up to -current.
 1.4.2.1  15-Sep-2002  nathanw file subr_devsw.c was added on branch nathanw_sa on 2002-09-17 21:22:16 +0000
 1.6.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1  03-Aug-2004  skrll Sync with HEAD
 1.7.16.6  24-Mar-2008  yamt sync with head.
 1.7.16.5  27-Feb-2008  yamt sync with head.
 1.7.16.4  07-Dec-2007  yamt sync with head
 1.7.16.3  15-Nov-2007  yamt sync with head.
 1.7.16.2  27-Oct-2007  yamt sync with head.
 1.7.16.1  03-Sep-2007  yamt sync with head.
 1.8.22.2  10-Dec-2006  yamt sync with head.
 1.8.22.1  22-Oct-2006  yamt sync with head
 1.10.10.1  11-Jul-2007  mjf Sync with head.
 1.10.8.6  25-Oct-2007  ad Export devsw_lock.
 1.10.8.5  28-Aug-2007  ad cdev_tty: check d_tty != NULL before calling it.
 1.10.8.4  24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.10.8.3  15-Jul-2007  ad Sync with head.
 1.10.8.2  14-Apr-2007  ad Fix a comment.
 1.10.8.1  13-Apr-2007  ad - Make the devsw interface MP safe, and add some comments.
- Allow individual block/character drivers to be marked MP safe.
- Provide wrappers around the device methods that look up the
device, returning ENXIO if it's not found, and acquire the
kernel lock if needed.
 1.11.10.1  14-Oct-2007  yamt sync with head.
 1.11.8.4  23-Mar-2008  matt sync with HEAD
 1.11.8.3  09-Jan-2008  matt sync with HEAD
 1.11.8.2  08-Nov-2007  matt sync with -HEAD
 1.11.8.1  06-Nov-2007  matt sync with HEAD
 1.11.6.3  21-Nov-2007  joerg Sync with HEAD.
 1.11.6.2  11-Nov-2007  joerg Sync with HEAD.
 1.11.6.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.4.3  18-Feb-2008  mjf Sync with HEAD.
 1.12.4.2  08-Dec-2007  mjf Sync with HEAD.
 1.12.4.1  19-Nov-2007  mjf Sync with HEAD.
 1.12.2.2  21-Nov-2007  bouyer Sync with HEAD
 1.12.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.15.6.9  17-Jan-2009  mjf Sync with HEAD.
 1.15.6.8  29-Jun-2008  mjf Sync with HEAD.
 1.15.6.7  02-Jun-2008  mjf Sync with HEAD.
 1.15.6.6  14-Apr-2008  mjf - remove comments that are no longer true
- add support to devfsd(8) and devfsctl(4) to handle wedges
- add cpuctl device registration
- extract the alloc part out of device_register_name() into a common function
that can be used by the new device_register_sync(), which is used to
synchronously create device files
 1.15.6.5  06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.15.6.4  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.15.6.3  03-Apr-2008  mjf Sync with HEAD.
 1.15.6.2  03-Apr-2008  mjf - Make distrib/sets and sys/fs/devfs catch up with dctl rename to devfsctl.

- The visibility of a node is now properly determined in devfs.

- device_lookup_info() has grown an argument to distinguish whether we're
looking for a character or block device, since it's possible for the same
dev_t value to be used for a character device and a different block device.
 1.15.6.1  20-Mar-2008  mjf - Introduce new API for allowing device drivers to register/unregister
names for device nodes along with a corresponding dev_t.

- Make device drivers that technically never get attached and need device
nodes (mem, zero, null) provide an initialisation function, which gets
an entry in a table of init functions that devsw_init() calls when the
device switch tables are initialised.

- Since we're moving to a new way of notifying devfsd(8) of new devices,
we no longer need to link together struct devices.
 1.17.4.4  16-Sep-2009  yamt sync with head
 1.17.4.3  19-Aug-2009  yamt sync with head.
 1.17.4.2  04-May-2009  yamt sync with head.
 1.17.4.1  16-May-2008  yamt sync with head.
 1.17.2.3  17-Jun-2008  yamt sync with head.
 1.17.2.2  04-Jun-2008  yamt sync with head
 1.17.2.1  18-May-2008  yamt sync with head.
 1.18.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.8.1  07-Feb-2009  snj Pull up following revision(s) (requested by enami in ticket #422):
sys/kern/subr_devsw.c: revision 1.25
- An errno is missed in rev. 1.11 while converting return statement to
goto statement.
- A local variable still in use is intercepted in rev. 1.6. Define and
use variable of its own.
 1.22.6.2  03-Mar-2009  skrll Sync with HEAD.
 1.22.6.1  19-Jan-2009  skrll Sync with HEAD.
 1.28.16.1  18-Feb-2012  mrg merge to -current.
 1.28.12.1  17-Apr-2012  yamt sync with head
 1.30.12.1  10-Aug-2014  tls Rebase.
 1.30.2.2  03-Dec-2017  jdolecek update from HEAD
 1.30.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.2.3  28-Aug-2017  skrll Sync with HEAD
 1.33.2.2  05-Feb-2017  skrll Sync with HEAD
 1.33.2.1  19-Mar-2016  skrll Sync with HEAD
 1.34.2.18  26-Apr-2017  pgoyette Sync with HEAD
 1.34.2.17  25-Apr-2017  pgoyette Use {b,c}devsw_acquire() and {b,c}devsw_release() in the various device
acccess methods.
 1.34.2.16  25-Apr-2017  pgoyette Add membar_datadep_consumer() to {b,c}devsw_lookup() to ensure that
the devsw content is visible.

Again, thanks riastradh@
 1.34.2.15  25-Apr-2017  pgoyette Call localcount_init() before publishing the new {b,c}devsw.

Thanks to riastradh@
 1.34.2.14  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.34.2.13  22-Jul-2016  pgoyette Fix a comment
 1.34.2.12  22-Jul-2016  pgoyette Continue previous - finish what we started
 1.34.2.11  22-Jul-2016  pgoyette Only retrieve the bdev/cdev from the xdevsw[] array once.
 1.34.2.10  22-Jul-2016  pgoyette Style: indent label 'out:' one space from the margin.
 1.34.2.9  21-Jul-2016  pgoyette Remove a stray call to mutex_exit() that is left over from a previous
incarnation of this code.
 1.34.2.8  20-Jul-2016  pgoyette Improved comment. No code change.
 1.34.2.7  17-Jul-2016  pgoyette Fix typo in KASSERTMSG macro name
 1.34.2.6  17-Jul-2016  pgoyette Instead of initializing the 'pserialize_t psz' while holding a lock,
create a new devsw_detach_init() routine to hande this, and call it
after the pserialize system has been initialized.
 1.34.2.5  17-Jul-2016  pgoyette More details in KASSERTs to aid debugging
 1.34.2.4  17-Jul-2016  pgoyette Defer initialization of the pserialize_t device_psz" until just before
we need it. We can't initialize within devsw_init() because init_main()
has not yet initialized the pserialize stuff.

Restore a "return bdev" in bdevsw_lookup_acquire() - accidental deletion

Update cdevsw_lookup_acquire() to match bdev_lookup_acquire()
 1.34.2.3  17-Jul-2016  pgoyette More locking fixes from riastradh@
 1.34.2.2  16-Jul-2016  pgoyette Fix some locking sequences. Thanks to ristradh@ for the review!
 1.34.2.1  16-Jul-2016  pgoyette First pass of adding localcount(9) support for devsw. As with the
earlier autoconf changes, nothing currently uses this new feature.
 1.37.2.4  17-May-2017  pgoyette Allow the argument to {b,c}devsw_release() to be NULL, and treat it as
a No-Op
 1.37.2.3  28-Apr-2017  pgoyette Use printf() instead of aprintf_normal(), fix the sense of a comparison
 1.37.2.2  28-Apr-2017  pgoyette No need to panic if a modular driver doesn't include the required
localcount members in the {b,c}devsw. Just log a console message
and return EINVAL to signal failure.
 1.37.2.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.38.8.1  14-Feb-2023  martin Pull up following revision(s) (requested by buhrow in ticket #1595):

sys/kern/subr_devsw.c: revision 1.50

When a device driver calls devsw_attach() it has the option of attaching a block device
structure and a character device structure, or, just the character device structure.
With the existing code, if a driver elects not to attach a block device structure and if it
asks for a major number to be dynamically assigned to its character interface,
that driver will not be able to detach and reattach its character driver interface. This is a very
long standing bug which didn't come to light until we began using loadable kernel modules more
heavily. this patch fixes this problem. With this patch in place, drivers that implement only
a character device interface may detach and reattach that character interface as often as they
need to.

Fixes PR kern/57229
 1.49.2.2  13-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #972):

sys/kern/subr_devsw.c: revision 1.52

devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held
 1.49.2.1  14-Feb-2023  martin Pull up following revision(s) (requested by buhrow in ticket #84):

sys/kern/subr_devsw.c: revision 1.50

When a device driver calls devsw_attach() it has the option of attaching a block device
structure and a character device structure, or, just the character device structure.
With the existing code, if a driver elects not to attach a block device structure and if it
asks for a major number to be dynamically assigned to its character interface,
that driver will not be able to detach and reattach its character driver interface. This is a very
long standing bug which didn't come to light until we began using loadable kernel modules more
heavily. this patch fixes this problem. With this patch in place, drivers that implement only
a character device interface may detach and reattach that character interface as often as they
need to.

Fixes PR kern/57229

RSS XML Feed