Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev Pull up following revision(s) (requested by sborr...



details:   https://anonhg.NetBSD.org/src/rev/d59f41648406
branches:  netbsd-9
changeset: 376153:d59f41648406
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jun 03 15:17:31 2023 +0000

description:
Pull up following revision(s) (requested by sborrill in ticket #1639):

        sys/dev/ipmi.c: revision 1.10

Ignore non-recoverable and critical limits smaller than the warning limits.
These are usually invalid.

Name the limit flags to make code more readable.

diffstat:

 sys/dev/ipmi.c |  42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diffs (92 lines):

diff -r 521daf536b6b -r d59f41648406 sys/dev/ipmi.c
--- a/sys/dev/ipmi.c    Sat Jun 03 15:07:53 2023 +0000
+++ b/sys/dev/ipmi.c    Sat Jun 03 15:17:31 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $ */
+/*     $NetBSD: ipmi.c,v 1.4.4.3 2023/06/03 15:17:31 martin Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.3 2023/06/03 15:17:31 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1533,6 +1533,14 @@ ipmi_get_limits(struct sysmon_envsys *sm
        return;
 }
 
+/* valid bits for (upper,lower) x (non-recoverable, critical, warn) */
+#define UN     0x20
+#define UC     0x10
+#define UW     0x08
+#define LN     0x04
+#define LC     0x02
+#define LW     0x01
+
 static void
 ipmi_get_sensor_limits(struct ipmi_softc *sc, struct ipmi_sensor *psensor,
                       sysmon_envsys_lim_t *limits, uint32_t *props)
@@ -1540,7 +1548,7 @@ ipmi_get_sensor_limits(struct ipmi_softc
        struct sdrtype1 *s1 = (struct sdrtype1 *)psensor->i_sdr;
        bool failure;
        int     rxlen;
-       uint8_t data[32];
+       uint8_t data[32], valid;
        uint32_t prop_critmax, prop_warnmax, prop_critmin, prop_warnmin;
        int32_t *pcritmax, *pwarnmax, *pcritmin, *pwarnmin;
 
@@ -1582,27 +1590,43 @@ ipmi_get_sensor_limits(struct ipmi_softc
                break;
        }
 
-       if (data[0] & 0x20 && data[6] != 0xff) {
+       valid = data[0];
+
+       /* if upper non-recoverable < warning, ignore it */
+       if ((valid & (UN|UW)) == (UN|UW) && data[6] < data[4])
+               valid ^= UN;
+       /* if upper critical < warning, ignore it */
+       if ((valid & (UC|UW)) == (UC|UW) && data[5] < data[4])
+               valid ^= UC;
+
+       /* if lower non-recoverable > warning, ignore it */
+       if ((data[0] & (LN|LW)) == (LN|LW) && data[3] > data[1])
+               valid ^= LN;
+       /* if lower critical > warning, ignore it */
+       if ((data[0] & (LC|LW)) == (LC|LW) && data[2] > data[1])
+               valid ^= LC;
+
+       if (valid & UN && data[6] != 0xff) {
                *pcritmax = ipmi_convert_sensor(&data[6], psensor);
                *props |= prop_critmax;
        }
-       if (data[0] & 0x10 && data[5] != 0xff) {
+       if (valid & UC && data[5] != 0xff) {
                *pcritmax = ipmi_convert_sensor(&data[5], psensor);
                *props |= prop_critmax;
        }
-       if (data[0] & 0x08 && data[4] != 0xff) {
+       if (valid & UW && data[4] != 0xff) {
                *pwarnmax = ipmi_convert_sensor(&data[4], psensor);
                *props |= prop_warnmax;
        }
-       if (data[0] & 0x04 && data[3] != 0x00) {
+       if (valid & LN && data[3] != 0x00) {
                *pcritmin = ipmi_convert_sensor(&data[3], psensor);
                *props |= prop_critmin;
        }
-       if (data[0] & 0x02 && data[2] != 0x00) {
+       if (valid & LC && data[2] != 0x00) {
                *pcritmin = ipmi_convert_sensor(&data[2], psensor);
                *props |= prop_critmin;
        }
-       if (data[0] & 0x01 && data[1] != 0x00) {
+       if (valid & LW && data[1] != 0x00) {
                *pwarnmin = ipmi_convert_sensor(&data[1], psensor);
                *props |= prop_warnmin;
        }



Home | Main Index | Thread Index | Old Index