Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys autoconf: Blame devices holding up boot with config_...
details: https://anonhg.NetBSD.org/src/rev/657ee8995b2f
branches: trunk
changeset: 1014822:657ee8995b2f
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Oct 03 22:32:50 2020 +0000
description:
autoconf: Blame devices holding up boot with config_pending.
Blame message requires `boot -x' (AB_DEBUG).
Fix ata so it doesn't mismatch config_pending_incr/decr devices.
diffstat:
sys/dev/ata/ata.c | 8 ++++----
sys/kern/subr_autoconf.c | 30 ++++++++++++++++++++----------
sys/sys/device.h | 5 ++++-
3 files changed, 28 insertions(+), 15 deletions(-)
diffs (132 lines):
diff -r 1cee6a91c8e0 -r 657ee8995b2f sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Sat Oct 03 22:27:00 2020 +0000
+++ b/sys/dev/ata/ata.c Sat Oct 03 22:32:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.160 2020/10/03 22:32:50 riastradh Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.160 2020/10/03 22:32:50 riastradh Exp $");
#include "opt_ata.h"
@@ -298,7 +298,7 @@
ata_delref(chp);
- config_pending_decr(atac->atac_dev);
+ config_pending_decr(atabus_sc->sc_dev);
}
/*
@@ -424,7 +424,7 @@
ata_delref(chp);
- config_pending_decr(atac->atac_dev);
+ config_pending_decr(atabus_sc->sc_dev);
kthread_exit(0);
}
diff -r 1cee6a91c8e0 -r 657ee8995b2f sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c Sat Oct 03 22:27:00 2020 +0000
+++ b/sys/kern/subr_autoconf.c Sat Oct 03 22:32:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.273 2020/08/01 11:18:26 jdolecek Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.274 2020/10/03 22:32:50 riastradh 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.273 2020/08/01 11:18:26 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.274 2020/10/03 22:32:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -224,7 +224,8 @@
static int alldevs_nwrite = 0;
static bool alldevs_garbage = false;
-static int config_pending; /* semaphore for mountroot */
+static struct devicelist config_pending =
+ TAILQ_HEAD_INITIALIZER(config_pending);
static kmutex_t config_misc_lock;
static kcondvar_t config_misc_cv;
@@ -2095,9 +2096,12 @@
{
mutex_enter(&config_misc_lock);
- config_pending++;
+ KASSERTMSG(dev->dv_pending < INT_MAX,
+ "%s: excess config_pending_incr", device_xname(dev));
+ if (dev->dv_pending++ == 0)
+ TAILQ_INSERT_TAIL(&config_pending, dev, dv_pending_list);
#ifdef DEBUG_AUTOCONF
- printf("%s: %s %d\n", __func__, device_xname(dev), config_pending);
+ printf("%s: %s %d\n", __func__, device_xname(dev), dev->dv_pending);
#endif
mutex_exit(&config_misc_lock);
}
@@ -2106,13 +2110,15 @@
config_pending_decr(device_t dev)
{
- KASSERT(0 < config_pending);
mutex_enter(&config_misc_lock);
- config_pending--;
+ KASSERTMSG(dev->dv_pending > 0,
+ "%s: excess config_pending_decr", device_xname(dev));
+ if (--dev->dv_pending == 0)
+ TAILQ_REMOVE(&config_pending, dev, dv_pending_list);
#ifdef DEBUG_AUTOCONF
- printf("%s: %s %d\n", __func__, device_xname(dev), config_pending);
+ printf("%s: %s %d\n", __func__, device_xname(dev), dev->dv_pending);
#endif
- if (config_pending == 0)
+ if (TAILQ_EMPTY(&config_pending))
cv_broadcast(&config_misc_cv);
mutex_exit(&config_misc_lock);
}
@@ -2165,8 +2171,12 @@
* them to finish any deferred autoconfiguration.
*/
mutex_enter(&config_misc_lock);
- while (config_pending != 0)
+ while (!TAILQ_EMPTY(&config_pending)) {
+ device_t dev;
+ TAILQ_FOREACH(dev, &config_pending, dv_pending_list)
+ aprint_debug_dev(dev, "holding up boot\n");
cv_wait(&config_misc_cv, &config_misc_lock);
+ }
mutex_exit(&config_misc_lock);
KERNEL_LOCK(1, NULL);
diff -r 1cee6a91c8e0 -r 657ee8995b2f sys/sys/device.h
--- a/sys/sys/device.h Sat Oct 03 22:27:00 2020 +0000
+++ b/sys/sys/device.h Sat Oct 03 22:32:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.157 2018/12/01 01:51:38 msaitoh Exp $ */
+/* $NetBSD: device.h,v 1.158 2020/10/03 22:32:50 riastradh Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -165,6 +165,9 @@
int *dv_locators; /* our actual locators (optional) */
prop_dictionary_t dv_properties;/* properties dictionary */
+ int dv_pending; /* config_pending count */
+ TAILQ_ENTRY(device) dv_pending_list;
+
size_t dv_activity_count;
void (**dv_activity_handlers)(device_t, devactive_t);
Home |
Main Index |
Thread Index |
Old Index