From 96fd048710b89a9df257e0420624f561987842e2 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 1 Feb 2022 12:50:13 +0000 Subject: [PATCH 04/13] autoconf(9): Use dv_detached, not dv_del_gen, for device_lookup. Not necessary to use dv_del_gen because the value of dv_del_gen is relevant to iteration but not lookup -- we only care about whether it's zero or not. And any time dv_del_gen is nonzero, dv_detached is set. Preferable to use dv_detached because if we want to put a pserialized fast path around these lookups, we need to set anything the fast path relies on atomically, but dv_del_gen is a 64-bit integer which we can't use atomics on in MI code. --- sys/kern/subr_autoconf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index f6d443e9f1f6..0a87bc954838 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -2643,7 +2643,7 @@ device_lookup(cfdriver_t cd, int unit) mutex_enter(&alldevs_lock); if (unit < 0 || unit >= cd->cd_ndevs) dv = NULL; - else if ((dv = cd->cd_devs[unit]) != NULL && dv->dv_del_gen != 0) + else if ((dv = cd->cd_devs[unit]) != NULL && dv->detached) dv = NULL; mutex_exit(&alldevs_lock); @@ -2690,7 +2690,6 @@ device_lookup_acquire(cfdriver_t cd, int unit) mutex_enter(&alldevs_lock); retry: if (unit < 0 || unit >= cd->cd_ndevs || (dv = cd->cd_devs[unit]) == NULL || - dv->dv_del_gen != 0 || dv->dv_detached) { dv = NULL; } else {