From 5f91e807f5a9360634d4f640424c9ad6386cc860 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 15 Jan 2022 20:01:53 +0000 Subject: [PATCH 03/36] driver(9): Use xcall(9) rather than pserialize(9) for devsw detach. devsw_init is called too early for the kmem(9) in pserialize_create, but pserialize_create doesn't do anything useful anyway. --- sys/kern/subr_devsw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/subr_devsw.c b/sys/kern/subr_devsw.c index 9b19b89b3538..ee2bb1cb1009 100644 --- a/sys/kern/subr_devsw.c +++ b/sys/kern/subr_devsw.c @@ -88,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.38 2017/11/07 18:35:57 christos Exp #include #include #include +#include #ifdef DEVSW_DEBUG #define DPRINTF(x) printf x @@ -114,7 +115,6 @@ extern int max_bdevsws, max_cdevsws, max_devsw_convs; static struct devswref *cdevswref; static struct devswref *bdevswref; -static struct pserialize *devsw_psz; static kcondvar_t devsw_cv; static int bdevsw_attach(const struct bdevsw *, devmajor_t *); @@ -133,7 +133,6 @@ devsw_init(void) KASSERT(sys_cdevsws < MAXDEVSW - 1); mutex_init(&device_lock, MUTEX_DEFAULT, IPL_NONE); - devsw_psz = pserialize_create(); cv_init(&devsw_cv, "devsw"); } @@ -406,8 +405,11 @@ devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev) /* * Wait for all bdevsw_lookup_acquire, cdevsw_lookup_acquire * calls to notice that the devsw is gone. + * + * XXX Can't use pserialize_perform here because devsw_init is + * too early for pserialize_create(). */ - pserialize_perform(devsw_psz); + xc_barrier(0); /* * Wait for all references to drain. It is the caller's