Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ipmi(4) and negative temperatures



Hi,

I finally got some some to look into the envsys framework and ipmi
driver searching for the reason why it doesn't handle negative
temperatures.

To summarize, my new amd64 developpement workstation show bogus
warnmin and critmin limits for system temp (triggering a wrong event).

                      Current  CritMax  WarnMax  WarnMin  CritMin  Unit
       System Temp:    32.137   77.330   75.321  252.074  250.066 degC

At the same time, ipmitool report the corresponding values as negative
ones (-5.000 and -7.000), which make sense IMO.

System Temp      | 32.000     | degrees C  | ok    | -9.000    | -7.000    | 
-5.000    | 75.000    | 77.000    | 79.000

After a few debugging, i noted that ipmi(4) does not take into account
that sensors can use signed values and always use an unsigned 8bit for
calculations ...

With the attached patch, the system temp min limits looks ok, and all
other ones remains unchanged.

                      Current  CritMax  WarnMax  WarnMin  CritMin  Unit
       System Temp:    32.137   77.330   75.321   -5.021   -7.030 degC

Does this looks ok ?
Thanks.

-- 
Nicolas Joly

Projects and Developments in Bioinformatics
Institut Pasteur, Paris.
Index: sys/arch/x86/x86/ipmi.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/ipmi.c,v
retrieving revision 1.52
diff -u -p -r1.52 ipmi.c
--- sys/arch/x86/x86/ipmi.c     2 Feb 2012 19:43:01 -0000       1.52
+++ sys/arch/x86/x86/ipmi.c     2 Apr 2012 17:59:47 -0000
@@ -1439,7 +1439,10 @@ ipmi_convert(uint8_t v, struct sdrtype1 
 {
        int64_t M, B;
        char    K1, K2;
-       int64_t val, v1, v2;
+       int64_t val, v1, v2, vs;
+       int sign = (s1->units1 >> 6) & 0x3;
+
+       vs = (sign == 0x1 || sign == 0x2) ? (int8_t)v : v;
 
        /* Calculate linear reading variables */
        M  = signextend((((short)(s1->m_tolerance & 0xC0)) << 2) + s1->m, 10);
@@ -1454,7 +1457,7 @@ ipmi_convert(uint8_t v, struct sdrtype1 
         *  y = L(M*v * 10^(K2+adj) + B * 10^(K1+K2+adj)); */
        v1 = powx(FIX10, INT2FIX(K2 + adj));
        v2 = powx(FIX10, INT2FIX(K1 + K2 + adj));
-       val = M * v * v1 + B * v2;
+       val = M * vs * v1 + B * v2;
 
        /* Linearization function: y = f(x) 0 : y = x 1 : y = ln(x) 2 : y =
         * log10(x) 3 : y = log2(x) 4 : y = e^x 5 : y = 10^x 6 : y = 2^x 7 : y


Home | Main Index | Thread Index | Old Index