Date: Wed, 10 Nov 2010 17:14:32 -0500 From: John Baldwin <jhb@freebsd.org> To: powerpc@freebsd.org Cc: raj@freebsd.org, dim@freebsd.org Subject: Use of MTX_UNOWNED in booke/trap_subr.S Message-ID: <201011101714.33194.jhb@freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/mutex.h> 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 <machine/tlb.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011101714.33194.jhb>