linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Eugene Surovegin <ebs@ebshome.net>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <kumar.gala@motorola.com>,
	linuxppc-embedded@lists.linuxppc.org,
	Matt Porter <mporter@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [RFC] "indirect" DCR access (40x, BookE)
Date: Mon, 22 Mar 2004 18:47:26 -0800	[thread overview]
Message-ID: <20040323024726.GA2939@gate.ebshome.net> (raw)
In-Reply-To: <1079668852.909.88.camel@gaston>


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/

  reply	other threads:[~2004-03-23  2:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-12  1:48 [RFC] "indirect" DCR access (40x, BookE) Eugene Surovegin
2004-03-12  2:46 ` Dan Malek
2004-03-12  3:05   ` Eugene Surovegin
2004-03-12  4:44     ` Stephen Williams
2004-03-12  4:54       ` Eugene Surovegin
2004-03-12 14:25         ` Kumar Gala
2004-03-12 14:53           ` Chuck Meade
2004-03-12 16:20           ` Eugene Surovegin
2004-03-12 18:01           ` Dan Malek
2004-03-19  4:00           ` Benjamin Herrenschmidt
2004-03-23  2:47             ` Eugene Surovegin [this message]
2004-04-01  5:36               ` Kumar Gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040323024726.GA2939@gate.ebshome.net \
    --to=ebs@ebshome.net \
    --cc=benh@kernel.crashing.org \
    --cc=kumar.gala@motorola.com \
    --cc=linuxppc-embedded@lists.linuxppc.org \
    --cc=mporter@kernel.crashing.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).