linux-mips
[Top] [All Lists]

Re: [PATCH v2 2/3] MIPS: cavium-octeon: rewrite the sched_clock()

To: Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH v2 2/3] MIPS: cavium-octeon: rewrite the sched_clock() based on mips_cyc2ns()
From: wu zhangjin <wuzhangjin@gmail.com>
Date: Thu, 29 Jul 2010 09:24:07 +0800
Cc: Wu Zhangjin <wuzhangjin@gmail.com>, linux-mips@linux-mips.org, David Daney <ddaney@caviumnetworks.com>, Ralf Rösch <roesch.ralf@web.de>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=0bi+7STJbxWM6UN1d5SkpF6YhBCp1jTFMq2iQh1BrCY=; b=qL12zKR82S7FGI1Jq6FO/R5wWtxnE81YNessALyKWuBkUfjLmFxcBGeGXmJKkdqmdO qZnCIpGdNfLoHh+tVimRwRooBIiRe48PR5PsjBhIVII3bZzj93/OYJsweSVOSzjlvSNy S7riRZK+YAdWKuXprGOH43WcATQAa/ByZDy5U=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=mg/px9v3QVYKnRhGzpsNzBG4cTbhwhpF5DP9l+MFE8OsxiJe2NmR+v4APS4vG6X7KG CIO4oU8nwx4xR5OUMfFtM6Iyy84In1YGzK2iyk8qqnOh6K66aWLYgwvndwU2n477n/Ki CXozJ6wFVnC2ulXjpb1L3vexbof8vLln+0FME=
In-reply-to: <503ec883993ca4be3a5680bf52091bf0fcf37357.1270655886.git.wuzhangjin@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1270655886.git.wuzhangjin@gmail.com> <cover.1270653461.git.wuzhangjin@gmail.com> <503ec883993ca4be3a5680bf52091bf0fcf37357.1270655886.git.wuzhangjin@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
Hi, Ralf

This may be not applicable for the original version is changed by

[PATCH] OCTEON: workaround linking failures with gcc-4.4.x 32-bits toolchains

from Florian Fainelli.

Regards,
Wu Zhangjin

On Thu, Apr 8, 2010 at 12:05 AM, Wu Zhangin <wuzhangjin@gmail.com> wrote:
From: Wu Zhangjin <wuzhangjin@gmail.com>

Changes from v1:

 o use the new interface mips_cyc2ns() intead of the old
 mips_sched_clock().

The commit "MIPS: add a common mips_cyc2ns()" have abstracted the
solution of the 64bit calculation's overflow problem into a common
mips_cyc2ns() function in arch/mips/include/asm/time.h, This patch just
rewrites the sched_clock() for cavium-octeon on it.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/cavium-octeon/csrc-octeon.c |   29 ++---------------------------
 1 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/arch/mips/cavium-octeon/csrc-octeon.c b/arch/mips/cavium-octeon/csrc-octeon.c
index 0bf4bbe..bca0004 100644
--- a/arch/mips/cavium-octeon/csrc-octeon.c
+++ b/arch/mips/cavium-octeon/csrc-octeon.c
@@ -52,34 +52,9 @@ static struct clocksource clocksource_mips = {

 unsigned long long notrace sched_clock(void)
 {
-       /* 64-bit arithmatic can overflow, so use 128-bit.  */
-#if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 3))
-       u64 t1, t2, t3;
-       unsigned long long rv;
-       u64 mult = clocksource_mips.mult;
-       u64 shift = clocksource_mips.shift;
-       u64 cnt = read_c0_cvmcount();
+       u64 cyc = read_c0_cvmcount();

-       asm (
-               "dmultu\t%[cnt],%[mult]\n\t"
-               "nor\t%[t1],$0,%[shift]\n\t"
-               "mfhi\t%[t2]\n\t"
-               "mflo\t%[t3]\n\t"
-               "dsll\t%[t2],%[t2],1\n\t"
-               "dsrlv\t%[rv],%[t3],%[shift]\n\t"
-               "dsllv\t%[t1],%[t2],%[t1]\n\t"
-               "or\t%[rv],%[t1],%[rv]\n\t"
-               : [rv] "=&r" (rv), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3)
-               : [cnt] "r" (cnt), [mult] "r" (mult), [shift] "r" (shift)
-               : "hi", "lo");
-       return rv;
-#else
-       /* GCC > 4.3 do it the easy way.  */
-       unsigned int __attribute__((mode(TI))) t;
-       t = read_c0_cvmcount();
-       t = t * clocksource_mips.mult;
-       return (unsigned long long)(t >> clocksource_mips.shift);
-#endif
+       return mips_cyc2ns(cyc, clocksource_mips.mult, clocksource_mips.shift);
 }

 void __init plat_time_init(void)
--
1.7.0.1




--
MSN+Gtalk: wuzhangjin@gmail.com
Blog: http://falcon.oss.lzu.edu.cn
Tel:+86-18710032278
<Prev in Thread] Current Thread [Next in Thread>
  • Re: [PATCH v2 2/3] MIPS: cavium-octeon: rewrite the sched_clock() based on mips_cyc2ns(), wu zhangjin <=