From 121098a3ec21939bdf64d5f837700ffc912d6d69 Mon Sep 17 00:00:00 2001 From: mrg Date: Tue, 18 May 2010 04:30:16 +0000 Subject: [PATCH] move the mutex_init() for ci_ctx_lock inside cpu_attach() so that we don't try to mutex_init() before lockdebug is available. fixes LOCKDEBUG crashes at startup (for USII systems.) --- sys/arch/sparc64/sparc64/cpu.c | 5 +++-- sys/arch/sparc64/sparc64/pmap.c | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c index 7d5d00cfdaba..3546c02e8a82 100644 --- a/sys/arch/sparc64/sparc64/cpu.c +++ b/sys/arch/sparc64/sparc64/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.94 2010/03/13 15:01:53 nakayama Exp $ */ +/* $NetBSD: cpu.c,v 1.95 2010/05/18 04:30:16 mrg Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.94 2010/03/13 15:01:53 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.95 2010/05/18 04:30:16 mrg Exp $"); #include "opt_multiprocessor.h" @@ -281,6 +281,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) #endif evcnt_attach_dynamic(&ci->ci_tick_evcnt, EVCNT_TYPE_INTR, NULL, device_xname(dev), "timer"); + mutex_init(&ci->ci_ctx_lock, MUTEX_SPIN, IPL_VM); clk = prom_getpropint(node, "clock-frequency", 0); if (clk == 0) { diff --git a/sys/arch/sparc64/sparc64/pmap.c b/sys/arch/sparc64/sparc64/pmap.c index 3042d8104fb5..83fbaa9caa95 100644 --- a/sys/arch/sparc64/sparc64/pmap.c +++ b/sys/arch/sparc64/sparc64/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.263 2010/03/30 01:50:03 mrg Exp $ */ +/* $NetBSD: pmap.c,v 1.264 2010/05/18 04:30:16 mrg Exp $ */ /* * * Copyright (C) 1996-1999 Eduardo Horvath. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.263 2010/03/30 01:50:03 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.264 2010/05/18 04:30:16 mrg Exp $"); #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ #define HWREF @@ -1217,15 +1217,17 @@ cpu_pmap_prepare(struct cpu_info *ci, bool initial) } /* - * Initialize the per CPU parts for the cpu running this code (despite the - * passed cpuinfo). + * Initialize the per CPU parts for the cpu running this code. */ void cpu_pmap_init(struct cpu_info *ci) { size_t ctxsize; - mutex_init(&ci->ci_ctx_lock, MUTEX_SPIN, IPL_VM); + /* + * We delay initialising ci_ctx_lock here as LOCKDEBUG isn't + * running for cpu0 yet.. + */ ci->ci_pmap_next_ctx = 1; #ifdef SUN4V #error find out if we have 16 or 13 bit context ids