CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Fri Jul 15 02:29:19 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: files.kern Added Files: src/sys/kern [pgoyette-localcount]: subr_localcount.c src/sys/sys [pgoyette-localcount]: localcount.h Log Message: Initial import of localcount(9) as proposed by riastradh@ This version compiles, but nothing uses it, yet. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.11.2.1 src/sys/kern/files.kern cvs rdiff -u -r0 -r1.1.2.1 src/sys/kern/subr_localcount.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/sys/localcount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/files.kern diff -u src/sys/kern/files.kern:1.11 src/sys/kern/files.kern:1.11.2.1 --- src/sys/kern/files.kern:1.11 Sat Apr 9 06:21:16 2016 +++ src/sys/kern/files.kern Fri Jul 15 02:29:19 2016 @@ -1,4 +1,4 @@ -# $NetBSD: files.kern,v 1.11 2016/04/09 06:21:16 riastradh Exp $ +# $NetBSD: files.kern,v 1.11.2.1 2016/07/15 02:29:19 pgoyette Exp $ # # kernel sources @@ -113,6 +113,7 @@ file kern/subr_kcpuset.c kern file kern/subr_kmem.c kern file kern/subr_kobj.c kern file kern/subr_kobj_vfs.c kern +file kern/subr_localcount.c kern file kern/subr_lockdebug.c kern file kern/subr_log.c kern file kern/subr_lwp_specificdata.c kern Added files: Index: src/sys/kern/subr_localcount.c diff -u /dev/null src/sys/kern/subr_localcount.c:1.1.2.1 --- /dev/null Fri Jul 15 02:29:19 2016 +++ src/sys/kern/subr_localcount.c Fri Jul 15 02:29:19 2016 @@ -0,0 +1,248 @@ +/* $NetBSD: subr_localcount.c,v 1.1.2.1 2016/07/15 02:29:19 pgoyette Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * CPU-local reference counts + * + * localcount(9) is a reference-counting scheme that involves no + * interprocessor synchronization most of the time, at the cost of + * eight bytes of memory per CPU per object and at the cost of + * expensive interprocessor synchronization to drain references. + * + * localcount(9) references may be held across sleeps, may be + * transferred from CPU to CPU or thread to thread: they behave + * semantically like typical reference counts, with different + * pragmatic performance characteristics. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.1.2.1 2016/07/15 02:29:19 pgoyette Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * localcount_init(lc) + * + * Initialize a localcount object. Returns 0 on success, error + * code on failure. May fail to allocate memory for percpu(9). + * + * The caller must call localcount_drain and then localcount_fini + * when done with lc. + */ +static void localcount_xc(void *, void *); + +int +localcount_init(struct localcount *lc) +{ + + lc->lc_totalp = NULL; + lc->lc_percpu = percpu_alloc(sizeof(int64_t)); + if (lc->lc_percpu == NULL) + return ENOMEM; + + return 0; +} + +/* + * localcount_drain(lc, cv, interlock) + * + * Wait for all acquired references to lc to drain. Caller must + * hold interlock; localcount_drain releases it during cross-calls + * and waits on cv. The cv and interlock passed here must be the + * same as are passed to localcount_release for this lc. + * + * Caller must guarantee that no new references can be acquired + * with localcount_acquire before calling localcount_drain. For + * example, any object that may be found in a list and acquired + * m
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sat Jul 16 02:13:08 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c src/sys/sys [pgoyette-localcount]: device.h Log Message: Initial set of changes for subr_autoconf usage of localcount mechanism. Nothing actually uses this yet - all callers of device_lookup() need conversion to device_lookup_acquire()/device_release(). This also means that callers of device_lookup_private() need to be modified to call device_release() when finished accessing the softc. XXX Perhaps device_lookup_private() should be removed, and all callers XXX modified to use device_lookup_acquire()/.../device_release()? To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.246.2.1 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.149 -r1.149.2.1 src/sys/sys/device.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246 src/sys/kern/subr_autoconf.c:1.246.2.1 --- src/sys/kern/subr_autoconf.c:1.246 Fri Jul 15 01:17:47 2016 +++ src/sys/kern/subr_autoconf.c Sat Jul 16 02:13:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246 2016/07/15 01:17:47 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.1 2016/07/16 02:13:07 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246 2016/07/15 01:17:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.1 2016/07/16 02:13:07 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -107,6 +107,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_autocon #include #include #include +#include #include @@ -227,6 +228,7 @@ static volatile int alldevs_nwrite = 0; static int config_pending; /* semaphore for mountroot */ static kmutex_t config_misc_lock; static kcondvar_t config_misc_cv; +static kcondvar_t config_drain_cv; static bool detachall = false; @@ -345,6 +347,7 @@ config_init(void) mutex_init(&config_misc_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(&config_misc_cv, "cfgmisc"); + cv_init(&config_drain_cv, "cfgdrain"); callout_init(&config_twiddle_ch, CALLOUT_MPSAFE); @@ -567,7 +570,6 @@ config_cfdriver_attach(struct cfdriver * if (STREQ(lcd->cd_name, cd->cd_name)) return EEXIST; } - LIST_INIT(&cd->cd_attach); LIST_INSERT_HEAD(&allcfdrivers, cd, cd_list); @@ -592,7 +594,6 @@ config_cfdriver_detach(struct cfdriver * } } config_alldevs_exit(&af); - if (rc != 0) return rc; @@ -1236,6 +1237,8 @@ config_devfree(device_t dev) { int priv = (dev->dv_flags & DVF_PRIV_ALLOC); + if (dev->dv_localcnt != NULL) + localcount_fini(dev->dv_localcnt); if (dev->dv_cfattach->ca_devsize > 0) kmem_free(dev->dv_private, dev->dv_cfattach->ca_devsize); if (priv) @@ -1254,6 +1257,9 @@ config_devunlink(device_t dev, struct de KASSERT(mutex_owned(&alldevs_mtx)); + localcount_drain(dev->dv_localcnt, &config_drain_cv, + &alldevs_mtx); + /* Unlink from device list. Link to garbage list. */ TAILQ_REMOVE(&alldevs, dev, dv_list); TAILQ_INSERT_TAIL(garbage, dev, dv_list); @@ -1392,8 +1398,8 @@ config_devalloc(const device_t parent, c printf("%s has not been converted to device_t\n", cd->cd_name); #endif } - if (dev == NULL) - panic("config_devalloc: memory allocation for device_t failed"); + KASSERTMSG(dev, "%s: memory allocation for %s device_t failed", + __func__, cd->cd_name); dev->dv_class = cd->cd_class; dev->dv_cfdata = cf; @@ -1403,6 +1409,10 @@ config_devalloc(const device_t parent, c dev->dv_activity_handlers = NULL; dev->dv_private = dev_private; dev->dv_flags = ca->ca_flags; /* inherit flags from class */ + dev->dv_localcnt = kmem_alloc(sizeof(*dev->dv_localcnt), KM_SLEEP); + KASSERTMSG(dev->dv_localcnt, "%s: unable to allocate localcnt for %s", + __func__, cd->cd_name); + localcount_init(dev->dv_localcnt); myunit = config_unit_alloc(dev, cd, cf); if (myunit == -1) { @@ -2245,6 +2255,37 @@ device_lookup(cfdriver_t cd, int unit) } /* + * device_lookup_accquire: + * + * Look up a device instance for a given driver and + * hold a reference to the device. + */ +device_t +device_lookup_acquire(cfdriver_t cd, int unit) +{ + device_t dv; + + dv = device_lookup(cd, unit); + if (dv != NULL) + localcount_acquire(dv->dv_localcnt); + return dv; +} + +/* + * device_release: + * + * Release the reference that was created by an earlier call to + * device_lookup_acquire(). + */ +void +device_release(device_t dv) +{ + + localcount_release(dv->dv_localcnt, &config_drain_cv, + &alldevs_mtx); +} + +/* * device_lookup_private: * * Look up a softc instance for a given driver. @@ -2253,7 +2294,7 @@ void * device_lookup_private(cfdriver_t cd, int unit) { - return device_private(device_lookup(cd, unit)); + return
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sat Jul 16 07:54:14 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c src/sys/sys [pgoyette-localcount]: conf.h Log Message: First pass of adding localcount(9) support for devsw. As with the earlier autoconf changes, nothing currently uses this new feature. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.34.2.1 src/sys/kern/subr_devsw.c cvs rdiff -u -r1.146 -r1.146.2.1 src/sys/sys/conf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34 src/sys/kern/subr_devsw.c:1.34.2.1 --- src/sys/kern/subr_devsw.c:1.34 Mon Feb 1 05:05:43 2016 +++ src/sys/kern/subr_devsw.c Sat Jul 16 07:54:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34 2016/02/01 05:05:43 riz Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.1 2016/07/16 07:54:13 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34 2016/02/01 05:05:43 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.1 2016/07/16 07:54:13 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -85,6 +85,8 @@ __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c #include #include #include +#include +#include #ifdef DEVSW_DEBUG #define DPRINTF(x) printf x @@ -107,7 +109,8 @@ static int bdevsw_attach(const struct bd static int cdevsw_attach(const struct cdevsw *, devmajor_t *); static void devsw_detach_locked(const struct bdevsw *, const struct cdevsw *); -kmutex_t device_lock; +kmutex_t device_lock; +kcondvar_t device_cv; void (*biodone_vfs)(buf_t *) = (void *)nullop; @@ -118,6 +121,7 @@ devsw_init(void) KASSERT(sys_bdevsws < MAXDEVSW - 1); KASSERT(sys_cdevsws < MAXDEVSW - 1); mutex_init(&device_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(&device_cv, "devsw"); } int @@ -160,8 +164,13 @@ devsw_attach(const char *devname, goto fail; } - if (bdev != NULL) + if (bdev != NULL) { + KASSERT(bdev->d_localcount != NULL); + localcount_init(bdev->d_localcount); bdevsw[*bmajor] = bdev; + } + KASSERT(cdev->d_localcount != NULL); + localcount_init(cdev->d_localcount); cdevsw[*cmajor] = cdev; mutex_exit(&device_lock); @@ -270,6 +279,8 @@ bdevsw_attach(const struct bdevsw *devsw return (EEXIST); bdevsw[*devmajor] = devsw; + KASSERT(devsw->d_localcount != NULL); + localcount_init(devsw->d_localcount); return (0); } @@ -317,33 +328,66 @@ cdevsw_attach(const struct cdevsw *devsw return (EEXIST); cdevsw[*devmajor] = devsw; + KASSERT(devsw->d_localcount != NULL); + localcount_init(devsw->d_localcount); return (0); } +/* + * First, look up both bdev and cdev indices, and confirm that the + * localcount pointer(s) exist. Then drain any existing references, + * deactivate the localcount(s). Finally, remove the {b,c}devsw[] + * entries. + */ + static void devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev) { - int i; + int i, j; KASSERT(mutex_owned(&device_lock)); + i = max_bdevsws; if (bdev != NULL) { for (i = 0 ; i < max_bdevsws ; i++) { if (bdevsw[i] != bdev) continue; - bdevsw[i] = NULL; + + KASSERTMSG(bdev->d_localcount != NULL, + "%s: no bdev localcount", __func__); break; } } + j = max_cdevsws; if (cdev != NULL) { - for (i = 0 ; i < max_cdevsws ; i++) { - if (cdevsw[i] != cdev) + for (j = 0 ; j < max_cdevsws ; j++) { + if (cdevsw[j] != cdev) continue; - cdevsw[i] = NULL; + + KASSERTMSG(cdev->d_localcount != NULL, + "%s: no cdev localcount", __func__); break; } } + if (i < max_bdevsws) { + localcount_drain(bdev->d_localcount, &device_cv, &device_lock); + localcount_fini(bdev->d_localcount); + bdevsw[i] = NULL; + } + if (j < max_cdevsws ) { + /* + * Take care not to drain/fini the d_localcount if the same + * one was used for both cdev and bdev! + */ + if (i >= max_bdevsws || + bdev->d_localcount != cdev->d_localcount) { + localcount_drain(cdev->d_localcount, &device_cv, + &device_lock); + localcount_fini(cdev->d_localcount); + } + cdevsw[j] = NULL; + } } int @@ -375,6 +419,35 @@ bdevsw_lookup(dev_t dev) return (bdevsw[bmajor]); } +const struct bdevsw * +bdevsw_lookup_acquire(dev_t dev) +{ + devmajor_t bmajor; + + if (dev == NODEV) + return (NULL); + bmajor = major(dev); + if (bmajor < 0 || bmajor >= max_bdevsws) + return (NULL); + + if (bdevsw[bmajor]->d_localcount != NULL) + localcount_acquire(bdevsw[bmajor]->d_localcount); + + return (bdevsw[bmajor]); +} + +void +bdevsw_release(const struct bdevsw *bd) +{ + devmajor_t bmaj; + + bmaj = bdevsw_lookup_major(bd); + + KASSERTMSG(bmaj != NODEVMAJOR, "%s: no bmajor to release!", __func__); + if (bd->d_localcount != NULL) + localcount_rele
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sat Jul 16 22:06:42 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c src/sys/sys [pgoyette-localcount]: device.h Log Message: Add new xxx_acquire variants for device_lookup_private() and device_find_by_driver_unit_acquire rather than blindly making the old variants call localcount_acquire(). Also fix a couple of locking sequences. Thanks to Taylor for the review! To generate a diff of this commit: cvs rdiff -u -r1.246.2.1 -r1.246.2.2 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.149.2.1 -r1.149.2.2 src/sys/sys/device.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.1 src/sys/kern/subr_autoconf.c:1.246.2.2 --- src/sys/kern/subr_autoconf.c:1.246.2.1 Sat Jul 16 02:13:07 2016 +++ src/sys/kern/subr_autoconf.c Sat Jul 16 22:06:42 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.1 2016/07/16 02:13:07 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.2 2016/07/16 22:06:42 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.1 2016/07/16 02:13:07 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.2 2016/07/16 22:06:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1257,9 +1257,6 @@ config_devunlink(device_t dev, struct de KASSERT(mutex_owned(&alldevs_mtx)); - localcount_drain(dev->dv_localcnt, &config_drain_cv, - &alldevs_mtx); - /* Unlink from device list. Link to garbage list. */ TAILQ_REMOVE(&alldevs, dev, dv_list); TAILQ_INSERT_TAIL(garbage, dev, dv_list); @@ -1267,6 +1264,10 @@ config_devunlink(device_t dev, struct de /* Remove from cfdriver's array. */ cd->cd_devs[dev->dv_unit] = NULL; + /* Now wait for references to drain - no new refs are possible */ + localcount_drain(dev->dv_localcnt, &config_drain_cv, + &alldevs_mtx); + /* * If the device now has no units in use, unlink its softc array. */ @@ -2265,9 +2266,15 @@ device_lookup_acquire(cfdriver_t cd, int { device_t dv; - dv = device_lookup(cd, unit); - if (dv != NULL) + mutex_enter(&alldevs_mtx); + if (unit < 0 || unit >= cd->cd_ndevs) + dv = NULL; + else if ((dv = cd->cd_devs[unit]) != NULL && dv->dv_del_gen != 0) + dv = NULL; + else localcount_acquire(dv->dv_localcnt); + mutex_exit(&alldevs_mtx); + return dv; } @@ -2294,6 +2301,19 @@ void * device_lookup_private(cfdriver_t cd, int unit) { + return device_private(device_lookup(cd, unit)); +} + +/* + * device_lookup_private_acquire: + * + * Look up the softc and acquire a reference to the device + * so it won't disappear. + */ +void * +device_lookup_private_acquire(cfdriver_t cd, int unit) +{ + return device_private(device_lookup_acquire(cd, unit)); } @@ -2330,6 +2350,23 @@ device_find_by_driver_unit(const char *n if ((cd = config_cfdriver_lookup(name)) == NULL) return NULL; + return device_lookup(cd, unit); +} + +/* + * device_find_by_driver_unit_acquire: + * + * Returns the device of the given driver name and unit or + * NULL if it doesn't exist. If driver is found, it's + * reference count is incremented so it won't go away. + */ +device_t +device_find_by_driver_unit_acquire(const char *name, int unit) +{ + struct cfdriver *cd; + + if ((cd = config_cfdriver_lookup(name)) == NULL) + return NULL; return device_lookup_acquire(cd, unit); } Index: src/sys/sys/device.h diff -u src/sys/sys/device.h:1.149.2.1 src/sys/sys/device.h:1.149.2.2 --- src/sys/sys/device.h:1.149.2.1 Sat Jul 16 02:13:08 2016 +++ src/sys/sys/device.h Sat Jul 16 22:06:42 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.149.2.1 2016/07/16 02:13:08 pgoyette Exp $ */ +/* $NetBSD: device.h,v 1.149.2.2 2016/07/16 22:06:42 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -493,6 +493,7 @@ device_t device_lookup(cfdriver_t, int); device_t device_lookup_acquire(cfdriver_t, int); void device_release(device_t); void *device_lookup_private(cfdriver_t, int); +void *device_lookup_private_acquire(cfdriver_t, int); void device_register(device_t, void *); void device_register_post_config(device_t, void *); @@ -526,6 +527,7 @@ bool device_is_a(device_t, const char * device_t device_find_by_xname(const char *); device_t device_find_by_driver_unit(const char *, int); +device_t device_find_by_driver_unit_acquire(const char *, int); bool device_pmf_is_registered(device_t);
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sun Jul 17 05:05:11 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c src/sys/external/bsd/ipf/netinet [pgoyette-localcount]: ip_fil_netbsd.c src/sys/net [pgoyette-localcount]: bpf.c src/sys/netsmb [pgoyette-localcount]: smb_dev.c Log Message: Adapt some modular drivers to the localcount(9) world. We're still not actually using the localcount stuff, but we need to differentiate between built-in vs loaded drivers and allocate a "struct localcount" only for loaded drivers. To generate a diff of this commit: cvs rdiff -u -r1.345.2.1 -r1.345.2.2 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.16 -r1.16.2.1 \ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c cvs rdiff -u -r1.199 -r1.199.2.1 src/sys/net/bpf.c cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/netsmb/smb_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 Sun Jul 17 02:44:41 2016 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 05:05:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -127,6 +127,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkin #include #include #include +#include #include @@ -216,6 +217,10 @@ static dev_type_strategy(raidstrategy); static dev_type_dump(raiddump); static dev_type_size(raidsize); +#ifdef _MODULE +struct localcount raid_localcount_bdev, raid_localcount_cdev; +#endif + const struct bdevsw raid_bdevsw = { .d_open = raidopen, .d_close = raidclose, @@ -224,6 +229,9 @@ const struct bdevsw raid_bdevsw = { .d_dump = raiddump, .d_psize = raidsize, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = &raid_localcount_bdev, +#endif .d_flag = D_DISK }; @@ -239,6 +247,9 @@ const struct cdevsw raid_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = &raid_localcount_bdev, +#endif .d_flag = D_DISK }; Index: src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c diff -u src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16.2.1 --- src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16 Thu Jul 7 09:32:02 2016 +++ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Sun Jul 17 05:05:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_fil_netbsd.c,v 1.16 2016/07/07 09:32:02 ozaki-r Exp $ */ +/* $NetBSD: ip_fil_netbsd.c,v 1.16.2.1 2016/07/17 05:05:10 pgoyette Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -8,7 +8,7 @@ #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.16 2016/07/07 09:32:02 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.16.2.1 2016/07/17 05:05:10 pgoyette Exp $"); #else static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed"; static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp"; @@ -57,6 +57,9 @@ static const char rcsid[] = "@(#)Id: ip_ #include #include #endif +#if (__NetBSD_Version__ >= 799003300) +#include +#endif #include #include @@ -137,6 +140,10 @@ static int ipfwrite(dev_t, struct u static int ipfpoll(dev_t, int events, PROC_T *); static void ipf_timer_func(void *ptr); +#if defined(_MODULE) && (__NetBSD_Version__ >= 799003300) +struct localcount ipl_localcount; +#endif + const struct cdevsw ipl_cdevsw = { .d_open = ipfopen, .d_close = ipfclose, @@ -150,6 +157,10 @@ const struct cdevsw ipl_cdevsw = { #if (__NetBSD_Version__ >= 2) .d_kqfilter = nokqfilter, #endif +#ifdef _MODULE + .d_localcount = &ipl_localcount, +#endif + .d_discard = nodiscard, #ifdef D_OTHER .d_flag = D_OTHER @@ -2162,7 +2173,9 @@ static int ipl_init(void *); static int ipl_fini(void *); static int ipl_modcmd(modcmd_t, void *); +#ifdef _MODULE static devmajor_t ipl_cmaj = -1, ipl_bmaj = -1; +#endif static int ipl_modcmd(modcmd_t cmd, void *opaque) @@ -2198,6 +2211,7 @@ ipl_init(void *opaque) mutex_init(&ipf_ref_mutex, MUTEX_DEFAULT, IPL_NONE); ipf_active = 0; +#ifdef _MODULE /* * Insert ourself into the cdevsw list.
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sun Jul 17 21:39:17 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: init_main.c subr_devsw.c src/sys/sys [pgoyette-localcount]: conf.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.482 -r1.482.2.1 src/sys/kern/init_main.c cvs rdiff -u -r1.34.2.5 -r1.34.2.6 src/sys/kern/subr_devsw.c cvs rdiff -u -r1.146.2.1 -r1.146.2.2 src/sys/sys/conf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.482 src/sys/kern/init_main.c:1.482.2.1 --- src/sys/kern/init_main.c:1.482 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/init_main.c Sun Jul 17 21:39:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.482 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: init_main.c,v 1.482.2.1 2016/07/17 21:39:17 pgoyette Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.482 2016/07/07 06:55:43 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.482.2.1 2016/07/17 21:39:17 pgoyette Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -311,6 +311,9 @@ main(void) /* Passive serialization. */ pserialize_init(); + /* Init the detach capability in devsw */ + devsw_detach_init(); + /* Initialize the extent manager. */ extent_init(); Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.5 src/sys/kern/subr_devsw.c:1.34.2.6 --- src/sys/kern/subr_devsw.c:1.34.2.5 Sun Jul 17 12:09:21 2016 +++ src/sys/kern/subr_devsw.c Sun Jul 17 21:39:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -127,6 +127,13 @@ devsw_init(void) cv_init(&device_cv, "devsw"); } +void +devsw_detach_init(void) +{ + + device_psz = pserialize_create(); +} + int devsw_attach(const char *devname, const struct bdevsw *bdev, devmajor_t *bmajor, @@ -397,12 +404,7 @@ devsw_detach_locked(const struct bdevsw if (j < max_cdevsws ) cdevsw[j] = NULL; - /* - * If we haven't already done so, create the serialization - * stucture. Then wait for all current readers to finish. - */ - if(__predict_false(device_psz == NULL)) - device_psz = pserialize_create(); + /* Wait for all current readers to finish with the devsw */ pserialize_perform(device_psz); /* Index: src/sys/sys/conf.h diff -u src/sys/sys/conf.h:1.146.2.1 src/sys/sys/conf.h:1.146.2.2 --- src/sys/sys/conf.h:1.146.2.1 Sat Jul 16 07:54:13 2016 +++ src/sys/sys/conf.h Sun Jul 17 21:39:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: conf.h,v 1.146.2.1 2016/07/16 07:54:13 pgoyette Exp $ */ +/* $NetBSD: conf.h,v 1.146.2.2 2016/07/17 21:39:17 pgoyette Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -270,6 +270,7 @@ struct devsw_conv { }; void devsw_init(void); +void devsw_detach_init(void); const char *devsw_blk2name(devmajor_t); const char *cdevsw_getname(devmajor_t); const char *bdevsw_getname(devmajor_t);
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Mon Jul 18 03:50:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: audio.c cgd.c fss.c ld.c md.c rndpseudo.c vnd.c src/sys/dev/dm [pgoyette-localcount]: device-mapper.c src/sys/dev/pci [pgoyette-localcount]: pci_usrreq.c src/sys/dev/scsipi [pgoyette-localcount]: cd.c sd.c src/sys/dev/sysmon [pgoyette-localcount]: sysmon.c src/sys/dev/usb [pgoyette-localcount]: ucom.c ulpt.c src/sys/dev/wscons [pgoyette-localcount]: wskbd.c wsmouse.c src/sys/kern [pgoyette-localcount]: kern_drvctl.c tty_ptm.c tty_pty.c tty_tty.c src/sys/net [pgoyette-localcount]: if_tap.c src/sys/net/npf [pgoyette-localcount]: npf.c src/sys/opencrypto [pgoyette-localcount]: cryptodev.c src/sys/rump/librump/rumpvfs [pgoyette-localcount]: devnull.c rumpblk.c Log Message: Rump drivers are always installed via devsw_attach() so we need to always allocate a 'struct localcount' for these drivers whenever they are built as modules. To generate a diff of this commit: cvs rdiff -u -r1.268 -r1.268.2.1 src/sys/dev/audio.c cvs rdiff -u -r1.108 -r1.108.2.1 src/sys/dev/cgd.c cvs rdiff -u -r1.93 -r1.93.2.1 src/sys/dev/fss.c cvs rdiff -u -r1.94 -r1.94.2.1 src/sys/dev/ld.c cvs rdiff -u -r1.76 -r1.76.2.1 src/sys/dev/md.c cvs rdiff -u -r1.35 -r1.35.2.1 src/sys/dev/rndpseudo.c cvs rdiff -u -r1.256 -r1.256.2.1 src/sys/dev/vnd.c cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/dev/pci/pci_usrreq.c cvs rdiff -u -r1.331 -r1.331.2.1 src/sys/dev/scsipi/cd.c cvs rdiff -u -r1.317 -r1.317.2.1 src/sys/dev/scsipi/sd.c cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.113 -r1.113.2.1 src/sys/dev/usb/ucom.c cvs rdiff -u -r1.97 -r1.97.2.1 src/sys/dev/usb/ulpt.c cvs rdiff -u -r1.136 -r1.136.2.1 src/sys/dev/wscons/wskbd.c cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/dev/wscons/wsmouse.c cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/kern/kern_drvctl.c cvs rdiff -u -r1.37 -r1.37.2.1 src/sys/kern/tty_ptm.c cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/kern/tty_pty.c cvs rdiff -u -r1.40 -r1.40.8.1 src/sys/kern/tty_tty.c cvs rdiff -u -r1.84 -r1.84.2.1 src/sys/net/if_tap.c cvs rdiff -u -r1.31 -r1.31.2.1 src/sys/net/npf/npf.c cvs rdiff -u -r1.85 -r1.85.2.1 src/sys/opencrypto/cryptodev.c cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/rump/librump/rumpvfs/devnull.c cvs rdiff -u -r1.64 -r1.64.2.1 src/sys/rump/librump/rumpvfs/rumpblk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio.c diff -u src/sys/dev/audio.c:1.268 src/sys/dev/audio.c:1.268.2.1 --- src/sys/dev/audio.c:1.268 Thu Jul 14 10:19:05 2016 +++ src/sys/dev/audio.c Mon Jul 18 03:49:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.268 2016/07/14 10:19:05 msaitoh Exp $ */ +/* $NetBSD: audio.c,v 1.268.2.1 2016/07/18 03:49:59 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -155,7 +155,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268 2016/07/14 10:19:05 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.1 2016/07/18 03:49:59 pgoyette Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -178,6 +178,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1. #include #include #include +#include #include #include @@ -346,6 +347,10 @@ dev_type_poll(audiopoll); dev_type_mmap(audiommap); dev_type_kqfilter(audiokqfilter); +#ifdef _MODULE +struct localcount audio_localcount; +#endif + const struct cdevsw audio_cdevsw = { .d_open = audioopen, .d_close = audioclose, @@ -358,6 +363,9 @@ const struct cdevsw audio_cdevsw = { .d_mmap = audiommap, .d_kqfilter = audiokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = &audio_localcount, +#endif .d_flag = D_OTHER | D_MPSAFE }; Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108 src/sys/dev/cgd.c:1.108.2.1 --- src/sys/dev/cgd.c:1.108 Sun Jul 10 17:40:23 2016 +++ src/sys/dev/cgd.c Mon Jul 18 03:49:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108 2016/07/10 17:40:23 riastradh Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.1 2016/07/18 03:49:59 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108 2016/07/10 17:40:23 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.1 2016/07/18 03:49:59 pgoyette Exp $"); #include #include @@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.10 #include #include #include +#include #include #include @@ -70,6 +71,10 @@ static dev_type_strategy(cgdstrategy); static dev_type_dump(cgddump); static dev_type_size(cgdsize); +#ifdef _MODULE +struct localcount cgd_b_localcount, cgd_c_localcount; +#endif + const struct bdevsw cgd_bdevsw = { .d_open = cgdopen, .d_close = cgdclose, @@ -78,6 +83,9 @
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Wed Jul 20 23:47:58 UTC 2016 Modified Files: src/sys/coda [pgoyette-localcount]: coda_vfsops.c src/sys/compat/common [pgoyette-localcount]: tty_60.c src/sys/compat/linux/arch/amd64 [pgoyette-localcount]: linux_machdep.c src/sys/compat/linux/arch/i386 [pgoyette-localcount]: linux_machdep.c src/sys/compat/linux/common [pgoyette-localcount]: linux_ioctl.c src/sys/dev [pgoyette-localcount]: clockctl.c src/sys/dev/dkwedge [pgoyette-localcount]: dk.c src/sys/dev/ir [pgoyette-localcount]: irframe_tty.c src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c src/sys/fs/adosfs [pgoyette-localcount]: advfsops.c src/sys/fs/cd9660 [pgoyette-localcount]: cd9660_vfsops.c src/sys/fs/filecorefs [pgoyette-localcount]: filecore_vfsops.c src/sys/fs/hfs [pgoyette-localcount]: hfs_vfsops.c src/sys/fs/msdosfs [pgoyette-localcount]: msdosfs_vfsops.c src/sys/fs/nilfs [pgoyette-localcount]: nilfs_vfsops.c src/sys/fs/ntfs [pgoyette-localcount]: ntfs_vfsops.c src/sys/fs/sysvbfs [pgoyette-localcount]: sysvbfs_vfsops.c src/sys/fs/udf [pgoyette-localcount]: udf_vfsops.c src/sys/fs/v7fs [pgoyette-localcount]: v7fs_vfsops.c src/sys/kern [pgoyette-localcount]: tty.c tty_pty.c vfs_mount.c src/sys/miscfs/specfs [pgoyette-localcount]: spec_vnops.c src/sys/net [pgoyette-localcount]: ppp_tty.c src/sys/ufs/chfs [pgoyette-localcount]: chfs_vfsops.c src/sys/ufs/ext2fs [pgoyette-localcount]: ext2fs_vfsops.c src/sys/ufs/ffs [pgoyette-localcount]: ffs_vfsops.c src/sys/ufs/lfs [pgoyette-localcount]: lfs_vfsops.c src/sys/uvm [pgoyette-localcount]: uvm_device.c uvm_swap.c Log Message: Adapt machine-independant code to the new {b,c}devsw reference-counting (using localcount(9)). All callers of {b,c}devsw_lookup() now call {b,c}devsw_lookup_acquire() which retains a reference on the 'struct {b,c}devsw'. This reference must be released by the caller once it is finished with the structure's content (or other data that would disappear if the 'struct {b,c}devsw' were to disappear). To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.84.2.1 src/sys/coda/coda_vfsops.c cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/compat/common/tty_60.c cvs rdiff -u -r1.48 -r1.48.10.1 \ src/sys/compat/linux/arch/amd64/linux_machdep.c cvs rdiff -u -r1.162 -r1.162.2.1 \ src/sys/compat/linux/arch/i386/linux_machdep.c cvs rdiff -u -r1.58 -r1.58.10.1 src/sys/compat/linux/common/linux_ioctl.c cvs rdiff -u -r1.34 -r1.34.2.1 src/sys/dev/clockctl.c cvs rdiff -u -r1.91 -r1.91.2.1 src/sys/dev/dkwedge/dk.c cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/dev/ir/irframe_tty.c cvs rdiff -u -r1.345.2.4 -r1.345.2.5 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.75 -r1.75.2.1 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.90 -r1.90.2.1 src/sys/fs/cd9660/cd9660_vfsops.c cvs rdiff -u -r1.78 -r1.78.2.1 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.33 -r1.33.2.1 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.118 -r1.118.2.1 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.22 -r1.22.2.1 src/sys/fs/nilfs/nilfs_vfsops.c cvs rdiff -u -r1.104 -r1.104.2.1 src/sys/fs/ntfs/ntfs_vfsops.c cvs rdiff -u -r1.46 -r1.46.2.1 src/sys/fs/sysvbfs/sysvbfs_vfsops.c cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/fs/udf/udf_vfsops.c cvs rdiff -u -r1.12 -r1.12.2.1 src/sys/fs/v7fs/v7fs_vfsops.c cvs rdiff -u -r1.271 -r1.271.2.1 src/sys/kern/tty.c cvs rdiff -u -r1.142.2.2 -r1.142.2.3 src/sys/kern/tty_pty.c cvs rdiff -u -r1.40 -r1.40.2.1 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.162 -r1.162.2.1 src/sys/miscfs/specfs/spec_vnops.c cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/net/ppp_tty.c cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.193 -r1.193.2.1 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.339 -r1.339.2.1 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.351 -r1.351.2.1 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.64 -r1.64.2.1 src/sys/uvm/uvm_device.c cvs rdiff -u -r1.174 -r1.174.2.1 src/sys/uvm/uvm_swap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/coda/coda_vfsops.c diff -u src/sys/coda/coda_vfsops.c:1.84 src/sys/coda/coda_vfsops.c:1.84.2.1 --- src/sys/coda/coda_vfsops.c:1.84 Sat Dec 13 15:59:30 2014 +++ src/sys/coda/coda_vfsops.c Wed Jul 20 23:47:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: coda_vfsops.c,v 1.84 2014/12/13 15:59:30 hannken Exp $ */ +/* $NetBSD: coda_vfsops.c,v 1.84.2.1 2016/07/20 23:47:55 pgoyette Exp $ */ /* * @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.84 2014/12/13 15:59:30 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.84.2.1 2016/07/20 23:47:55 pgoyette Exp $"); #include #include @@ -212,7 +212,7 @@ coda_mount(struct mo
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sun Jul 24 05:39:29 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c src/sys/sys [pgoyette-localcount]: device.h Log Message: Add a device_acquire() for when we need to grab a reference and we already have a pointer to the device. To generate a diff of this commit: cvs rdiff -u -r1.246.2.5 -r1.246.2.6 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.149.2.2 -r1.149.2.3 src/sys/sys/device.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.5 src/sys/kern/subr_autoconf.c:1.246.2.6 --- src/sys/kern/subr_autoconf.c:1.246.2.5 Fri Jul 22 12:03:15 2016 +++ src/sys/kern/subr_autoconf.c Sun Jul 24 05:39:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.6 2016/07/24 05:39:29 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.6 2016/07/24 05:39:29 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -2238,6 +2238,19 @@ config_alldevs_exit(struct alldevs_foray } /* + * device_acquire: + * + * Acquire a reference to the device. + */ +void +device_acquire(device_t dv) +{ + + if (dv->dv_localcnt != NULL) + localcount_acquire(dv->dv_localcnt); +} + +/* * device_lookup: * * Look up a device instance for a given driver. @@ -2274,7 +2287,7 @@ device_lookup_acquire(cfdriver_t cd, int else if ((dv = cd->cd_devs[unit]) != NULL && dv->dv_del_gen != 0) dv = NULL; if (dv != NULL) - localcount_acquire(dv->dv_localcnt); + device_acquire(dv); mutex_exit(&alldevs_mtx); return dv; @@ -2284,7 +2297,7 @@ device_lookup_acquire(cfdriver_t cd, int * device_release: * * Release the reference that was created by an earlier call to - * device_lookup_acquire(). + * device_acquire() or device_lookup_acquire(). */ void device_release(device_t dv) Index: src/sys/sys/device.h diff -u src/sys/sys/device.h:1.149.2.2 src/sys/sys/device.h:1.149.2.3 --- src/sys/sys/device.h:1.149.2.2 Sat Jul 16 22:06:42 2016 +++ src/sys/sys/device.h Sun Jul 24 05:39:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.149.2.2 2016/07/16 22:06:42 pgoyette Exp $ */ +/* $NetBSD: device.h,v 1.149.2.3 2016/07/24 05:39:28 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -491,6 +491,7 @@ void null_childdetached(device_t, device device_t device_lookup(cfdriver_t, int); device_t device_lookup_acquire(cfdriver_t, int); +void device_acquire(device_t); void device_release(device_t); void *device_lookup_private(cfdriver_t, int); void *device_lookup_private_acquire(cfdriver_t, int);
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Tue Jul 26 05:54:40 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: audio.c cgd.c fss.c ld.c md.c rndpseudo.c vnd.c src/sys/dev/dm [pgoyette-localcount]: device-mapper.c src/sys/dev/pad [pgoyette-localcount]: pad.c src/sys/dev/pci [pgoyette-localcount]: pci_usrreq.c src/sys/dev/pud [pgoyette-localcount]: pud_dev.c src/sys/dev/putter [pgoyette-localcount]: putter.c src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c src/sys/dev/scsipi [pgoyette-localcount]: cd.c sd.c src/sys/dev/sysmon [pgoyette-localcount]: sysmon.c src/sys/dev/usb [pgoyette-localcount]: ucom.c ulpt.c src/sys/dev/wscons [pgoyette-localcount]: wskbd.c wsmouse.c src/sys/external/bsd/ipf/netinet [pgoyette-localcount]: ip_fil_netbsd.c src/sys/kern [pgoyette-localcount]: kern_drvctl.c tty_ptm.c tty_pty.c tty_tty.c src/sys/net [pgoyette-localcount]: bpf.c if_tap.c src/sys/net/npf [pgoyette-localcount]: npf.c src/sys/netsmb [pgoyette-localcount]: smb_dev.c src/sys/opencrypto [pgoyette-localcount]: cryptodev.c src/sys/rump/librump/rumpvfs [pgoyette-localcount]: devnull.c rumpblk.c src/sys/sys [pgoyette-localcount]: localcount.h Log Message: Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes what we're doing, and why. To generate a diff of this commit: cvs rdiff -u -r1.268.2.4 -r1.268.2.5 src/sys/dev/audio.c cvs rdiff -u -r1.108.2.15 -r1.108.2.16 src/sys/dev/cgd.c cvs rdiff -u -r1.93.2.2 -r1.93.2.3 src/sys/dev/fss.c cvs rdiff -u -r1.94.2.2 -r1.94.2.3 src/sys/dev/ld.c cvs rdiff -u -r1.76.2.2 -r1.76.2.3 src/sys/dev/md.c cvs rdiff -u -r1.35.2.2 -r1.35.2.3 src/sys/dev/rndpseudo.c cvs rdiff -u -r1.256.2.6 -r1.256.2.7 src/sys/dev/vnd.c cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/dev/dm/device-mapper.c cvs rdiff -u -r1.25.2.3 -r1.25.2.4 src/sys/dev/pad/pad.c cvs rdiff -u -r1.29.2.2 -r1.29.2.3 src/sys/dev/pci/pci_usrreq.c cvs rdiff -u -r1.7.2.3 -r1.7.2.4 src/sys/dev/pud/pud_dev.c cvs rdiff -u -r1.35.8.2 -r1.35.8.3 src/sys/dev/putter/putter.c cvs rdiff -u -r1.345.2.5 -r1.345.2.6 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.331.2.2 -r1.331.2.3 src/sys/dev/scsipi/cd.c cvs rdiff -u -r1.317.2.2 -r1.317.2.3 src/sys/dev/scsipi/sd.c cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.113.2.2 -r1.113.2.3 src/sys/dev/usb/ucom.c cvs rdiff -u -r1.97.2.2 -r1.97.2.3 src/sys/dev/usb/ulpt.c cvs rdiff -u -r1.136.2.2 -r1.136.2.3 src/sys/dev/wscons/wskbd.c cvs rdiff -u -r1.66.8.2 -r1.66.8.3 src/sys/dev/wscons/wsmouse.c cvs rdiff -u -r1.16.2.3 -r1.16.2.4 \ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c cvs rdiff -u -r1.41.2.2 -r1.41.2.3 src/sys/kern/kern_drvctl.c cvs rdiff -u -r1.37.2.2 -r1.37.2.3 src/sys/kern/tty_ptm.c cvs rdiff -u -r1.142.2.3 -r1.142.2.4 src/sys/kern/tty_pty.c cvs rdiff -u -r1.40.8.2 -r1.40.8.3 src/sys/kern/tty_tty.c cvs rdiff -u -r1.199.2.2 -r1.199.2.3 src/sys/net/bpf.c cvs rdiff -u -r1.84.2.2 -r1.84.2.3 src/sys/net/if_tap.c cvs rdiff -u -r1.31.2.2 -r1.31.2.3 src/sys/net/npf/npf.c cvs rdiff -u -r1.44.2.3 -r1.44.2.4 src/sys/netsmb/smb_dev.c cvs rdiff -u -r1.85.2.2 -r1.85.2.3 src/sys/opencrypto/cryptodev.c cvs rdiff -u -r1.7.2.2 -r1.7.2.3 src/sys/rump/librump/rumpvfs/devnull.c cvs rdiff -u -r1.64.2.2 -r1.64.2.3 src/sys/rump/librump/rumpvfs/rumpblk.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/sys/localcount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio.c diff -u src/sys/dev/audio.c:1.268.2.4 src/sys/dev/audio.c:1.268.2.5 --- src/sys/dev/audio.c:1.268.2.4 Tue Jul 26 03:52:14 2016 +++ src/sys/dev/audio.c Tue Jul 26 05:54:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $ */ +/* $NetBSD: audio.c,v 1.268.2.5 2016/07/26 05:54:39 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -155,7 +155,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.5 2016/07/26 05:54:39 pgoyette Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -348,7 +348,7 @@ dev_type_mmap(audiommap); dev_type_kqfilter(audiokqfilter); const struct cdevsw audio_cdevsw = { - LOCALCOUNT_INITIALIZER + DEVSW_MODULE_INIT .d_open = audioopen, .d_close = audioclose, .d_read = audioread, Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.15 src/sys/dev/cgd.c:1.108.2.16 --- src/sys/dev/cgd.c:1.108.2.15 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/cgd.c Tue Jul 26 05:54:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.15 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.16 2016/07/26 05:54:39 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Sun Jul 31 01:36:49 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c src/sys/rump/dev/lib/libfss [pgoyette-localcount]: fss_component.c Log Message: When initializing the rump component, detach the [bc]devsw after using the devmajors to create the device nodes. Normal module initialization will reattach them. XXX This code sequence is fairly common, and probably should be XXX extracted into a separate routine and/or macro. But there's XXX a lot of variables/parameters involved... To generate a diff of this commit: cvs rdiff -u -r1.93.2.5 -r1.93.2.6 src/sys/dev/fss.c cvs rdiff -u -r1.2 -r1.2.2.1 src/sys/rump/dev/lib/libfss/fss_component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.5 src/sys/dev/fss.c:1.93.2.6 --- src/sys/dev/fss.c:1.93.2.5 Wed Jul 27 03:25:00 2016 +++ src/sys/dev/fss.c Sun Jul 31 01:36:49 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $"); #include #include @@ -1321,10 +1321,11 @@ fss_bs_thread(void *arg) MODULE(MODULE_CLASS_DRIVER, fss, NULL); CFDRIVER_DECL(fss, DV_DISK, NULL); +devmajor_t fss_bmajor = -1, fss_cmajor = -1; + static int fss_modcmd(modcmd_t cmd, void *arg) { - devmajor_t bmajor = -1, cmajor = -1; int error = 0; switch (cmd) { @@ -1342,9 +1343,8 @@ fss_modcmd(modcmd_t cmd, void *arg) break; } error = devsw_attach(fss_cd.cd_name, - &fss_bdevsw, &bmajor, &fss_cdevsw, &cmajor); - if (error == EEXIST) - error = 0; + &fss_bdevsw, &fss_bmajor, &fss_cdevsw, &fss_cmajor); + if (error) { config_cfattach_detach(fss_cd.cd_name, &fss_ca); config_cfdriver_detach(&fss_cd); @@ -1354,11 +1354,14 @@ fss_modcmd(modcmd_t cmd, void *arg) break; case MODULE_CMD_FINI: + devsw_detach(&fss_bdevsw, &fss_cdevsw); error = config_cfattach_detach(fss_cd.cd_name, &fss_ca); - if (error) + if (error) { + devsw_attach(fss_cd.cd_name, &fss_bdevsw, &fss_bmajor, + &fss_cdevsw, &fss_cmajor); break; + } config_cfdriver_detach(&fss_cd); - devsw_detach(&fss_bdevsw, &fss_cdevsw); mutex_destroy(&fss_device_lock); break; Index: src/sys/rump/dev/lib/libfss/fss_component.c diff -u src/sys/rump/dev/lib/libfss/fss_component.c:1.2 src/sys/rump/dev/lib/libfss/fss_component.c:1.2.2.1 --- src/sys/rump/dev/lib/libfss/fss_component.c:1.2 Tue Jan 26 23:12:15 2016 +++ src/sys/rump/dev/lib/libfss/fss_component.c Sun Jul 31 01:36:49 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $ */ +/* $NetBSD: fss_component.c,v 1.2.2.1 2016/07/31 01:36:49 pgoyette Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss_component.c,v 1.2.2.1 2016/07/31 01:36:49 pgoyette Exp $"); #include #include @@ -40,20 +40,22 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV) { extern const struct bdevsw fss_bdevsw; extern const struct cdevsw fss_cdevsw; - devmajor_t bmaj, cmaj; + extern devmajor_t fss_bmajor, fss_cmajor; int error; - bmaj = bdevsw_lookup_major(&fss_bdevsw); - cmaj = cdevsw_lookup_major(&fss_cdevsw); + fss_bmajor = bdevsw_lookup_major(&fss_bdevsw); + fss_cmajor = cdevsw_lookup_major(&fss_cdevsw); - if ((error = devsw_attach("fss", &fss_bdevsw, &bmaj, - &fss_cdevsw, &cmaj)) != 0) + if ((error = devsw_attach("fss", &fss_bdevsw, &fss_bmajor, + &fss_cdevsw, &fss_cmajor)) != 0) panic("cannot attach fss: %d", error); if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/fss", '0', - bmaj, 0, 4)) != 0) + fss_bmajor, 0, 4)) != 0) panic("cannot create cooked fss dev nodes: %d", error); if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rfss", '0', - cmaj, 0, 4)) != 0) + fss_cmajor, 0, 4)) != 0) panic("cannot create raw fss dev nodes: %d", error); + + devsw_detach(&fss_bdevsw, &fss_cdevsw); }
CVS commit: [pgoyette-localcount] src/sys
Module Name:src Committed By: pgoyette Date: Wed Apr 26 02:57:17 UTC 2017 Modified Files: src/sys/arch/sh3/include [pgoyette-localcount]: ieeefp.h src/sys/dev/pci [pgoyette-localcount]: piixpm.c Log Message: Resolve a couple of conflicts To generate a diff of this commit: cvs rdiff -u -r1.4.62.1 -r1.4.62.2 src/sys/arch/sh3/include/ieeefp.h cvs rdiff -u -r1.49.2.3 -r1.49.2.4 src/sys/dev/pci/piixpm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sh3/include/ieeefp.h diff -u src/sys/arch/sh3/include/ieeefp.h:1.4.62.1 src/sys/arch/sh3/include/ieeefp.h:1.4.62.2 --- src/sys/arch/sh3/include/ieeefp.h:1.4.62.1 Wed Apr 26 02:53:07 2017 +++ src/sys/arch/sh3/include/ieeefp.h Wed Apr 26 02:57:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ieeefp.h,v 1.4.62.1 2017/04/26 02:53:07 pgoyette Exp $ */ +/* $NetBSD: ieeefp.h,v 1.4.62.2 2017/04/26 02:57:17 pgoyette Exp $ */ /* * Written by J.T. Conklin, Apr 6, 1995 @@ -32,14 +32,11 @@ typedef int fexcept_t; #if defined(_NETBSD_SOURCE) typedef int fp_except; -<<< ieeefp.h -=== #ifdef __SH_FPU_ANY__ /* hardfloat */ ->>> 1.7 #define FP_X_INV FE_INVALID /* invalid operation exception */ #define FP_X_DNML FE_DENORMAL /* denormalization exception */ #define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ Index: src/sys/dev/pci/piixpm.c diff -u src/sys/dev/pci/piixpm.c:1.49.2.3 src/sys/dev/pci/piixpm.c:1.49.2.4 --- src/sys/dev/pci/piixpm.c:1.49.2.3 Wed Apr 26 02:53:22 2017 +++ src/sys/dev/pci/piixpm.c Wed Apr 26 02:57:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: piixpm.c,v 1.49.2.3 2017/04/26 02:53:22 pgoyette Exp $ */ +/* $NetBSD: piixpm.c,v 1.49.2.4 2017/04/26 02:57:17 pgoyette Exp $ */ /* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */ /* @@ -22,11 +22,7 @@ */ #include -<<< piixpm.c -__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.49.2.3 2017/04/26 02:53:22 pgoyette Exp $"); -=== -__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.49.2.3 2017/04/26 02:53:22 pgoyette Exp $"); ->>> 1.52 +__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.49.2.4 2017/04/26 02:57:17 pgoyette Exp $"); #include #include
CVS commit: [pgoyette-localcount] src/sys/sys
Module Name:src Committed By: pgoyette Date: Sat Jul 16 20:40:30 UTC 2016 Modified Files: src/sys/sys [pgoyette-localcount]: Makefile Log Message: Install the localcount.h header file To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.159.2.1 src/sys/sys/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/Makefile diff -u src/sys/sys/Makefile:1.159 src/sys/sys/Makefile:1.159.2.1 --- src/sys/sys/Makefile:1.159 Sun Apr 24 19:48:29 2016 +++ src/sys/sys/Makefile Sat Jul 16 20:40:30 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.159 2016/04/24 19:48:29 dholland Exp $ +# $NetBSD: Makefile,v 1.159.2.1 2016/07/16 20:40:30 pgoyette Exp $ .include @@ -25,7 +25,7 @@ INCS= acct.h agpio.h aio.h ansi.h aout_m ioctl_compat.h iostat.h ipc.h \ joystick.h \ kcore.h kcpuset.h kgdb.h kmem.h ksem.h ksyms.h ktrace.h \ - localedef.h lock.h lockf.h lua.h lwp.h lwpctl.h \ + localcount.h localedef.h lock.h lockf.h lua.h lwp.h lwpctl.h \ malloc.h mallocvar.h mbuf.h md4.h md5.h midiio.h \ mman.h module.h mount.h mqueue.h msg.h msgbuf.h mtio.h mutex.h \ namei.h null.h \
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Sat Jul 16 22:35:34 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Fix some locking sequences. Thanks to ristradh@ for the review! To generate a diff of this commit: cvs rdiff -u -r1.34.2.1 -r1.34.2.2 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.1 src/sys/kern/subr_devsw.c:1.34.2.2 --- src/sys/kern/subr_devsw.c:1.34.2.1 Sat Jul 16 07:54:13 2016 +++ src/sys/kern/subr_devsw.c Sat Jul 16 22:35:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.1 2016/07/16 07:54:13 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.2 2016/07/16 22:35:34 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.1 2016/07/16 07:54:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.2 2016/07/16 22:35:34 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -85,8 +85,10 @@ __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c #include #include #include +#include #include #include +#include #ifdef DEVSW_DEBUG #define DPRINTF(x) printf x @@ -139,6 +141,13 @@ devsw_attach(const char *devname, mutex_enter(&device_lock); + if (bdev != NULL) { + KASSERT(bdev->d_localcount != NULL); + KASSERT(bdev->d_localcount != cdev->d_localcount); + } + if (cdev != NULL) + KASSERT(cdev->d_localcount != NULL); + for (i = 0 ; i < max_devsw_convs ; i++) { conv = &devsw_conv[i]; if (conv->d_name == NULL || strcmp(devname, conv->d_name) != 0) @@ -164,13 +173,14 @@ devsw_attach(const char *devname, goto fail; } + /* use membar_producer() to ensure visibility of the xdevsw */ if (bdev != NULL) { - KASSERT(bdev->d_localcount != NULL); localcount_init(bdev->d_localcount); + membar_producer(); bdevsw[*bmajor] = bdev; } - KASSERT(cdev->d_localcount != NULL); localcount_init(cdev->d_localcount); + membar_producer(); cdevsw[*cmajor] = cdev; mutex_exit(&device_lock); @@ -278,6 +288,9 @@ bdevsw_attach(const struct bdevsw *devsw if (bdevsw[*devmajor] != NULL) return (EEXIST); + /* ensure visibility of the bdevsw */ + membar_producer(); + bdevsw[*devmajor] = devsw; KASSERT(devsw->d_localcount != NULL); localcount_init(devsw->d_localcount); @@ -327,6 +340,9 @@ cdevsw_attach(const struct cdevsw *devsw if (cdevsw[*devmajor] != NULL) return (EEXIST); + /* ensure visibility of the bdevsw */ + membar_producer(); + cdevsw[*devmajor] = devsw; KASSERT(devsw->d_localcount != NULL); localcount_init(devsw->d_localcount); @@ -335,16 +351,15 @@ cdevsw_attach(const struct cdevsw *devsw } /* - * First, look up both bdev and cdev indices, and confirm that the - * localcount pointer(s) exist. Then drain any existing references, - * deactivate the localcount(s). Finally, remove the {b,c}devsw[] - * entries. + * First, look up both bdev and cdev indices, and remove the + * {b,c]devsw[] entries so no new references can be taken. Then + * drain any existing references. */ static void devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev) { - int i, j; + int i, j, s; KASSERT(mutex_owned(&device_lock)); @@ -370,24 +385,21 @@ devsw_detach_locked(const struct bdevsw break; } } - if (i < max_bdevsws) { + if (i < max_bdevsws) + bdevsw[i] = NULL; + if (j < max_cdevsws ) + cdevsw[j] = NULL; + + s = pserialize_read_enter(); + if (i < max_bdevsws && bdev->d_localcount != NULL) { localcount_drain(bdev->d_localcount, &device_cv, &device_lock); localcount_fini(bdev->d_localcount); - bdevsw[i] = NULL; } - if (j < max_cdevsws ) { - /* - * Take care not to drain/fini the d_localcount if the same - * one was used for both cdev and bdev! - */ - if (i >= max_bdevsws || - bdev->d_localcount != cdev->d_localcount) { - localcount_drain(cdev->d_localcount, &device_cv, - &device_lock); - localcount_fini(cdev->d_localcount); - } - cdevsw[j] = NULL; + if (j < max_cdevsws && cdev->d_localcount != NULL ) { + localcount_drain(cdev->d_localcount, &device_cv, &device_lock); + localcount_fini(cdev->d_localcount); } + pserialize_read_exit(s); } int @@ -423,6 +435,8 @@ const struct bdevsw * bdevsw_lookup_acquire(dev_t dev) { devmajor_t bmajor; + const struct bdevsw *bdev = NULL; + int s; if (dev == NODEV) return (NULL); @@ -430,20 +444,35 @@ bdevsw_lookup_acquire(dev_t dev) if (bmajor < 0 || bmajor >= max_bdevsws) return (NULL); + /* Prevent any concurrent attempts to detach the device */ + mutex_enter(&device_lock); + + /* Start a read transaction to block localcount_drain() */ + s = pserialize_read_enter(); + + /* Get the struct bdevsw pointer */ + bdev = bdevsw[bmaj
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Sun Jul 17 02:37:54 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: More locking fixes from riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.34.2.2 -r1.34.2.3 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.2 src/sys/kern/subr_devsw.c:1.34.2.3 --- src/sys/kern/subr_devsw.c:1.34.2.2 Sat Jul 16 22:35:34 2016 +++ src/sys/kern/subr_devsw.c Sun Jul 17 02:37:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.2 2016/07/16 22:35:34 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.2 2016/07/16 22:35:34 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -113,6 +113,7 @@ static void devsw_detach_locked(const st kmutex_t device_lock; kcondvar_t device_cv; +pserialize_t device_psz; void (*biodone_vfs)(buf_t *) = (void *)nullop; @@ -124,6 +125,7 @@ devsw_init(void) KASSERT(sys_cdevsws < MAXDEVSW - 1); mutex_init(&device_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(&device_cv, "devsw"); + device_psz = pserialize_init(); } int @@ -359,7 +361,7 @@ cdevsw_attach(const struct cdevsw *devsw static void devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev) { - int i, j, s; + int i, j; KASSERT(mutex_owned(&device_lock)); @@ -390,7 +392,15 @@ devsw_detach_locked(const struct bdevsw if (j < max_cdevsws ) cdevsw[j] = NULL; - s = pserialize_read_enter(); + /* We need to wait for all current readers to finish. */ + pserialize_perform(device_psz); + + /* + * Here, no new readers can reach the bdev and cdev via the + * {b,c}devsw[] arrays. Wait for existing references to + * drain, and then destroy. + */ + if (i < max_bdevsws && bdev->d_localcount != NULL) { localcount_drain(bdev->d_localcount, &device_cv, &device_lock); localcount_fini(bdev->d_localcount); @@ -399,7 +409,6 @@ devsw_detach_locked(const struct bdevsw localcount_drain(cdev->d_localcount, &device_cv, &device_lock); localcount_fini(cdev->d_localcount); } - pserialize_read_exit(s); } int @@ -444,9 +453,6 @@ bdevsw_lookup_acquire(dev_t dev) if (bmajor < 0 || bmajor >= max_bdevsws) return (NULL); - /* Prevent any concurrent attempts to detach the device */ - mutex_enter(&device_lock); - /* Start a read transaction to block localcount_drain() */ s = pserialize_read_enter(); @@ -463,9 +469,6 @@ bdevsw_lookup_acquire(dev_t dev) localcount_acquire(bdevsw[bmajor]->d_localcount); out: pserialize_read_exit(s); - mutex_exit(&device_lock); - - return bdev; } void
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Sun Jul 17 05:02:20 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: 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() To generate a diff of this commit: cvs rdiff -u -r1.34.2.3 -r1.34.2.4 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.3 src/sys/kern/subr_devsw.c:1.34.2.4 --- src/sys/kern/subr_devsw.c:1.34.2.3 Sun Jul 17 02:37:54 2016 +++ src/sys/kern/subr_devsw.c Sun Jul 17 05:02:19 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.3 2016/07/17 02:37:54 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -113,7 +113,7 @@ static void devsw_detach_locked(const st kmutex_t device_lock; kcondvar_t device_cv; -pserialize_t device_psz; +pserialize_t device_psz = NULL; void (*biodone_vfs)(buf_t *) = (void *)nullop; @@ -125,7 +125,6 @@ devsw_init(void) KASSERT(sys_cdevsws < MAXDEVSW - 1); mutex_init(&device_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(&device_cv, "devsw"); - device_psz = pserialize_init(); } int @@ -392,7 +391,12 @@ devsw_detach_locked(const struct bdevsw if (j < max_cdevsws ) cdevsw[j] = NULL; - /* We need to wait for all current readers to finish. */ + /* + * If we haven't already done so, create the serialization + * stucture. Then wait for all current readers to finish. + */ + if(__predict_false(device_psz == NULL)) + device_psz = pserialize_create(); pserialize_perform(device_psz); /* @@ -469,6 +473,8 @@ bdevsw_lookup_acquire(dev_t dev) localcount_acquire(bdevsw[bmajor]->d_localcount); out: pserialize_read_exit(s); + + return bdev; } void @@ -512,9 +518,6 @@ cdevsw_lookup_acquire(dev_t dev) if (cmajor < 0 || cmajor >= max_cdevsws) return (NULL); - /* Prevent any concurrent attempts to detach the device */ - mutex_enter(&device_lock); - /* Start a read transaction to block localcount_drain() */ s = pserialize_read_enter(); @@ -523,7 +526,7 @@ cdevsw_lookup_acquire(dev_t dev) if (cdev == NULL) goto out; - /* Wait for the content of the struct bdevsw to become visible */ + /* Wait for the content of the struct cdevsw to become visible */ membar_datadep_consumer(); /* If the devsw is not statically linked, acquire a reference */
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Sun Jul 17 12:09:21 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: More details in KASSERTs to aid debugging To generate a diff of this commit: cvs rdiff -u -r1.34.2.4 -r1.34.2.5 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.4 src/sys/kern/subr_devsw.c:1.34.2.5 --- src/sys/kern/subr_devsw.c:1.34.2.4 Sun Jul 17 05:02:19 2016 +++ src/sys/kern/subr_devsw.c Sun Jul 17 12:09:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.4 2016/07/17 05:02:19 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.5 2016/07/17 12:09:21 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -143,11 +143,15 @@ devsw_attach(const char *devname, mutex_enter(&device_lock); if (bdev != NULL) { - KASSERT(bdev->d_localcount != NULL); - KASSERT(bdev->d_localcount != cdev->d_localcount); + KASSERTMSG(bdev->d_localcount != NULL, + "%s: bdev %s has no d_localcount", __func__, devname); + KASSERTMSG(bdev->d_localcount != cdev->d_localcount, + "%s: bdev and cdev for %s have same d_localcount", + __func__, devname); } if (cdev != NULL) - KASSERT(cdev->d_localcount != NULL); + KASSERTMGS(cdev->d_localcount != NULL, + "%s: cdev %s has no d_localcount", __func__, devname); for (i = 0 ; i < max_devsw_convs ; i++) { conv = &devsw_conv[i]; @@ -272,7 +276,7 @@ bdevsw_attach(const struct bdevsw *devsw } if (*devmajor >= MAXDEVSW) { - printf("bdevsw_attach: block majors exhausted"); + printf("%s: block majors exhausted", __func__); return (ENOMEM); } @@ -293,7 +297,8 @@ bdevsw_attach(const struct bdevsw *devsw membar_producer(); bdevsw[*devmajor] = devsw; - KASSERT(devsw->d_localcount != NULL); + KASSERTMSG(devsw->d_localcount != NULL, "%s: bdev for major %d has " + "no localcount", __func__, *devmajor); localcount_init(devsw->d_localcount); return (0); @@ -324,7 +329,7 @@ cdevsw_attach(const struct cdevsw *devsw } if (*devmajor >= MAXDEVSW) { - printf("cdevsw_attach: character majors exhausted"); + printf("%s: character majors exhausted", __func__); return (ENOMEM); } @@ -345,7 +350,8 @@ cdevsw_attach(const struct cdevsw *devsw membar_producer(); cdevsw[*devmajor] = devsw; - KASSERT(devsw->d_localcount != NULL); + KASSERTMSG(devsw->d_localcount != NULL, "%s: cdev for major %d has " + "no localcount", __func__, *devmajor); localcount_init(devsw->d_localcount); return (0); @@ -371,7 +377,7 @@ devsw_detach_locked(const struct bdevsw continue; KASSERTMSG(bdev->d_localcount != NULL, - "%s: no bdev localcount", __func__); + "%s: no bdev localcount for major %d", __func__, i); break; } } @@ -382,7 +388,7 @@ devsw_detach_locked(const struct bdevsw continue; KASSERTMSG(cdev->d_localcount != NULL, - "%s: no cdev localcount", __func__); + "%s: no cdev localcount for major %d", __func__, j); break; } } @@ -400,7 +406,7 @@ devsw_detach_locked(const struct bdevsw pserialize_perform(device_psz); /* - * Here, no new readers can reach the bdev and cdev via the + * No new readers can reach the bdev and cdev via the * {b,c}devsw[] arrays. Wait for existing references to * drain, and then destroy. */
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Sun Jul 17 21:40:47 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Fix typo in KASSERTMSG macro name To generate a diff of this commit: cvs rdiff -u -r1.34.2.6 -r1.34.2.7 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.6 src/sys/kern/subr_devsw.c:1.34.2.7 --- src/sys/kern/subr_devsw.c:1.34.2.6 Sun Jul 17 21:39:17 2016 +++ src/sys/kern/subr_devsw.c Sun Jul 17 21:40:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.6 2016/07/17 21:39:17 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -157,7 +157,7 @@ devsw_attach(const char *devname, __func__, devname); } if (cdev != NULL) - KASSERTMGS(cdev->d_localcount != NULL, + KASSERTMSG(cdev->d_localcount != NULL, "%s: cdev %s has no d_localcount", __func__, devname); for (i = 0 ; i < max_devsw_convs ; i++) {
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:18:49 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Another case of needing to use the two different localcount that were allocated. To generate a diff of this commit: cvs rdiff -u -r1.256.2.1 -r1.256.2.2 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.1 src/sys/dev/vnd.c:1.256.2.2 --- src/sys/dev/vnd.c:1.256.2.1 Mon Jul 18 03:49:59 2016 +++ src/sys/dev/vnd.c Mon Jul 18 21:18:49 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.1 2016/07/18 03:49:59 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.2 2016/07/18 21:18:49 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.1 2016/07/18 03:49:59 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.2 2016/07/18 21:18:49 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -228,7 +228,7 @@ const struct cdevsw vnd_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = &vnd_b_localcount, + .d_localcount = &vnd_c_localcount, #endif .d_flag = D_DISK };
CVS commit: [pgoyette-localcount] src/sys/arch
Module Name:src Committed By: pgoyette Date: Wed Jul 20 02:06:16 UTC 2016 Modified Files: src/sys/arch/acorn26/ioc [pgoyette-localcount]: arcpp.c src/sys/arch/acorn32/mainbus [pgoyette-localcount]: fd.c src/sys/arch/acorn32/podulebus [pgoyette-localcount]: asc.c src/sys/arch/alpha/pci [pgoyette-localcount]: mcpcia.c src/sys/arch/alpha/tc [pgoyette-localcount]: ioasic.c src/sys/arch/amiga/dev [pgoyette-localcount]: afsc.c ahsc.c atzsc.c bppcsc.c cbiiisc.c drsc.c fd.c gtsc.c mfc.c mgnsc.c wesc.c src/sys/arch/arc/jazz [pgoyette-localcount]: fd.c src/sys/arch/arm/amlogic [pgoyette-localcount]: amlogic_com.c src/sys/arch/arm/at91 [pgoyette-localcount]: at91dbgu.c at91usart.c Log Message: Redo previous. Rather than separately extracting the device_t, we can rely on sc->sc_dev when we need to call device_release(). To generate a diff of this commit: cvs rdiff -u -r1.15.2.1 -r1.15.2.2 src/sys/arch/acorn26/ioc/arcpp.c cvs rdiff -u -r1.58.2.1 -r1.58.2.2 src/sys/arch/acorn32/mainbus/fd.c cvs rdiff -u -r1.20.4.1 -r1.20.4.2 src/sys/arch/acorn32/podulebus/asc.c cvs rdiff -u -r1.29.28.1 -r1.29.28.2 src/sys/arch/alpha/pci/mcpcia.c cvs rdiff -u -r1.46.10.1 -r1.46.10.2 src/sys/arch/alpha/tc/ioasic.c cvs rdiff -u -r1.44.18.1 -r1.44.18.2 src/sys/arch/amiga/dev/afsc.c cvs rdiff -u -r1.38.18.1 -r1.38.18.2 src/sys/arch/amiga/dev/ahsc.c cvs rdiff -u -r1.43.18.1 -r1.43.18.2 src/sys/arch/amiga/dev/atzsc.c cvs rdiff -u -r1.3.18.1 -r1.3.18.2 src/sys/arch/amiga/dev/bppcsc.c cvs rdiff -u -r1.21.18.1 -r1.21.18.2 src/sys/arch/amiga/dev/cbiiisc.c cvs rdiff -u -r1.33.10.1 -r1.33.10.2 src/sys/arch/amiga/dev/drsc.c cvs rdiff -u -r1.96.2.1 -r1.96.2.2 src/sys/arch/amiga/dev/fd.c cvs rdiff -u -r1.41.18.1 -r1.41.18.2 src/sys/arch/amiga/dev/gtsc.c cvs rdiff -u -r1.57.8.1 -r1.57.8.2 src/sys/arch/amiga/dev/mfc.c cvs rdiff -u -r1.46.18.1 -r1.46.18.2 src/sys/arch/amiga/dev/mgnsc.c cvs rdiff -u -r1.40.18.1 -r1.40.18.2 src/sys/arch/amiga/dev/wesc.c cvs rdiff -u -r1.47.2.1 -r1.47.2.2 src/sys/arch/arc/jazz/fd.c cvs rdiff -u -r1.5.4.1 -r1.5.4.2 src/sys/arch/arm/amlogic/amlogic_com.c cvs rdiff -u -r1.15.2.1 -r1.15.2.2 src/sys/arch/arm/at91/at91dbgu.c cvs rdiff -u -r1.13.2.1 -r1.13.2.2 src/sys/arch/arm/at91/at91usart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/acorn26/ioc/arcpp.c diff -u src/sys/arch/acorn26/ioc/arcpp.c:1.15.2.1 src/sys/arch/acorn26/ioc/arcpp.c:1.15.2.2 --- src/sys/arch/acorn26/ioc/arcpp.c:1.15.2.1 Tue Jul 19 06:26:57 2016 +++ src/sys/arch/acorn26/ioc/arcpp.c Wed Jul 20 02:06:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: arcpp.c,v 1.15.2.1 2016/07/19 06:26:57 pgoyette Exp $ */ +/* $NetBSD: arcpp.c,v 1.15.2.2 2016/07/20 02:06:15 pgoyette Exp $ */ /*- * Copyright (c) 2001 Ben Harris @@ -52,7 +52,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: arcpp.c,v 1.15.2.1 2016/07/19 06:26:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arcpp.c,v 1.15.2.2 2016/07/20 02:06:15 pgoyette Exp $"); #include #include @@ -191,16 +191,10 @@ arcppopen(dev_t dev, int flag, int mode, bus_space_tag_t iot; bus_space_handle_t ioh; int error, s; - device_t self; - self = device_lookup_acquire(&arcpp_cd, minor(dev)); - if (self == NULL) + sc = device_lookup_private_acquire(&arcpp_cd, ARCPPUNIT(dev)); + if (sc == NULL) return ENXIO; - sc = device_private(self); - if (sc == NULL) { - error = ENXIO; - goto out; - } #ifdef DIAGNOSTIC if (sc->sc_state) @@ -208,10 +202,8 @@ arcppopen(dev_t dev, int flag, int mode, sc->sc_state); #endif - if (sc->sc_state) { - error = EBUSY; - goto out; - } + if (sc->sc_state) + return EBUSY; sc->sc_state = ARCPP_INIT; sc->sc_flags = flags; @@ -226,13 +218,14 @@ arcppopen(dev_t dev, int flag, int mode, if (error == EWOULDBLOCK) { sc->sc_state = 0; splx(s); - error = EBUSY; - goto out; + device_release(sc->sc_dev); + return EBUSY; } if (error) { sc->sc_state = 0; splx(s); - goto out; + device_release(sc->sc_dev); + return error; } sc->sc_inbuf = malloc(ARCPP_BSIZE, M_DEVBUF, M_WAITOK); @@ -243,10 +236,8 @@ arcppopen(dev_t dev, int flag, int mode, arcppintr(sc); splx(s); + device_release(sc->sc_dev); return 0; - - out: device_release(self); - return error; } /* @@ -255,17 +246,9 @@ arcppopen(dev_t dev, int flag, int mode, int arcppclose(dev_t dev, int flag, int mode, struct lwp *l) { - device_t self; - struct arcpp_softc *sc; + struct arcpp_softc *sc = + device_lookup_private_acquire(&arcpp_cd, ARCPPUNIT(dev)); - self = device_lookup_acquire(&arcpp_cd, minor(dev)); - if (self == NULL) - return ENXIO; - sc = device_private(&arcpp_cd, ARCPPUNIT(dev)); - if (sc == NULL) { - device_release(self); - return ENXIO; - } if (sc->sc_count) (void) arcpppushbytes(sc); @@ -274,7 +257,7 @@ arcppclose(dev_t dev, int flag, int mode sc->sc_state = 0;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 04:33:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Rather than manually manipulating individual autoconf data, just use config_{init,fini}_component() to do it all at once. To generate a diff of this commit: cvs rdiff -u -r1.108.2.2 -r1.108.2.3 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.2 src/sys/dev/cgd.c:1.108.2.3 --- src/sys/dev/cgd.c:1.108.2.2 Tue Jul 19 06:26:58 2016 +++ src/sys/dev/cgd.c Wed Jul 20 04:33:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.2 2016/07/19 06:26:58 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.2 2016/07/19 06:26:58 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $"); #include #include @@ -1045,35 +1045,54 @@ cgd_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE - error = config_cfdriver_attach(&cgd_cd); - if (error) - break; - - error = config_cfattach_attach(cgd_cd.cd_name, &cgd_ca); - if (error) { - config_cfdriver_detach(&cgd_cd); - aprint_error("%s: unable to register cfattach\n", + /* + * Insert the driver into the autoconf database + */ + error = config_init_component(cfdriver_ioconf_cgd, +cfattach_ioconf_cgd, cfdata_ioconf_cgd); + if (error) { + aprint_error("%s: unable to init component", cgd_cd.cd_name); break; } + /* + * Attach the {b,c}devsw's + */ error = devsw_attach("cgd", &cgd_bdevsw, &bmajor, &cgd_cdevsw, &cmajor); + + /* + * If devsw_attach fails, remove from autoconf database + */ if (error) { - config_cfattach_detach(cgd_cd.cd_name, &cgd_ca); - config_cfdriver_detach(&cgd_cd); - break; + config_fini_component(cfdriver_ioconf_cgd, + cfattach_ioconf_cgd, cfdata_ioconf_cgd); + aprint_error("%s: unable to attach devsw", +cgd_cd.cd_name); } #endif break; case MODULE_CMD_FINI: #ifdef _MODULE - error = config_cfattach_detach(cgd_cd.cd_name, &cgd_ca); - if (error) - break; - config_cfdriver_detach(&cgd_cd); + /* + * Remove {b,c}devsw's + */ devsw_detach(&cgd_bdevsw, &cgd_cdevsw); + + /* + * Now remove device from autoconf database + */ + error = config_fini_component(cfdriver_ioconf_cgd, + cfattach_ioconf_cgd, cfdata_ioconf_cgd); + + /* + * If removal fails, re-attach our {b,c}devsw's + */ + if (error) + devsw_attach("cgd", &cgd_bdevsw, &bmajor, + &cgd_cdevsw, &cmajor); #endif break;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 06:51:13 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: First pass at updating the cgd(4) driver for use with localcount(9) ref-counts. So far all I've done is to manage the ref-counts. This will defer removal of the driver from the devsw tables and/or the autoconf tree while anyone has a reference to any of the device's critical data (mostly, the softc or the device_t). Note that these ref-counts will only defer the removal; once the references are released, the removal will proceed. On-going work is needed to identify potentially blocking operations, and to deny any removals if such operations are in-flight. We really shouldn't be waiting (possibly indefinitely) for these operations to complete, especially since removals could be attempted by the module(9) subsystem while holding the kernel_config lock. To generate a diff of this commit: cvs rdiff -u -r1.108.2.3 -r1.108.2.4 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.3 src/sys/dev/cgd.c:1.108.2.4 --- src/sys/dev/cgd.c:1.108.2.3 Wed Jul 20 04:33:53 2016 +++ src/sys/dev/cgd.c Wed Jul 20 06:51:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $"); #include #include @@ -176,6 +176,17 @@ static void hexprint(const char *, void /* The code */ +static void +cgd_release(dev_t dev) +{ + int unit = CGDUNIT(dev); + device_t self; + + self = device_lookup_acquire(&cgd_cd, unit); + if (self != NULL) + device_release(self); +} + static struct cgd_softc * getcgd_softc(dev_t dev) { @@ -247,6 +258,7 @@ cgdattach(int num) static struct cgd_softc * cgd_spawn(int unit) { + device_t self; cfdata_t cf; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); @@ -255,7 +267,17 @@ cgd_spawn(int unit) cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - return device_private(config_attach_pseudo(cf)); + if (config_attach_pseudo(cf) == NULL) + return NULL; + + self = device_lookup_acquire(&cgd_cd, unit); + if (self == NULL) + return NULL; + else + /* + * Note that we return with a reference to the device! + */ + return device_private(self); } static int @@ -326,23 +348,30 @@ cgdstrategy(struct buf *bp) bp->b_error = EINVAL; bp->b_resid = bp->b_bcount; biodone(bp); + cgd_release(bp->b_dev); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(&cs->sc_dksc, bp); + cgd_release(bp->b_dev); return; } static int cgdsize(dev_t dev) { + int retval; struct cgd_softc *cs = getcgd_softc(dev); DPRINTF_FOLLOW(("cgdsize(0x%"PRIx64")\n", dev)); if (!cs) - return -1; - return dk_size(&cs->sc_dksc, dev); + retval = -1; + else + retval = dk_size(&cs->sc_dksc, dev); + + cgd_release(dev); + return retval; } /* @@ -451,6 +480,7 @@ cgd_diskstart(device_t dev, struct buf * static void cgdiodone(struct buf *nbp) { + dev_t dev; struct buf *obp = nbp->b_private; struct cgd_softc *cs = getcgd_softc(obp->b_dev); struct dk_softc *dksc = &cs->sc_dksc; @@ -494,7 +524,14 @@ cgdiodone(struct buf *nbp) if (obp->b_error != 0) obp->b_resid = obp->b_bcount; + /* + * copy the dev_t, finish the disk operation, and release the + * reference we're holding on to (from cgd_getsoftc() earlier) + */ + dev = obp->b_dev; dk_done(dksc, obp); + cgd_release(dev); + dk_start(dksc, NULL); } @@ -817,8 +854,10 @@ cgd_ioctl_get(dev_t dev, void *data, str if (cgu->cgu_unit == -1) cgu->cgu_unit = unit; - if (cgu->cgu_unit < 0) + if (cgu->cgu_unit < 0) { + cgd_release(dev); return EINVAL; /* XXX: should this be ENXIO? */ + } cs = device_lookup_private(&cgd_cd, unit); if (cs == NULL || !DK_ATTACHED(dksc)) { @@ -836,6 +875,7 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_mode = cs->sc_cdata.cf_mode; cgu->cgu_keylen = cs->sc_cdata.cf_keylen; } + cgd_release(dev); return 0; } @@ -1030,7 +1070,7 @@ hexprint(const char *start, void *buf, i MODULE(MODULE_CLASS_DRIVER, cgd, "dk_subr"); #ifdef _MODULE -CFDRIVER_DECL(cgd, DV_DISK, NULL); +#include "ioconf.c" #endif static int @@ -1051,8 +1091,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) error = config_init_component(cfdriver_ioconf_cgd, cfattach_ioconf_cgd, cfdata_ioconf_cgd); if (error) { - aprint_error("%s: unable to init component", - cgd_cd.cd_name); + aprint_error("%s: unable to init component" + ", error %d", cgd_cd.cd_name, error); break; } @
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Wed Jul 20 07:07:05 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Improved comment. No code change. To generate a diff of this commit: cvs rdiff -u -r1.34.2.7 -r1.34.2.8 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.7 src/sys/kern/subr_devsw.c:1.34.2.8 --- src/sys/kern/subr_devsw.c:1.34.2.7 Sun Jul 17 21:40:47 2016 +++ src/sys/kern/subr_devsw.c Wed Jul 20 07:07:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.8 2016/07/20 07:07:04 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.7 2016/07/17 21:40:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.8 2016/07/20 07:07:04 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -404,13 +404,14 @@ devsw_detach_locked(const struct bdevsw if (j < max_cdevsws ) cdevsw[j] = NULL; - /* Wait for all current readers to finish with the devsw */ + /* Wait for all current readers to finish with the devsw's */ pserialize_perform(device_psz); /* - * No new readers can reach the bdev and cdev via the - * {b,c}devsw[] arrays. Wait for existing references to - * drain, and then destroy. + * No new accessors can reach the bdev and cdev via the + * {b,c}devsw[] arrays, so no new references can be + * acquired. Wait for all existing references to drain, + * and then destroy. */ if (i < max_bdevsws && bdev->d_localcount != NULL) {
CVS commit: [pgoyette-localcount] src/sys/arch
Module Name:src Committed By: pgoyette Date: Wed Jul 20 23:50:56 UTC 2016 Modified Files: src/sys/arch/acorn32/mainbus [pgoyette-localcount]: fd.c src/sys/arch/alpha/alpha [pgoyette-localcount]: machdep.c src/sys/arch/amd64/amd64 [pgoyette-localcount]: machdep.c src/sys/arch/amiga/amiga [pgoyette-localcount]: machdep.c src/sys/arch/amiga/dev [pgoyette-localcount]: ser.c src/sys/arch/arm/arm32 [pgoyette-localcount]: stubs.c src/sys/arch/atari/atari [pgoyette-localcount]: autoconf.c machdep.c src/sys/arch/atari/dev [pgoyette-localcount]: md_root.c src/sys/arch/cesfic/cesfic [pgoyette-localcount]: machdep.c src/sys/arch/hp300/dev [pgoyette-localcount]: dcm.c src/sys/arch/hp300/hp300 [pgoyette-localcount]: machdep.c src/sys/arch/hppa/hppa [pgoyette-localcount]: machdep.c src/sys/arch/i386/i386 [pgoyette-localcount]: dumpsys.c src/sys/arch/luna68k/luna68k [pgoyette-localcount]: machdep.c src/sys/arch/mac68k/dev [pgoyette-localcount]: zs_kgdb.c src/sys/arch/mac68k/mac68k [pgoyette-localcount]: machdep.c src/sys/arch/mips/mips [pgoyette-localcount]: mips_machdep.c src/sys/arch/mipsco/obio [pgoyette-localcount]: zs_kgdb.c src/sys/arch/mvme68k/mvme68k [pgoyette-localcount]: machdep.c src/sys/arch/news68k/news68k [pgoyette-localcount]: machdep.c src/sys/arch/next68k/dev [pgoyette-localcount]: zs_kgdb.c src/sys/arch/next68k/next68k [pgoyette-localcount]: machdep.c src/sys/arch/sgimips/dev [pgoyette-localcount]: zs_kgdb.c src/sys/arch/sparc/dev [pgoyette-localcount]: zs_kgdb.c src/sys/arch/sparc/sparc [pgoyette-localcount]: machdep.c src/sys/arch/sparc64/sparc64 [pgoyette-localcount]: machdep.c src/sys/arch/sun2/dev [pgoyette-localcount]: consinit.c zs_kgdb.c src/sys/arch/sun2/sun2 [pgoyette-localcount]: machdep.c src/sys/arch/sun3/dev [pgoyette-localcount]: zs_kgdb.c src/sys/arch/sun3/sun3 [pgoyette-localcount]: machdep.c src/sys/arch/sun3/sun3x [pgoyette-localcount]: machdep.c src/sys/arch/vax/vax [pgoyette-localcount]: machdep.c src/sys/arch/x68k/x68k [pgoyette-localcount]: machdep.c src/sys/arch/xen/xen [pgoyette-localcount]: xbdback_xenbus.c Log Message: Adapt the machine/arch dependent code to the new {b,c}devsw reference counting. XXX Most of these will require testing by someone other than myself, as I have a limited selection of hardware! To generate a diff of this commit: cvs rdiff -u -r1.58.2.2 -r1.58.2.3 src/sys/arch/acorn32/mainbus/fd.c cvs rdiff -u -r1.346 -r1.346.4.1 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.223 -r1.223.2.1 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.246 -r1.246.2.1 src/sys/arch/amiga/amiga/machdep.c cvs rdiff -u -r1.83.8.1 -r1.83.8.2 src/sys/arch/amiga/dev/ser.c cvs rdiff -u -r1.24 -r1.24.18.1 src/sys/arch/arm/arm32/stubs.c cvs rdiff -u -r1.65 -r1.65.10.1 src/sys/arch/atari/atari/autoconf.c cvs rdiff -u -r1.177 -r1.177.10.1 src/sys/arch/atari/atari/machdep.c cvs rdiff -u -r1.33 -r1.33.44.1 src/sys/arch/atari/dev/md_root.c cvs rdiff -u -r1.66 -r1.66.2.1 src/sys/arch/cesfic/cesfic/machdep.c cvs rdiff -u -r1.88 -r1.88.4.1 src/sys/arch/hp300/dev/dcm.c cvs rdiff -u -r1.229 -r1.229.8.1 src/sys/arch/hp300/hp300/machdep.c cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/arch/hppa/hppa/machdep.c cvs rdiff -u -r1.16 -r1.16.28.1 src/sys/arch/i386/i386/dumpsys.c cvs rdiff -u -r1.99 -r1.99.2.1 src/sys/arch/luna68k/luna68k/machdep.c cvs rdiff -u -r1.11 -r1.11.68.1 src/sys/arch/mac68k/dev/zs_kgdb.c cvs rdiff -u -r1.349 -r1.349.2.1 src/sys/arch/mac68k/mac68k/machdep.c cvs rdiff -u -r1.272 -r1.272.2.1 src/sys/arch/mips/mips/mips_machdep.c cvs rdiff -u -r1.10 -r1.10.44.1 src/sys/arch/mipsco/obio/zs_kgdb.c cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/arch/mvme68k/mvme68k/machdep.c cvs rdiff -u -r1.101 -r1.101.10.1 src/sys/arch/news68k/news68k/machdep.c cvs rdiff -u -r1.12 -r1.12.68.1 src/sys/arch/next68k/dev/zs_kgdb.c cvs rdiff -u -r1.111 -r1.111.10.1 src/sys/arch/next68k/next68k/machdep.c cvs rdiff -u -r1.15 -r1.15.44.1 src/sys/arch/sgimips/dev/zs_kgdb.c cvs rdiff -u -r1.21 -r1.21.44.1 src/sys/arch/sparc/dev/zs_kgdb.c cvs rdiff -u -r1.327 -r1.327.4.1 src/sys/arch/sparc/sparc/machdep.c cvs rdiff -u -r1.285 -r1.285.2.1 src/sys/arch/sparc64/sparc64/machdep.c cvs rdiff -u -r1.9 -r1.9.20.1 src/sys/arch/sun2/dev/consinit.c cvs rdiff -u -r1.10 -r1.10.68.1 src/sys/arch/sun2/dev/zs_kgdb.c cvs rdiff -u -r1.77 -r1.77.10.1 src/sys/arch/sun2/sun2/machdep.c cvs rdiff -u -r1.26 -r1.26.18.1 src/sys/arch/sun3/dev/zs_kgdb.c cvs rdiff -u -r1.208 -r1.208.10.1 src/sys/arch/sun3/sun3/machdep.c cvs rdiff -u -r1.135 -r1.135.10.1 src/sys/arch/sun3/sun3x/machdep.c cvs rdiff -u -r1.191 -r1.191.2.1 src/sys/arch/vax/vax/machdep.c cvs rdiff -u -r1.193 -r1.193.2.1 src/sys/arch/x68k/x68k/machdep.c cvs rdiff -u -r1.62 -r1.62.2.1 src/sys/arch/xen/
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Thu Jul 21 06:22:31 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Remove a stray call to mutex_exit() that is left over from a previous incarnation of this code. To generate a diff of this commit: cvs rdiff -u -r1.34.2.8 -r1.34.2.9 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.8 src/sys/kern/subr_devsw.c:1.34.2.9 --- src/sys/kern/subr_devsw.c:1.34.2.8 Wed Jul 20 07:07:04 2016 +++ src/sys/kern/subr_devsw.c Thu Jul 21 06:22:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.8 2016/07/20 07:07:04 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.9 2016/07/21 06:22:31 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.8 2016/07/20 07:07:04 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.9 2016/07/21 06:22:31 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -543,7 +543,6 @@ cdevsw_lookup_acquire(dev_t dev) localcount_acquire(cdevsw[cmajor]->d_localcount); out: pserialize_read_exit(s); - mutex_exit(&device_lock); return cdev; }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 02:02:24 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c Log Message: In config_devfree(), free the 'struct localcount' In device_lookup_private_acquire() we need to ensure that the caller has access to the device_t so the reference that we're acquiring can later be device_release()d. So we must require that the device has non-NULL private data where the pointer back to the device_t can be stored (ie, in xxx->sc_dev). To generate a diff of this commit: cvs rdiff -u -r1.246.2.2 -r1.246.2.3 src/sys/kern/subr_autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.2 src/sys/kern/subr_autoconf.c:1.246.2.3 --- src/sys/kern/subr_autoconf.c:1.246.2.2 Sat Jul 16 22:06:42 2016 +++ src/sys/kern/subr_autoconf.c Fri Jul 22 02:02:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.2 2016/07/16 22:06:42 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.3 2016/07/22 02:02:24 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.2 2016/07/16 22:06:42 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.3 2016/07/22 02:02:24 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1237,8 +1237,10 @@ config_devfree(device_t dev) { int priv = (dev->dv_flags & DVF_PRIV_ALLOC); - if (dev->dv_localcnt != NULL) + if (dev->dv_localcnt != NULL) { localcount_fini(dev->dv_localcnt); + kmem_free(dev->dv_localcnt, sizeof(*dev->dv_localcnt)); + } if (dev->dv_cfattach->ca_devsize > 0) kmem_free(dev->dv_private, dev->dv_cfattach->ca_devsize); if (priv) @@ -2256,7 +2258,7 @@ device_lookup(cfdriver_t cd, int unit) } /* - * device_lookup_accquire: + * device_lookup_acquire: * * Look up a device instance for a given driver and * hold a reference to the device. @@ -2307,14 +2309,27 @@ device_lookup_private(cfdriver_t cd, int /* * device_lookup_private_acquire: * - * Look up the softc and acquire a reference to the device - * so it won't disappear. + * Look up the softc and acquire a reference to the device so it + * won't disappear. Note that the caller must ensure that it is + * capable of calling device_release() at some later point in + * time, thus the returned private data must contain some data + * to locate the original device. Thus the private data must be + * present, not NULL! If this cannot be guaranteed, the caller + * should use device_lookup_acquire() in order to retain the + * device_t pointer. */ void * device_lookup_private_acquire(cfdriver_t cd, int unit) { + device_t dv; + void *p; - return device_private(device_lookup_acquire(cd, unit)); + dv = device_lookup_acquire(cd, unit); + p = device_private(dv); + KASSERTMSG(p != NULL || dv == NULL, + "%s: device %s has no private data", __func__, cd->cd_name); +unit, dv, p); */ + return p; } /*
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 02:05:39 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c Log Message: Remove stray debugging info To generate a diff of this commit: cvs rdiff -u -r1.246.2.3 -r1.246.2.4 src/sys/kern/subr_autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.3 src/sys/kern/subr_autoconf.c:1.246.2.4 --- src/sys/kern/subr_autoconf.c:1.246.2.3 Fri Jul 22 02:02:24 2016 +++ src/sys/kern/subr_autoconf.c Fri Jul 22 02:05:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.3 2016/07/22 02:02:24 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.4 2016/07/22 02:05:39 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.3 2016/07/22 02:02:24 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.4 2016/07/22 02:05:39 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -2328,7 +2328,6 @@ device_lookup_private_acquire(cfdriver_t p = device_private(dv); KASSERTMSG(p != NULL || dv == NULL, "%s: device %s has no private data", __func__, cd->cd_name); -unit, dv, p); */ return p; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:39:43 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Make sure that whenever we're using the cgd device's softc, we maintain a reference to the device so things won't get deleted out from under us! To generate a diff of this commit: cvs rdiff -u -r1.108.2.4 -r1.108.2.5 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.4 src/sys/dev/cgd.c:1.108.2.5 --- src/sys/dev/cgd.c:1.108.2.4 Wed Jul 20 06:51:13 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:39:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $"); #include #include @@ -102,7 +102,7 @@ const struct cdevsw cgd_cdevsw = { static int cgd_match(device_t, cfdata_t, void *); static void cgd_attach(device_t, device_t, void *); static int cgd_detach(device_t, int); -static struct cgd_softc *cgd_spawn(int); +static struct cgd_softc *cgd_spawn(int, *device_t); static int cgd_destroy(device_t); /* Internal Functions */ @@ -172,7 +172,8 @@ static void hexprint(const char *, void /* Utility Functions */ #define CGDUNIT(x) DISKUNIT(x) -#define GETCGD_SOFTC(_cs, x) if (!((_cs) = getcgd_softc(x))) return ENXIO +#define GETCGD_SOFTC(_cs, x, _dv)\ + if (!((_cs) = getcgd_softc(x, &_dv))) return ENXIO; /* The code */ @@ -188,16 +189,20 @@ cgd_release(dev_t dev) } static struct cgd_softc * -getcgd_softc(dev_t dev) +getcgd_softc(dev_t dev, device_t *self) { int unit = CGDUNIT(dev); struct cgd_softc *sc; DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); - sc = device_lookup_private(&cgd_cd, unit); + *self = device_lookup_acquire(&cgd_cd, unit); + if (*self == NULL) + return NULL; + + sc = device_private(*self); if (sc == NULL) - sc = cgd_spawn(unit); + sc = cgd_spawn(unit, *self); return sc; } @@ -256,9 +261,8 @@ cgdattach(int num) } static struct cgd_softc * -cgd_spawn(int unit) +cgd_spawn(int unit, device_t *self) { - device_t self; cfdata_t cf; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); @@ -270,14 +274,15 @@ cgd_spawn(int unit) if (config_attach_pseudo(cf) == NULL) return NULL; - self = device_lookup_acquire(&cgd_cd, unit); + *self = device_lookup_acquire(&cgd_cd, unit); if (self == NULL) return NULL; else /* - * Note that we return with a reference to the device! + * Note that we return while still holding a reference + * to the device! */ - return device_private(self); + return device_private(*self); } static int @@ -297,40 +302,50 @@ cgd_destroy(device_t dev) static int cgdopen(dev_t dev, int flags, int fmt, struct lwp *l) { + device_t self; + int error; struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); - GETCGD_SOFTC(cs, dev); - return dk_open(&cs->sc_dksc, dev, flags, fmt, l); + GETCGD_SOFTC(cs, dev, self); + error = dk_open(&cs->sc_dksc, dev, flags, fmt, l); + device_release(self); + return error; } static int cgdclose(dev_t dev, int flags, int fmt, struct lwp *l) { int error; + device_t self; struct cgd_softc *cs; struct dk_softc *dksc; DPRINTF_FOLLOW(("cgdclose(0x%"PRIx64", %d)\n", dev, flags)); - GETCGD_SOFTC(cs, dev); + GETCGD_SOFTC(cs, dev, self); dksc = &cs->sc_dksc; - if ((error = dk_close(dksc, dev, flags, fmt, l)) != 0) + if ((error = dk_close(dksc, dev, flags, fmt, l)) != 0) { + device_release(self); return error; + } if (!DK_ATTACHED(dksc)) { if ((error = cgd_destroy(cs->sc_dksc.sc_dev)) != 0) { aprint_error_dev(dksc->sc_dev, "unable to detach instance\n"); + device_release(self); return error; } } - return 0; + device_release(self); + return error; } static void cgdstrategy(struct buf *bp) { - struct cgd_softc *cs = getcgd_softc(bp->b_dev); + device_t self; + struct cgd_softc *cs = getcgd_softc(bp->b_dev, &self); struct dk_softc *dksc = &cs->sc_dksc; struct disk_geom *dg = &dksc->sc_dkdev.dk_geom; @@ -349,12 +364,14 @@ cgdstrategy(struct buf *bp) bp->b_resid = bp->b_bcount; biodone(bp); cgd_release(bp->b_dev); + device_release(self); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(&cs->sc_dksc, bp); cgd_release(bp->b_dev); + device_release(self); return; } @@ -362,7 +379,8 @@ static int cgdsize(dev_t dev) { int retval; - struct cgd_softc *cs = getcgd_softc(dev); + device_t self; + struct cgd_softc *cs = getcgd_softc(dev, &self); DPRINTF_FOLLOW(("
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:40:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Use correct prototype. To generate a diff of this commit: cvs rdiff -u -r1.108.2.5 -r1.108.2.6 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.5 src/sys/dev/cgd.c:1.108.2.6 --- src/sys/dev/cgd.c:1.108.2.5 Fri Jul 22 03:39:43 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:40:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $"); #include #include @@ -102,7 +102,7 @@ const struct cdevsw cgd_cdevsw = { static int cgd_match(device_t, cfdata_t, void *); static void cgd_attach(device_t, device_t, void *); static int cgd_detach(device_t, int); -static struct cgd_softc *cgd_spawn(int, *device_t); +static struct cgd_softc *cgd_spawn(int, device_t *); static int cgd_destroy(device_t); /* Internal Functions */
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:44:36 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Pass correct arg to cgd_spawn() To generate a diff of this commit: cvs rdiff -u -r1.108.2.6 -r1.108.2.7 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.6 src/sys/dev/cgd.c:1.108.2.7 --- src/sys/dev/cgd.c:1.108.2.6 Fri Jul 22 03:40:51 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:44:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $"); #include #include @@ -202,7 +202,7 @@ getcgd_softc(dev_t dev, device_t *self) sc = device_private(*self); if (sc == NULL) - sc = cgd_spawn(unit, *self); + sc = cgd_spawn(unit, self); return sc; }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:55:12 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: vfs_mount.c Log Message: Fix up the error/exit path. Return actual error, not blindly report success! To generate a diff of this commit: cvs rdiff -u -r1.40.2.1 -r1.40.2.2 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.40.2.1 src/sys/kern/vfs_mount.c:1.40.2.2 --- src/sys/kern/vfs_mount.c:1.40.2.1 Wed Jul 20 23:47:57 2016 +++ src/sys/kern/vfs_mount.c Fri Jul 22 03:55:12 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.40.2.1 2016/07/20 23:47:57 pgoyette Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.40.2.2 2016/07/22 03:55:12 pgoyette Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.40.2.1 2016/07/20 23:47:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.40.2.2 2016/07/22 03:55:12 pgoyette Exp $"); #define _VFS_VNODE_PRIVATE @@ -1316,7 +1316,7 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv { vnode_t *bvp; dev_t dev; - int d_type, busy; + int d_type, ret; const struct cdevsw *cdev = NULL; const struct bdevsw *bdev = NULL; @@ -1359,8 +1359,10 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv break; } - if (d_type != D_DISK) - return EINVAL; + if (d_type != D_DISK) { + ret = EINVAL; + goto out; + } if (bvpp != NULL) *bvpp = bvp; @@ -1370,16 +1372,18 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv * XXX: not only if this specific slice is mounted, but * XXX: if it's on a disk with any other mounted slice. */ - busy =vfs_mountedon(bvp); + if (vfs_mountedon(bvp) != 0) + ret = EBUSY; + else + ret = 0; + out: if (bdev != NULL) bdevsw_release(bdev); if (cdev != NULL) cdevsw_release(cdev); - if (busy) - return EBUSY; - return 0; + return ret; } /*
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 05:49:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call cgd_spawn() if the requested device doesn't exist, rather than if the device exists but without any softc data. To generate a diff of this commit: cvs rdiff -u -r1.108.2.7 -r1.108.2.8 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.7 src/sys/dev/cgd.c:1.108.2.8 --- src/sys/dev/cgd.c:1.108.2.7 Fri Jul 22 03:44:36 2016 +++ src/sys/dev/cgd.c Fri Jul 22 05:49:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $"); #include #include @@ -194,15 +194,19 @@ getcgd_softc(dev_t dev, device_t *self) int unit = CGDUNIT(dev); struct cgd_softc *sc; +printf("%s: unit %d\n", __func__, unit); DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); *self = device_lookup_acquire(&cgd_cd, unit); +printf("%s: *self %p\n", __func__, *self); + if (*self == NULL) - return NULL; - - sc = device_private(*self); - if (sc == NULL) sc = cgd_spawn(unit, self); +printf("%s: return sc %p\n", __func__, sc); + else + sc = device_private(*self); +printf("%s: sc %p\n", __func__, sc); + return sc; } @@ -272,9 +276,12 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) +{ printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; +} *self = device_lookup_acquire(&cgd_cd, unit); +printf("%s: self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -307,9 +314,12 @@ cgdopen(dev_t dev, int flags, int fmt, s struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); +printf("%s: dev %lx\n", __func__, (long unsigned int)dev); GETCGD_SOFTC(cs, dev, self); +printf("%s: cs %p, self %p\n", __func__, cs, self); error = dk_open(&cs->sc_dksc, dev, flags, fmt, l); device_release(self); +printf("%s: return %d\n", __func__, error); return error; } @@ -546,7 +556,7 @@ cgdiodone(struct buf *nbp) /* * copy the dev_t, finish the disk operation, and release the - * reference we're holding on to (from cgd_getsoftc() earlier) + * reference we're holding on to (from getcgd_softc() earlier) */ dev = obp->b_dev; dk_done(dksc, obp);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 06:32:54 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug To generate a diff of this commit: cvs rdiff -u -r1.108.2.8 -r1.108.2.9 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.8 src/sys/dev/cgd.c:1.108.2.9 --- src/sys/dev/cgd.c:1.108.2.8 Fri Jul 22 05:49:53 2016 +++ src/sys/dev/cgd.c Fri Jul 22 06:32:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $"); #include #include @@ -194,18 +194,15 @@ getcgd_softc(dev_t dev, device_t *self) int unit = CGDUNIT(dev); struct cgd_softc *sc; -printf("%s: unit %d\n", __func__, unit); DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); *self = device_lookup_acquire(&cgd_cd, unit); -printf("%s: *self %p\n", __func__, *self); - if (*self == NULL) + if (*self == NULL) { sc = cgd_spawn(unit, self); -printf("%s: return sc %p\n", __func__, sc); - else + } else { sc = device_private(*self); -printf("%s: sc %p\n", __func__, sc); + } return sc; } @@ -281,7 +278,6 @@ cgd_spawn(int unit, device_t *self) } *self = device_lookup_acquire(&cgd_cd, unit); -printf("%s: self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -314,12 +310,9 @@ cgdopen(dev_t dev, int flags, int fmt, s struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); -printf("%s: dev %lx\n", __func__, (long unsigned int)dev); GETCGD_SOFTC(cs, dev, self); -printf("%s: cs %p, self %p\n", __func__, cs, self); error = dk_open(&cs->sc_dksc, dev, flags, fmt, l); device_release(self); -printf("%s: return %d\n", __func__, error); return error; } @@ -1143,7 +1136,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) devmajor_t bmajor = -1, cmajor = -1; #endif -printf("%s: cmd %d\n", __func__, cmd); switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE @@ -1208,7 +1200,6 @@ printf("%s: cmd %d\n", __func__, cmd); error = ENOTTY; break; } -printf("%s: return %d\n", __func__, error); return error; }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 11:59:51 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Style: indent label 'out:' one space from the margin. To generate a diff of this commit: cvs rdiff -u -r1.34.2.9 -r1.34.2.10 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.9 src/sys/kern/subr_devsw.c:1.34.2.10 --- src/sys/kern/subr_devsw.c:1.34.2.9 Thu Jul 21 06:22:31 2016 +++ src/sys/kern/subr_devsw.c Fri Jul 22 11:59:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.9 2016/07/21 06:22:31 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.10 2016/07/22 11:59:51 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.9 2016/07/21 06:22:31 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.10 2016/07/22 11:59:51 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -481,7 +481,7 @@ bdevsw_lookup_acquire(dev_t dev) if (bdevsw[bmajor]->d_localcount != NULL) localcount_acquire(bdevsw[bmajor]->d_localcount); -out: pserialize_read_exit(s); + out: pserialize_read_exit(s); return bdev; } @@ -542,7 +542,7 @@ cdevsw_lookup_acquire(dev_t dev) if (cdevsw[cmajor]->d_localcount != NULL) localcount_acquire(cdevsw[cmajor]->d_localcount); -out: pserialize_read_exit(s); + out: pserialize_read_exit(s); return cdev; }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 12:03:15 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c Log Message: Fix logic to avoid dereferencing NULL pointer To generate a diff of this commit: cvs rdiff -u -r1.246.2.4 -r1.246.2.5 src/sys/kern/subr_autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.4 src/sys/kern/subr_autoconf.c:1.246.2.5 --- src/sys/kern/subr_autoconf.c:1.246.2.4 Fri Jul 22 02:05:39 2016 +++ src/sys/kern/subr_autoconf.c Fri Jul 22 12:03:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.4 2016/07/22 02:05:39 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.4 2016/07/22 02:05:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -2273,7 +2273,7 @@ device_lookup_acquire(cfdriver_t cd, int dv = NULL; else if ((dv = cd->cd_devs[unit]) != NULL && dv->dv_del_gen != 0) dv = NULL; - else + if (dv != NULL) localcount_acquire(dv->dv_localcnt); mutex_exit(&alldevs_mtx);
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 23:02:55 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Only retrieve the bdev/cdev from the xdevsw[] array once. To generate a diff of this commit: cvs rdiff -u -r1.34.2.10 -r1.34.2.11 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.10 src/sys/kern/subr_devsw.c:1.34.2.11 --- src/sys/kern/subr_devsw.c:1.34.2.10 Fri Jul 22 11:59:51 2016 +++ src/sys/kern/subr_devsw.c Fri Jul 22 23:02:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.10 2016/07/22 11:59:51 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.11 2016/07/22 23:02:55 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.10 2016/07/22 11:59:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.11 2016/07/22 23:02:55 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -478,7 +478,7 @@ bdevsw_lookup_acquire(dev_t dev) membar_datadep_consumer(); /* If the devsw is not statically linked, acquire a reference */ - if (bdevsw[bmajor]->d_localcount != NULL) + if (bdev->d_localcount != NULL) localcount_acquire(bdevsw[bmajor]->d_localcount); out: pserialize_read_exit(s); @@ -539,7 +539,7 @@ cdevsw_lookup_acquire(dev_t dev) membar_datadep_consumer(); /* If the devsw is not statically linked, acquire a reference */ - if (cdevsw[cmajor]->d_localcount != NULL) + if (cdev->d_localcount != NULL) localcount_acquire(cdevsw[cmajor]->d_localcount); out: pserialize_read_exit(s);
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 23:04:01 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Continue previous - finish what we started To generate a diff of this commit: cvs rdiff -u -r1.34.2.11 -r1.34.2.12 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.11 src/sys/kern/subr_devsw.c:1.34.2.12 --- src/sys/kern/subr_devsw.c:1.34.2.11 Fri Jul 22 23:02:55 2016 +++ src/sys/kern/subr_devsw.c Fri Jul 22 23:04:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.11 2016/07/22 23:02:55 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.12 2016/07/22 23:04:01 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.11 2016/07/22 23:02:55 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.12 2016/07/22 23:04:01 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -479,7 +479,7 @@ bdevsw_lookup_acquire(dev_t dev) /* If the devsw is not statically linked, acquire a reference */ if (bdev->d_localcount != NULL) - localcount_acquire(bdevsw[bmajor]->d_localcount); + localcount_acquire(bdev->d_localcount); out: pserialize_read_exit(s); @@ -540,7 +540,7 @@ cdevsw_lookup_acquire(dev_t dev) /* If the devsw is not statically linked, acquire a reference */ if (cdev->d_localcount != NULL) - localcount_acquire(cdevsw[cmajor]->d_localcount); + localcount_acquire(cdev->d_localcount); out: pserialize_read_exit(s);
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 22 23:16:36 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Fix a comment To generate a diff of this commit: cvs rdiff -u -r1.34.2.12 -r1.34.2.13 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.12 src/sys/kern/subr_devsw.c:1.34.2.13 --- src/sys/kern/subr_devsw.c:1.34.2.12 Fri Jul 22 23:04:01 2016 +++ src/sys/kern/subr_devsw.c Fri Jul 22 23:16:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.12 2016/07/22 23:04:01 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.13 2016/07/22 23:16:36 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.12 2016/07/22 23:04:01 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.13 2016/07/22 23:16:36 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -353,7 +353,7 @@ cdevsw_attach(const struct cdevsw *devsw if (cdevsw[*devmajor] != NULL) return (EEXIST); - /* ensure visibility of the bdevsw */ + /* ensure visibility of the cdevsw */ membar_producer(); cdevsw[*devmajor] = devsw;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 02:36:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Revert changes in revision 1.108.2.3 For pseudo-devices, config(1) doesn't provide a valid cfattach, so when a modular driver calls config_pseudo_attach() it will fail. This is not an issue for built-in drivers. To generate a diff of this commit: cvs rdiff -u -r1.108.2.9 -r1.108.2.10 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.9 src/sys/dev/cgd.c:1.108.2.10 --- src/sys/dev/cgd.c:1.108.2.9 Fri Jul 22 06:32:54 2016 +++ src/sys/dev/cgd.c Sat Jul 23 02:36:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $"); #include #include @@ -172,8 +172,12 @@ static void hexprint(const char *, void /* Utility Functions */ #define CGDUNIT(x) DISKUNIT(x) -#define GETCGD_SOFTC(_cs, x, _dv)\ - if (!((_cs) = getcgd_softc(x, &_dv))) return ENXIO; +#define GETCGD_SOFTC(_cs, x, _dv) \ + printf("%s: GETCGD_SOFTC\n", __func__); \ + if (!((_cs) = getcgd_softc(x, &_dv))) { \ + printf("%s: cs NULL\n", __func__); \ + return ENXIO;\ + } /* The code */ @@ -196,13 +200,16 @@ getcgd_softc(dev_t dev, device_t *self) DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); +printf("%s: unit %d\n", __func__, unit); *self = device_lookup_acquire(&cgd_cd, unit); +printf("%s: *self %p\n", __func__, *self); if (*self == NULL) { sc = cgd_spawn(unit, self); } else { sc = device_private(*self); } +printf("%s: return, sc %p\n", __func__, sc); return sc; } @@ -253,12 +260,18 @@ cgd_detach(device_t self, int flags) void cgdattach(int num) { +/* + * We don't need to do anything here - the config database is updated + * in module initialization code. + int error; error = config_cfattach_attach(cgd_cd.cd_name, &cgd_ca); if (error != 0) aprint_error("%s: unable to register cfattach\n", cgd_cd.cd_name); + * + */ } static struct cgd_softc * @@ -273,11 +286,13 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) -{ printf("%s: config_attach_pseudo() failed\n", __func__); +{ +printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; } *self = device_lookup_acquire(&cgd_cd, unit); +printf("%s: pseudo added, *self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -659,6 +674,7 @@ cgdioctl(dev_t dev, u_long cmd, void *da DPRINTF_FOLLOW(("cgdioctl(0x%"PRIx64", %ld, %p, %d, %p)\n", dev, cmd, data, flag, l)); +printf("%s: dev %lx cmd %lx\n", __func__, (long unsigned int)dev, cmd); switch (cmd) { case CGDIOCGET: return cgd_ioctl_get(dev, data, l); @@ -672,21 +688,25 @@ cgdioctl(dev_t dev, u_long cmd, void *da dksc = &cs->sc_dksc; break; } +printf("%s: softc %p, self %p\n", __func__, cs, self); switch (cmd) { case CGDIOCSET: +printf("%s: case CGDIOCSET\n", __func__); if (DK_ATTACHED(dksc)) error = EBUSY; else - cgd_ioctl_set(cs, data, l); + error = cgd_ioctl_set(cs, data, l); break; case CGDIOCCLR: +printf("%s: case CGDIOCCLR\n", __func__); if (DK_BUSY(&cs->sc_dksc, pmask)) error = EBUSY; else - cgd_ioctl_clr(cs, l); + error = cgd_ioctl_clr(cs, l); break; case DIOCCACHESYNC: +printf("%s: case CGDIOCCACHESYNC\n", __func__); /* * XXX Do we really need to care about having a writable * file descriptor here? @@ -703,18 +723,24 @@ cgdioctl(dev_t dev, u_long cmd, void *da break; case DIOCGSTRATEGY: case DIOCSSTRATEGY: - if (!DK_ATTACHED(dksc)) +printf("%s: case CGDIOCxSTRATEGY\n", __func__); + if (!DK_ATTACHED(dksc)) { error = ENOENT; + break; + } /*FALLTHROUGH*/ default: - if (error == 0) - error = dk_ioctl(dksc, dev, cmd, data, flag, l); +printf("%s: case default\n", __func__); + error = dk_ioctl(dksc, dev, cmd, data, flag, l); break; case CGDIOCGET: +printf("%s: case CGDIOCGET\n", __func__); KASSERT(0); error = EINVAL; + break; } device_release(self); +printf("%s: return value %d\n", __func__, error); return error; } @@ -1139,14 +1165,15 @@ cgd_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE - /* - * Insert the driver into the autoconf database - */ - error = config_init_component(cfdriver_ioconf_cgd, -cfattach_ioconf_cgd, cfdata_ioconf_cgd); - if (error) { - aprint_error("%s: unable to i
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 03:20:37 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug printfs. For MODULE builds, define cgd_cd via CFDRIVER_DECL To generate a diff of this commit: cvs rdiff -u -r1.108.2.10 -r1.108.2.11 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.10 src/sys/dev/cgd.c:1.108.2.11 --- src/sys/dev/cgd.c:1.108.2.10 Sat Jul 23 02:36:51 2016 +++ src/sys/dev/cgd.c Sat Jul 23 03:20:37 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $"); #include #include @@ -200,16 +200,13 @@ getcgd_softc(dev_t dev, device_t *self) DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); -printf("%s: unit %d\n", __func__, unit); *self = device_lookup_acquire(&cgd_cd, unit); -printf("%s: *self %p\n", __func__, *self); if (*self == NULL) { sc = cgd_spawn(unit, self); } else { sc = device_private(*self); } -printf("%s: return, sc %p\n", __func__, sc); return sc; } @@ -286,13 +283,9 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) -{ -printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; -} *self = device_lookup_acquire(&cgd_cd, unit); -printf("%s: pseudo added, *self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -674,7 +667,6 @@ cgdioctl(dev_t dev, u_long cmd, void *da DPRINTF_FOLLOW(("cgdioctl(0x%"PRIx64", %ld, %p, %d, %p)\n", dev, cmd, data, flag, l)); -printf("%s: dev %lx cmd %lx\n", __func__, (long unsigned int)dev, cmd); switch (cmd) { case CGDIOCGET: return cgd_ioctl_get(dev, data, l); @@ -688,25 +680,21 @@ printf("%s: dev %lx cmd %lx\n", __func__ dksc = &cs->sc_dksc; break; } -printf("%s: softc %p, self %p\n", __func__, cs, self); switch (cmd) { case CGDIOCSET: -printf("%s: case CGDIOCSET\n", __func__); if (DK_ATTACHED(dksc)) error = EBUSY; else error = cgd_ioctl_set(cs, data, l); break; case CGDIOCCLR: -printf("%s: case CGDIOCCLR\n", __func__); if (DK_BUSY(&cs->sc_dksc, pmask)) error = EBUSY; else error = cgd_ioctl_clr(cs, l); break; case DIOCCACHESYNC: -printf("%s: case CGDIOCCACHESYNC\n", __func__); /* * XXX Do we really need to care about having a writable * file descriptor here? @@ -723,24 +711,20 @@ printf("%s: case CGDIOCCACHESYNC\n", __f break; case DIOCGSTRATEGY: case DIOCSSTRATEGY: -printf("%s: case CGDIOCxSTRATEGY\n", __func__); if (!DK_ATTACHED(dksc)) { error = ENOENT; break; } /*FALLTHROUGH*/ default: -printf("%s: case default\n", __func__); error = dk_ioctl(dksc, dev, cmd, data, flag, l); break; case CGDIOCGET: -printf("%s: case CGDIOCGET\n", __func__); KASSERT(0); error = EINVAL; break; } device_release(self); -printf("%s: return value %d\n", __func__, error); return error; } @@ -1150,7 +1134,7 @@ hexprint(const char *start, void *buf, i MODULE(MODULE_CLASS_DRIVER, cgd, "dk_subr"); #ifdef _MODULE -#include "ioconf.c" +CFDRIVER_DECL(cgd, DV_DISK, NULL); #endif static int @@ -1172,7 +1156,7 @@ cgd_modcmd(modcmd_t cmd, void *arg) error = config_cfattach_attach(cgd_cd.cd_name, &cgd_ca); if (error) { config_cfdriver_detach(&cgd_cd); - aprint_error("%s: unable to register cfattach for ", + aprint_error("%s: unable to register cfattach for " "%s, error %d", __func__, cgd_cd.cd_name, error); break; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 00:14:08 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove cgd_release() - it's not needed now that getcgd_softc() provides access to the device_t Restore original cgdattach() - seems to be needed after all. Remove some debug printf's from GETCGD_SOFTC() macro. To generate a diff of this commit: cvs rdiff -u -r1.108.2.11 -r1.108.2.12 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.11 src/sys/dev/cgd.c:1.108.2.12 --- src/sys/dev/cgd.c:1.108.2.11 Sat Jul 23 03:20:37 2016 +++ src/sys/dev/cgd.c Sun Jul 24 00:14:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $"); #include #include @@ -173,25 +173,12 @@ static void hexprint(const char *, void #define CGDUNIT(x) DISKUNIT(x) #define GETCGD_SOFTC(_cs, x, _dv) \ - printf("%s: GETCGD_SOFTC\n", __func__); \ - if (!((_cs) = getcgd_softc(x, &_dv))) { \ - printf("%s: cs NULL\n", __func__); \ + if (((_cs) = getcgd_softc(x, &_dv)) == NULL) { \ return ENXIO;\ } /* The code */ -static void -cgd_release(dev_t dev) -{ - int unit = CGDUNIT(dev); - device_t self; - - self = device_lookup_acquire(&cgd_cd, unit); - if (self != NULL) - device_release(self); -} - static struct cgd_softc * getcgd_softc(dev_t dev, device_t *self) { @@ -257,18 +244,12 @@ cgd_detach(device_t self, int flags) void cgdattach(int num) { -/* - * We don't need to do anything here - the config database is updated - * in module initialization code. - int error; error = config_cfattach_attach(cgd_cd.cd_name, &cgd_ca); if (error != 0) aprint_error("%s: unable to register cfattach\n", cgd_cd.cd_name); - * - */ } static struct cgd_softc * @@ -349,7 +330,7 @@ cgdclose(dev_t dev, int flags, int fmt, } } device_release(self); - return error; + return 0; } static void @@ -374,14 +355,12 @@ cgdstrategy(struct buf *bp) bp->b_error = EINVAL; bp->b_resid = bp->b_bcount; biodone(bp); - cgd_release(bp->b_dev); device_release(self); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(&cs->sc_dksc, bp); - cgd_release(bp->b_dev); device_release(self); return; } @@ -399,7 +378,6 @@ cgdsize(dev_t dev) else retval = dk_size(&cs->sc_dksc, dev); - cgd_release(dev); device_release(self); return retval; } @@ -510,7 +488,6 @@ cgd_diskstart(device_t dev, struct buf * static void cgdiodone(struct buf *nbp) { - dev_t dev; device_t self; struct buf *obp = nbp->b_private; struct cgd_softc *cs = getcgd_softc(obp->b_dev, &self); @@ -555,13 +532,7 @@ cgdiodone(struct buf *nbp) if (obp->b_error != 0) obp->b_resid = obp->b_bcount; - /* - * copy the dev_t, finish the disk operation, and release the - * reference we're holding on to (from getcgd_softc() earlier) - */ - dev = obp->b_dev; dk_done(dksc, obp); - cgd_release(dev); device_release(self); dk_start(dksc, NULL); @@ -917,7 +888,6 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_unit = unit; if (cgu->cgu_unit < 0) { - cgd_release(dev); device_release(self); return EINVAL; /* XXX: should this be ENXIO? */ } @@ -938,7 +908,6 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_mode = cs->sc_cdata.cf_mode; cgu->cgu_keylen = cs->sc_cdata.cf_keylen; } - cgd_release(dev); device_release(self); return 0; } @@ -1175,6 +1144,7 @@ cgd_modcmd(modcmd_t cmd, void *arg) config_cfdriver_detach(&cgd_cd); aprint_error("%s: unable to attach %s devsw, " "error %d", __func__, cgd_cd.cd_name, error); + break; } #endif break;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 10:44:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call device_release() in appropriate error paths. In the module initialization code, make the bmajor/cmajor variables global so they can be shared with the rump component initialization. To generate a diff of this commit: cvs rdiff -u -r1.108.2.12 -r1.108.2.13 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.12 src/sys/dev/cgd.c:1.108.2.13 --- src/sys/dev/cgd.c:1.108.2.12 Sun Jul 24 00:14:08 2016 +++ src/sys/dev/cgd.c Sun Jul 24 10:44:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $"); #include #include @@ -179,6 +179,13 @@ static void hexprint(const char *, void /* The code */ +/* + * Lookup the device and return it's softc. If the device doesn't + * exist, spawn it. + * + * In either case, the device is "acquired", and must be "released" + * by the caller after it is finished with the softc. + */ static struct cgd_softc * getcgd_softc(dev_t dev, device_t *self) { @@ -208,7 +215,9 @@ cgd_match(device_t self, cfdata_t cfdata static void cgd_attach(device_t parent, device_t self, void *aux) { - struct cgd_softc *sc = device_private(self); + struct cgd_softc *sc; + + sc = device_private(self); mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_BIO); dk_init(&sc->sc_dksc, self, DKTYPE_CGD); @@ -220,6 +229,10 @@ cgd_attach(device_t parent, device_t sel } +/* + * The caller must hold a reference to the device's localcount. the + * reference is released if the device is available for detach. + */ static int cgd_detach(device_t self, int flags) { @@ -238,6 +251,7 @@ cgd_detach(device_t self, int flags) disk_destroy(&dksc->sc_dkdev); mutex_destroy(&sc->sc_lock); + device_release(self); return 0; } @@ -256,6 +270,7 @@ static struct cgd_softc * cgd_spawn(int unit, device_t *self) { cfdata_t cf; + struct cgd_softc *sc; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); cf->cf_name = cgd_cd.cd_name; @@ -269,12 +284,14 @@ cgd_spawn(int unit, device_t *self) *self = device_lookup_acquire(&cgd_cd, unit); if (self == NULL) return NULL; - else + else { /* * Note that we return while still holding a reference * to the device! */ - return device_private(*self); + sc = device_private(*self); + return sc; + } } static int @@ -285,10 +302,10 @@ cgd_destroy(device_t dev) cf = device_cfdata(dev); error = config_detach(dev, DETACH_QUIET); - if (error) - return error; - free(cf, M_DEVBUF); - return 0; + if (error == 0) + free(cf, M_DEVBUF); + + return error; } static int @@ -325,11 +342,10 @@ cgdclose(dev_t dev, int flags, int fmt, if ((error = cgd_destroy(cs->sc_dksc.sc_dev)) != 0) { aprint_error_dev(dksc->sc_dev, "unable to detach instance\n"); - device_release(self); return error; } - } - device_release(self); + } else + device_release(self); return 0; } @@ -597,8 +613,10 @@ cgdread(dev_t dev, struct uio *uio, int (unsigned long long)dev, uio, flags)); GETCGD_SOFTC(cs, dev, self); dksc = &cs->sc_dksc; - if (!DK_ATTACHED(dksc)) + if (!DK_ATTACHED(dksc)) { + device_release(self); return ENXIO; + } error = physio(cgdstrategy, NULL, dev, B_READ, minphys, uio); device_release(self); return error; @@ -1104,6 +1122,8 @@ MODULE(MODULE_CLASS_DRIVER, cgd, "dk_sub #ifdef _MODULE CFDRIVER_DECL(cgd, DV_DISK, NULL); + +devmajor_t cgd_bmajor = -1, cgd_cmajor = -1; #endif static int @@ -,10 +1131,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) { int error = 0; -#ifdef _MODULE - devmajor_t bmajor = -1, cmajor = -1; -#endif - switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE @@ -1133,8 +1149,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) /* * Attach the {b,c}devsw's */ - error = devsw_attach("cgd", &cgd_bdevsw, &bmajor, - &cgd_cdevsw, &cmajor); + error = devsw_attach("cgd", &cgd_bdevsw, &cgd_bmajor, + &cgd_cdevsw, &cgd_cmajor); /* * If devsw_attach fails, remove from autoconf database @@ -1161,8 +1177,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) */ error = config_cfattach_detach(cgd_cd.cd_name, &cgd_ca); if (error) { - error = devsw_attach("cgd", &cgd_bdevsw, &bmajor, - &cgd_cdevsw, &cmajor); + error = devsw_attach("cgd", &cgd_bdevsw, &cgd_bmajor, + &cgd_cdevsw, &cgd_cmajor); aprint_error("%s: failed to detach %s cfattach, " "error %d\n", __f
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:40:52 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Add a comment to describe why we didn't convert one caller of device_lokup_private(). To generate a diff of this commit: cvs rdiff -u -r1.108.2.13 -r1.108.2.14 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.13 src/sys/dev/cgd.c:1.108.2.14 --- src/sys/dev/cgd.c:1.108.2.13 Sun Jul 24 10:44:57 2016 +++ src/sys/dev/cgd.c Mon Jul 25 03:40:52 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.14 2016/07/25 03:40:52 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.14 2016/07/25 03:40:52 pgoyette Exp $"); #include #include @@ -910,6 +910,11 @@ cgd_ioctl_get(dev_t dev, void *data, str return EINVAL; /* XXX: should this be ENXIO? */ } + /* + * XXX This appears to be redundant, given the initialization + * XXX when it was declared. Leave it for now, but don't + * XXX take an extra reference to the device! + */ cs = device_lookup_private(&cgd_cd, unit); if (cs == NULL || !DK_ATTACHED(dksc)) { cgu->cgu_dev = 0;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 22:06:09 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Update vnd for using localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.256.2.3 -r1.256.2.4 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.3 src/sys/dev/vnd.c:1.256.2.4 --- src/sys/dev/vnd.c:1.256.2.3 Tue Jul 19 06:26:58 2016 +++ src/sys/dev/vnd.c Mon Jul 25 22:06:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.3 2016/07/19 06:26:58 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.4 2016/07/25 22:06:09 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.3 2016/07/19 06:26:58 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.4 2016/07/25 22:06:09 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -324,6 +324,7 @@ vnd_destroy(device_t dev) static int vndopen(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int unit = vndunit(dev); struct vnd_softc *sc; int error = 0, part, pmask; @@ -333,7 +334,7 @@ vndopen(dev_t dev, int flags, int mode, if (vnddebug & VDB_FOLLOW) printf("vndopen(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l); #endif - sc = device_lookup_private(&vnd_cd, unit); + sc = device_lookup_private_acquire(&vnd_cd, unit, &self); if (sc == NULL) { sc = vnd_spawn(unit); if (sc == NULL) @@ -410,12 +411,14 @@ vndopen(dev_t dev, int flags, int mode, done: mutex_exit(&sc->sc_dkdev.dk_openlock); vndunlock(sc); + device_release(self); return error; } static int vndclose(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int unit = vndunit(dev); struct vnd_softc *sc; int error = 0, part; @@ -424,12 +427,17 @@ vndclose(dev_t dev, int flags, int mode, if (vnddebug & VDB_FOLLOW) printf("vndclose(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l); #endif - sc = device_lookup_private(&vnd_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(&vnd_cd, unit, &self); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((error = vndlock(sc)) != 0) + if ((error = vndlock(sc)) != 0) { + device_release(self); return error; + } mutex_enter(&sc->sc_dkdev.dk_openlock); @@ -462,10 +470,12 @@ vndclose(dev_t dev, int flags, int mode, if ((error = vnd_destroy(sc->sc_dev)) != 0) { aprint_error_dev(sc->sc_dev, "unable to detach instance\n"); + device_release(self); return error; } } + device_release(self); return 0; } @@ -475,9 +485,10 @@ vndclose(dev_t dev, int flags, int mode, static void vndstrategy(struct buf *bp) { + device_t self; int unit = vndunit(bp->b_dev); struct vnd_softc *vnd = - device_lookup_private(&vnd_cd, unit); + device_lookup_private_acquire(&vnd_cd, unit, &self); struct disklabel *lp; daddr_t blkno; int s = splbio(); @@ -561,12 +572,15 @@ vndstrategy(struct buf *bp) bufq_put(vnd->sc_tab, bp); wakeup(&vnd->sc_tab); splx(s); + device_release(self); return; done: bp->b_resid = bp->b_bcount; biodone(bp); splx(s); + if (self != NULL) + device_release(self); } static bool @@ -981,6 +995,8 @@ vndiodone(struct buf *bp) static int vndread(dev_t dev, struct uio *uio, int flags) { + device_t self; + int error; int unit = vndunit(dev); struct vnd_softc *sc; @@ -989,20 +1005,29 @@ vndread(dev_t dev, struct uio *uio, int printf("vndread(0x%"PRIx64", %p)\n", dev, uio); #endif - sc = device_lookup_private(&vnd_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(&vnd_cd, unit, &self); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((sc->sc_flags & VNF_INITED) == 0) + if ((sc->sc_flags & VNF_INITED) == 0) { + device_release(self); return ENXIO; + } - return physio(vndstrategy, NULL, dev, B_READ, minphys, uio); + error = physio(vndstrategy, NULL, dev, B_READ, minphys, uio); + device_release(self); + return error; } /* ARGSUSED */ static int vndwrite(dev_t dev, struct uio *uio, int flags) { + device_t self; + int error; int unit = vndunit(dev); struct vnd_softc *sc; @@ -1011,19 +1036,27 @@ vndwrite(dev_t dev, struct uio *uio, int printf("vndwrite(0x%"PRIx64", %p)\n", dev, uio); #endif - sc = device_lookup_private(&vnd_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(&vnd_cd, unit, &self); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((sc->sc_flags & VNF_INITED) == 0) + if ((sc->sc_flags & VNF_INITED) == 0) { + device_release(self); return ENXIO; + } - return physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio); + error = physio(
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 03:52:14 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: audio.c Log Message: Fix typo in local copy To generate a diff of this commit: cvs rdiff -u -r1.268.2.3 -r1.268.2.4 src/sys/dev/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio.c diff -u src/sys/dev/audio.c:1.268.2.3 src/sys/dev/audio.c:1.268.2.4 --- src/sys/dev/audio.c:1.268.2.3 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/audio.c Tue Jul 26 03:52:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.268.2.3 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -155,7 +155,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.3 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -1186,7 +1186,7 @@ audio_enter(dev_t dev, krw_t rw, struct struct audio_softc *sc; /* First, find the device and take sc_lock. */ - self = device_lookup_acquire(&audio_cd, ADUIOUNIT(dev)); + self = device_lookup_acquire(&audio_cd, AUDIOUNIT(dev)); if (self == NULL) return ENXIO; sc = device_private(self);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 04:30:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Fix some sloppy typos To generate a diff of this commit: cvs rdiff -u -r1.256.2.5 -r1.256.2.6 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.5 src/sys/dev/vnd.c:1.256.2.6 --- src/sys/dev/vnd.c:1.256.2.5 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/vnd.c Tue Jul 26 04:30:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.5 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.6 2016/07/26 04:30:50 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.5 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.6 2016/07/26 04:30:50 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -312,7 +312,7 @@ vnd_spawn(int unit) if (config_attach_pseudo(cf) == NULL) return NULL; - *self = device_lookup_acquire(&cgd_cd, unit); + self = device_lookup_acquire(&vnd_cd, unit); if (self == NULL) return NULL; else { @@ -320,7 +320,7 @@ vnd_spawn(int unit) * Note that we return while still holding a reference * to the device! */ - return device_private(*self); + return device_private(self); } } @@ -353,7 +353,7 @@ vndopen(dev_t dev, int flags, int mode, #endif self = device_lookup_acquire(&vnd_cd, unit); if (self != NULL) - sc = device-private(self); + sc = device_private(self); else { sc = vnd_spawn(unit); if (sc == NULL) @@ -1055,7 +1055,7 @@ vndwrite(dev_t dev, struct uio *uio, int self = device_lookup_acquire(&vnd_cd, unit); if (self == NULL) return ENXIO; - sc = device_lookup_private_acquire(&vnd_cd, unit, &self); + sc = device_private(self); if ((sc->sc_flags & VNF_INITED) == 0) { device_release(self); @@ -1079,7 +1079,7 @@ vnd_cget(struct lwp *l, int unit, int *u if (*un < 0) return EINVAL; - self - device_lookup_acquire(&vnd_cd, unit); + self = device_lookup_acquire(&vnd_cd, unit); if (self == NULL) return -1; vnd = device_private(self); @@ -1226,12 +1226,11 @@ vndioctl(dev_t dev, u_long cmd, void *da break; } - vnd = device_lookup_private(&vnd_cd, unit); - if (vnd == NULL) { - if (self != NULL) - device_release(self); + self = device_lookup_acquire(&vnd_cd, unit); + if (self != NULL) return ENXIO; - } + vnd = device_private(self); + vio = (struct vnd_ioctl *)data; /* Must be open for writes for these commands... */
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:42:40 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: midi.c Log Message: Fix botched edit. To generate a diff of this commit: cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/dev/midi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/midi.c diff -u src/sys/dev/midi.c:1.85.2.1 src/sys/dev/midi.c:1.85.2.2 --- src/sys/dev/midi.c:1.85.2.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/midi.c Tue Jul 26 07:42:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: midi.c,v 1.85.2.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: midi.c,v 1.85.2.2 2016/07/26 07:42:39 pgoyette Exp $ */ /* * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.85.2.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.85.2.2 2016/07/26 07:42:39 pgoyette Exp $"); #include "midi.h" #include "sequencer.h" @@ -1598,9 +1598,8 @@ out: int midi_writebytes(int unit, u_char *bf, int cc) { - device_t self = device_lookup_acquire(&midi_cd, MIDIUNIT(dev)); + device_t self = device_lookup_acquire(&midi_cd, unit); struct midi_softc *sc; - device_lookup_private_acquire(&midi_cd, unit, &self); int error; if (self == NULL)
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:44 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: video.c Log Message: Typo To generate a diff of this commit: cvs rdiff -u -r1.32.8.1 -r1.32.8.2 src/sys/dev/video.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/video.c diff -u src/sys/dev/video.c:1.32.8.1 src/sys/dev/video.c:1.32.8.2 --- src/sys/dev/video.c:1.32.8.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/video.c Tue Jul 26 07:44:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: video.c,v 1.32.8.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: video.c,v 1.32.8.2 2016/07/26 07:44:44 pgoyette Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.32.8.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.32.8.2 2016/07/26 07:44:44 pgoyette Exp $"); #include "video.h" #if NVIDEO > 0 @@ -1630,7 +1630,7 @@ videoopen(dev_t dev, int flags, int ifmt flags, sc, sc->hw_dev)); hw = sc->hw_if; - if (hw == NULL) [ + if (hw == NULL) { device_release(sc->sc_dev); return ENXIO; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 01:13:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c ld.c md.c Log Message: Update a few more drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/dev/fss.c cvs rdiff -u -r1.94.2.3 -r1.94.2.4 src/sys/dev/ld.c cvs rdiff -u -r1.76.2.3 -r1.76.2.4 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.3 src/sys/dev/fss.c:1.93.2.4 --- src/sys/dev/fss.c:1.93.2.3 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/fss.c Wed Jul 27 01:13:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.3 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.3 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $"); #include #include @@ -172,6 +172,10 @@ fss_attach(device_t parent, device_t sel vfs_hooks_attach(&fss_vfs_hooks); } +/* + * Caller must hold a reference to the device's localcount. The + * reference is released upon successful exit. + */ static int fss_detach(device_t self, int flags) { @@ -193,12 +197,14 @@ fss_detach(device_t self, int flags) disk_destroy(sc->sc_dkdev); free(sc->sc_dkdev, M_DEVBUF); + device_release(self); return 0; } int fss_open(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int mflag; cfdata_t cf; struct fss_softc *sc; @@ -207,15 +213,23 @@ fss_open(dev_t dev, int flags, int mode, mutex_enter(&fss_device_lock); - sc = device_lookup_private(&fss_cd, minor(dev)); + self = device_lookup_acquire(&fss_cd, minor(dev)); + if (self == NULL) + sc = NULL; + else + sc = device_private(self); + if (sc == NULL) { cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); cf->cf_name = fss_cd.cd_name; cf->cf_atname = fss_cd.cd_name; cf->cf_unit = minor(dev); cf->cf_fstate = FSTATE_STAR; - sc = device_private(config_attach_pseudo(cf)); + self = config_attach_pseudo(cf)); + device_acquire(self); + sc = device_private(self); if (sc == NULL) { + device_release(self); mutex_exit(&fss_device_lock); return ENOMEM; } @@ -228,15 +242,17 @@ fss_open(dev_t dev, int flags, int mode, mutex_exit(&sc->sc_slock); mutex_exit(&fss_device_lock); + device_release(sc); return 0; } int fss_close(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self = device_lookup_acquire(&fss_cd, minor(dev)); int mflag, error; cfdata_t cf; - struct fss_softc *sc = device_lookup_private(&fss_cd, minor(dev)); + struct fss_softc *sc = device_private(self); mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN); error = 0; @@ -248,6 +264,7 @@ restart: sc->sc_flags &= ~mflag; mutex_exit(&sc->sc_slock); mutex_exit(&fss_device_lock); + device_release(self); return 0; } if ((sc->sc_flags & FSS_ACTIVE) != 0 && @@ -260,6 +277,7 @@ restart: if ((sc->sc_flags & FSS_ACTIVE) != 0) { mutex_exit(&sc->sc_slock); mutex_exit(&fss_device_lock); + device_release(self); return error; } @@ -272,14 +290,16 @@ restart: free(cf, M_DEVBUF); mutex_exit(&fss_device_lock); + /* device_release() was called by fss_detach() from config_detach() */ return error; } void fss_strategy(struct buf *bp) { + device_t self = device_lookup_acquire(&fss_cd, minor(bp->b_dev));; const bool write = ((bp->b_flags & B_READ) != B_READ); - struct fss_softc *sc = device_lookup_private(&fss_cd, minor(bp->b_dev)); + struct fss_softc *sc = device_private(self); mutex_enter(&sc->sc_slock); @@ -290,6 +310,7 @@ fss_strategy(struct buf *bp) bp->b_error = (write ? EROFS : ENXIO); bp->b_resid = bp->b_bcount; biodone(bp); + device_release(self); return; } @@ -298,6 +319,7 @@ fss_strategy(struct buf *bp) cv_signal(&sc->sc_work_cv); mutex_exit(&sc->sc_slock); + device_release(self); } int @@ -315,8 +337,9 @@ fss_write(dev_t dev, struct uio *uio, in int fss_ioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { + device_t self = device_lookup_acquire(&fss_cd, minor(dev)); int error; - struct fss_softc *sc = device_lookup_private(&fss_cd, minor(dev)); + struct fss_softc *sc = device_private(self); struct fss_set _fss; struct fss_set *fss = (struct fss_set *)data; struct fss_set50 *fss50 = (struct fss_set50 *)data; @@ -430,6 +453,7 @@ fss_ioctl(dev_t dev, u_long cmd, void *d break; } + device_release(self); return error; } @@ -570,18 +594,22 @@ fss_softc_free(struct fss_softc *sc) static void fss_unmount_hook(struct mount *mp) { + device_t self; int i; struct fss_softc *sc; mutex_enter(&fss_device_lock); for (i = 0; i <
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 03:25:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c md.c Log Message: Repair the inevitable tyops in previous. To generate a diff of this commit: cvs rdiff -u -r1.93.2.4 -r1.93.2.5 src/sys/dev/fss.c cvs rdiff -u -r1.76.2.4 -r1.76.2.5 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.4 src/sys/dev/fss.c:1.93.2.5 --- src/sys/dev/fss.c:1.93.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/fss.c Wed Jul 27 03:25:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $"); #include #include @@ -225,7 +225,7 @@ fss_open(dev_t dev, int flags, int mode, cf->cf_atname = fss_cd.cd_name; cf->cf_unit = minor(dev); cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf)); + self = config_attach_pseudo(cf); device_acquire(self); sc = device_private(self); if (sc == NULL) { @@ -242,7 +242,7 @@ fss_open(dev_t dev, int flags, int mode, mutex_exit(&sc->sc_slock); mutex_exit(&fss_device_lock); - device_release(sc); + device_release(self); return 0; } Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.76.2.4 src/sys/dev/md.c:1.76.2.5 --- src/sys/dev/md.c:1.76.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/md.c Wed Jul 27 03:25:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.76.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_md.h" @@ -291,7 +291,7 @@ mdopen(dev_t dev, int flag, int fmt, str cf->cf_atname = md_cd.cd_name; cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf)); + self = config_attach_pseudo(cf); if (self != NULL) { device_acquire(self); sc = device_private(self); @@ -465,7 +465,7 @@ mdstrategy(struct buf *bp) } sc = device_private(self); - if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) { + if (sc->sc_type == MD_UNCONFIGURED) { bp->b_error = ENXIO; goto done; } @@ -515,11 +515,11 @@ mdstrategy(struct buf *bp) break; } - done: mutex_exit(&sc->sc_lock); - + done: biodone(bp); - device_release(self); + if (self != NULL) + device_release(self); } static int
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:23:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When we spawn a new unit, make sure we get a pointer to its device_t so we have something to give device_release() when we're finished! Also, add a call to device_release() in an error path. To generate a diff of this commit: cvs rdiff -u -r1.256.2.7 -r1.256.2.8 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.7 src/sys/dev/vnd.c:1.256.2.8 --- src/sys/dev/vnd.c:1.256.2.7 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/vnd.c Wed Jul 27 11:23:32 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.7 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.7 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -359,12 +359,21 @@ vndopen(dev_t dev, int flags, int mode, if (sc == NULL) return ENOMEM; + /* + * get a pointer to the new device_t; we don't need + * need to _acquire() it, since vnd_spawn() will + * already have taken a reference. + */ + self = device_lookup(&vnd_cd, unit); + /* compatibility, keep disklabel after close */ sc->sc_flags = VNF_KLABEL; } - if ((error = vndlock(sc)) != 0) + if ((error = vndlock(sc)) != 0) { + device_release(self); return error; + } mutex_enter(&sc->sc_dkdev.dk_openlock);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:51:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When detaching, call device_release() to allow the detach to complete. To generate a diff of this commit: cvs rdiff -u -r1.256.2.8 -r1.256.2.9 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.8 src/sys/dev/vnd.c:1.256.2.9 --- src/sys/dev/vnd.c:1.256.2.8 Wed Jul 27 11:23:32 2016 +++ src/sys/dev/vnd.c Wed Jul 27 11:51:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -275,6 +275,10 @@ vnd_attach(device_t parent, device_t sel aprint_error_dev(self, "couldn't establish power handler\n"); } +/* + * The caller must hold a reference to the device's localcount. the + * reference is released if the device is available for detach. + */ static int vnd_detach(device_t self, int flags) { @@ -291,6 +295,7 @@ vnd_detach(device_t self, int flags) bufq_free(sc->sc_tab); disk_destroy(&sc->sc_dkdev); + device_release(self); return 0; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 23:17:31 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Return ENXIO if the device is NOT found, not when the device IS found! To generate a diff of this commit: cvs rdiff -u -r1.256.2.9 -r1.256.2.10 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.9 src/sys/dev/vnd.c:1.256.2.10 --- src/sys/dev/vnd.c:1.256.2.9 Wed Jul 27 11:51:57 2016 +++ src/sys/dev/vnd.c Wed Jul 27 23:17:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -1241,7 +1241,7 @@ vndioctl(dev_t dev, u_long cmd, void *da } self = device_lookup_acquire(&vnd_cd, unit); - if (self != NULL) + if (self == NULL) return ENXIO; vnd = device_private(self);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:07:20 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Clean up the vnd_spawn() routine so it actually works. In particular, it needs to return the new unit's sc _after_ acquiring a reference to the unit. To generate a diff of this commit: cvs rdiff -u -r1.256.2.10 -r1.256.2.11 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.10 src/sys/dev/vnd.c:1.256.2.11 --- src/sys/dev/vnd.c:1.256.2.10 Wed Jul 27 23:17:31 2016 +++ src/sys/dev/vnd.c Thu Jul 28 01:07:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -311,12 +311,10 @@ vnd_spawn(int unit) cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; + /* Attach a new unit */ self = config_attach_pseudo(cf); - return device_private(config_attach_pseudo(cf)); - - if (config_attach_pseudo(cf) == NULL) - return NULL; + /* And acquire a reference to it */ self = device_lookup_acquire(&vnd_cd, unit); if (self == NULL) return NULL;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:44:56 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Don't try to call device_release() if we succesfully called vnd_destroy() To generate a diff of this commit: cvs rdiff -u -r1.256.2.11 -r1.256.2.12 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.11 src/sys/dev/vnd.c:1.256.2.12 --- src/sys/dev/vnd.c:1.256.2.11 Thu Jul 28 01:07:20 2016 +++ src/sys/dev/vnd.c Thu Jul 28 01:44:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.12 2016/07/28 01:44:55 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.12 2016/07/28 01:44:55 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -500,8 +500,8 @@ vndclose(dev_t dev, int flags, int mode, aprint_error_dev(sc->sc_dev, "unable to detach instance\n"); device_release(self); - return error; } + return error; } device_release(self);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 06:45:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove duplicated code (cut-and-paste error) To generate a diff of this commit: cvs rdiff -u -r1.108.2.16 -r1.108.2.17 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.16 src/sys/dev/cgd.c:1.108.2.17 --- src/sys/dev/cgd.c:1.108.2.16 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/cgd.c Thu Jul 28 06:45:32 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.16 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.17 2016/07/28 06:45:32 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.16 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.17 2016/07/28 06:45:32 pgoyette Exp $"); #include #include @@ -1157,12 +1157,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) &cgd_cdevsw, &cgd_cmajor); /* - * Attach the {b,c}devsw's - */ - error = devsw_attach("cgd", &cgd_bdevsw, &cgd_bmajor, - &cgd_cdevsw, &cgd_cmajor); - - /* * If devsw_attach fails, remove from autoconf database */ if (error) {
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 23:59:15 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: md.c Log Message: Since md(4) has a pointer from the softc back to the device_t, it is OK for us to use device_lookup_private_acquire() rather than calling device_lookup_acquire() followed by device_private(). So, redo earlier changes, which reduces diff to the original code at the branch-point. To generate a diff of this commit: cvs rdiff -u -r1.76.2.5 -r1.76.2.6 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.76.2.5 src/sys/dev/md.c:1.76.2.6 --- src/sys/dev/md.c:1.76.2.5 Wed Jul 27 03:25:00 2016 +++ src/sys/dev/md.c Thu Jul 28 23:59:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ +/* $NetBSD: md.c,v 1.76.2.6 2016/07/28 23:59:15 pgoyette Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.6 2016/07/28 23:59:15 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_md.h" @@ -243,14 +243,12 @@ static int md_ioctl_kalloc(struct md_sof static int mdsize(dev_t dev) { - device_t self; struct md_softc *sc; int res; - self = device_lookup_acquire(&md_cd, MD_UNIT(dev)); - if (self == NULL) + sc = device_lookup_private_acquire(&md_cd, MD_UNIT(dev)); + if (sc == NULL) return 0; - sc = device_private(self); mutex_enter(&sc->sc_lock); if (sc->sc_type == MD_UNCONFIGURED) @@ -259,14 +257,14 @@ mdsize(dev_t dev) res = sc->sc_size >> DEV_BSHIFT; mutex_exit(&sc->sc_lock); - device_release(self); + device_release(sc->sc_dev); return res; } static int mdopen(dev_t dev, int flag, int fmt, struct lwp *l) { - device_t self; + device_t self, new_self; int unit; int part = DISKPART(dev); int pmask = 1 << part; @@ -279,9 +277,8 @@ mdopen(dev_t dev, int flag, int fmt, str mutex_enter(&md_device_lock); unit = MD_UNIT(dev); - sc = NULL; - self = device_lookup_acquire(&md_cd, unit); - if (self == NULL) { + sc = device_lookup_private_acquire(&md_cd, unit); + if (sc == NULL) { if (part != RAW_PART) { mutex_exit(&md_device_lock); return ENXIO; @@ -291,19 +288,16 @@ mdopen(dev_t dev, int flag, int fmt, str cf->cf_atname = md_cd.cd_name; cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf); - if (self != NULL) { - device_acquire(self); - sc = device_private(self); - } + new_self = config_attach_pseudo(cf); + self = device_lookup_acquire(&md_cd, unit); + KASSERT(self == new_self); + sc = device_private(self); if (sc == NULL) { mutex_exit(&md_device_lock); - device_release(self); + device_release(sc->sc_dev); return ENOMEM; } } - else - sc = device_private(self); dk = &sc->sc_dkdev; @@ -328,11 +322,11 @@ mdopen(dev_t dev, int flag, int fmt, str */ if (sc->sc_type == MD_UNCONFIGURED) { mutex_exit(&md_device_lock); - device_release(self); + device_release(sc->sc_dev); return ENXIO; } -ok: + ok: /* XXX duplicates code in dk_open(). Call dk_open(), instead? */ mutex_enter(&dk->dk_openlock); /* Mark our unit as open. */ @@ -349,14 +343,13 @@ ok: mutex_exit(&dk->dk_openlock); mutex_exit(&md_device_lock); - device_release(self); + device_release(sc->sc_dev); return 0; } static int mdclose(dev_t dev, int flag, int fmt, struct lwp *l) { - device_t self; int part = DISKPART(dev); int pmask = 1 << part; int error; @@ -364,10 +357,9 @@ mdclose(dev_t dev, int flag, int fmt, st struct md_softc *sc; struct disk *dk; - self = device_lookup_acquire(&md_cd, MD_UNIT(dev)); - if (self == NULL) + sc = device_lookup_private_acquire(&md_cd, MD_UNIT(dev)); + if (sc == NULL) return ENXIO; - sc = device_private(self); dk = &sc->sc_dkdev; @@ -384,7 +376,7 @@ mdclose(dev_t dev, int flag, int fmt, st dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask; if (dk->dk_openmask != 0) { mutex_exit(&dk->dk_openlock); - device_release(self); + device_release(sc->sc_dev); return 0; } @@ -396,52 +388,48 @@ mdclose(dev_t dev, int flag, int fmt, st if (! error) free(cf, M_DEVBUF); mutex_exit(&md_device_lock); - device_release(self); + if (error) + device_release(sc->sc_dev); return error; } static int mdread(dev_t dev, struct uio *uio, int flags) { - device_t self; struct md_softc *sc; int error; - self = device_lookup_acquire(&md_cd, MD_UNIT(dev)); - if (self == NULL) - return ENXIO; + sc = device_lookup_private_acquire(&md_cd, MD_UNIT(dev)); - sc = device_private(self); if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) { - device_release(self); + if (sc != NULL) + device_release(sc->sc_dev); return ENXIO; } error = (phy
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 29 01:49:39 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: tty_pty.c Log Message: Redo previous, restoring "return xxx;" in each case of the select. This gets the exit conditions back the way they were, and allows the atf test kernel/t_pty to pass. To generate a diff of this commit: cvs rdiff -u -r1.142.2.4 -r1.142.2.5 src/sys/kern/tty_pty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/tty_pty.c diff -u src/sys/kern/tty_pty.c:1.142.2.4 src/sys/kern/tty_pty.c:1.142.2.5 --- src/sys/kern/tty_pty.c:1.142.2.4 Tue Jul 26 05:54:40 2016 +++ src/sys/kern/tty_pty.c Fri Jul 29 01:49:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tty_pty.c,v 1.142.2.4 2016/07/26 05:54:40 pgoyette Exp $ */ +/* $NetBSD: tty_pty.c,v 1.142.2.5 2016/07/29 01:49:39 pgoyette Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.4 2016/07/26 05:54:40 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.5 2016/07/29 01:49:39 pgoyette Exp $"); #include "opt_ptm.h" @@ -1093,13 +1093,13 @@ ptyioctl(dev_t dev, u_long cmd, void *da cdev = cdevsw_lookup_acquire(dev); if (cdev != NULL && cdev->d_open == ptcopen) { - error = 0; switch (cmd) { #ifndef NO_DEV_PTM case TIOCGRANTPT: if ((error = pty_getmp(l, &mp)) == 0) error = pty_grant_slave(l, dev, mp); - break; + cdevsw_release(cdev); + return error; #endif case TIOCGPGRP: @@ -1108,7 +1108,8 @@ ptyioctl(dev_t dev, u_long cmd, void *da * in that case, tp must be the controlling terminal. */ *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0; - break; + cdevsw_release(cdev); + return 0; case TIOCPKT: if (*(int *)data) { @@ -1117,7 +1118,8 @@ ptyioctl(dev_t dev, u_long cmd, void *da pti->pt_flags |= PF_PKT; } else pti->pt_flags &= ~PF_PKT; - break; + cdevsw_release(cdev); + return 0; case TIOCUCNTL: if (*(int *)data) { @@ -1126,7 +1128,8 @@ ptyioctl(dev_t dev, u_long cmd, void *da pti->pt_flags |= PF_UCNTL; } else pti->pt_flags &= ~PF_UCNTL; - break; + cdevsw_release(cdev); + return 0; case TIOCREMOTE: if (*(int *)data) @@ -1136,7 +1139,8 @@ ptyioctl(dev_t dev, u_long cmd, void *da mutex_spin_enter(&tty_lock); ttyflush(tp, FREAD|FWRITE); mutex_spin_exit(&tty_lock); - break; + cdevsw_release(cdev); + return 0; case TIOCSETP: case TIOCSETN: @@ -1147,7 +1151,6 @@ ptyioctl(dev_t dev, u_long cmd, void *da mutex_spin_enter(&tty_lock); ndflush(&tp->t_outq, tp->t_outq.c_cc); mutex_spin_exit(&tty_lock); - error = -1; break; case TIOCSIG: @@ -1160,17 +1163,16 @@ ptyioctl(dev_t dev, u_long cmd, void *da tp->t_state |= TS_SIGINFO; ttysig(tp, TTYSIG_PG1, sig); mutex_spin_exit(&tty_lock); - break; + error = 0; + cdevsw_release(cdev); + return 0; case FIONREAD: mutex_spin_enter(&tty_lock); *(int *)data = tp->t_outq.c_cc; mutex_spin_exit(&tty_lock); - break; - } - if (error >= 0 ) { cdevsw_release(cdev); - return error; + return 0; } } error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l);
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 29 02:19:52 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: tty_pty.c Log Message: Add a note to revisit the locking for this device. To generate a diff of this commit: cvs rdiff -u -r1.142.2.5 -r1.142.2.6 src/sys/kern/tty_pty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/tty_pty.c diff -u src/sys/kern/tty_pty.c:1.142.2.5 src/sys/kern/tty_pty.c:1.142.2.6 --- src/sys/kern/tty_pty.c:1.142.2.5 Fri Jul 29 01:49:39 2016 +++ src/sys/kern/tty_pty.c Fri Jul 29 02:19:52 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tty_pty.c,v 1.142.2.5 2016/07/29 01:49:39 pgoyette Exp $ */ +/* $NetBSD: tty_pty.c,v 1.142.2.6 2016/07/29 02:19:52 pgoyette Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.5 2016/07/29 01:49:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.6 2016/07/29 02:19:52 pgoyette Exp $"); #include "opt_ptm.h" @@ -1046,6 +1046,12 @@ ptytty(dev_t dev) int ptyioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { +/* + * XXX We really should use device_lookup_acquire(...) to lock the + * XXX device before fetching its softc pointer. Acquiring the + * XXX cdevsw prevents the driver from being detached, but doesn't + * XXX prevent the specific instance/unit from disappearing. + */ struct pt_softc *pti = pt_softc[minor(dev)]; struct tty *tp = pti->pt_tty; const struct cdevsw *cdev;
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Fri Jul 29 02:28:38 UTC 2016 Modified Files: src/sys/kern [pgoyette-localcount]: tty_pty.c Log Message: Add module initializers in the pmax-specific copies of the [bc]devsw's To generate a diff of this commit: cvs rdiff -u -r1.142.2.6 -r1.142.2.7 src/sys/kern/tty_pty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/tty_pty.c diff -u src/sys/kern/tty_pty.c:1.142.2.6 src/sys/kern/tty_pty.c:1.142.2.7 --- src/sys/kern/tty_pty.c:1.142.2.6 Fri Jul 29 02:19:52 2016 +++ src/sys/kern/tty_pty.c Fri Jul 29 02:28:38 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tty_pty.c,v 1.142.2.6 2016/07/29 02:19:52 pgoyette Exp $ */ +/* $NetBSD: tty_pty.c,v 1.142.2.7 2016/07/29 02:28:38 pgoyette Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.6 2016/07/29 02:19:52 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.142.2.7 2016/07/29 02:28:38 pgoyette Exp $"); #include "opt_ptm.h" @@ -151,6 +151,7 @@ const struct cdevsw pts_cdevsw = { */ const struct cdevsw ptc_ultrix_cdevsw = { + DEVSW_MODULE_INIT .d_open = ptcopen, .d_close = ptcclose, .d_read = ptcread, @@ -166,6 +167,7 @@ const struct cdevsw ptc_ultrix_cdevsw = }; const struct cdevsw pts_ultrix_cdevsw = { + DEVSW_MODULE_INIT .d_open = ptsopen, .d_close = ptsclose, .d_read = ptsread,
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 31 01:32:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: ld.c Log Message: Use after initialization, not before To generate a diff of this commit: cvs rdiff -u -r1.94.2.4 -r1.94.2.5 src/sys/dev/ld.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ld.c diff -u src/sys/dev/ld.c:1.94.2.4 src/sys/dev/ld.c:1.94.2.5 --- src/sys/dev/ld.c:1.94.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/ld.c Sun Jul 31 01:32:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ld.c,v 1.94.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: ld.c,v 1.94.2.5 2016/07/31 01:32:00 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.94.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.94.2.5 2016/07/31 01:32:00 pgoyette Exp $"); #include #include @@ -627,10 +627,11 @@ static void ld_config_interrupts(device_t d) { struct ld_softc *sc; - struct dk_softc *dksc = &sc->sc_dksc; + struct dk_softc *dksc; device_acquire(d); sc = device_private(d); + dksc = &sc->sc_dksc; dkwedge_discover(&dksc->sc_dkdev); device_release(d); } @@ -654,6 +655,7 @@ ld_discard(device_t dev, off_t pos, off_ static int lddiscard(dev_t dev, off_t pos, off_t len) { + device_t self; struct ld_softc *sc; struct dk_softc *dksc; int unit;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 31 13:12:59 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c Log Message: mport rev 1.95 from HEAD To generate a diff of this commit: cvs rdiff -u -r1.93.2.6 -r1.93.2.7 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.6 src/sys/dev/fss.c:1.93.2.7 --- src/sys/dev/fss.c:1.93.2.6 Sun Jul 31 01:36:49 2016 +++ src/sys/dev/fss.c Sun Jul 31 13:12:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.7 2016/07/31 13:12:59 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.7 2016/07/31 13:12:59 pgoyette Exp $"); #include #include @@ -472,17 +472,20 @@ fss_dump(dev_t dev, daddr_t blkno, void /* * An error occurred reading or writing the snapshot or backing store. - * If it is the first error log to console. + * If it is the first error log to console and disestablish cow handler. * The caller holds the mutex. */ static inline void fss_error(struct fss_softc *sc, const char *msg) { - if ((sc->sc_flags & (FSS_ACTIVE|FSS_ERROR)) == FSS_ACTIVE) - aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); - if ((sc->sc_flags & FSS_ACTIVE) == FSS_ACTIVE) - sc->sc_flags |= FSS_ERROR; + if ((sc->sc_flags & (FSS_ACTIVE | FSS_ERROR)) != FSS_ACTIVE) + return; + + aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); + if ((sc->sc_flags & FSS_PERSISTENT) == 0) + fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); + sc->sc_flags |= FSS_ERROR; } /* @@ -605,9 +608,8 @@ fss_unmount_hook(struct mount *mp) continue; sc = device_private(self); mutex_enter(&sc->sc_slock); - if ((sc->sc_flags & FSS_ACTIVE) != 0 && - sc->sc_mount == mp) - fss_error(sc, "forced unmount"); + if ((sc->sc_flags & FSS_ACTIVE) != 0 && sc->sc_mount == mp) + fss_error(sc, "forced by unmount"); mutex_exit(&sc->sc_slock); device_release(self); } @@ -917,7 +919,7 @@ static int fss_delete_snapshot(struct fss_softc *sc, struct lwp *l) { - if ((sc->sc_flags & FSS_PERSISTENT) == 0) + if ((sc->sc_flags & (FSS_PERSISTENT | FSS_ERROR)) == 0) fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); mutex_enter(&sc->sc_slock);
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Tue Apr 25 09:03:03 UTC 2017 Modified Files: src/sys/kern [pgoyette-localcount]: subr_autoconf.c Log Message: Use KASSERTMSG() to ensure that the device has a localcount. To generate a diff of this commit: cvs rdiff -u -r1.246.2.8 -r1.246.2.9 src/sys/kern/subr_autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.246.2.8 src/sys/kern/subr_autoconf.c:1.246.2.9 --- src/sys/kern/subr_autoconf.c:1.246.2.8 Mon Mar 20 06:57:47 2017 +++ src/sys/kern/subr_autoconf.c Tue Apr 25 09:03:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.246.2.8 2017/03/20 06:57:47 pgoyette Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.246.2.9 2017/04/25 09:03:03 pgoyette Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.8 2017/03/20 06:57:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.9 2017/04/25 09:03:03 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -2252,8 +2252,9 @@ void device_acquire(device_t dv) { - if (dv->dv_localcnt != NULL) - localcount_acquire(dv->dv_localcnt); + KASSERTMSG(dv->dv_localcnt != NULL, "%s: device %s has no localcnt!", + __func__, dv->dv_cfdriver->cd_name) + localcount_acquire(dv->dv_localcnt); } /*
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Tue Apr 25 21:31:33 UTC 2017 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Call localcount_init() before publishing the new {b,c}devsw. Thanks to riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.34.2.14 -r1.34.2.15 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.14 src/sys/kern/subr_devsw.c:1.34.2.15 --- src/sys/kern/subr_devsw.c:1.34.2.14 Sat Jan 7 08:56:49 2017 +++ src/sys/kern/subr_devsw.c Tue Apr 25 21:31:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.14 2017/01/07 08:56:49 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.15 2017/04/25 21:31:33 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.14 2017/01/07 08:56:49 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.15 2017/04/25 21:31:33 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -300,13 +300,14 @@ bdevsw_attach(const struct bdevsw *devsw if (bdevsw[*devmajor] != NULL) return (EEXIST); + KASSERTMSG(devsw->d_localcount != NULL, "%s: bdev for major %d has " + "no localcount", __func__, *devmajor); + localcount_init(devsw->d_localcount); + /* ensure visibility of the bdevsw */ membar_producer(); bdevsw[*devmajor] = devsw; - KASSERTMSG(devsw->d_localcount != NULL, "%s: bdev for major %d has " - "no localcount", __func__, *devmajor); - localcount_init(devsw->d_localcount); return (0); } @@ -353,13 +354,14 @@ cdevsw_attach(const struct cdevsw *devsw if (cdevsw[*devmajor] != NULL) return (EEXIST); + KASSERTMSG(devsw->d_localcount != NULL, "%s: cdev for major %d has " + "no localcount", __func__, *devmajor); + localcount_init(devsw->d_localcount); + /* ensure visibility of the cdevsw */ membar_producer(); cdevsw[*devmajor] = devsw; - KASSERTMSG(devsw->d_localcount != NULL, "%s: cdev for major %d has " - "no localcount", __func__, *devmajor); - localcount_init(devsw->d_localcount); return (0); }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Tue Apr 25 21:36:41 UTC 2017 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Add membar_datadep_consumer() to {b,c}devsw_lookup() to ensure that the devsw content is visible. Again, thanks riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.34.2.15 -r1.34.2.16 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.15 src/sys/kern/subr_devsw.c:1.34.2.16 --- src/sys/kern/subr_devsw.c:1.34.2.15 Tue Apr 25 21:31:33 2017 +++ src/sys/kern/subr_devsw.c Tue Apr 25 21:36:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.15 2017/04/25 21:31:33 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.16 2017/04/25 21:36:41 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.15 2017/04/25 21:31:33 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.16 2017/04/25 21:36:41 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -452,6 +452,9 @@ bdevsw_lookup(dev_t dev) if (bmajor < 0 || bmajor >= max_bdevsws) return (NULL); + /* Wait for the content of the struct bdevsw to become visible */ + membar_datadep_consumer(); + return (bdevsw[bmajor]); } @@ -513,6 +516,9 @@ cdevsw_lookup(dev_t dev) if (cmajor < 0 || cmajor >= max_cdevsws) return (NULL); + /* Wait for the content of the struct bdevsw to become visible */ + membar_datadep_consumer(); + return (cdevsw[cmajor]); }
CVS commit: [pgoyette-localcount] src/sys/kern
Module Name:src Committed By: pgoyette Date: Tue Apr 25 21:53:06 UTC 2017 Modified Files: src/sys/kern [pgoyette-localcount]: subr_devsw.c Log Message: Use {b,c}devsw_acquire() and {b,c}devsw_release() in the various device acccess methods. To generate a diff of this commit: cvs rdiff -u -r1.34.2.16 -r1.34.2.17 src/sys/kern/subr_devsw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_devsw.c diff -u src/sys/kern/subr_devsw.c:1.34.2.16 src/sys/kern/subr_devsw.c:1.34.2.17 --- src/sys/kern/subr_devsw.c:1.34.2.16 Tue Apr 25 21:36:41 2017 +++ src/sys/kern/subr_devsw.c Tue Apr 25 21:53:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_devsw.c,v 1.34.2.16 2017/04/25 21:36:41 pgoyette Exp $ */ +/* $NetBSD: subr_devsw.c,v 1.34.2.17 2017/04/25 21:53:06 pgoyette Exp $ */ /*- * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.16 2017/04/25 21:36:41 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34.2.17 2017/04/25 21:53:06 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -877,7 +877,7 @@ bdev_open(dev_t dev, int flag, int devty * with attach/detach. */ mutex_enter(&device_lock); - d = bdevsw_lookup(dev); + d = bdevsw_lookup_acquire(dev); mutex_exit(&device_lock); if (d == NULL) return ENXIO; @@ -885,6 +885,7 @@ bdev_open(dev_t dev, int flag, int devty DEV_LOCK(d); rv = (*d->d_open)(dev, flag, devtype, l); DEV_UNLOCK(d); + bdevsw_release(dev); return rv; } @@ -895,12 +896,13 @@ bdev_close(dev_t dev, int flag, int devt const struct bdevsw *d; int rv, mpflag; - if ((d = bdevsw_lookup(dev)) == NULL) + if ((d = bdevsw_lookup_acquire(dev)) == NULL) return ENXIO; DEV_LOCK(d); rv = (*d->d_close)(dev, flag, devtype, l); DEV_UNLOCK(d); + bdevsw_release(dev); return rv; } @@ -916,7 +918,7 @@ bdev_strategy(struct buf *bp) SDT_PROBE1(io, kernel, , start, bp); - if ((d = bdevsw_lookup(bp->b_dev)) == NULL) { + if ((d = bdevsw_lookup_acquire(bp->b_dev)) == NULL) { bp->b_error = ENXIO; bp->b_resid = bp->b_bcount; biodone_vfs(bp); /* biodone() iff vfs present */ @@ -926,6 +928,7 @@ bdev_strategy(struct buf *bp) DEV_LOCK(d); (*d->d_strategy)(bp); DEV_UNLOCK(d); + bdevsw_release(bp->b_dev); } int @@ -934,12 +937,13 @@ bdev_ioctl(dev_t dev, u_long cmd, void * const struct bdevsw *d; int rv, mpflag; - if ((d = bdevsw_lookup(dev)) == NULL) + if ((d = bdevsw_lookup_acquire(dev)) == NULL) return ENXIO; DEV_LOCK(d); rv = (*d->d_ioctl)(dev, cmd, data, flag, l); DEV_UNLOCK(d); + bdevsw_release(dev); return rv; } @@ -969,20 +973,28 @@ int bdev_flags(dev_t dev) { const struct bdevsw *d; + int rv; - if ((d = bdevsw_lookup(dev)) == NULL) + if ((d = bdevsw_lookup_acquire(dev)) == NULL) return 0; - return d->d_flag & ~D_TYPEMASK; + rv = d->d_flag & ~D_TYPEMASK; + bdevsw_release(); + + return rv; } int bdev_type(dev_t dev) { const struct bdevsw *d; + int rv; - if ((d = bdevsw_lookup(dev)) == NULL) + if ((d = bdevsw_lookup_acquire(dev)) == NULL) return D_OTHER; - return d->d_flag & D_TYPEMASK; + rv = d->d_flag & D_TYPEMASK; + bdevsw_release(dev); + + return rv; } int @@ -991,7 +1003,7 @@ bdev_size(dev_t dev) const struct bdevsw *d; int rv, mpflag = 0; - if ((d = bdevsw_lookup(dev)) == NULL || + if ((d = bdevsw_lookup_acquire(dev)) == NULL || d->d_psize == NULL) return -1; @@ -1004,7 +1016,7 @@ bdev_size(dev_t dev) rv = (*d->d_psize)(dev); if ((boothowto & RB_DUMP) == 0) DEV_UNLOCK(d); - + bdevsw_release(dev); return rv; } @@ -1014,12 +1026,13 @@ bdev_discard(dev_t dev, off_t pos, off_t const struct bdevsw *d; int rv, mpflag; - if ((d = bdevsw_lookup(dev)) == NULL) + if ((d = bdevsw_lookup_acquire(dev)) == NULL) return ENXIO; DEV_LOCK(d); rv = (*d->d_discard)(dev, pos, len); DEV_UNLOCK(d); + bdevsw_release(dev); return rv; } @@ -1035,7 +1048,7 @@ cdev_open(dev_t dev, int flag, int devty * with attach/detach. */ mutex_enter(&device_lock); - d = cdevsw_lookup(dev); + d = cdevsw_lookup_acquire(dev); mutex_exit(&device_lock); if (d == NULL) return ENXIO; @@ -1043,6 +1056,7 @@ cdev_open(dev_t dev, int flag, int devty DEV_LOCK(d); rv = (*d->d_open)(dev, flag, devtype, l); DEV_UNLOCK(d); + cdevsw_release(dev); return rv; } @@ -1053,12 +1067,13 @@ cdev_close(dev_t dev, int flag, int devt const struct cdevsw *d; int rv, mpflag; - if ((d = cdevsw_lookup(dev)) == NULL) + if ((d = cdevsw_lookup_acquire(dev)) == NULL) return ENXIO; DEV_LOCK(d); rv = (*d->d_close)(dev, flag, devtype, l); DEV_UNLOCK(d); + cdevsw_release(dev); return rv; } @@ -1069,12 +1084,13 @@ cdev_read(dev_t dev, struct uio *uio, in const struct cdevsw *d; int rv, mpflag; - if ((d = cdevsw_lookup(dev)) == NULL) +
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Sun Jul 17 02:44:41 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: Don't call devsw_attach() and devsw_detach() for built-in modules. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.345.2.1 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345 Wed Apr 27 02:47:39 2016 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 02:44:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.345 2016/04/27 02:47:39 christos Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345 2016/04/27 02:47:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -3766,7 +3766,9 @@ static int raid_modcmd_init(void) { int error; +#ifdef _MODULE int bmajor, cmajor; +#endif mutex_init(&raid_lock, MUTEX_DEFAULT, IPL_NONE); mutex_enter(&raid_lock); @@ -3778,15 +3780,15 @@ raid_modcmd_init(void) rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; #endif +#ifdef _MODULE bmajor = cmajor = -1; error = devsw_attach("raid", &raid_bdevsw, &bmajor, &raid_cdevsw, &cmajor); - if (error != 0 && error != EEXIST) { + if (error != 0) { aprint_error("%s: devsw_attach failed %d\n", __func__, error); mutex_exit(&raid_lock); return error; } -#ifdef _MODULE error = config_cfdriver_attach(&raid_cd); if (error != 0) { aprint_error("%s: config_cfdriver_attach failed %d\n", @@ -3860,17 +3862,15 @@ raid_modcmd_fini(void) mutex_exit(&raid_lock); return error; } -#endif error = devsw_detach(&raid_bdevsw, &raid_cdevsw); if (error != 0) { aprint_error("%s: cannot detach devsw\n",__func__); -#ifdef _MODULE config_cfdriver_attach(&raid_cd); -#endif config_cfattach_attach(raid_cd.cd_name, &raid_ca); mutex_exit(&raid_lock); return error; } +#endif rf_BootRaidframe(false); #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) rf_destroy_mutex2(rf_sparet_wait_mutex);
CVS commit: [pgoyette-localcount] src/sys/dev/putter
Module Name:src Committed By: pgoyette Date: Mon Jul 18 06:25:40 UTC 2016 Modified Files: src/sys/dev/putter [pgoyette-localcount]: putter.c Log Message: Another devsw needing a localcount when built as a module. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.35.8.1 src/sys/dev/putter/putter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/putter/putter.c diff -u src/sys/dev/putter/putter.c:1.35 src/sys/dev/putter/putter.c:1.35.8.1 --- src/sys/dev/putter/putter.c:1.35 Fri Jul 25 08:10:38 2014 +++ src/sys/dev/putter/putter.c Mon Jul 18 06:25:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: putter.c,v 1.35 2014/07/25 08:10:38 dholland Exp $ */ +/* $NetBSD: putter.c,v 1.35.8.1 2016/07/18 06:25:40 pgoyette Exp $ */ /* * Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.35 2014/07/25 08:10:38 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.35.8.1 2016/07/18 06:25:40 pgoyette Exp $"); #include #include @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: putter.c,v 1 #include #include #include +#include #include @@ -61,6 +62,10 @@ dev_type_close(puttercdclose); dev_type_ioctl(puttercdioctl); /* dev */ +#ifdef _MODULE +struct localcount putter_localcount; +#endif + const struct cdevsw putter_cdevsw = { .d_open = puttercdopen, .d_close = puttercdclose, @@ -73,6 +78,9 @@ const struct cdevsw putter_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = &putter_localcount, +#endif .d_flag = D_OTHER };
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:12:11 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Add 'struct localcount' for modular builds To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.25.2.1 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.25 src/sys/dev/pad/pad.c:1.25.2.1 --- src/sys/dev/pad/pad.c:1.25 Thu Jul 7 06:55:41 2016 +++ src/sys/dev/pad/pad.c Mon Jul 18 11:12:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $ */ +/* $NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $"); #include #include @@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25 #include #include #include +#include #include #include @@ -129,6 +130,10 @@ dev_type_open(pad_open); dev_type_close(pad_close); dev_type_read(pad_read); +#ifdef _MODULE +struct localcount pad_localcount; +#endif + const struct cdevsw pad_cdevsw = { .d_open = pad_open, .d_close = pad_close, @@ -141,6 +146,9 @@ const struct cdevsw pad_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = &pad_cdevsw, +#endif .d_flag = D_OTHER | D_MPSAFE, };
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:13:23 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: We created two different 'stuct localcount' for a reason - devsw_attach() requires them to be different! So use them both in their respective {b,c}devsw initializations. To generate a diff of this commit: cvs rdiff -u -r1.345.2.2 -r1.345.2.3 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.3 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2 Sun Jul 17 05:05:10 2016 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Mon Jul 18 11:13:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.3 2016/07/18 11:13:23 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.3 2016/07/18 11:13:23 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -248,7 +248,7 @@ const struct cdevsw raid_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = &raid_localcount_bdev, + .d_localcount = &raid_localcount_cdev, #endif .d_flag = D_DISK };
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:25:07 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Good grief - what was I thinking? Let's make the d_localcount pointer point to a 'struct localcount' as intended. To generate a diff of this commit: cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.25.2.1 src/sys/dev/pad/pad.c:1.25.2.2 --- src/sys/dev/pad/pad.c:1.25.2.1 Mon Jul 18 11:12:11 2016 +++ src/sys/dev/pad/pad.c Mon Jul 18 11:25:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $ */ +/* $NetBSD: pad.c,v 1.25.2.2 2016/07/18 11:25:07 pgoyette Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.2 2016/07/18 11:25:07 pgoyette Exp $"); #include #include @@ -147,7 +147,7 @@ const struct cdevsw pad_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = &pad_cdevsw, + .d_localcount = &pad_localcount, #endif .d_flag = D_OTHER | D_MPSAFE, };
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:55:44 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: Another driver that needs its 'struct localcount' since it is used in rump. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pud/pud_dev.c diff -u src/sys/dev/pud/pud_dev.c:1.7 src/sys/dev/pud/pud_dev.c:1.7.2.1 --- src/sys/dev/pud/pud_dev.c:1.7 Tue Dec 8 20:36:15 2015 +++ src/sys/dev/pud/pud_dev.c Mon Jul 18 21:55:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pud_dev.c,v 1.7 2015/12/08 20:36:15 christos Exp $ */ +/* $NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7 2015/12/08 20:36:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $"); #include #include @@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v #include #include #include +#include #include @@ -98,6 +99,10 @@ static dev_type_dump(pud_bdev_dump); static dev_type_size(pud_bdev_size); #endif +#ifdef _MODULE +struct localcount pud_b_localcount, pud_c_localcount; +#endif + struct bdevsw pud_bdevsw = { .d_open = pud_bdev_open, .d_close = pud_bdev_close, @@ -107,6 +112,9 @@ struct bdevsw pud_bdevsw = { .d_dump = pud_bdev_dump, .d_psize = pud_bdev_size, #endif +#ifdef _MODULE + .d_localcount = pud_b_localcount, +#endif }; static int @@ -210,6 +218,9 @@ struct cdevsw pud_cdevsw = { .d_poll = pud_cdev_poll, .d_mmap = pud_cdev_mmap, .d_kqfilter = pud_cdev_kqfilter, +#ifdef _MODULE + .d_localcount = pud_b_localcount, +#endif .d_flag = D_OTHER, };
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 22:00:05 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: And use the address of the localcount ... To generate a diff of this commit: cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pud/pud_dev.c diff -u src/sys/dev/pud/pud_dev.c:1.7.2.1 src/sys/dev/pud/pud_dev.c:1.7.2.2 --- src/sys/dev/pud/pud_dev.c:1.7.2.1 Mon Jul 18 21:55:44 2016 +++ src/sys/dev/pud/pud_dev.c Mon Jul 18 22:00:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $ */ +/* $NetBSD: pud_dev.c,v 1.7.2.2 2016/07/18 22:00:05 pgoyette Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.2 2016/07/18 22:00:05 pgoyette Exp $"); #include #include @@ -113,7 +113,7 @@ struct bdevsw pud_bdevsw = { .d_psize = pud_bdev_size, #endif #ifdef _MODULE - .d_localcount = pud_b_localcount, + .d_localcount = &pud_b_localcount, #endif }; @@ -219,7 +219,7 @@ struct cdevsw pud_cdevsw = { .d_mmap = pud_cdev_mmap, .d_kqfilter = pud_cdev_kqfilter, #ifdef _MODULE - .d_localcount = pud_b_localcount, + .d_localcount = &pud_b_localcount, #endif .d_flag = D_OTHER, };
CVS commit: [pgoyette-localcount] src/sys/dev/mscp
Module Name:src Committed By: pgoyette Date: Thu Jul 21 00:02:13 UTC 2016 Modified Files: src/sys/dev/mscp [pgoyette-localcount]: mscp_disk.c Log Message: Partial adaptation to the new {b,c}devsw locking. Still needs some work. (See XXX comments in code) To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.89.2.1 src/sys/dev/mscp/mscp_disk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/mscp/mscp_disk.c diff -u src/sys/dev/mscp/mscp_disk.c:1.89 src/sys/dev/mscp/mscp_disk.c:1.89.2.1 --- src/sys/dev/mscp/mscp_disk.c:1.89 Tue Mar 29 04:55:53 2016 +++ src/sys/dev/mscp/mscp_disk.c Thu Jul 21 00:02:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -82,7 +82,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $"); #include #include @@ -1129,6 +1129,9 @@ ra_putonline(dev_t dev, struct ra_softc { struct disklabel *dl; const char *msg; +#if NRACD + const struct cdevsw *cdev; +#endif if (rx_putonline(ra) != MSCP_DONE) return MSCP_FAILED; @@ -1144,10 +1147,15 @@ ra_putonline(dev_t dev, struct ra_softc ra->ra_state = DK_OPEN; } #if NRACD - else if (cdevsw_lookup(dev) == &racd_cdevsw) { - dl->d_partitions[0].p_offset = 0; - dl->d_partitions[0].p_size = dl->d_secperunit; - dl->d_partitions[0].p_fstype = FS_ISO9660; + else { + cdev = cdevsw_lookup_acquire(dev); + if (cdev == &racd_cdevsw) { + dl->d_partitions[0].p_offset = 0; + dl->d_partitions[0].p_size = dl->d_secperunit; + dl->d_partitions[0].p_fstype = FS_ISO9660; + } + if (cdev != NULL) + cdevsw_release(cdev); } #endif /* NRACD */ else { @@ -1159,7 +1167,14 @@ ra_putonline(dev_t dev, struct ra_softc return MSCP_DONE; } - +/* XXX + * This code needs to be restructured to deal with the localcount(9) + * referencing counting on {b,c}devsw. Since we're returning the + * softc address here, we need to use cdevsw_lookup_acquire() to + * keep a reference to the device. So all callers need to be able + * to determine which device's cdevsw needs to be released later on. + * XXX + */ static inline struct ra_softc * mscp_device_lookup(dev_t dev) {
CVS commit: [pgoyette-localcount] src/sys/ufs/ffs
Module Name:src Committed By: pgoyette Date: Thu Jul 21 10:37:09 UTC 2016 Modified Files: src/sys/ufs/ffs [pgoyette-localcount]: ffs_vfsops.c Log Message: Actually save the bdev value when it is retrieved, so we can use it later in a call to bdevsw_release(). To generate a diff of this commit: cvs rdiff -u -r1.339.2.1 -r1.339.2.2 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.339.2.1 src/sys/ufs/ffs/ffs_vfsops.c:1.339.2.2 --- src/sys/ufs/ffs/ffs_vfsops.c:1.339.2.1 Wed Jul 20 23:47:57 2016 +++ src/sys/ufs/ffs/ffs_vfsops.c Thu Jul 21 10:37:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.339.2.1 2016/07/20 23:47:57 pgoyette Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.339.2.2 2016/07/21 10:37:09 pgoyette Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.339.2.1 2016/07/20 23:47:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.339.2.2 2016/07/21 10:37:09 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -452,10 +452,13 @@ ffs_mount(struct mount *mp, const char * if (devvp->v_type != VBLK) { DPRINTF("non block device %d", devvp->v_type); error = ENOTBLK; - } else if (bdevsw_lookup_acquire(devvp->v_rdev) == NULL) { -DPRINTF("can't find block device 0x%jx", -devvp->v_rdev); -error = ENXIO; + } else { +bdev = bdevsw_lookup_acquire(devvp->v_rdev); +if (bdev == NULL) { + DPRINTF("can't find block device 0x%jx", + devvp->v_rdev); + error = ENXIO; +} } } else { /*
CVS commit: [pgoyette-localcount] src/sys/fs/adosfs
Module Name:src Committed By: pgoyette Date: Thu Jul 21 11:02:56 UTC 2016 Modified Files: src/sys/fs/adosfs [pgoyette-localcount]: advfsops.c Log Message: Call bdevsw_release() in the normal-exit path. To generate a diff of this commit: cvs rdiff -u -r1.75.2.1 -r1.75.2.2 src/sys/fs/adosfs/advfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.75.2.1 src/sys/fs/adosfs/advfsops.c:1.75.2.2 --- src/sys/fs/adosfs/advfsops.c:1.75.2.1 Wed Jul 20 23:47:56 2016 +++ src/sys/fs/adosfs/advfsops.c Thu Jul 21 11:02:56 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.75.2.1 2016/07/20 23:47:56 pgoyette Exp $ */ +/* $NetBSD: advfsops.c,v 1.75.2.2 2016/07/21 11:02:56 pgoyette Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.75.2.1 2016/07/20 23:47:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.75.2.2 2016/07/21 11:02:56 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -157,8 +157,10 @@ adosfs_mount(struct mount *mp, const cha amp->uid = args->uid; amp->gid = args->gid; amp->mask = args->mask; - return set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, - mp->mnt_op->vfs_name, mp, l); + error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, + UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l); + bdevsw_release(bdev); + return error } int
CVS commit: [pgoyette-localcount] src/sys/fs/adosfs
Module Name:src Committed By: pgoyette Date: Thu Jul 21 11:13:01 UTC 2016 Modified Files: src/sys/fs/adosfs [pgoyette-localcount]: advfsops.c Log Message: Add missing semicolon To generate a diff of this commit: cvs rdiff -u -r1.75.2.2 -r1.75.2.3 src/sys/fs/adosfs/advfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.75.2.2 src/sys/fs/adosfs/advfsops.c:1.75.2.3 --- src/sys/fs/adosfs/advfsops.c:1.75.2.2 Thu Jul 21 11:02:56 2016 +++ src/sys/fs/adosfs/advfsops.c Thu Jul 21 11:13:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.75.2.2 2016/07/21 11:02:56 pgoyette Exp $ */ +/* $NetBSD: advfsops.c,v 1.75.2.3 2016/07/21 11:13:01 pgoyette Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.75.2.2 2016/07/21 11:02:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.75.2.3 2016/07/21 11:13:01 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -160,7 +160,7 @@ adosfs_mount(struct mount *mp, const cha error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l); bdevsw_release(bdev); - return error + return error; } int
CVS commit: [pgoyette-localcount] src/sys/miscfs/specfs
Module Name:src Committed By: pgoyette Date: Thu Jul 21 13:09:47 UTC 2016 Modified Files: src/sys/miscfs/specfs [pgoyette-localcount]: spec_vnops.c Log Message: fix an error patch to call {b,c}devsw_release() To generate a diff of this commit: cvs rdiff -u -r1.162.2.1 -r1.162.2.2 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.162.2.1 src/sys/miscfs/specfs/spec_vnops.c:1.162.2.2 --- src/sys/miscfs/specfs/spec_vnops.c:1.162.2.1 Wed Jul 20 23:47:57 2016 +++ src/sys/miscfs/specfs/spec_vnops.c Thu Jul 21 13:09:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.162.2.1 2016/07/20 23:47:57 pgoyette Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.162.2.2 2016/07/21 13:09:47 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.1 2016/07/20 23:47:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.2 2016/07/21 13:09:47 pgoyette Exp $"); #include #include @@ -654,14 +654,14 @@ spec_open(void *v) mutex_exit(&device_lock); if (cdev_type(dev) != D_DISK || error != 0) - return error; + goto out; - ioctl = vp->v_type == VCHR ? cdev_ioctl : bdev_ioctl; error = (*ioctl)(vp->v_rdev, DIOCGPARTINFO, &pi, FREAD, curlwp); if (error == 0) uvm_vnp_setsize(vp, (voff_t)pi.pi_secsize * pi.pi_size); + out: if (cdev != NULL) cdevsw_release(cdev); if (bdev != NULL)
CVS commit: [pgoyette-localcount] src/sys/miscfs/specfs
Module Name:src Committed By: pgoyette Date: Fri Jul 22 01:50:12 UTC 2016 Modified Files: src/sys/miscfs/specfs [pgoyette-localcount]: spec_vnops.c Log Message: Return the actual error code, rather than blind success. To generate a diff of this commit: cvs rdiff -u -r1.162.2.2 -r1.162.2.3 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.162.2.2 src/sys/miscfs/specfs/spec_vnops.c:1.162.2.3 --- src/sys/miscfs/specfs/spec_vnops.c:1.162.2.2 Thu Jul 21 13:09:47 2016 +++ src/sys/miscfs/specfs/spec_vnops.c Fri Jul 22 01:50:12 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.162.2.2 2016/07/21 13:09:47 pgoyette Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.162.2.3 2016/07/22 01:50:12 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.2 2016/07/21 13:09:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.3 2016/07/22 01:50:12 pgoyette Exp $"); #include #include @@ -667,7 +667,7 @@ spec_open(void *v) if (bdev != NULL) bdevsw_release(bdev); - return 0; + return error; } /*
CVS commit: [pgoyette-localcount] src/sys/fs/cd9660
Module Name:src Committed By: pgoyette Date: Sat Jul 23 00:44:59 UTC 2016 Modified Files: src/sys/fs/cd9660 [pgoyette-localcount]: cd9660_vfsops.c Log Message: Be consistent in the ordering of operations. To generate a diff of this commit: cvs rdiff -u -r1.90.2.1 -r1.90.2.2 src/sys/fs/cd9660/cd9660_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/cd9660/cd9660_vfsops.c diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.90.2.1 src/sys/fs/cd9660/cd9660_vfsops.c:1.90.2.2 --- src/sys/fs/cd9660/cd9660_vfsops.c:1.90.2.1 Wed Jul 20 23:47:56 2016 +++ src/sys/fs/cd9660/cd9660_vfsops.c Sat Jul 23 00:44:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.90.2.1 2016/07/20 23:47:56 pgoyette Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.90.2.2 2016/07/23 00:44:59 pgoyette Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.90.2.1 2016/07/20 23:47:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.90.2.2 2016/07/23 00:44:59 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -292,8 +292,8 @@ cd9660_mount(struct mount *mp, const cha fail: VOP_UNLOCK(devvp); - bdevsw_release(bdev); vrele(devvp); + bdevsw_release(bdev); return (error); }
CVS commit: [pgoyette-localcount] src/sys/miscfs/specfs
Module Name:src Committed By: pgoyette Date: Sat Jul 23 05:01:09 UTC 2016 Modified Files: src/sys/miscfs/specfs [pgoyette-localcount]: spec_vnops.c Log Message: Restore original handling of ioctl() returns. If the underlying disk's ioctl() returns success, we call uvm_vnp_setsize(). Regardless of any error from the ioctl() call we should return success. To generate a diff of this commit: cvs rdiff -u -r1.162.2.3 -r1.162.2.4 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.162.2.3 src/sys/miscfs/specfs/spec_vnops.c:1.162.2.4 --- src/sys/miscfs/specfs/spec_vnops.c:1.162.2.3 Fri Jul 22 01:50:12 2016 +++ src/sys/miscfs/specfs/spec_vnops.c Sat Jul 23 05:01:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.162.2.3 2016/07/22 01:50:12 pgoyette Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.162.2.4 2016/07/23 05:01:09 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.3 2016/07/22 01:50:12 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.4 2016/07/23 05:01:09 pgoyette Exp $"); #include #include @@ -661,6 +661,13 @@ spec_open(void *v) if (error == 0) uvm_vnp_setsize(vp, (voff_t)pi.pi_secsize * pi.pi_size); + if (cdev != NULL) + cdevsw_release(cdev); + if (bdev != NULL) + bdevsw_release(bdev); + + return 0; + out: if (cdev != NULL) cdevsw_release(cdev);
CVS commit: [pgoyette-localcount] src/sys/miscfs/specfs
Module Name:src Committed By: pgoyette Date: Sat Jul 23 21:54:50 UTC 2016 Modified Files: src/sys/miscfs/specfs [pgoyette-localcount]: spec_vnops.c Log Message: Simplify, remove redundant code. To generate a diff of this commit: cvs rdiff -u -r1.162.2.4 -r1.162.2.5 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.162.2.4 src/sys/miscfs/specfs/spec_vnops.c:1.162.2.5 --- src/sys/miscfs/specfs/spec_vnops.c:1.162.2.4 Sat Jul 23 05:01:09 2016 +++ src/sys/miscfs/specfs/spec_vnops.c Sat Jul 23 21:54:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.162.2.4 2016/07/23 05:01:09 pgoyette Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.162.2.5 2016/07/23 21:54:50 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.4 2016/07/23 05:01:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.162.2.5 2016/07/23 21:54:50 pgoyette Exp $"); #include #include @@ -661,12 +661,7 @@ spec_open(void *v) if (error == 0) uvm_vnp_setsize(vp, (voff_t)pi.pi_secsize * pi.pi_size); - if (cdev != NULL) - cdevsw_release(cdev); - if (bdev != NULL) - bdevsw_release(bdev); - - return 0; + error = 0; out: if (cdev != NULL)
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:30:52 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Update a few drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.110.2.1 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116 -r1.116.2.1 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110 src/sys/dev/isa/fd.c:1.110.2.1 --- src/sys/dev/isa/fd.c:1.110 Tue Dec 8 20:36:15 2015 +++ src/sys/dev/isa/fd.c Mon Jul 25 03:30:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,7 +695,9 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - struct fd_softc *fd = device_lookup_private(&fd_cd, FDUNIT(bp->b_dev)); + device_t self; + struct fd_softc *fd = + device_lookup_private_acquire(&fd_cd, FDUNIT(bp->b_dev), &self); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -753,12 +755,14 @@ fdstrategy(struct buf *bp) } #endif mutex_exit(&fdc->sc_mtx); + device_release(self); return; done: /* Toss transfer; we're done early. */ bp->b_resid = bp->b_bcount; biodone(bp); + device_release(self); } void @@ -917,20 +921,28 @@ out_fdc(bus_space_tag_t iot, bus_space_h int fdopen(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private(&fd_cd, FDUNIT(dev)); - if (fd == NULL) + fd = device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); + if (fd == NULL) { + if (self != NULL) + device_release(self); return (ENXIO); + } type = fd_dev_to_type(fd, dev); - if (type == NULL) + if (type == NULL) { + device_release(self); return ENXIO; + } if ((fd->sc_flags & FD_OPEN) != 0 && - memcmp(fd->sc_type, type, sizeof(*type))) + memcmp(fd->sc_type, type, sizeof(*type))) { + device_release(self); return EBUSY; + } fd->sc_type_copy = *type; fd->sc_type = &fd->sc_type_copy; @@ -939,17 +951,20 @@ fdopen(dev_t dev, int flags, int mode, s fd_set_geometry(fd); + device_release(self); return 0; } int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(&fd_cd, FDUNIT(dev)); + device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); + device_release(self); return 0; } @@ -1396,8 +1411,9 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(&fd_cd, FDUNIT(dev)); + device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1426,20 +1442,25 @@ fdioctl(dev_t dev, u_long cmd, void *add lp->d_secpercyl = fd->sc_type->seccyl; lp->d_secperunit = fd->sc_type->size; - if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) + if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) { + device_release(self); return EINVAL; + } break; } error = disk_ioctl(&fd->sc_dk, dev, cmd, addr, flag, l); - if (error != EPASSTHROUGH) + if (error != EPASSTHROUGH) { + device_release(self); return error; + } switch (cmd) { case DIOCWLABEL: if ((flag & FWRITE) == 0) return EBADF; /* XXX do something */ + device_release(self); return 0; case DIOCWDINFO: @@ -1447,8 +1468,10 @@ fdioctl(dev_t dev, u_long cmd, void *add case ODIOCWDINFO: #endif { - if ((flag & FWRITE) == 0) + if ((flag & FWRITE) == 0) { + device_release(self); return EBADF; + } #ifdef __HAVE_OLD_DISKLABEL if (cmd == ODIOCWDINFO) { memset(&newlabel, 0, sizeof newlabel); @@ -1457,10 +1480,10 @@ fdioctl(dev_t dev, u_long cmd, void *add } #endif error = setdisklabel(lp, addr, 0, NULL); - if (error) - return error; + if (error == 0) + error = writedisklabel(dev, fdstrategy, lp, NULL); - error = writedisklabel(dev, fdstrategy, lp, NULL); + device_release(self); return error; } @@ -1488,21 +1511,23 @@ fdioctl(dev_t dev, u_long cmd, void *add default: return EINVAL; } + device_release(self); return 0; case FDIOCSETFORMAT: if((flag & FWRITE) == 0) return EBADF; /* must be ope
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 23:40:33 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Redo previous To generate a diff of this commit: cvs rdiff -u -r1.110.2.1 -r1.110.2.2 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116.2.1 -r1.116.2.2 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110.2.1 src/sys/dev/isa/fd.c:1.110.2.2 --- src/sys/dev/isa/fd.c:1.110.2.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/fd.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,9 +695,8 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(&fd_cd, FDUNIT(bp->b_dev), &self); + device_t self = device_lookup_acquire(&fd_cd, FDUNIT(bp->b_dev)); + struct fd_softc *fd = device_private(self); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -925,12 +924,10 @@ fdopen(dev_t dev, int flags, int mode, s struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); - if (fd == NULL) { - if (self != NULL) - device_release(self); - return (ENXIO); - } + self = device_lookup_acquire(&fd_cd, FDUNIT(dev)); + if (self == NULL) + return ENXIO; + fd = device_private(self); type = fd_dev_to_type(fd, dev); if (type == NULL) { @@ -958,9 +955,8 @@ fdopen(dev_t dev, int flags, int mode, s int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); + device_t self = device_lookup_acquire(&fd_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); @@ -1411,9 +1407,8 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); + device_t self = device_lookup_acquire(&fd_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1642,10 +1637,9 @@ fdioctl(dev_t dev, u_long cmd, void *add int fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct lwp *l) { - device_t self; + device_t self = device_lookup_acquire(&fd_cd, FDUNIT(dev)); int rv = 0; - struct fd_softc *fd = - device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self); + struct fd_softc *fd = device_private(self); struct fd_type *type = fd->sc_type; struct buf *bp; Index: src/sys/dev/isa/isv.c diff -u src/sys/dev/isa/isv.c:1.7.8.1 src/sys/dev/isa/isv.c:1.7.8.2 --- src/sys/dev/isa/isv.c:1.7.8.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/isv.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $"); #include #include @@ -259,16 +259,14 @@ isv_attach(device_t parent, device_t sel int isv_open(dev_t dev, int flag, int devtype, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(&isv_cd, minor(dev)); vaddr_t va; - struct isv_softc *sc = - device_lookup_private_acquire(&isv_cd, minor(dev), &self); + struct isv_softc *sc; - if (sc == NULL) { - if (self != NULL) - device_release(self); + if (self == NULL) return ENXIO; - } + + sc = device_private(self); if (sc->sc_frame != NULL) { device_release(self); return 0; @@ -412,10 +410,9 @@ isv_capture(struct isv_softc *sc) int isv_ioctl(dev_t dev, u_long cmd, void *data, int flag, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(&isv_cd, minor(dev)); struct isv_cmd ic; - struct isv_softc *sc = - device_lookup_private_acquire(&isv_cd, minor(dev), &self); + struct isv_softc *sc; int error; if (cmd != ISV_CMD) { @@ -432,6 +429,11 @@ isv_ioctl(dev_t dev, u_long cmd, void *d return EINVAL; } + if (
CVS commit: [pgoyette-localcount] src/sys/dev/acpi
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:21 UTC 2016 Modified Files: src/sys/dev/acpi [pgoyette-localcount]: pckbc_acpi.c Log Message: Fix conversion to device_lookup_acquire() To generate a diff of this commit: cvs rdiff -u -r1.34.10.1 -r1.34.10.2 src/sys/dev/acpi/pckbc_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/pckbc_acpi.c diff -u src/sys/dev/acpi/pckbc_acpi.c:1.34.10.1 src/sys/dev/acpi/pckbc_acpi.c:1.34.10.2 --- src/sys/dev/acpi/pckbc_acpi.c:1.34.10.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/acpi/pckbc_acpi.c Tue Jul 26 07:44:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc_acpi.c,v 1.34.10.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: pckbc_acpi.c,v 1.34.10.2 2016/07/26 07:44:21 pgoyette Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.34.10.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.34.10.2 2016/07/26 07:44:21 pgoyette Exp $"); #include #include @@ -234,7 +234,7 @@ out: static void pckbc_acpi_intr_establish(struct pckbc_softc *sc, pckbc_slot_t slot) { - device_t self; + device_t self = NULL; struct pckbc_acpi_softc *psc; isa_chipset_tag_t ic = NULL; void *rv = NULL; @@ -245,7 +245,11 @@ pckbc_acpi_intr_establish(struct pckbc_s * Note we're always called with sc == first. */ for (i = 0; i < pckbc_cd.cd_ndevs; i++) { - psc = device_lookup_private_acquire(&pckbc_cd, i, &self); + self = device_lookup_acquire(&pckbc_cd, i); + if (self == NULL) + psc = NULL; + else + psc = device_private(self); if (psc && psc->sc_slot == slot) { irq = psc->sc_irq; ist = psc->sc_ist; @@ -263,7 +267,8 @@ pckbc_acpi_intr_establish(struct pckbc_s aprint_normal_dev(sc->sc_dv, "using irq %d for %s slot\n", irq, pckbc_slot_names[slot]); } - device_release(self); + if (self != NULL) + device_release(self); } static void
CVS commit: [pgoyette-localcount] src/sys/dev/pci
Module Name:src Committed By: pgoyette Date: Wed Apr 26 05:35:36 UTC 2017 Modified Files: src/sys/dev/pci [pgoyette-localcount]: pcidevs Log Message: Somehow this got out of sync on the branch. To generate a diff of this commit: cvs rdiff -u -r1.1253.2.5 -r1.1253.2.6 src/sys/dev/pci/pcidevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/pcidevs diff -u src/sys/dev/pci/pcidevs:1.1253.2.5 src/sys/dev/pci/pcidevs:1.1253.2.6 --- src/sys/dev/pci/pcidevs:1.1253.2.5 Wed Apr 26 02:53:13 2017 +++ src/sys/dev/pci/pcidevs Wed Apr 26 05:35:36 2017 @@ -1,4 +1,4 @@ -$NetBSD: pcidevs,v 1.1253.2.5 2017/04/26 02:53:13 pgoyette Exp $ +$NetBSD: pcidevs,v 1.1253.2.6 2017/04/26 05:35:36 pgoyette Exp $ /* * Copyright (c) 1995, 1996 Christopher G. Demetriou @@ -694,6 +694,7 @@ product 3COM 3C940 0x1700 3c940 Gigabit product 3COM 3C339 0x3390 3c339 TokenLink Velocity product 3COM 3C359 0x3590 3c359 TokenLink Velocity XL product 3COM 3C450TX 0x4500 3c450-TX 10/100 Ethernet +product 3COM 3C555 0x5055 3c555 10/100 Mini-PCI Ethernet product 3COM 3C575TX 0x5057 3c575-TX 10/100 Ethernet product 3COM 3C575BTX 0x5157 3CCFE575BT 10/100 Ethernet product 3COM 3C575CTX 0x5257 3CCFE575CT 10/100 Ethernet @@ -701,7 +702,6 @@ product 3COM 3C590 0x5900 3c590 Ethernet product 3COM 3C595TX 0x5950 3c595-TX 10/100 Ethernet product 3COM 3C595T4 0x5951 3c595-T4 10/100 Ethernet product 3COM 3C595MII 0x5952 3c595-MII 10/100 Ethernet -product 3COM 3C555 0x5055 3c555 10/100 Mini-PCI Ethernet product 3COM 3C154G72 0x6001 3CRWE154G72 Wireless LAN Adapter product 3COM 3C556 0x6055 3c556 10/100 Mini-PCI Ethernet product 3COM 3C556B 0x6056 3c556B 10/100 Mini-PCI Ethernet @@ -717,11 +717,11 @@ product 3COM 3C804 0x7980 3c804 FDDILink product 3COM TOKEN 0x8811 Token Ring product 3COM 3C900TPO 0x9000 3c900-TPO Ethernet product 3COM 3C900COMBO 0x9001 3c900-COMBO Ethernet -product 3COM 3C905TX 0x9050 3c905-TX 10/100 Ethernet -product 3COM 3C905T4 0x9051 3c905-T4 10/100 Ethernet product 3COM 3C900BTPO 0x9004 3c900B-TPO Ethernet product 3COM 3C900BCOMBO 0x9005 3c900B-COMBO Ethernet product 3COM 3C900BTPC 0x9006 3c900B-TPC Ethernet +product 3COM 3C905TX 0x9050 3c905-TX 10/100 Ethernet +product 3COM 3C905T4 0x9051 3c905-T4 10/100 Ethernet product 3COM 3C905BTX 0x9055 3c905B-TX 10/100 Ethernet product 3COM 3C905BT4 0x9056 3c905B-T4 10/100 Ethernet product 3COM 3C905BCOMBO 0x9058 3c905B-COMBO 10/100 Ethernet @@ -822,13 +822,13 @@ product ALI M1647 0x1647 M1647 Host-PCI product ALI M1689 0x1689 M1689 Host-PCI Bridge product ALI M3309 0x3309 M3309 MPEG Decoder product ALI M4803 0x5215 M4803 -product ALI M5257 0x5257 M5257 PCI Software Modem product ALI M5229 0x5229 M5229 UDMA IDE Controller product ALI M5237 0x5237 M5237 USB 1.1 Host Controller product ALI M5239 0x5239 M5239 USB 2.0 Host Controller product ALI M5243 0x5243 M5243 PCI-AGP Bridge product ALI M5247 0x5247 M5247 PCI-AGP Bridge product ALI M5249 0x5249 M5249 Hypertransport to PCI Bridge +product ALI M5257 0x5257 M5257 PCI Software Modem product ALI M5261 0x5261 M5261 Tulip Ethernet Controller product ALI M5288 0x5288 M5288 SATA/Raid Controller product ALI M5451 0x5451 M5451 AC-Link Controller Audio Device @@ -842,10 +842,10 @@ product ADP AIC7850 0x5078 AIC-7850 product ADP AIC7855 0x5578 AIC-7855 product ADP AIC5900 0x5900 AIC-5900 ATM product ADP AIC5905 0x5905 AIC-5905 ATM -product ADP AIC6915 0x6915 AIC-6915 10/100 Ethernet -product ADP AIC7860 0x6078 AIC-7860 product ADP APA1480 0x6075 APA-1480 Ultra +product ADP AIC7860 0x6078 AIC-7860 product ADP 2940AU 0x6178 AHA-2940A Ultra +product ADP AIC6915 0x6915 AIC-6915 10/100 Ethernet product ADP AIC7870 0x7078 AIC-7870 product ADP 2940 0x7178 AHA-2940 product ADP 3940 0x7278 AHA-3940 @@ -876,6 +876,7 @@ product ADP2 AIC7899F 0x00c5 AIC-7899F product ADP2 AIC7899P 0x00cf AIC-7899P U160 product ADP2 1420SA 0x0241 RAID 1420SA product ADP2 1430SA 0x0243 RAID 1430SA +product ADP2 SERVERAID 0x0250 ServeRAID 6/7 (marco) product ADP2 AAC2622 0x0282 AAC-2622 product ADP2 ASR2200S 0x0285 ASR-2200S product ADP2 ASR2120S 0x0286 ASR-2120S @@ -891,11 +892,10 @@ product ADP2 PERC_2QC 0x1364 Dell PERC /* XXX guess */ product ADP2 PERC_3QC 0x1365 Dell PERC 3/QC product ADP2 HP_M110_G2 0x3227 HP M110 G2 / ASR-2610SA -product ADP2 SERVERAID 0x0250 ServeRAID 6/7 (marco) /* Addtron Products */ -product ADDTRON 8139 0x1360 8139 Ethernet product ADDTRON RHINEII 0x1320 Rhine II 10/100 Ethernet +product ADDTRON 8139 0x1360 8139 Ethernet /* ADMtek products */ product ADMTEK AL981 0x0981 AL981 (Comet) 10/100 Ethernet @@ -920,9 +920,9 @@ product AGILENT TACHYON_DX2 0x0100 Tachy /* Aironet Wireless Communicasions products */ product AIRONET PC4xxx 0x0001 PC4500/PC4800 Wireless LAN Adapter product AIRONET PCI350 0x0350 PCI350 Wireless LAN Adapter -product AIRONET MPI350 0xa504
CVS commit: [pgoyette-localcount] src/sys/dev/pci
Module Name:src Committed By: pgoyette Date: Wed Apr 26 05:52:57 UTC 2017 Modified Files: src/sys/dev/pci [pgoyette-localcount]: pcidevs.h pcidevs_data.h Log Message: Regen To generate a diff of this commit: cvs rdiff -u -r1.1246.2.5 -r1.1246.2.6 src/sys/dev/pci/pcidevs.h cvs rdiff -u -r1.1245.2.5 -r1.1245.2.6 src/sys/dev/pci/pcidevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/pcidevs.h diff -u src/sys/dev/pci/pcidevs.h:1.1246.2.5 src/sys/dev/pci/pcidevs.h:1.1246.2.6 --- src/sys/dev/pci/pcidevs.h:1.1246.2.5 Wed Apr 26 02:53:13 2017 +++ src/sys/dev/pci/pcidevs.h Wed Apr 26 05:52:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pcidevs.h,v 1.1246.2.5 2017/04/26 02:53:13 pgoyette Exp $ */ +/* $NetBSD: pcidevs.h,v 1.1246.2.6 2017/04/26 05:52:48 pgoyette Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -701,6 +701,7 @@ #define PCI_PRODUCT_3COM_3C339 0x3390 /* 3c339 TokenLink Velocity */ #define PCI_PRODUCT_3COM_3C359 0x3590 /* 3c359 TokenLink Velocity XL */ #define PCI_PRODUCT_3COM_3C450TX 0x4500 /* 3c450-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C555 0x5055 /* 3c555 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C575TX 0x5057 /* 3c575-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C575BTX 0x5157 /* 3CCFE575BT 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C575CTX 0x5257 /* 3CCFE575CT 10/100 Ethernet */ @@ -708,7 +709,6 @@ #define PCI_PRODUCT_3COM_3C595TX 0x5950 /* 3c595-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C595T4 0x5951 /* 3c595-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C595MII 0x5952 /* 3c595-MII 10/100 Ethernet */ -#define PCI_PRODUCT_3COM_3C555 0x5055 /* 3c555 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C154G72 0x6001 /* 3CRWE154G72 Wireless LAN Adapter */ #define PCI_PRODUCT_3COM_3C556 0x6055 /* 3c556 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C556B 0x6056 /* 3c556B 10/100 Mini-PCI Ethernet */ @@ -724,11 +724,11 @@ #define PCI_PRODUCT_3COM_TOKEN 0x8811 /* Token Ring */ #define PCI_PRODUCT_3COM_3C900TPO 0x9000 /* 3c900-TPO Ethernet */ #define PCI_PRODUCT_3COM_3C900COMBO 0x9001 /* 3c900-COMBO Ethernet */ -#define PCI_PRODUCT_3COM_3C905TX 0x9050 /* 3c905-TX 10/100 Ethernet */ -#define PCI_PRODUCT_3COM_3C905T4 0x9051 /* 3c905-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C900BTPO 0x9004 /* 3c900B-TPO Ethernet */ #define PCI_PRODUCT_3COM_3C900BCOMBO 0x9005 /* 3c900B-COMBO Ethernet */ #define PCI_PRODUCT_3COM_3C900BTPC 0x9006 /* 3c900B-TPC Ethernet */ +#define PCI_PRODUCT_3COM_3C905TX 0x9050 /* 3c905-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905T4 0x9051 /* 3c905-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BTX 0x9055 /* 3c905B-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BT4 0x9056 /* 3c905B-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BCOMBO 0x9058 /* 3c905B-COMBO 10/100 Ethernet */ @@ -829,13 +829,13 @@ #define PCI_PRODUCT_ALI_M1689 0x1689 /* M1689 Host-PCI Bridge */ #define PCI_PRODUCT_ALI_M3309 0x3309 /* M3309 MPEG Decoder */ #define PCI_PRODUCT_ALI_M4803 0x5215 /* M4803 */ -#define PCI_PRODUCT_ALI_M5257 0x5257 /* M5257 PCI Software Modem */ #define PCI_PRODUCT_ALI_M5229 0x5229 /* M5229 UDMA IDE Controller */ #define PCI_PRODUCT_ALI_M5237 0x5237 /* M5237 USB 1.1 Host Controller */ #define PCI_PRODUCT_ALI_M5239 0x5239 /* M5239 USB 2.0 Host Controller */ #define PCI_PRODUCT_ALI_M5243 0x5243 /* M5243 PCI-AGP Bridge */ #define PCI_PRODUCT_ALI_M5247 0x5247 /* M5247 PCI-AGP Bridge */ #define PCI_PRODUCT_ALI_M5249 0x5249 /* M5249 Hypertransport to PCI Bridge */ +#define PCI_PRODUCT_ALI_M5257 0x5257 /* M5257 PCI Software Modem */ #define PCI_PRODUCT_ALI_M5261 0x5261 /* M5261 Tulip Ethernet Controller */ #define PCI_PRODUCT_ALI_M5288 0x5288 /* M5288 SATA/Raid Controller */ #define PCI_PRODUCT_ALI_M5451 0x5451 /* M5451 AC-Link Controller Audio Device */ @@ -849,10 +849,10 @@ #define PCI_PRODUCT_ADP_AIC7855 0x5578 /* AIC-7855 */ #define PCI_PRODUCT_ADP_AIC5900 0x5900 /* AIC-5900 ATM */ #define PCI_PRODUCT_ADP_AIC5905 0x5905 /* AIC-5905 ATM */ -#define PCI_PRODUCT_ADP_AIC6915 0x6915 /* AIC-6915 10/100 Ethernet */ -#define PCI_PRODUCT_ADP_AIC7860 0x6078 /* AIC-7860 */ #define PCI_PRODUCT_ADP_APA1480 0x6075 /* APA-1480 Ultra */ +#define PCI_PRODUCT_ADP_AIC7860 0x6078 /* AIC-7860 */ #define PCI_PRODUCT_ADP_2940AU 0x6178 /* AHA-2940A Ultra */ +#define PCI_PRODUCT_ADP_AIC6915 0x6915 /* AIC-6915 10/100 Ethernet */ #define PCI_PRODUCT_ADP_AIC7870 0x7078 /* AIC-7870 */ #define PCI_PRODUCT_ADP_2940 0x7178 /* AHA-2940 */ #define PCI_PRODUCT_ADP_3940 0x7278 /* AHA-3940 */ @@ -883,6 +883,7 @@ #define PCI_PRODUCT_ADP2_AIC7899P 0x00cf /* AIC-7899P U160 */ #define PCI_PRODUCT_ADP2_1420SA 0x0241 /* RAID 1420SA */ #define PCI_PRODUCT_ADP2_1430SA 0x0243 /* RAID 1430SA */ +#define PCI_PRODUCT_ADP2_SERVERAID
CVS commit: [pgoyette-localcount] src/sys/rump/librump/rumpkern
Module Name:src Committed By: pgoyette Date: Sat Jul 16 11:07:00 UTC 2016 Modified Files: src/sys/rump/librump/rumpkern [pgoyette-localcount]: Makefile.rumpkern Log Message: Make sure we include the localcount routines in the rump libraries To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.167.2.1 \ src/sys/rump/librump/rumpkern/Makefile.rumpkern Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.167 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.167.2.1 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.167 Mon Apr 11 06:49:11 2016 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Sat Jul 16 11:06:59 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.167 2016/04/11 06:49:11 ozaki-r Exp $ +# $NetBSD: Makefile.rumpkern,v 1.167.2.1 2016/07/16 11:06:59 pgoyette Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -108,6 +108,7 @@ SRCS+= init_sysctl_base.c \ subr_kcpuset.c \ subr_kmem.c \ subr_kobj.c \ + subr_localcount.c \ subr_log.c \ subr_lwp_specificdata.c \ subr_once.c \
CVS commit: [pgoyette-localcount] src/sys/rump/librump/rumpkern
Module Name:src Committed By: pgoyette Date: Mon Jul 18 06:58:44 UTC 2016 Modified Files: src/sys/rump/librump/rumpkern [pgoyette-localcount]: rump.c Log Message: We also need to init devsw's pserialize stuff when running as rump. XXX Noted that in rump, pserialize is initialized much sooner than devsw, XXX while in "real" kernels, pserialize comes _after_ devsw. Hmmm. To generate a diff of this commit: cvs rdiff -u -r1.329 -r1.329.2.1 src/sys/rump/librump/rumpkern/rump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.329 src/sys/rump/librump/rumpkern/rump.c:1.329.2.1 --- src/sys/rump/librump/rumpkern/rump.c:1.329 Tue Mar 8 14:30:48 2016 +++ src/sys/rump/librump/rumpkern/rump.c Mon Jul 18 06:58:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.329 2016/03/08 14:30:48 joerg Exp $ */ +/* $NetBSD: rump.c,v 1.329.2.1 2016/07/18 06:58:44 pgoyette Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.329 2016/03/08 14:30:48 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.329.2.1 2016/07/18 06:58:44 pgoyette Exp $"); #include #define ELFSIZE ARCH_ELFSIZE @@ -402,6 +402,7 @@ rump_init(void) fd_sys_init(); module_init(); devsw_init(); + devsw_detach_init(); pipe_init(); resource_init(); procinit_sysctl();
CVS commit: [pgoyette-localcount] src/sys/compat/linux/common
Module Name:src Committed By: pgoyette Date: Thu Jul 21 10:34:11 UTC 2016 Modified Files: src/sys/compat/linux/common [pgoyette-localcount]: linux_ioctl.c Log Message: simplify for readability To generate a diff of this commit: cvs rdiff -u -r1.58.10.1 -r1.58.10.2 \ src/sys/compat/linux/common/linux_ioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ioctl.c diff -u src/sys/compat/linux/common/linux_ioctl.c:1.58.10.1 src/sys/compat/linux/common/linux_ioctl.c:1.58.10.2 --- src/sys/compat/linux/common/linux_ioctl.c:1.58.10.1 Wed Jul 20 23:47:55 2016 +++ src/sys/compat/linux/common/linux_ioctl.c Thu Jul 21 10:34:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ioctl.c,v 1.58.10.1 2016/07/20 23:47:55 pgoyette Exp $ */ +/* $NetBSD: linux_ioctl.c,v 1.58.10.2 2016/07/21 10:34:11 pgoyette Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.58.10.1 2016/07/20 23:47:55 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.58.10.2 2016/07/21 10:34:11 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "sequencer.h" @@ -168,10 +168,11 @@ linux_sys_ioctl(struct lwp *l, const str vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(vp, &va, l->l_cred); VOP_UNLOCK(vp); - if (error == 0 && - (cdev = cdevsw_lookup_acquire(va.va_rdev)) == - &sequencer_cdevsw) -is_sequencer = true; + if (error == 0) { +cdev = cdevsw_lookup_acquire(va.va_rdev); +if (cdev == &sequencer_cdevsw) + is_sequencer = true; + } } if (is_sequencer) { error = oss_ioctl_sequencer(l,
CVS commit: [pgoyette-localcount] src/sys/arch/x86/x86
Module Name:src Committed By: pgoyette Date: Sat Aug 6 10:45:22 UTC 2016 Modified Files: src/sys/arch/x86/x86 [pgoyette-localcount]: pmap.c Log Message: Resolve $NetBSD$ conflict To generate a diff of this commit: cvs rdiff -u -r1.211.2.2 -r1.211.2.3 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.211.2.2 src/sys/arch/x86/x86/pmap.c:1.211.2.3 --- src/sys/arch/x86/x86/pmap.c:1.211.2.2 Sat Aug 6 00:19:06 2016 +++ src/sys/arch/x86/x86/pmap.c Sat Aug 6 10:45:22 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.211.2.2 2016/08/06 00:19:06 pgoyette Exp $ */ +/* $NetBSD: pmap.c,v 1.211.2.3 2016/08/06 10:45:22 pgoyette Exp $ */ /*- * Copyright (c) 2008, 2010, 2016 The NetBSD Foundation, Inc. @@ -171,11 +171,7 @@ */ #include -<<< pmap.c -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.2 2016/08/06 00:19:06 pgoyette Exp $"); -=== -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.2 2016/08/06 00:19:06 pgoyette Exp $"); ->>> 1.218 +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.3 2016/08/06 10:45:22 pgoyette Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h"
CVS commit: [pgoyette-localcount] src/sys/rump/dev/lib/libcgd
Module Name:src Committed By: pgoyette Date: Sat Jul 23 05:05:47 UTC 2016 Modified Files: src/sys/rump/dev/lib/libcgd [pgoyette-localcount]: cgd_component.c Log Message: The rump_cgd component needs to do an early cdevsw_attact() to figure out the device major numbers being used. But we then need to detach the [bc]devsw's to allow them to get attached normally during module initialization. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.2.2.1 src/sys/rump/dev/lib/libcgd/cgd_component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libcgd/cgd_component.c diff -u src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2 src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.1 --- src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2 Tue Jan 26 23:12:15 2016 +++ src/sys/rump/dev/lib/libcgd/cgd_component.c Sat Jul 23 05:05:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $ */ +/* $NetBSD: cgd_component.c,v 1.2.2.1 2016/07/23 05:05:47 pgoyette Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2.2.1 2016/07/23 05:05:47 pgoyette Exp $"); #include #include @@ -56,4 +56,5 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV) if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rcgd0", 'a', cmaj, 0, 7)) != 0) panic("cannot create raw cgd dev nodes: %d", error); + cdevsw_detach(&cgd_bdevsw, &cgd_cdevsw); }
CVS commit: [pgoyette-localcount] src/sys/rump/dev/lib/libcgd
Module Name:src Committed By: pgoyette Date: Sat Jul 23 07:41:14 UTC 2016 Modified Files: src/sys/rump/dev/lib/libcgd [pgoyette-localcount]: cgd_component.c Log Message: Use correct function name - devsw_detach() vs cdevsw_detach() -- To generate a diff of this commit: cvs rdiff -u -r1.2.2.1 -r1.2.2.2 src/sys/rump/dev/lib/libcgd/cgd_component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libcgd/cgd_component.c diff -u src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.1 src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.2 --- src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.1 Sat Jul 23 05:05:47 2016 +++ src/sys/rump/dev/lib/libcgd/cgd_component.c Sat Jul 23 07:41:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd_component.c,v 1.2.2.1 2016/07/23 05:05:47 pgoyette Exp $ */ +/* $NetBSD: cgd_component.c,v 1.2.2.2 2016/07/23 07:41:14 pgoyette Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2.2.1 2016/07/23 05:05:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2.2.2 2016/07/23 07:41:14 pgoyette Exp $"); #include #include @@ -56,5 +56,5 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV) if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rcgd0", 'a', cmaj, 0, 7)) != 0) panic("cannot create raw cgd dev nodes: %d", error); - cdevsw_detach(&cgd_bdevsw, &cgd_cdevsw); + devsw_detach(&cgd_bdevsw, &cgd_cdevsw); }
CVS commit: [pgoyette-localcount] src/sys/rump/dev/lib/libcgd
Module Name:src Committed By: pgoyette Date: Sun Jul 24 10:37:10 UTC 2016 Modified Files: src/sys/rump/dev/lib/libcgd [pgoyette-localcount]: cgd_component.c Log Message: since we're now attached the [bc]devsw's, grabbing the assigned majors, and then detaching (in anticipation of the driver module doing its own attach), we need to make sure that the driver name matches what is expected in devsw_attach(). In particular, the driver name is "cgd" and not "/dev/cgd0" :) While here, we might as well record the major numbers from the first call, and just reuse them later. So make the module's variables global, and reference them in the rump initialization code. Yay - cgd now works in the localcount world, both as a kernel module and as a rump component. To generate a diff of this commit: cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/rump/dev/lib/libcgd/cgd_component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/dev/lib/libcgd/cgd_component.c diff -u src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.2 src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.3 --- src/sys/rump/dev/lib/libcgd/cgd_component.c:1.2.2.2 Sat Jul 23 07:41:14 2016 +++ src/sys/rump/dev/lib/libcgd/cgd_component.c Sun Jul 24 10:37:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd_component.c,v 1.2.2.2 2016/07/23 07:41:14 pgoyette Exp $ */ +/* $NetBSD: cgd_component.c,v 1.2.2.3 2016/07/24 10:37:10 pgoyette Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2.2.2 2016/07/23 07:41:14 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.2.2.3 2016/07/24 10:37:10 pgoyette Exp $"); #include #include @@ -40,21 +40,21 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV) { extern const struct bdevsw cgd_bdevsw; extern const struct cdevsw cgd_cdevsw; - devmajor_t bmaj, cmaj; + extern devmajor_t cgd_bmajor, cgd_cmajor; int error; /* go, mydevfs */ - bmaj = cmaj = -1; - if ((error = devsw_attach("/dev/cgd0", &cgd_bdevsw, &bmaj, - &cgd_cdevsw, &cmaj)) != 0) + if ((error = devsw_attach("cgd", &cgd_bdevsw, &cgd_bmajor, + &cgd_cdevsw, &cgd_cmajor)) != 0) panic("cannot attach cgd: %d", error); if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/cgd0", 'a', - bmaj, 0, 7)) != 0) + cgd_bmajor, 0, 7)) != 0) panic("cannot create cooked cgd dev nodes: %d", error); if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rcgd0", 'a', - cmaj, 0, 7)) != 0) + cgd_cmajor, 0, 7)) != 0) panic("cannot create raw cgd dev nodes: %d", error); + devsw_detach(&cgd_bdevsw, &cgd_cdevsw); }