From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 22 Mar 2004 18:47:26 -0800 From: Eugene Surovegin To: Benjamin Herrenschmidt Cc: Kumar Gala , linuxppc-embedded@lists.linuxppc.org, Matt Porter , Paul Mackerras Subject: Re: [RFC] "indirect" DCR access (40x, BookE) Message-ID: <20040323024726.GA2939@gate.ebshome.net> References: <20040312014800.GA25455@gate.ebshome.net> <405124A3.3040002@embeddededge.com> <20040312030502.GA25644@gate.ebshome.net> <24019-11838@sneakemail.com> <20040312045451.GA25876@gate.ebshome.net> <1921A482-7431-11D8-AFB6-000393DBC2E8@motorola.com> <1079668852.909.88.camel@gaston> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1079668852.909.88.camel@gaston> Sender: owner-linuxppc-embedded@lists.linuxppc.org List-Id: On Fri, Mar 19, 2004 at 03:00:53PM +1100, Benjamin Herrenschmidt wrote: > I much prefer Eugene's idea. During discussion with Ben on IRC he suggested that having two different DCR access wasn't a good idea and better if we use GCC __builtin_constant_p extension to decide what version to call. New patch version can be found http://kernel.ebshome.net/dcr-2.6-2.diff Here is only _new_ part for review: ===== include/asm-ppc/reg_booke.h 1.5 vs edited ===== --- 1.5/include/asm-ppc/reg_booke.h Fri Feb 13 07:24:55 2004 +++ edited/include/asm-ppc/reg_booke.h Mon Mar 22 17:44:02 2004 @@ -10,20 +10,33 @@ #define __ASM_PPC_REG_BOOKE_H__ #ifndef __ASSEMBLY__ +#include + /* Device Control Registers */ +void __mtdcr(int reg, unsigned int val); +unsigned int __mfdcr(int reg); #define mfdcr(rn) mfdcr_or_dflt(rn, 0) #define mfdcr_or_dflt(rn,default_rval) \ ({unsigned int rval; \ - if (rn == 0) \ + if (unlikely(rn == 0)) \ rval = default_rval; \ else \ - asm volatile("mfdcr %0," __stringify(rn) : "=r" (rval)); \ + if (__builtin_constant_p(rn)) \ + asm volatile("mfdcr %0," __stringify(rn) \ + : "=r" (rval)); \ + else \ + rval = __mfdcr(rn); \ rval;}) #define mtdcr(rn, v) \ do { \ - if (rn != 0) \ - asm volatile("mtdcr " __stringify(rn) ",%0" : : "r" (v)); \ + if (likely(rn != 0)){ \ + if (__builtin_constant_p(rn)) \ + asm volatile("mtdcr " __stringify(rn) ",%0" \ + : : "r" (v)); \ + else \ + __mtdcr(rn, v); \ + } \ } while (0) /* R/W of indirect DCRs make use of standard naming conventions for DCRs */ Thanks, Eugene ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/