Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/prg-localcount2]: src Introduce config_detach_release() which does all t...
details: https://anonhg.NetBSD.org/src/rev/6f2d449db850
branches: prg-localcount2
changeset: 823519:6f2d449db850
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Fri Apr 28 06:00:33 2017 +0000
description:
Introduce config_detach_release() which does all the work from the
former config_detach(). Now, config_detach() simply acquires a
reference to the device, which config_detach_release() can release!
This is needed because some drivers call config_detach() with a
reference, while other drivers have not been updated to use the
localcount reference mechanism. So we provide a shim to make
everyone equal.
diffstat:
distrib/sets/lists/comp/mi | 5 ++++-
share/man/man9/Makefile | 3 ++-
share/man/man9/autoconf.9 | 15 ++++++++++++---
sys/dev/cgd.c | 10 ++++------
sys/dev/fss.c | 11 ++++-------
sys/dev/md.c | 10 ++++------
sys/dev/vnd.c | 11 +++++------
sys/kern/subr_autoconf.c | 29 ++++++++++++++++++++++++++---
sys/sys/device.h | 3 ++-
9 files changed, 63 insertions(+), 34 deletions(-)
diffs (truncated from 368 to 300 lines):
diff -r 8d646c41c2be -r 6f2d449db850 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Fri Apr 28 03:46:57 2017 +0000
+++ b/distrib/sets/lists/comp/mi Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2125.2.1 2017/04/27 05:36:30 pgoyette Exp $
+# $NetBSD: mi,v 1.2125.2.2 2017/04/28 06:00:33 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -10313,6 +10313,7 @@
./usr/share/man/cat9/config_defer.0 comp-sys-catman .cat
./usr/share/man/cat9/config_detach.0 comp-sys-catman .cat
./usr/share/man/cat9/config_detach_children.0 comp-sys-catman .cat
+./usr/share/man/cat9/config_detach_release.0 comp-sys-catman .cat
./usr/share/man/cat9/config_finalize_register.0 comp-sys-catman .cat
./usr/share/man/cat9/config_found.0 comp-sys-catman .cat
./usr/share/man/cat9/config_found_ia.0 comp-sys-catman .cat
@@ -17776,6 +17777,7 @@
./usr/share/man/html9/config_defer.html comp-sys-htmlman html
./usr/share/man/html9/config_detach.html comp-sys-htmlman html
./usr/share/man/html9/config_detach_children.html comp-sys-htmlman html
+./usr/share/man/html9/config_detach_release.html comp-sys-htmlman html
./usr/share/man/html9/config_finalize_register.html comp-sys-htmlman html
./usr/share/man/html9/config_found.html comp-sys-htmlman html
./usr/share/man/html9/config_found_ia.html comp-sys-htmlman html
@@ -25351,6 +25353,7 @@
./usr/share/man/man9/config_defer.9 comp-sys-man .man
./usr/share/man/man9/config_detach.9 comp-sys-man .man
./usr/share/man/man9/config_detach_children.9 comp-sys-man .man
+./usr/share/man/man9/config_detach_release.9 comp-sys-man .man
./usr/share/man/man9/config_finalize_register.9 comp-sys-man .man
./usr/share/man/man9/config_found.9 comp-sys-man .man
./usr/share/man/man9/config_found_ia.9 comp-sys-man .man
diff -r 8d646c41c2be -r 6f2d449db850 share/man/man9/Makefile
--- a/share/man/man9/Makefile Fri Apr 28 03:46:57 2017 +0000
+++ b/share/man/man9/Makefile Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.409.2.1 2017/04/27 05:36:31 pgoyette Exp $
+# $NetBSD: Makefile,v 1.409.2.2 2017/04/28 06:00:33 pgoyette Exp $
# Makefile for section 9 (kernel function and variable) manual pages.
@@ -119,6 +119,7 @@
autoconf.9 config_attach_pseudo.9 \
autoconf.9 config_detach.9 \
autoconf.9 config_detach_children.9 \
+ autoconf.9 config_detach_release.9 \
autoconf.9 config_deactivate.9 \
autoconf.9 config_defer.9 \
autoconf.9 config_interrupts.9 \
diff -r 8d646c41c2be -r 6f2d449db850 share/man/man9/autoconf.9
--- a/share/man/man9/autoconf.9 Fri Apr 28 03:46:57 2017 +0000
+++ b/share/man/man9/autoconf.9 Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: autoconf.9,v 1.30 2013/03/13 00:09:21 riastradh Exp $
+.\" $NetBSD: autoconf.9,v 1.30.20.1 2017/04/28 06:00:33 pgoyette Exp $
.\"
.\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 17, 2012
+.Dd April 28, 2017
.Dt AUTOCONF 9
.Os
.Sh NAME
@@ -43,6 +43,7 @@
.Nm config_attach_pseudo ,
.Nm config_detach ,
.Nm config_detach_children ,
+.Nm config_detach_release ,
.Nm config_deactivate ,
.Nm config_defer ,
.Nm config_interrupts ,
@@ -84,6 +85,8 @@
.Ft int
.Fn config_detach_children "device_t dev" "int flags"
.Ft int
+.Fn config_detach_release "device_t dev" "int flags"
+.Ft int
.Fn config_deactivate "device_t dev"
.Ft int
.Fn config_defer "device_t dev" "void (*func)(device_t)"
@@ -340,7 +343,13 @@
.Fn config_search_loc
for regular devices.
.It Fn config_detach "dev" "flags"
-Called by the parent to detach the child device.
+.It Fn config_detach_release "dev" "flags"
+Called by the parent to acquire a reference to and detach the child device.
+If the parent has already acquired a reference to the child via
+.Fn device_acquire ,
+it should call
+.Fn config_detach_release .
+In either case, the reference is released.
The second argument
.Em flags
contains detachment flags.
diff -r 8d646c41c2be -r 6f2d449db850 sys/dev/cgd.c
--- a/sys/dev/cgd.c Fri Apr 28 03:46:57 2017 +0000
+++ b/sys/dev/cgd.c Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.3 2017/04/27 12:07:23 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.4 2017/04/28 06:00:33 pgoyette Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.3 2017/04/27 12:07:23 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.4 2017/04/28 06:00:33 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -337,8 +337,7 @@
/*
- * The caller must hold a reference to the device's localcount. the
- * reference is released if the device is available for detach.
+ * The caller must hold a reference to the device's localcount.
*/
static int
cgd_detach(device_t self, int flags)
@@ -358,7 +357,6 @@
disk_destroy(&dksc->sc_dkdev);
mutex_destroy(&sc->sc_lock);
- device_release(self);
return 0;
}
@@ -407,7 +405,7 @@
cfdata_t cf;
cf = device_cfdata(dev);
- error = config_detach(dev, DETACH_QUIET);
+ error = config_detach_release(dev, DETACH_QUIET);
if (error == 0)
free(cf, M_DEVBUF);
diff -r 8d646c41c2be -r 6f2d449db850 sys/dev/fss.c
--- a/sys/dev/fss.c Fri Apr 28 03:46:57 2017 +0000
+++ b/sys/dev/fss.c Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.97.4.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: fss.c,v 1.97.4.2 2017/04/28 06:00:33 pgoyette Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.97.4.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.97.4.2 2017/04/28 06:00:33 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -173,8 +173,7 @@
}
/*
- * Caller must hold a reference to the device's localcount. The
- * reference is released upon successful exit.
+ * Caller must hold a reference to the device's localcount.
*/
static int
fss_detach(device_t self, int flags)
@@ -197,7 +196,6 @@
disk_destroy(sc->sc_dkdev);
free(sc->sc_dkdev, M_DEVBUF);
- device_release(self);
return 0;
}
@@ -285,12 +283,11 @@
KASSERT((sc->sc_flags & (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) == mflag);
mutex_exit(&sc->sc_slock);
cf = device_cfdata(sc->sc_dev);
- error = config_detach(sc->sc_dev, DETACH_QUIET);
+ error = config_detach_release(sc->sc_dev, DETACH_QUIET);
if (! error)
free(cf, M_DEVBUF);
mutex_exit(&fss_device_lock);
- /* device_release() was called by fss_detach() from config_detach() */
return error;
}
diff -r 8d646c41c2be -r 6f2d449db850 sys/dev/md.c
--- a/sys/dev/md.c Fri Apr 28 03:46:57 2017 +0000
+++ b/sys/dev/md.c Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.78.6.2 2017/04/27 23:18:21 pgoyette Exp $ */
+/* $NetBSD: md.c,v 1.78.6.3 2017/04/28 06:00:33 pgoyette Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.2 2017/04/27 23:18:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.3 2017/04/28 06:00:33 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_md.h"
@@ -216,7 +216,6 @@
if (rc != 0)
return rc;
- device_release(self);
pmf_device_deregister(self);
disk_detach(&sc->sc_dkdev);
disk_destroy(&sc->sc_dkdev);
@@ -384,12 +383,11 @@
mutex_enter(&md_device_lock);
cf = device_cfdata(sc->sc_dev);
- error = config_detach(sc->sc_dev, DETACH_QUIET);
+ error = config_detach_release(sc->sc_dev, DETACH_QUIET);
if (! error)
free(cf, M_DEVBUF);
mutex_exit(&md_device_lock);
- if (error)
- device_release(sc->sc_dev);
+
return error;
}
diff -r 8d646c41c2be -r 6f2d449db850 sys/dev/vnd.c
--- a/sys/dev/vnd.c Fri Apr 28 03:46:57 2017 +0000
+++ b/sys/dev/vnd.c Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.259.4.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: vnd.c,v 1.259.4.2 2017/04/28 06:00:33 pgoyette Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.2 2017/04/28 06:00:33 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -334,7 +334,7 @@
cfdata_t cf;
cf = device_cfdata(dev);
- error = config_detach(dev, DETACH_QUIET);
+ error = config_detach_release(dev, DETACH_QUIET);
if (error)
return error;
free(cf, M_DEVBUF);
@@ -499,12 +499,11 @@
if ((error = vnd_destroy(sc->sc_dev)) != 0) {
aprint_error_dev(sc->sc_dev,
"unable to detach instance\n");
- device_release(self);
}
return error;
- }
+ } else
+ device_release(self);
- device_release(self);
return 0;
}
diff -r 8d646c41c2be -r 6f2d449db850 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c Fri Apr 28 03:46:57 2017 +0000
+++ b/sys/kern/subr_autoconf.c Fri Apr 28 06:00:33 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.252.4.1 2017/04/27 05:36:37 pgoyette Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.252.4.2 2017/04/28 06:00:33 pgoyette Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.252.4.1 2017/04/27 05:36:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.252.4.2 2017/04/28 06:00:33 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1275,6 +1275,12 @@
/* Remove from cfdriver's array. */
cd->cd_devs[dev->dv_unit] = NULL;
Home |
Main Index |
Thread Index |
Old Index