From owner-svn-src-stable-7@FreeBSD.ORG Tue Jan 25 22:08:44 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1098E1065696; Tue, 25 Jan 2011 22:08:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F19098FC36; Tue, 25 Jan 2011 22:08:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0PM8hMp052747; Tue, 25 Jan 2011 22:08:43 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0PM8hN7052738; Tue, 25 Jan 2011 22:08:43 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201101252208.p0PM8hN7052738@svn.freebsd.org> From: John Baldwin Date: Tue, 25 Jan 2011 22:08:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217856 - in stable/7/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 pc98/pc98 powerpc/powerpc sparc64/sparc64 sun4v/sun4v X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2011 22:08:44 -0000 Author: jhb Date: Tue Jan 25 22:08:43 2011 New Revision: 217856 URL: http://svn.freebsd.org/changeset/base/217856 Log: MFC 214835: Adjust the order of operations in spinlock_enter() and spinlock_exit() to work properly with single-stepping in a kernel debugger. Modified: stable/7/sys/amd64/amd64/machdep.c stable/7/sys/arm/arm/machdep.c stable/7/sys/i386/i386/machdep.c stable/7/sys/ia64/ia64/machdep.c stable/7/sys/pc98/pc98/machdep.c stable/7/sys/powerpc/powerpc/machdep.c stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sun4v/sun4v/machdep.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/amd64/amd64/machdep.c ============================================================================== --- stable/7/sys/amd64/amd64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/amd64/amd64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -1405,11 +1405,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -1417,12 +1421,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } /* Modified: stable/7/sys/arm/arm/machdep.c ============================================================================== --- stable/7/sys/arm/arm/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/arm/arm/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -475,11 +475,15 @@ void spinlock_enter(void) { struct thread *td; + register_t cspr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_cspr = disable_interrupts(I32_bit | F32_bit); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + cspr = disable_interrupts(I32_bit | F32_bit); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_cspr = cspr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -487,12 +491,14 @@ void spinlock_exit(void) { struct thread *td; + register_t cspr; td = curthread; critical_exit(); + cspr = td->td_md.md_saved_cspr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - restore_interrupts(td->td_md.md_saved_cspr); + restore_interrupts(cspr); } /* Modified: stable/7/sys/i386/i386/machdep.c ============================================================================== --- stable/7/sys/i386/i386/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/i386/i386/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -2440,11 +2440,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -2452,12 +2456,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } #if defined(I586_CPU) && !defined(NO_F00F_HACK) Modified: stable/7/sys/ia64/ia64/machdep.c ============================================================================== --- stable/7/sys/ia64/ia64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/ia64/ia64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -410,11 +410,15 @@ void spinlock_enter(void) { struct thread *td; + int intr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_intr = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + intr = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_intr = intr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -422,12 +426,14 @@ void spinlock_exit(void) { struct thread *td; + int intr; td = curthread; critical_exit(); + intr = td->td_md.md_saved_intr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_intr); + intr_restore(intr); } void Modified: stable/7/sys/pc98/pc98/machdep.c ============================================================================== --- stable/7/sys/pc98/pc98/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/pc98/pc98/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -2179,11 +2179,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -2191,12 +2195,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } #if defined(I586_CPU) && !defined(NO_F00F_HACK) Modified: stable/7/sys/powerpc/powerpc/machdep.c ============================================================================== --- stable/7/sys/powerpc/powerpc/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/powerpc/powerpc/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -942,11 +942,15 @@ void spinlock_enter(void) { struct thread *td; + register_t msr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_msr = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + msr = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_msr = msr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -954,12 +958,14 @@ void spinlock_exit(void) { struct thread *td; + register_t msr; td = curthread; critical_exit(); + msr = td->td_md.md_saved_msr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_msr); + intr_restore(msr); } /* Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/sparc64/sparc64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -222,9 +222,10 @@ spinlock_enter(void) if (td->td_md.md_spinlock_count == 0) { pil = rdpr(pil); wrpr(pil, 0, PIL_TICK); + td->td_md.md_spinlock_count = 1; td->td_md.md_saved_pil = pil; - } - td->td_md.md_spinlock_count++; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -232,12 +233,14 @@ void spinlock_exit(void) { struct thread *td; + register_t pil; td = curthread; critical_exit(); + pil = td->td_md.md_saved_pil; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - wrpr(pil, td->td_md.md_saved_pil, 0); + wrpr(pil, pil, 0); } static phandle_t Modified: stable/7/sys/sun4v/sun4v/machdep.c ============================================================================== --- stable/7/sys/sun4v/sun4v/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/sun4v/sun4v/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -267,9 +267,10 @@ spinlock_enter(void) td = curthread; if (td->td_md.md_spinlock_count == 0) { pil = intr_disable(); + td->td_md.md_spinlock_count = 1; td->td_md.md_saved_pil = pil; - } - td->td_md.md_spinlock_count++; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -277,14 +278,14 @@ void spinlock_exit(void) { struct thread *td; + register_t pil; td = curthread; critical_exit(); + pil = td->td_md.md_saved_pil; td->td_md.md_spinlock_count--; - if (td->td_md.md_spinlock_count == 0) { - intr_restore(td->td_md.md_saved_pil); - } - + if (td->td_md.md_spinlock_count == 0) + intr_restore(pil); } unsigned