[RFC] "indirect" DCR access (40x, BookE)

Kumar Gala kumar.gala at motorola.com
Thu Apr 1 15:36:10 EST 2004


Looks good to me.

- kumar

On Mar 22, 2004, at 8:47 PM, Eugene Surovegin wrote:

>
> 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 <linux/compiler.h>
> +
>  /* 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/





More information about the Linuxppc-embedded mailing list