From e000e0011875e76478b1a705bdb8a83835e4eedb Mon Sep 17 00:00:00 2001 From: Peter Grehan Date: Sun, 7 Aug 2005 02:20:35 +0000 Subject: [PATCH] Export a routine, kobj_machdep_init(), that allows platforms to use the kobj subsystem as soon at mutex_init() has been called instead of having to wait for the SI_SUB_LOCK sysinit. Reviewed by: dfr --- sys/kern/subr_kobj.c | 13 +++++++++++-- sys/sys/kobj.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index 1704a0f4a3c..b8528fa276a 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -57,6 +57,7 @@ SYSCTL_UINT(_kern, OID_AUTO, kobj_misses, CTLFLAG_RD, #endif static struct mtx kobj_mtx; +static int kobj_mutex_inited; static int kobj_next_id = 1; SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, @@ -65,12 +66,20 @@ SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, static void kobj_init_mutex(void *arg) { - - mtx_init(&kobj_mtx, "kobj", NULL, MTX_DEF); + if (!kobj_mutex_inited) { + mtx_init(&kobj_mtx, "kobj", NULL, MTX_DEF); + kobj_mutex_inited = 1; + } } SYSINIT(kobj, SI_SUB_LOCK, SI_ORDER_ANY, kobj_init_mutex, NULL); +void +kobj_machdep_init(void) +{ + kobj_init_mutex(NULL); +} + /* * This method structure is used to initialise new caches. Since the * desc pointer is NULL, it is guaranteed never to match any read diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index d2cd0da6b74..86788e597e1 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -246,4 +246,9 @@ kobj_method_t* kobj_lookup_method(kobj_class_t cls, */ int kobj_error_method(void); +/* + * Machine-dependent initialisation call for boot-time kobj clients + */ +void kobj_machdep_init(void); + #endif /* !_SYS_KOBJ_H_ */