Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=31ee4b2f40994e8b21691f85cdd4052551a789b7
Commit:     31ee4b2f40994e8b21691f85cdd4052551a789b7
Parent:     31cb4bd31a48f62105d037ad53192b94d4c08f53
Author:     Martin Schwidefsky <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 5 21:18:31 2007 +0100
Committer:  Martin Schwidefsky <[EMAIL PROTECTED]>
CommitDate: Mon Feb 5 21:18:31 2007 +0100

    [S390] Calibrate delay and bogomips.
    
    Preset the bogomips number to the cpu capacity value reported by
    store system information in SYSIB 1.2.2. This value is constant
    for a particular machine model and can be used to determine
    relative performance differences between machines.
    
    Signed-off-by: Martin Schwidefsky <[EMAIL PROTECTED]>
---
 arch/s390/Kconfig             |    4 --
 arch/s390/kernel/setup.c      |    1 +
 arch/s390/lib/Makefile        |    2 +-
 arch/s390/lib/qrnnd.S         |   77 +++++++++++++++++++++++++++++++++++++++++
 arch/s390/math-emu/Makefile   |    2 +-
 arch/s390/math-emu/math.c     |    2 +-
 arch/s390/math-emu/qrnnd.S    |   77 -----------------------------------------
 arch/s390/math-emu/sfp-util.h |   66 -----------------------------------
 drivers/s390/Makefile         |    2 +
 drivers/s390/sysinfo.c        |   63 +++++++++++++++++++++++++++++++++-
 include/asm-s390/processor.h  |    1 +
 include/asm-s390/sfp-util.h   |   66 +++++++++++++++++++++++++++++++++++
 12 files changed, 212 insertions(+), 151 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 5c7e981..eaed402 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -34,10 +34,6 @@ config GENERIC_HWEIGHT
        bool
        default y
 
-config GENERIC_CALIBRATE_DELAY
-       bool
-       default y
-
 config GENERIC_TIME
        def_bool y
 
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 2569aaf..2fa866f 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -938,6 +938,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
         struct cpuinfo_S390 *cpuinfo;
        unsigned long n = (unsigned long) v - 1;
 
