From owner-freebsd-ppc@FreeBSD.ORG Wed Nov 10 22:14:35 2010 Return-Path: Delivered-To: powerpc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0ADA1065702; Wed, 10 Nov 2010 22:14:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id A265A8FC17; Wed, 10 Nov 2010 22:14:35 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 3C67246B0C; Wed, 10 Nov 2010 17:14:35 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3F7768A009; Wed, 10 Nov 2010 17:14:34 -0500 (EST) From: John Baldwin To: powerpc@freebsd.org Date: Wed, 10 Nov 2010 17:14:32 -0500 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201011101714.33194.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 10 Nov 2010 17:14:34 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=0.7 required=4.2 tests=BAYES_00,TO_NO_BRKTS_DIRECT autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: raj@freebsd.org, dim@freebsd.org Subject: Use of MTX_UNOWNED in booke/trap_subr.S X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2010 22:14:35 -0000 First of, sorry for breaking the build. I built a powerpc GENERIC and a powerpc64 GENERIC before I committed, but that obviously wasn't sufficient. dim@ pointed me at the use of MTX_UNOWNED in booke/trap_subr.S. The first thought I had was to re-allow in assembly code, or to expose MTX_UNOWNED via assym.s. However, it looks like the tlb lock in trap_subr.S is a home-grown spinlock rather than an actual 'struct mtx'. For that reason, I'd prefer it use its own constant to avoid confusion. To that end, the patch below adds a TLB_UNLOCKED constant to and uses it for the tlb locks. (I do wonder if we couldn't put the tlb_lock/unlock prototypes in machine/tlb.h as well rather than booke/pmap.c? Then it could all be grouped together to be more consistent.) Index: powerpc/booke/machdep.c =================================================================== --- powerpc/booke/machdep.c (revision 215090) +++ powerpc/booke/machdep.c (working copy) @@ -453,7 +453,7 @@ ptr = &tlb0_miss_locks[cpuid * words_per_gran]; pcpu->pc_booke_tlb_lock = ptr; - *ptr = MTX_UNOWNED; + *ptr = TLB_UNLOCKED; *(ptr + 1) = 0; /* recurse counter */ #endif } Index: powerpc/booke/trap_subr.S =================================================================== --- powerpc/booke/trap_subr.S (revision 215090) +++ powerpc/booke/trap_subr.S (working copy) @@ -330,7 +330,7 @@ lwz %r22, PC_BOOKE_TLB_LOCK(%r20); \ \ 1: lwarx %r23, 0, %r22; \ - cmpwi %r23, MTX_UNOWNED; \ + cmpwi %r23, TLB_UNLOCKED; \ beq 2f; \ \ /* check if this is recursion */ \ @@ -364,7 +364,7 @@ msync; \ \ /* release the lock */ \ - li %r23, MTX_UNOWNED; \ + li %r23, TLB_UNLOCKED; \ stw %r23, 0(%r22); \ 1: isync; \ msync @@ -860,7 +860,7 @@ GET_CPUINFO(%r5) lwz %r5, PC_CURTHREAD(%r5) 1: lwarx %r4, 0, %r3 - cmpwi %r4, MTX_UNOWNED + cmpwi %r4, TLB_UNLOCKED bne 1b stwcx. %r5, 0, %r3 bne- 1b @@ -871,7 +871,7 @@ ENTRY(tlb_unlock) isync msync - li %r4, MTX_UNOWNED + li %r4, TLB_UNLOCKED stw %r4, 0(%r3) isync msync Index: powerpc/include/tlb.h =================================================================== --- powerpc/include/tlb.h (revision 215090) +++ powerpc/include/tlb.h (working copy) @@ -129,6 +129,9 @@ #define TID_MAX 255 #define TID_NONE -1 +/* Lock value for an unlocked per-CPU TLB lock for BookE. */ +#define TLB_UNLOCKED 4 + #if !defined(LOCORE) typedef struct tlb_entry { uint32_t mas1; -- John Baldwin