+       s390_adjust_jiffies();
        preempt_disable();
        if (!n) {
                seq_printf(m, "vendor_id       : IBM/S390\n"
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
index b5f94cf..7a44fed 100644
--- a/arch/s390/lib/Makefile
+++ b/arch/s390/lib/Makefile
@@ -4,7 +4,7 @@
 
 EXTRA_AFLAGS := -traditional
 
-lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
+lib-y += delay.o string.o uaccess_std.o uaccess_pt.o qrnnd.o
 lib-$(CONFIG_32BIT) += div64.o
 lib-$(CONFIG_64BIT) += uaccess_mvcos.o
 lib-$(CONFIG_SMP) += spinlock.o
diff --git a/arch/s390/lib/qrnnd.S b/arch/s390/lib/qrnnd.S
new file mode 100644
index 0000000..eb1df63
--- /dev/null
+++ b/arch/s390/lib/qrnnd.S
@@ -0,0 +1,77 @@
+# S/390 __udiv_qrnnd
+
+# r2 : &__r
+# r3 : upper half of 64 bit word n
+# r4 : lower half of 64 bit word n
+# r5 : divisor d
+# the reminder r of the division is to be stored to &__r and
+# the quotient q is to be returned
+
+       .text
+       .globl __udiv_qrnnd
+__udiv_qrnnd:
+       st    %r2,24(%r15)        # store pointer to reminder for later
+       lr    %r0,%r3             # reload n
+       lr    %r1,%r4
+       ltr   %r2,%r5             # reload and test divisor
+       jp    5f
+       # divisor >= 0x80000000
+       srdl  %r0,2               # n/4
+       srl   %r2,1               # d/2
+       slr   %r1,%r2             # special case if last bit of d is set
+       brc   3,0f                #  (n/4) div (n/2) can overflow by 1
+       ahi   %r0,-1              #  trick: subtract n/2, then divide
+0:     dr    %r0,%r2             # signed division
+       ahi   %r1,1               #  trick part 2: add 1 to the quotient
+       # now (n >> 2) = (d >> 1) * %r1 + %r0
+       lhi   %r3,1
+       nr    %r3,%r1             # test last bit of q
+       jz    1f
+       alr   %r0,%r2             # add (d>>1) to r
+1:     srl   %r1,1               # q >>= 1
+       # now (n >> 2) = (d&-2) * %r1 + %r0
+       lhi   %r3,1
+       nr    %r3,%r5             # test last bit of d
+       jz    2f
+       slr   %r0,%r1             # r -= q
+       brc   3,2f                # borrow ?
+       alr   %r0,%r5             # r += d
+       ahi   %r1,-1
+2:     # now (n >> 2) = d * %r1 + %r0
+       alr   %r1,%r1             # q <<= 1
+       alr   %r0,%r0             # r <<= 1
+       brc   12,3f               # overflow on r ?
+       slr   %r0,%r5             # r -= d
+       ahi   %r1,1               # q += 1
+3:     lhi   %r3,2
+       nr    %r3,%r4             # test next to last bit of n
+       jz    4f
+       ahi   %r0,1               # r += 1
+4:     clr   %r0,%r5             # r >= d ?
+       jl    6f
+       slr   %r0,%r5             # r -= d
+       ahi   %r1,1               # q += 1
+       # now (n >> 1) = d * %r1 + %r0
+       j     6f
+5:     # divisor < 0x80000000
+       srdl  %r0,1
+       dr    %r0,%r2             # signed division
+       # now (n >> 1) = d * %r1 + %r0
+6:     alr   %r1,%r1             # q <<= 1
+       alr   %r0,%r0             # r <<= 1
+       brc   12,7f               # overflow on r ?
+       slr   %r0,%r5             # r -= d
+       ahi   %r1,1               # q += 1
+7:     lhi   %r3,1
+       nr    %r3,%r4             # isolate last bit of n
+       alr   %r0,%r3             # r += (n & 1)
+       clr   %r0,%r5             # r >= d ?
+       jl    8f
+       slr   %r0,%r5             # r -= d
+       ahi   %r1,1               # q += 1
+8:     # now n = d * %r1 + %r0
+       l     %r2,24(%r15)
+       st    %r0,0(%r2)
+       lr    %r2,%r1
+       br    %r14
+       .end    __udiv_qrnnd
diff --git a/arch/s390/math-emu/Makefile b/arch/s390/math-emu/Makefile
index c10df14..73b3e72 100644
--- a/arch/s390/math-emu/Makefile
+++ b/arch/s390/math-emu/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the FPU instruction emulation.
 #
 
-obj-$(CONFIG_MATHEMU) := math.o qrnnd.o
+obj-$(CONFIG_MATHEMU) := math.o
 
 EXTRA_CFLAGS := -I$(src) -Iinclude/math-emu -w
 EXTRA_AFLAGS := -traditional
diff --git a/arch/s390/math-emu/math.c b/arch/s390/math-emu/math.c
index 6b9aec5..3ee78cc 100644
--- a/arch/s390/math-emu/math.c
+++ b/arch/s390/math-emu/math.c
@@ -15,7 +15,7 @@
 #include <asm/uaccess.h>
 #include <asm/lowcore.h>
 
-#include "sfp-util.h"
+#include <asm/sfp-util.h>
 #include <math-emu/soft-fp.h>
 #include <math-emu/single.h>
 #include <math-emu/double.h>
diff --git a/arch/s390/math-emu/qrnnd.S b/arch/s390/math-emu/qrnnd.S
deleted file mode 100644
index b01c2b6..0000000
--- a/arch/s390/math-emu/qrnnd.S
+++ /dev/null
@@ -1,77 +0,0 @@
-# S/390 __udiv_qrnnd
-
-# r2 : &__r
-# r3 : upper half of 64 bit word n
-# r4 : lower half of 64 bit word n
-# r5 : divisor d
-# the reminder r of the division is to be stored to &__r and
-# the quotient q is to be returned
-
-        .text
-        .globl __udiv_qrnnd
-__udiv_qrnnd:
-        st    %r2,24(%r15)        # store pointer to reminder for later
-        lr    %r0,%r3             # reload n
-       lr    %r1,%r4
-       ltr   %r2,%r5             # reload and test divisor
-        jp    5f
-        # divisor >= 0x80000000
-       srdl  %r0,2               # n/4
-        srl   %r2,1               # d/2
-        slr   %r1,%r2             # special case if last bit of d is set
-        brc   3,0f                #  (n/4) div (n/2) can overflow by 1
-        ahi   %r0,-1              #  trick: subtract n/2, then divide
-0:      dr    %r0,%r2             # signed division
-        ahi   %r1,1               #  trick part 2: add 1 to the quotient
-        # now (n >> 2) = (d >> 1) * %r1 + %r0
-       lhi   %r3,1
-        nr    %r3,%r1             # test last bit of q
-        jz    1f
-        alr   %r0,%r2             # add (d>>1) to r
-1:      srl   %r1,1               # q >>= 1
-        # now (n >> 2) = (d&-2) * %r1 + %r0
-        lhi   %r3,1
-        nr    %r3,%r5             # test last bit of d
-        jz    2f
-        slr   %r0,%r1             # r -= q
-       brc   3,2f                # borrow ?
-       alr   %r0,%r5             # r += d
-       ahi   %r1,-1
-2:      # now (n >> 2) = d * %r1 + %r0
-        alr   %r1,%r1             # q <<= 1
-        alr   %r0,%r0             # r <<= 1
-        brc   12,3f               # overflow on r ?
-        slr   %r0,%r5             # r -= d
-        ahi   %r1,1               # q += 1
-3:      lhi   %r3,2
-        nr    %r3,%r4             # test next to last bit of n
-        jz    4f
-        ahi   %r0,1               # r += 1
-4:      clr   %r0,%r5             # r >= d ?
-        jl    6f
-        slr   %r0,%r5             # r -= d
-        ahi   %r1,1               # q += 1
-        # now (n >> 1) = d * %r1 + %r0
-        j     6f
-5:      # divisor < 0x80000000
-       srdl  %r0,1
-        dr    %r0,%r2             # signed division
-        # now (n >> 1) = d * %r1 + %r0
-6:      alr   %r1,%r1             # q <<= 1
-        alr   %r0,%r0             # r <<= 1
-        brc   12,7f               # overflow on r ?
-        slr   %r0,%r5             # r -= d
-        ahi   %r1,1               # q += 1
-7:      lhi   %r3,1
-        nr    %r3,%r4             # isolate last bit of n
-        alr   %r0,%r3             # r += (n & 1)
-        clr   %r0,%r5             # r >= d ?
-        jl    8f
-        slr   %r0,%r5             # r -= d
-        ahi   %r1,1               # q += 1
-8:      # now n = d * %r1 + %r0
-       l     %r2,24(%r15)
-        st    %r0,0(%r2)
-        lr    %r2,%r1
-        br    %r14
-       .end    __udiv_qrnnd
diff --git a/arch/s390/math-emu/sfp-util.h b/arch/s390/math-emu/sfp-util.h
deleted file mode 100644
index 5b6ca45..0000000
--- a/arch/s390/math-emu/sfp-util.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <asm/byteorder.h>
-
-#define add_ssaaaa(sh, sl, ah, al, bh, bl) ({          \
-       unsigned int __sh = (ah);                       \
-       unsigned int __sl = (al);                       \
-       asm volatile(                                   \
-               "       alr     %1,%3\n"                \
-               "       brc     12,0f\n"                \
-               "       ahi     %0,1\n"                 \
-               "0:     alr  %0,%2"                     \
-               : "+&d" (__sh), "+d" (__sl)             \
-               : "d" (bh), "d" (bl) : "cc");           \
-       (sh) = __sh;                                    \
-       (sl) = __sl;                                    \
-})
-
-#define sub_ddmmss(sh, sl, ah, al, bh, bl) ({          \
-       unsigned int __sh = (ah);                       \
-       unsigned int __sl = (al);                       \
-       asm volatile(                                   \
-               "       slr     %1,%3\n"                \
-               "       brc     3,0f\n"                 \
-               "       ahi     %0,-1\n"                \
-               "0:     slr     %0,%2"                  \
-               : "+&d" (__sh), "+d" (__sl)             \
-               : "d" (bh), "d" (bl) : "cc");           \
-       (sh) = __sh;                                    \
-       (sl) = __sl;                                    \
-})
-
-/* a umul b = a mul b + (a>=2<<31) ? b<<32:0 + (b>=2<<31) ? a<<32:0 */
-#define umul_ppmm(wh, wl, u, v) ({                     \
-       unsigned int __wh = u;                          \
-       unsigned int __wl = v;                          \
-       asm volatile(                                   \
-               "       ltr     1,%0\n"                 \
-               "       mr      0,%1\n"                 \
-               "       jnm     0f\n"                           \
-               "       alr     0,%1\n"                 \
-               "0:     ltr     %1,%1\n"                        \
-               "       jnm     1f\n"                           \
-               "       alr     0,%0\n"                 \
-               "1:     lr      %0,0\n"                 \
-               "       lr      %1,1\n"                 \
-               : "+d" (__wh), "+d" (__wl)              \
-               : : "0", "1", "cc");                    \
-       wh = __wh;                                      \
-       wl = __wl;                                      \
-})
-
-#define udiv_qrnnd(q, r, n1, n0, d)                    \
-  do { unsigned long __r;                              \
-    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                \
-    (r) = __r;                                         \
-  } while (0)
-extern unsigned long __udiv_qrnnd (unsigned long *, unsigned long,
-                                  unsigned long , unsigned long);
-
-#define UDIV_NEEDS_NORMALIZATION 0
-
-#define abort() return 0
-
-#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/drivers/s390/Makefile b/drivers/s390/Makefile
index 9803c93..5a88870 100644
--- a/drivers/s390/Makefile
+++ b/drivers/s390/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the S/390 specific device drivers
 #
 
+CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w
+
 obj-y += s390mach.o sysinfo.o s390_rdev.o
 obj-y += cio/ block/ char/ crypto/ net/ scsi/
 
diff --git a/drivers/s390/sysinfo.c b/drivers/s390/sysinfo.c
index 1e788e8..090743d 100644
--- a/drivers/s390/sysinfo.c
+++ b/drivers/s390/sysinfo.c
@@ -9,8 +9,14 @@
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 #include <asm/ebcdic.h>
 
+/* Sigh, math-emu. Don't ask. */
+#include <asm/sfp-util.h>
+#include <math-emu/soft-fp.h>
+#include <math-emu/single.h>
+
 struct sysinfo_1_1_1 {
        char reserved_0[32];
        char manufacturer[16];
@@ -198,7 +204,7 @@ static int stsi_1_2_2(struct sysinfo_1_2_2 *info, char 
*page, int len)
                 * if the higher order 8 bits are not zero. Printing
                 * a floating point number in the kernel is a no-no,
                 * always print the number as 32 bit unsigned integer.
-                * The user-space needs to know about the stange
+                * The user-space needs to know about the strange
                 * encoding of the alternate cpu capability.
                 */
                len += sprintf(page + len, "Capability:           %u %u\n",
@@ -351,3 +357,58 @@ static __init int create_proc_sysinfo(void)
 
 __initcall(create_proc_sysinfo);
 
+/*
+ * CPU capability might have changed. Therefore recalculate loops_per_jiffy.
+ */
+void s390_adjust_jiffies(void)
+{
+       struct sysinfo_1_2_2 *info;
+       const unsigned int fmil = 0x4b189680;   /* 1e7 as 32-bit float. */
+       FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR);
+       FP_DECL_EX;
+       unsigned int capability;
+
+       info = (void *) get_zeroed_page(GFP_KERNEL);
+       if (!info)
+               return;
+
+       if (stsi(info, 1, 2, 2) != -ENOSYS) {
+               /*
+                * Major sigh. The cpu capability encoding is "special".
+                * If the first 9 bits of info->capability are 0 then it
+                * is a 32 bit unsigned integer in the range 0 .. 2^23.
+                * If the first 9 bits are != 0 then it is a 32 bit float.
+                * In addition a lower value indicates a proportionally
+                * higher cpu capacity. Bogomips are the other way round.
+                * To get to a halfway suitable number we divide 1e7
+                * by the cpu capability number. Yes, that means a floating
+                * point division .. math-emu here we come :-)
+                */
+               FP_UNPACK_SP(SA, &fmil);
+               if ((info->capability >> 23) == 0)
+                       FP_FROM_INT_S(SB, info->capability, 32, int);
+               else
+                       FP_UNPACK_SP(SB, &info->capability);
+               FP_DIV_S(SR, SA, SB);
+               FP_TO_INT_S(capability, SR, 32, 0);
+       } else
+               /*
+                * Really old machine without stsi block for basic
+                * cpu information. Report 42.0 bogomips.
+                */
+               capability = 42;
+       loops_per_jiffy = capability * (500000/HZ);
+       free_page((unsigned long) info);
+}
+
+/*
+ * calibrate the delay loop
+ */
+void __init calibrate_delay(void)
+{
+       s390_adjust_jiffies();
+       /* Print the good old Bogomips line .. */
+       printk(KERN_DEBUG "Calibrating delay loop (skipped)... "
+              "%lu.%02lu BogoMIPS preset\n", loops_per_jiffy/(500000/HZ),
+              (loops_per_jiffy/(5000/HZ)) % 100);
+}
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h
index 5af8535..cf71c54 100644
--- a/include/asm-s390/processor.h
+++ b/include/asm-s390/processor.h
@@ -50,6 +50,7 @@ struct cpuinfo_S390
         unsigned long pgtable_cache_sz;
 };
 
+extern void s390_adjust_jiffies(void);
 extern void print_cpu_info(struct cpuinfo_S390 *);
 
 /* Lazy FPU handling on uni-processor */
diff --git a/include/asm-s390/sfp-util.h b/include/asm-s390/sfp-util.h
new file mode 100644
index 0000000..8cabcd2
--- /dev/null
+++ b/include/asm-s390/sfp-util.h
@@ -0,0 +1,66 @@
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <asm/byteorder.h>
+
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) ({          \
+       unsigned int __sh = (ah);                       \
+       unsigned int __sl = (al);                       \
+       asm volatile(                                   \
+               "       alr     %1,%3\n"                \
+               "       brc     12,0f\n"                \
+               "       ahi     %0,1\n"                 \
+               "0:     alr  %0,%2"                     \
+               : "+&d" (__sh), "+d" (__sl)             \
+               : "d" (bh), "d" (bl) : "cc");           \
+       (sh) = __sh;                                    \
+       (sl) = __sl;                                    \
+})
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) ({          \
+       unsigned int __sh = (ah);                       \
+       unsigned int __sl = (al);                       \
+       asm volatile(                                   \
+               "       slr     %1,%3\n"                \
+               "       brc     3,0f\n"                 \
+               "       ahi     %0,-1\n"                \
+               "0:     slr     %0,%2"                  \
+               : "+&d" (__sh), "+d" (__sl)             \
+               : "d" (bh), "d" (bl) : "cc");           \
+       (sh) = __sh;                                    \
+       (sl) = __sl;                                    \
+})
+
+/* a umul b = a mul b + (a>=2<<31) ? b<<32:0 + (b>=2<<31) ? a<<32:0 */
+#define umul_ppmm(wh, wl, u, v) ({                     \
+       unsigned int __wh = u;                          \
+       unsigned int __wl = v;                          \
+       asm volatile(                                   \
+               "       ltr     1,%0\n"                 \
+               "       mr      0,%1\n"                 \
+               "       jnm     0f\n"                           \
+               "       alr     0,%1\n"                 \
+               "0:     ltr     %1,%1\n"                        \
+               "       jnm     1f\n"                           \
+               "       alr     0,%0\n"                 \
+               "1:     lr      %0,0\n"                 \
+               "       lr      %1,1\n"                 \
+               : "+d" (__wh), "+d" (__wl)              \
+               : : "0", "1", "cc");                    \
+       wh = __wh;                                      \
+       wl = __wl;                                      \
+})
+
+#define udiv_qrnnd(q, r, n1, n0, d)                    \
+  do { unsigned int __r;                               \
+    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                \
+    (r) = __r;                                         \
+  } while (0)
+extern unsigned long __udiv_qrnnd (unsigned int *, unsigned int,
+                                  unsigned int , unsigned int);
+
+#define UDIV_NEEDS_NORMALIZATION 0
+
+#define abort() return 0
+
+#define __BYTE_ORDER __BIG_ENDIAN
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to