All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH skeleton v6 00/20] Add fan control algorithm
@ 2016-04-15  7:01 OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 01/20] add i2craw tool and hdd status function OpenBMC Patches
                   ` (19 more replies)
  0 siblings, 20 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc



<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/openbmc/skeleton/59)
<!-- Reviewable:end -->


https://github.com/openbmc/skeleton/pull/59

Ken (8):
  add i2craw tool and hdd status function
  Heartbeat Led function
  fix info memory leak
  Setup FUNC_MODE[2:0]
  fix info memory leak
  Revert "Fill in the threshold settings for CPU and DIMM"
  Add fan control algorithm
  Fix skeleton Makefile

Ken Lai (1):
  Revert "Add I2C-6 lm75 outlet temperature sensor"

johnhcwang (11):
  Fill in the threshold settings for CPU and DIMM
  Fill in the threshold settings for CPU and DIMM
  Add I2C-6 lm75 outlet temperature sensor
  Modify the hard-coded hwmon ID for PowerCap
  Fill in the threshold settings for CPU and DIMM
  Set lower threshold for ambient/CPU/DIMM sensors
  Fix memory leak
  Support FAN tach sensors
  Generate thermaltrip event
  Keep original design to generate thermaltrip event
  Support FAN LED feature

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 01/20] add i2craw tool and hdd status function
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 02/20] Heartbeat Led function OpenBMC Patches
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 Makefile                   |  13 +-
 bin/Barreleye.py           |   6 +
 bin/chassis_control.py     |   7 +-
 bin/startup_hacks.sh       |   8 +
 objects/button_power_obj.c |  17 ++-
 objects/i2c-dev.h          | 362 +++++++++++++++++++++++++++++++++++++++++++++
 objects/i2craw.c           | 245 ++++++++++++++++++++++++++++++
 objects/info.c             | 355 ++++++++++++++++++++++++++++++++++++++++++++
 objects/log.h              |  59 ++++++++
 9 files changed, 1059 insertions(+), 13 deletions(-)
 create mode 100644 objects/i2c-dev.h
 create mode 100644 objects/i2craw.c
 create mode 100644 objects/info.c
 create mode 100644 objects/log.h

diff --git a/Makefile b/Makefile
index 8a88a37..3b8a2ae 100755
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,11 @@ LIBS=$(shell pkg-config --libs gio-unix-2.0 glib-2.0) -Llib -lopenbmc_intf
 INCLUDES += $(shell pkg-config --cflags --libs libsystemd) -I. -O2
 LIB_FLAG += $(shell pkg-config  --libs libsystemd)
 
+DEPPKGS = libsystemd
+INCLUDES_info += $(shell pkg-config --cflags $(DEPPKGS))
+LIBS_info += $(shell pkg-config --libs $(DEPPKGS))
+
+
 %.o: interfaces/%.c 
 	$(CC) -c -fPIC -o obj/$@ $< $(CFLAGS) $(INCLUDES)
 
@@ -24,7 +29,7 @@ LIB_FLAG += $(shell pkg-config  --libs libsystemd)
 %.o: objects/pflash/libflash/%.c
 	$(CC) -c -o obj/$@ $< $(CFLAGS) $(INCLUDES)
 
-all: setup libopenbmc_intf power_control led_controller button_power button_reset control_host host_watchdog board_vpd pcie_slot_present flash_bios flasher pflash hwmons_barreleye control_bmc
+all: setup libopenbmc_intf power_control led_controller button_power button_reset control_host host_watchdog board_vpd pcie_slot_present flash_bios flasher pflash hwmons_barreleye control_bmc i2craw info
 
 setup: 
 	mkdir -p obj lib
@@ -69,6 +74,12 @@ flasher:  $(OBJS2) flasher_obj.o libopenbmc_intf
 pflash:  $(OBJS2) pflash.o
 	$(CC) -o bin/$@ obj/pflash.o $(OBJS3) $(LDFLAGS)
 
+i2craw:  $(OBJS2) i2craw.o
+	$(CC) -o bin/$@ obj/i2craw.o $(LDFLAGS)
+
+info:   info.o
+	$(CC) -o bin/$@ obj/info.o $(LDFLAGS) $(LIBS_info)
+
 hwmons_barreleye: hwmons_barreleye.o object_mapper.o libopenbmc_intf
 	$(CC) -o bin/$@.exe obj/hwmons_barreleye.o obj/object_mapper.o  $(LDFLAGS) $(LIBS)
 
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 09fefa0..08a91a9 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -210,6 +210,12 @@ APPS = {
 		'monitor_process' : False,
 		'process_name'    : 'discover_system_state.py',
 	},
+        'info' : {
+                'system_state'    : 'BMC_STARTING2',
+                'start_process'   : True,
+                'monitor_process' : True,
+                'process_name'    : 'info',
+        },
 	'bmc_control' : {
 		'system_state'    : 'BMC_STARTING',
 		'start_process'   : True,
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index 334fbbf..cd8a98d 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -76,9 +76,6 @@ class ChassisControlObject(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 		bus.add_signal_receiver(self.power_button_signal_handler, 
 					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
 					path="/org/openbmc/buttons/power0" )
-		bus.add_signal_receiver(self.reset_button_signal_handler, 
-					dbus_interface = "org.openbmc.Button", signal_name = "PressedLong", 
-					path="/org/openbmc/buttons/power0" )
 		bus.add_signal_receiver(self.softreset_button_signal_handler, 
 					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
 					path="/org/openbmc/buttons/reset0" )
@@ -154,7 +151,7 @@ class ChassisControlObject(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 	def reboot(self):
 		print "Rebooting"
 		if self.getPowerState() == POWER_OFF:
-			self.powerOn();
+			print "Power off, no reboot."
 		else:
 			self.Set(DBUS_NAME,"reboot",1)
 			self.powerOff()
@@ -199,7 +196,7 @@ class ChassisControlObject(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 		self.reboot();
 
 	def softreset_button_signal_handler(self):
-		self.softReboot();
+		self.reboot();
 		
 	def host_watchdog_signal_handler(self):
 		print "Watchdog Error, Hard Rebooting"
diff --git a/bin/startup_hacks.sh b/bin/startup_hacks.sh
index 3a93e90..cf3632a 100755
--- a/bin/startup_hacks.sh
+++ b/bin/startup_hacks.sh
@@ -2,6 +2,14 @@
 
 systemctl stop serial-getty@ttyS0
 
+# Set to output pin
+ i2cset -y 0x06 0x20 0x06 0x00
+ i2cset -y 0x06 0x20 0x07 0x00
+ 
+ # Turn on all fan LED to BLUE
+ i2cset -y 0x06 0x20 0x03 0x55
+ i2cset -y 0x06 0x20 0x02 0xaa
+
 # Setup VUART
 VUART=/sys/devices/platform/ahb/ahb:apb/1e787000.vuart
 echo 4 > $VUART/sirq
diff --git a/objects/button_power_obj.c b/objects/button_power_obj.c
index 94f8922..57881b2 100644
--- a/objects/button_power_obj.c
+++ b/objects/button_power_obj.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include "interfaces/openbmc_intf.h"
 #include "gpio.h"
 #include "openbmc.h"
@@ -42,7 +43,10 @@ on_button_interrupt( GIOChannel *channel,
 
 	GError *error = 0;
 	gsize bytes_read = 0;
-	gchar buf[2]; 
+	gchar buf[2];
+ 
+ 	uint8_t val;
+ 	int rc1 = GPIO_OK;
 	buf[1] = '\0';
 	g_io_channel_seek_position( channel, 0, G_SEEK_SET, 0 );
 	GIOStatus rc = g_io_channel_read_chars( channel,
@@ -65,12 +69,11 @@ on_button_interrupt( GIOChannel *channel,
 		{
 			long press_time = current_time-button_get_timer(button);
 			printf("Power Button released, held for %ld seconds\n",press_time);
-			if (press_time > LONG_PRESS_SECONDS)
-			{
-				button_emit_pressed_long(button);
-			} else {
-				button_emit_released(button);
-			}
+			rc1 =  gpio_open(&gpio_button);
+			rc1 = gpio_read(&gpio_button,&val);
+			if (val == 1)
+			button_emit_released(button);
+
 		}
 	} 
 	else { gpio_button.irq_inited = true; }
diff --git a/objects/i2c-dev.h b/objects/i2c-dev.h
new file mode 100644
index 0000000..eefb6e4
--- /dev/null
+++ b/objects/i2c-dev.h
@@ -0,0 +1,362 @@
+/*
+    i2c-dev.h - i2c-bus driver, char device interface
+
+    Copyright (C) 1995-97 Simon G. Vogl
+    Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301 USA.
+*/
+
+#ifndef _LINUX_I2C_DEV_H
+#define _LINUX_I2C_DEV_H
+
+#include <linux/types.h>
+#include <sys/ioctl.h>
+#include <stddef.h>
+#include <string.h>
+
+
+/* -- i2c.h -- */
+
+#define _I2C_MIN(a, b) (((a) <= (b)) ? (a) : (b))
+
+/*
+ * I2C Message - used for pure i2c transaction, also from /dev interface
+ */
+struct i2c_msg {
+	__u16 addr;	/* slave address			*/
+	unsigned short flags;
+#define I2C_CLIENT_PEC	0x04		/* Use Packet Error Checking */
+#define I2C_M_TEN		0x0010	/* this is a ten bit chip address */
+#define I2C_M_RD		0x0001	/* read data, from slave to master */
+#define I2C_M_NOSTART		0x4000	/* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_REV_DIR_ADDR	0x2000	/* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_IGNORE_NAK	0x1000	/* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_NO_RD_ACK		0x0800	/* if I2C_FUNC_PROTOCOL_MANGLING */
+#define I2C_M_RECV_LEN		0x0400	/* length will be first received byte */
+	short len;		/* msg length				*/
+	char *buf;		/* pointer to msg data			*/
+};
+
+/* To determine what functionality is present */
+
+#define I2C_FUNC_I2C			0x00000001
+#define I2C_FUNC_10BIT_ADDR		0x00000002
+#define I2C_FUNC_PROTOCOL_MANGLING	0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
+#define I2C_FUNC_SMBUS_PEC		0x00000008
+#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL	0x00008000 /* SMBus 2.0 */
+#define I2C_FUNC_SMBUS_QUICK		0x00010000
+#define I2C_FUNC_SMBUS_READ_BYTE	0x00020000
+#define I2C_FUNC_SMBUS_WRITE_BYTE	0x00040000
+#define I2C_FUNC_SMBUS_READ_BYTE_DATA	0x00080000
+#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA	0x00100000
+#define I2C_FUNC_SMBUS_READ_WORD_DATA	0x00200000
+#define I2C_FUNC_SMBUS_WRITE_WORD_DATA	0x00400000
+#define I2C_FUNC_SMBUS_PROC_CALL	0x00800000
+#define I2C_FUNC_SMBUS_READ_BLOCK_DATA	0x01000000
+#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
+#define I2C_FUNC_SMBUS_READ_I2C_BLOCK	0x04000000 /* I2C-like block xfer  */
+#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK	0x08000000 /* w/ 1-byte reg. addr. */
+
+#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
+                             I2C_FUNC_SMBUS_WRITE_BYTE)
+#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
+                                  I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
+#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
+                                  I2C_FUNC_SMBUS_WRITE_WORD_DATA)
+#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
+                                   I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
+#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
+                                  I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
+
+/* Old name, for compatibility */
+#define I2C_FUNC_SMBUS_HWPEC_CALC	I2C_FUNC_SMBUS_PEC
+
+/*
+ * Data for SMBus Messages
+ */
+#define I2C_SMBUS_BLOCK_MAX	32	/* As specified in SMBus standard */
+#define I2C_SMBUS_I2C_BLOCK_MAX	32	/* Not specified but we use same structure */
+union i2c_smbus_data {
+	__u8 byte;
+	__u16 word;
+	__u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
+	                                            /* and one more for PEC */
+};
+
+#define I2C_SMBUS_BLOCK_LARGE_MAX	240
+union i2c_smbus_large_data {
+  union i2c_smbus_data data;
+  __u8 block[I2C_SMBUS_BLOCK_LARGE_MAX + 2]; /* block[0] is used for length */
+                                             /* and one more for PEC */
+};
+
+/* smbus_access read or write markers */
+#define I2C_SMBUS_READ	1
+#define I2C_SMBUS_WRITE	0
+
+/* SMBus transaction types (size parameter in the above functions)
+   Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
+#define I2C_SMBUS_QUICK		    0
+#define I2C_SMBUS_BYTE		    1
+#define I2C_SMBUS_BYTE_DATA	    2
+#define I2C_SMBUS_WORD_DATA	    3
+#define I2C_SMBUS_PROC_CALL	    4
+#define I2C_SMBUS_BLOCK_DATA	    5
+#define I2C_SMBUS_I2C_BLOCK_BROKEN  6
+#define I2C_SMBUS_BLOCK_PROC_CALL   7		/* SMBus 2.0 */
+#define I2C_SMBUS_I2C_BLOCK_DATA    8
+#define I2C_SMBUS_BLOCK_LARGE_DATA    9
+
+
+/* /dev/i2c-X ioctl commands.  The ioctl's parameter is always an
+ * unsigned long, except for:
+ *	- I2C_FUNCS, takes pointer to an unsigned long
+ *	- I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
+ *	- I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
+ */
+#define I2C_RETRIES	0x0701	/* number of times a device address should
+				   be polled when not acknowledging */
+#define I2C_TIMEOUT	0x0702	/* set timeout in units of 10 ms */
+
+/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
+ * are NOT supported! (due to code brokenness)
+ */
+#define I2C_SLAVE	0x0703	/* Use this slave address */
+#define I2C_SLAVE_FORCE	0x0706	/* Use this slave address, even if it
+				   is already in use by a driver! */
+#define I2C_TENBIT	0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit */
+
+#define I2C_FUNCS	0x0705	/* Get the adapter functionality mask */
+
+#define I2C_RDWR	0x0707	/* Combined R/W transfer (one STOP only) */
+
+#define I2C_PEC		0x0708	/* != 0 to use PEC with SMBus */
+#define I2C_SMBUS	0x0720	/* SMBus transfer */
+
+
+/* This is the structure as used in the I2C_SMBUS ioctl call */
+struct i2c_smbus_ioctl_data {
+	__u8 read_write;
+	__u8 command;
+	__u32 size;
+	union i2c_smbus_data *data;
+};
+
+/* This is the structure as used in the I2C_RDWR ioctl call */
+struct i2c_rdwr_ioctl_data {
+	struct i2c_msg *msgs;	/* pointers to i2c_msgs */
+	__u32 nmsgs;			/* number of i2c_msgs */
+};
+
+#define  I2C_RDRW_IOCTL_MAX_MSGS	42
+
+
+static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
+                                     int size, union i2c_smbus_data *data)
+{
+	struct i2c_smbus_ioctl_data args;
+
+	args.read_write = read_write;
+	args.command = command;
+	args.size = size;
+	args.data = data;
+	return ioctl(file,I2C_SMBUS,&args);
+}
+
+
+static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
+{
+	return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
+}
+
+static inline __s32 i2c_smbus_read_byte(int file)
+{
+	union i2c_smbus_data data;
+	if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
+		return -1;
+	else
+		return 0x0FF & data.byte;
+}
+
+static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
+{
+	return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
+	                        I2C_SMBUS_BYTE,NULL);
+}
+
+static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
+{
+	union i2c_smbus_data data;
+	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
+	                     I2C_SMBUS_BYTE_DATA,&data))
+		return -1;
+	else
+		return 0x0FF & data.byte;
+}
+
+static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
+                                              __u8 value)
+{
+	union i2c_smbus_data data;
+	data.byte = value;
+	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                        I2C_SMBUS_BYTE_DATA, &data);
+}
+
+static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
+{
+	union i2c_smbus_data data;
+	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
+	                     I2C_SMBUS_WORD_DATA,&data))
+		return -1;
+	else
+		return 0x0FFFF & data.word;
+}
+
+static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
+                                              __u16 value)
+{
+	union i2c_smbus_data data;
+	data.word = value;
+	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                        I2C_SMBUS_WORD_DATA, &data);
+}
+
+static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
+{
+	union i2c_smbus_data data;
+	data.word = value;
+	if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                     I2C_SMBUS_PROC_CALL,&data))
+		return -1;
+	else
+		return 0x0FFFF & data.word;
+}
+
+
+/* Returns the number of read bytes */
+static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
+                                              __u8 *values)
+{
+	union i2c_smbus_data data;
+	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
+	                     I2C_SMBUS_BLOCK_DATA,&data))
+		return -1;
+	else {
+		memcpy(values, &data.block[1], _I2C_MIN(data.block[0], I2C_SMBUS_BLOCK_MAX));
+		return data.block[0];
+	}
+}
+
+static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
+                                               __u8 length, const __u8 *values)
+{
+	union i2c_smbus_data data;
+	if (length > 32)
+		length = 32;
+	memcpy(&data.block[1], values, length);
+	data.block[0] = length;
+	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                        I2C_SMBUS_BLOCK_DATA, &data);
+}
+
+static inline __s32 i2c_smbus_read_block_large_data(int file, __u8 command,
+                                                    __u8 *values)
+{
+  union i2c_smbus_large_data data;
+  if (i2c_smbus_access(file, I2C_SMBUS_READ, command,
+                       I2C_SMBUS_BLOCK_LARGE_DATA,
+                       (union i2c_smbus_data *)&data)) {
+    return -1;
+  } else {
+    /* the first byte is the length which is not copied */
+    memcpy(values, &data.block[1], _I2C_MIN(data.block[0], I2C_SMBUS_BLOCK_LARGE_MAX));
+    return data.block[0];
+  }
+}
+
+static inline __s32 i2c_smbus_write_block_large_data(int file, __u8 command,
+                                                     __u8 length,
+                                                     const __u8 *values)
+{
+  union i2c_smbus_large_data data;
+  if (length > I2C_SMBUS_BLOCK_LARGE_MAX) {
+    length = I2C_SMBUS_BLOCK_LARGE_MAX;
+  }
+  data.block[0] = length;
+  memcpy(&data.block[1], values, length);
+  return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
+                          I2C_SMBUS_BLOCK_LARGE_DATA,
+                          (union i2c_smbus_data *)&data);
+}
+
+/* Returns the number of read bytes */
+/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
+   ask for less than 32 bytes, your code will only work with kernels
+   2.6.23 and later. */
+static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
+                                                  __u8 length, __u8 *values)
+{
+	union i2c_smbus_data data;
+
+	if (length > 32)
+		length = 32;
+	data.block[0] = length;
+	if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
+	                     length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
+	                      I2C_SMBUS_I2C_BLOCK_DATA,&data))
+		return -1;
+	else {
+		memcpy(values, &data.block[1], _I2C_MIN(data.block[0], I2C_SMBUS_BLOCK_MAX));
+		return data.block[0];
+	}
+}
+
+static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
+                                                   __u8 length,
+                                                   const __u8 *values)
+{
+	union i2c_smbus_data data;
+	if (length > 32)
+		length = 32;
+	memcpy(&data.block[1], values, length);
+	data.block[0] = length;
+	return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                        I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
+}
+
+/* Returns the number of read bytes */
+static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
+                                                 __u8 length, __u8 *values)
+{
+	union i2c_smbus_data data;
+	if (length > 32)
+		length = 32;
+	memcpy(&data.block[1], values, length);
+	data.block[0] = length;
+	if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
+	                     I2C_SMBUS_BLOCK_PROC_CALL,&data))
+		return -1;
+	else {
+		memcpy(values, &data.block[1], _I2C_MIN(data.block[0], I2C_SMBUS_BLOCK_MAX));
+		return data.block[0];
+	}
+}
+
+#undef _I2C_MIN
+
+#endif /* _LINUX_I2C_DEV_H */
diff --git a/objects/i2craw.c b/objects/i2craw.c
new file mode 100644
index 0000000..a74cc49
--- /dev/null
+++ b/objects/i2craw.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2004-present Facebook. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#include "i2c-dev.h"
+#include "log.h"
+
+void usage(const char *prog) {
+  printf("Usage: %s [options] <bus number> <slave address>\n", prog);
+  printf("\n  Options:\n"
+         "\n\t-w 'bytes to write':\n"
+         "\t\t i2c write\n"
+         "\n\t-r <number of bytes to read>:\n"
+         "\t\t if 0 is provided, the first byte of read is used to determine\n"
+         "\t\t how many bytes more to read\n"
+         "\n\t-p:\n"
+         "\t\t Use PEC\n"
+         "\n\t-h:\n"
+         "\t\t Print this help\n"
+         "\n  Note: if both '-w' and '-r' are specified, write will be"
+         "\n        performed first, followed by read\n");
+}
+
+#define MAX_BYTES 255
+
+int g_use_pec = 0;
+int g_has_write = 0;
+int g_n_write = 0;
+uint8_t g_write_bytes[MAX_BYTES];
+int g_has_read = 0;
+int g_n_read = -1;
+uint8_t g_read_bytes[MAX_BYTES];
+uint8_t g_bus = -1;
+uint8_t g_slave_addr = 0xff;
+
+static int parse_byte_string(const char *str) {
+  const char *startptr = str;
+  char *endptr;
+  int total = 0;
+  unsigned long val;
+
+  do {
+    val = strtoul(startptr, &endptr, 0);
+    if (startptr == endptr) {
+      printf("'%s' is invalid\n", str);
+      return -1;
+    }
+    if (val > MAX_BYTES) {
+      printf("'%s' is invalid\n", str);
+      return -1;
+    }
+    g_write_bytes[total++] = val;
+    if (*endptr == '\0') {
+      break;
+    }
+    if (total >= MAX_BYTES) {
+      printf("'%s' is invalid\n", str);
+      return -1;
+    }
+    startptr = endptr;
+  } while(1);
+
+  return total;
+}
+
+static int i2c_open() {
+  int fd;
+  char fn[32];
+  int rc;
+
+  snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+  fd = open(fn, O_RDWR);
+  if (fd == -1) {
+    LOG_ERR(errno, "Failed to open i2c device %s", fn);
+    return -1;
+  }
+
+  rc = ioctl(fd, I2C_SLAVE, g_slave_addr);
+  if (rc < 0) {
+    LOG_ERR(errno, "Failed to open slave @ address 0x%x", g_slave_addr);
+    close(fd);
+  }
+
+  return fd;
+}
+
+static int i2c_io(int fd) {
+  struct i2c_rdwr_ioctl_data data;
+  struct i2c_msg msg[2];
+  int n_msg = 0;
+  int rc;
+
+  memset(&msg, 0, sizeof(msg));
+
+  if (g_has_write) {
+    msg[n_msg].addr = g_slave_addr;
+    msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+    msg[n_msg].len = g_n_write;
+    msg[n_msg].buf = g_write_bytes;
+    n_msg++;
+  }
+
+  if (g_has_read) {
+    msg[n_msg].addr = g_slave_addr;
+    msg[n_msg].flags = I2C_M_RD
+      | ((g_use_pec) ? I2C_CLIENT_PEC : 0)
+      | ((g_n_read == 0) ? I2C_M_RECV_LEN : 0);
+    /*
+     * In case of g_n_read is 0, block length will be added by
+     * the underlying bus driver.
+     */
+    msg[n_msg].len = (g_n_read) ? g_n_read : 256;
+    msg[n_msg].buf = g_read_bytes;
+    if (g_n_read == 0) {
+      /* If we're using variable length block reads, we have to set the
+       * first byte of the buffer to at least one or the kernel complains.
+       */
+      g_read_bytes[0] = 1;
+    }
+    n_msg++;
+  }
+
+  data.msgs = msg;
+  data.nmsgs = n_msg;
+
+  rc = ioctl(fd, I2C_RDWR, &data);
+  if (rc < 0) {
+    LOG_ERR(errno, "Failed to do raw io");
+    return -1;
+  }
+
+  return 0;
+}
+
+int main(int argc, char * const argv[]) {
+  int i;
+  int fd;
+  int opt;
+  while ((opt = getopt(argc, argv, "hpw:r:")) != -1) {
+    switch (opt) {
+    case 'h':
+      usage(argv[0]);
+      return 0;
+    case 'p':
+      g_use_pec = 1;
+      break;
+    case 'w':
+      g_has_write = 1;
+      if ((g_n_write = parse_byte_string(optarg)) <= 0) {
+        usage(argv[0]);
+        return -1;
+      }
+      break;
+    case 'r':
+      g_has_read = 1;
+      g_n_read = atoi(optarg);
+      break;
+    default:
+      usage(argv[0]);
+      return -1;
+    }
+  }
+
+  /* make sure we still have arguments for bus and slave address */
+  if (optind + 2 != argc) {
+    printf("Bus or slave address is missing\n");
+    usage(argv[0]);
+    return -1;
+  }
+
+  g_bus = atoi(argv[optind]);
+  g_slave_addr = strtoul(argv[optind + 1], NULL, 0);
+  if ((g_slave_addr & 0x80)) {
+    printf("Slave address must be 7-bit\n");
+    return -1;
+  }
+
+  if (!g_has_write && !g_has_read) {
+    /* by default, read, first byte read is the length */
+    g_has_read = 1;
+    g_n_read = 0;
+  }
+
+  printf("Bus: %d\nDevice address: 0x%x\n", g_bus, g_slave_addr);
+  if (g_has_write) {
+    printf("To write %d bytes:", g_n_write);
+    for (i = 0; i < g_n_write; i++) {
+      printf(" 0x%x", g_write_bytes[i]);
+    }
+    printf("\n");
+  }
+  if (g_has_read) {
+    if (g_n_read) {
+      printf("To read %d bytes.\n", g_n_read);
+    } else {
+      printf("To read data.\n");
+    }
+  }
+
+  fd = i2c_open();
+  if (fd < 0) {
+    return -1;
+  }
+
+  if (i2c_io(fd) < 0) {
+    return -1;
+  }
+
+  if (g_has_read) {
+    printf("Received:\n ");
+    if (g_n_read == 0) {
+      g_n_read = g_read_bytes[0] + 1;
+    }
+    for (i = 0; i < g_n_read; i++) {
+      printf(" 0x%x", g_read_bytes[i]);
+    }
+    printf("\n");
+  }
+
+  return 0;
+}
diff --git a/objects/info.c b/objects/info.c
new file mode 100644
index 0000000..ab2d98c
--- /dev/null
+++ b/objects/info.c
@@ -0,0 +1,355 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <systemd/sd-bus.h>
+#include "i2c-dev.h"
+#include "log.h"
+
+const char *gService = "org.openbmc.Sensors";
+const char *gObjPath = "/org/openbmc/sensors/temperature/cpu0/core0";
+const char *gObjPath_o = "/org/openbmc/sensors/host/OccStatus";
+const char *gIntPath = "org.openbmc.SensorValue";
+
+const char *gService_c = "org.openbmc.control.Chassis";
+const char *gObjPath_c = "/org/openbmc/control/chassis0";
+const char *gIntPath_c = "org.openbmc.control.Chassis";
+//const char *chassis_iface = "org.openbmc.SensorValue";
+
+char *gMessage = NULL;
+sd_bus *bus = NULL;
+
+#define MAX_BYTES 255
+
+int g_use_pec = 0;
+int g_has_write = 1;
+int g_n_write = 0;
+uint8_t g_write_bytes[MAX_BYTES];
+int g_has_read = 1;
+int g_n_read = -1;
+uint8_t g_read_bytes[MAX_BYTES];
+uint8_t g_read_tmp[MAX_BYTES];
+uint8_t g_bus = -1;
+uint8_t g_slave_addr = 0xff;
+
+static int i2c_open() {
+  int fd;
+  char fn[32];
+  int rc;
+
+  g_bus = 6;
+  snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+  fd = open(fn, O_RDWR);
+  if (fd == -1) {
+    LOG_ERR(errno, "Failed to open i2c device %s", fn);
+    return -1;
+  }
+
+  g_slave_addr = 0x4f;
+  rc = ioctl(fd, I2C_SLAVE, g_slave_addr);
+  if (rc < 0) {
+    LOG_ERR(errno, "Failed to open slave @ address 0x%x", g_slave_addr);
+    close(fd);
+  }
+
+  return fd;
+}
+
+static int i2c_io(int fd) {
+  struct i2c_rdwr_ioctl_data data;
+  struct i2c_msg msg[2];
+  int n_msg = 0;
+  int rc;
+
+  memset(&msg, 0, sizeof(msg));
+
+  g_slave_addr = 0x5f;
+  g_use_pec = 0;
+  g_n_write = 3;
+  g_write_bytes[0] = 0xfc;
+  g_write_bytes[1] = 0x3;
+  g_write_bytes[2] = 0x0;
+  
+
+  g_n_read = 5;
+  
+
+  if (1) {
+    msg[n_msg].addr = g_slave_addr;
+    msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+    msg[n_msg].len = g_n_write;
+    msg[n_msg].buf = g_write_bytes;
+    n_msg++;
+  }
+
+  if (1) {
+    msg[n_msg].addr = g_slave_addr;
+    msg[n_msg].flags = I2C_M_RD
+      | ((g_use_pec) ? I2C_CLIENT_PEC : 0)
+      | ((g_n_read == 0) ? I2C_M_RECV_LEN : 0);
+    /*
+     * In case of g_n_read is 0, block length will be added by
+     * the underlying bus driver.
+     */
+    msg[n_msg].len = (g_n_read) ? g_n_read : 256;
+    msg[n_msg].buf = g_read_bytes;
+    if (g_n_read == 0) {
+      /* If we're using variable length block reads, we have to set the
+       * first byte of the buffer to at least one or the kernel complains.
+       */
+      g_read_bytes[0] = 1;
+    }
+    n_msg++;
+  }
+
+  data.msgs = msg;
+  data.nmsgs = n_msg;
+
+  rc = ioctl(fd, I2C_RDWR, &data);
+  if (rc < 0) {
+    LOG_ERR(errno, "Failed to do raw io");
+    return -1;
+  }
+
+  return 0;
+}
+
+int get_hdd_status(void)
+{
+  int fd, i;
+  char *test;
+  test="Ken";
+  char str[10];
+  fd = i2c_open();
+  if (fd < 0) {
+    return -1;
+  }
+
+  if (i2c_io(fd) < 0) {
+    return -1;
+  }
+
+    //printf("Received:\n ");
+    if (g_n_read == 0) {
+      g_n_read = g_read_bytes[0] + 1;
+    }
+    for (i = 0; i < g_n_read; i++) {
+      //printf(" 0x%x", g_read_bytes[i]);
+    }
+    if ((g_read_tmp[2]!=g_read_bytes[2])||(g_read_tmp[3]!=g_read_bytes[3]))
+    {
+    sprintf(str, "HDD change:0x%x,0x%x", g_read_bytes[2], g_read_bytes[3]);
+   
+	send_esel_to_dbus(str, "Low", "assoc", "hack", 3);
+    }
+
+    g_read_tmp[2]=g_read_bytes[2];
+    g_read_tmp[3]=g_read_bytes[3];
+
+}
+
+int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) {
+
+	sd_bus *mbus = NULL;
+    sd_bus_error error = SD_BUS_ERROR_NULL;
+    sd_bus_message *reply = NULL, *m=NULL;
+    uint16_t x;
+    int r;
+	sd_bus_error_free(&error);
+
+	printf("add sel\n");
+ 	r = sd_bus_open_system(&mbus);
+	if (r < 0) {
+		fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+		goto finish;
+	}
+
+    r = sd_bus_message_new_method_call(mbus,&m,
+    									"org.openbmc.records.events",
+    									"/org/openbmc/records/events",
+    									"org.openbmc.recordlog",
+    									"acceptHostMessage");
+    if (r < 0) {
+        fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
+        goto finish;
+    }
+
+    r = sd_bus_message_append(m, "sss", desc, sev, details);
+    if (r < 0) {
+        fprintf(stderr, "Failed add the message strings : %s\n", strerror(-r));
+        goto finish;
+    }
+
+    r = sd_bus_message_append_array(m, 'y', debug, debuglen);
+    if (r < 0) {
+        fprintf(stderr, "Failed to add the raw array of bytes: %s\n", strerror(-r));
+        goto finish;
+    }
+    // Call the IPMI responder on the bus so the message can be sent to the CEC
+    r = sd_bus_call(mbus, m, 0, &error, &reply);
+    if (r < 0) {
+        fprintf(stderr, "Failed to call the method: %s %s\n", __FUNCTION__, strerror(-r));
+        goto finish;
+    }
+    r = sd_bus_message_read(reply, "q", &x);
+    if (r < 0) {
+        fprintf(stderr, "Failed to get a rc from the method: %s\n", strerror(-r));
+    }
+
+finish:
+    sd_bus_error_free(&error);
+    sd_bus_message_unref(m);
+    sd_bus_message_unref(reply);
+    return r;	
+}
+int start_system_information(void) {
+
+	sd_bus *bus;
+	sd_bus_slot *slot;
+	int r, x, rc,retry;
+	char *OccStatus;
+    r = -1;
+	while(r < 0) {
+	/* Connect to the user bus this time */
+	r = sd_bus_open_system(&bus);
+		if(r < 0){	
+			fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+		sleep(1);
+			}
+	//	goto finish;
+	
+		}
+	// SD Bus error report mechanism.
+	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
+	sd_bus_message *response = NULL, *m = NULL;;
+        sd_bus_error_free(&bus_error);
+        sd_bus_message_unref(response);
+//		send_esel_to_dbus("desc", "sev", "assoc", "hack", 3);
+
+while(1){
+       sd_bus_error_free(&bus_error);
+
+
+	   
+       rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService_c,               // Service to contact
+                                gObjPath_c,            // Object path
+                                gIntPath_c,              // Interface name
+                                "getPowerState",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+                                // NULL);                  // First argument to getObjectFromId
+                                //"BOARD_1");             // Second Argument
+        if(rc < 0)
+        {
+            fprintf(stderr, "Failed to resolve getPowerState to dbus: %s\n", bus_error.message);
+	    r = sd_bus_open_system(&bus);
+                if(r < 0){
+                        fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+                        sleep(1);
+                        }
+
+            goto finish;
+        }
+
+        rc = sd_bus_message_read(response, "i", &x);
+        if (rc < 0 )
+        {
+           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
+           goto finish;
+        }
+        printf("PowerState value=[%d] \n",x);
+	if (x == 0 ) goto finish;
+	get_hdd_status();	
+        sleep(1);
+       sd_bus_error_free(&bus_error);
+       rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gObjPath_o,            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+                                // NULL);                  // First argument to getObjectFromId
+                                //"BOARD_1");             // Second Argument
+        if(rc < 0)
+        {
+            fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+            goto finish;
+        }
+
+        rc = sd_bus_message_read(response, "v","s", &OccStatus);
+        if (rc < 0 )
+        {
+           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
+           goto finish;
+        }
+        printf("OCCtate value=[%s][%d] \n",OccStatus,strcmp(OccStatus, "Disable"));
+	
+        if (strcmp(OccStatus, "Disable") != 1 ) goto finish;
+
+        rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gObjPath,            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+                                // NULL);                  // First argument to getObjectFromId
+                                //"BOARD_1");             // Second Argument
+
+        if(rc < 0)
+        {
+            fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+            goto finish;
+        }
+
+	rc = sd_bus_message_read(response, "v","i", &x);
+	if (rc < 0 )
+	{ 
+           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
+           goto finish;
+	}
+	printf("CPU value=[%d] \n",x);
+
+	if(x >= 90)
+	{
+	//printf("====Ken poweroff==== \n");
+	send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
+	sd_bus_error_free(&bus_error);
+        rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService_c,               // Service to contact
+                                gObjPath_c,            // Object path
+                                gIntPath_c,              // Interface name
+                                "powerOff",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+                                // NULL);                  // First argument to getObjectFromId
+                                //"BOARD_1");             // Second Argument
+
+        if(rc < 0)
+        {
+            fprintf(stderr, "Failed to resolve poweroff to dbus: %s\n", bus_error.message);
+            goto finish;
+        }
+
+	}
+	
+	sleep(1);
+///		sd_bus_unref(bus);
+	finish:
+		sd_bus_unref(bus);
+		sleep(1);
+}
+	return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+
+int main(int argc, char *argv[]) {
+
+	return start_system_information();
+}
diff --git a/objects/log.h b/objects/log.h
new file mode 100644
index 0000000..a69d69e
--- /dev/null
+++ b/objects/log.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014-present Facebook. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef LOG_H
+#define LOG_H
+
+#include <stdio.h>
+#include <string.h>
+
+//#define DEBUG
+//#define VERBOSE
+
+#define _LOG(dst, fmt, ...) do {                  \
+  fprintf(dst, "%s:%d " fmt "\n",                 \
+          __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+  fflush(dst);                                    \
+} while(0)
+
+#define LOG_ERR(err, fmt, ...) do {                       \
+  char buf[128];                                          \
+  strerror_r(err, buf, sizeof(buf));                      \
+  _LOG(stderr, "ERROR " fmt ": %s", ##__VA_ARGS__, buf);  \
+} while(0)
+
+#define LOG_INFO(fmt, ...) do {                 \
+  _LOG(stdout, fmt, ##__VA_ARGS__);             \
+} while(0)
+
+#ifdef DEBUG
+#define LOG_DBG(fmt, ...) do {                  \
+  _LOG(stdout, fmt, ##__VA_ARGS__);             \
+} while(0)
+#else
+#define LOG_DBG(fmt, ...)
+#endif
+
+#ifdef VERBOSE
+#define LOG_VER(fmt, ...) do {                  \
+  _LOG(stdout, fmt, ##__VA_ARGS__);             \
+} while(0)
+#else
+#define LOG_VER(fmt, ...)
+#endif
+
+#endif
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 02/20] Heartbeat Led function
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 01/20] add i2craw tool and hdd status function OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 03/20] fix info memory leak OpenBMC Patches
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 bin/Barreleye.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 08a91a9..ff6690b 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -68,9 +68,9 @@ ENTER_STATE_CALLBACK = {
 
 	},
 	'BMC_READY' : {
-		'setOn' : {
+		'setBlinkSlow' : {
 			'bus_name'   : 'org.openbmc.control.led',
-			'obj_name'   : '/org/openbmc/control/led/beep',
+			'obj_name'   : '/org/openbmc/control/led/heartbeat',
 			'interface_name' : 'org.openbmc.Led',
 		},
 		'init' : {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 03/20] fix info memory leak
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 01/20] add i2craw tool and hdd status function OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 02/20] Heartbeat Led function OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:19   ` Stewart Smith
  2016-04-15  7:01 ` [PATCH skeleton v6 04/20] Setup FUNC_MODE[2:0] OpenBMC Patches
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 objects/info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/objects/info.c b/objects/info.c
index ab2d98c..76c17d9 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -145,7 +145,7 @@ int get_hdd_status(void)
 
     g_read_tmp[2]=g_read_bytes[2];
     g_read_tmp[3]=g_read_bytes[3];
-
+    close(fd);
 }
 
 int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 04/20] Setup FUNC_MODE[2:0]
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (2 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 03/20] fix info memory leak OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 05/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 objects/control_bmc_barreleye.c |  2 +-
 objects/control_bmc_obj.c       | 88 ++++++++++++++++++++---------------------
 2 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/objects/control_bmc_barreleye.c b/objects/control_bmc_barreleye.c
index ddfde88..84f79f5 100644
--- a/objects/control_bmc_barreleye.c
+++ b/objects/control_bmc_barreleye.c
@@ -96,7 +96,7 @@ void reg_init()
 	devmem(bmcreg+0x80,0xCB000000);
 	devmem(bmcreg+0x88,0x01C000FF);
 	devmem(bmcreg+0x8c,0xC1C000FF);
-	devmem(bmcreg+0x90,0x003FA009);
+	devmem(bmcreg+0x90,0x003FA008);
 	devmem(bmcreg+0x88,0x01C0007F);
 
 
diff --git a/objects/control_bmc_obj.c b/objects/control_bmc_obj.c
index f1a47c7..a02f369 100644
--- a/objects/control_bmc_obj.c
+++ b/objects/control_bmc_obj.c
@@ -22,11 +22,11 @@ static const gchar* dbus_name        = "org.openbmc.control.Bmc";
 #define LPC_HICR7		0x88
 #define LPC_HICR8		0x8c
 #define SPI_BASE		(off_t)0x1e630000
-#define SCU_BASE                (off_t)0x1e780000
+#define SCU_BASE                (off_t)0x1e6e2000
 #define UART_BASE               (off_t)0x1e783000
 #define COM_BASE                (off_t)0x1e789000
 #define COM_BASE2               (off_t)0x1e789100
-#define GPIO_BASE		(off_t)0x1e6e2000
+#define GPIO_BASE		(off_t)0x1e780000
 
 static GDBusObjectManagerServer *manager = NULL;
 
@@ -45,7 +45,7 @@ void* memmap(int mem_fd,off_t base)
 
 void reg_init()
 {
-	g_print("BMC init\n");
+	g_print("===============BMC init===============\n");
 	// BMC init done here
 
 	void *bmcreg;
@@ -54,7 +54,9 @@ void reg_init()
 		printf("ERROR: Unable to open /dev/mem");
 		exit(1);
 	}
-
+	bmcreg = memmap(mem_fd,SCU_BASE);
+	devmem(bmcreg+0x90,0x003FA008);
+/*
 	bmcreg = memmap(mem_fd,LPC_BASE);
 	devmem(bmcreg+LPC_HICR6,0x00000500); //Enable LPC FWH cycles, Enable LPC to AHB bridge
 	devmem(bmcreg+LPC_HICR7,0x30000E00); //32M PNOR
@@ -66,7 +68,6 @@ void reg_init()
 	devmem(bmcreg+0x04,0x00002404);
 
 	//UART
-
 	bmcreg = memmap(mem_fd,UART_BASE);
 	devmem(bmcreg+0x00,0x00000000);  //Set Baud rate divisor -> 13 (Baud 115200)
 	devmem(bmcreg+0x04,0x00000000);  //Set Baud rate divisor -> 13 (Baud 115200)
@@ -74,26 +75,24 @@ void reg_init()
 	bmcreg = memmap(mem_fd,COM_BASE);
 	devmem(bmcreg+0x9C,0x00000000);  //Set UART routing
 
-	bmcreg = memmap(mem_fd,SCU_BASE);
+	bmcreg = memmap(mem_fd,GPIO_BASE);
 	devmem(bmcreg+0x00,0x13008CE7);
 	devmem(bmcreg+0x04,0x0370E677);
 	devmem(bmcreg+0x20,0xDF48F7FF);
 	devmem(bmcreg+0x24,0xC738F202);
-
-
-	//GPIO
-	bmcreg = memmap(mem_fd,GPIO_BASE);
+	
+	bmcreg = memmap(mem_fd,SCU_BASE);
 	devmem(bmcreg+0x84,0x00fff0c0);  //Enable UART1
         devmem(bmcreg+0x70,0x120CE406);
 	devmem(bmcreg+0x80,0xCB000000);
 	devmem(bmcreg+0x88,0x01C000FF);
 	devmem(bmcreg+0x8c,0xC1C000FF);
-	devmem(bmcreg+0x90,0x003FA009);
+	devmem(bmcreg+0x90,0x003FA008);
 
 	bmcreg = memmap(mem_fd,COM_BASE);
 	devmem(bmcreg+0x170,0x00000042);
 	devmem(bmcreg+0x174,0x00004000);
-
+*/
 
 	close(mem_fd);
 }
@@ -110,29 +109,29 @@ on_init (Control          *control,
 	//control_emit_goto_system_state(control,"BMC_STARTING");
 	return TRUE;
 }
-
-static gboolean
-on_warm_reset (ControlBmc            	*bmc,
-               GDBusMethodInvocation	*invocation,
-               gpointer		            user_data)
-{
-	GError *err = NULL;
-	/* Wait a while before reboot, so the caller can be responded.
-	 * Note that g_spawn_command_line_async() cannot parse ';' as
-	 * a command separator. Need to use 'sh -c' to let shell parse it.
-	 */
-	gchar *reboot_command = "/bin/sh -c 'sleep 3;reboot'";
-
-	g_spawn_command_line_async(reboot_command, &err);
-	if (err != NULL) {
-		fprintf(stderr, "warmReset() error: %s\n", err->message);
-		g_error_free(err);
-	}
-
-	control_bmc_complete_warm_reset(bmc, invocation);
-	return TRUE;
-}
-
+
+static gboolean
+on_warm_reset (ControlBmc            	*bmc,
+               GDBusMethodInvocation	*invocation,
+               gpointer		            user_data)
+{
+	GError *err = NULL;
+	/* Wait a while before reboot, so the caller can be responded.
+	 * Note that g_spawn_command_line_async() cannot parse ';' as
+	 * a command separator. Need to use 'sh -c' to let shell parse it.
+	 */
+	gchar *reboot_command = "/bin/sh -c 'sleep 3;reboot'";
+
+	g_spawn_command_line_async(reboot_command, &err);
+	if (err != NULL) {
+		fprintf(stderr, "warmReset() error: %s\n", err->message);
+		g_error_free(err);
+	}
+
+	control_bmc_complete_warm_reset(bmc, invocation);
+	return TRUE;
+}
+
 gboolean go(gpointer user_data)
 {
  	cmdline *cmd = user_data;
@@ -145,8 +144,8 @@ gboolean go(gpointer user_data)
 	//g_main_loop_quit(cmd->loop);
 	return FALSE;
 }
-
-static void
+
+static void
 on_bus_acquired (GDBusConnection *connection,
                  const gchar     *name,
                  gpointer         user_data)
@@ -174,12 +173,12 @@ on_bus_acquired (GDBusConnection *connection,
                	    G_CALLBACK (on_init),
                	    NULL); /* user_data */
 
-
-	g_signal_connect (control_bmc,
-		"handle-warm-reset",
-		G_CALLBACK (on_warm_reset),
-		NULL); /* user_data */
-
+
+	g_signal_connect (control_bmc,
+		"handle-warm-reset",
+		G_CALLBACK (on_warm_reset),
+		NULL); /* user_data */
+
 	/* Export the object (@manager takes its own reference to @object) */
 	g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
 	g_object_unref (object);
@@ -225,6 +224,7 @@ main (gint argc, gchar *argv[])
   guint id;
   loop = g_main_loop_new (NULL, FALSE);
   cmd.loop = loop;
+  reg_init();
 
   id = g_bus_own_name (DBUS_TYPE,
                        dbus_name,
@@ -237,7 +237,7 @@ main (gint argc, gchar *argv[])
                        NULL);
 
   g_main_loop_run (loop);
-
+
   g_bus_unown_name (id);
   g_main_loop_unref (loop);
   return 0;
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 05/20] Fill in the threshold settings for CPU and DIMM
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (3 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 04/20] Setup FUNC_MODE[2:0] OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 06/20] " OpenBMC Patches
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <john.hc.wang@foxconn.com>

Fill in the threshold settings for CPU and DIMM based on the table from
thermal team
---
 bin/Barreleye.py | 171 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 106 insertions(+), 65 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index ff6690b..9cbf777 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -574,7 +574,8 @@ def convertGpio(name):
 HWMON_CONFIG = {
 	'0-004a' :  {
 		'names' : {
-			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+					'critical_upper' : 40, 'warning_upper' : 36, 'emergency_enabled' : True },
 		}
 	},
 	'6-002d' : {
@@ -630,97 +631,137 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
 		}
 	},
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
 		}
 	},
 }
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 06/20] Fill in the threshold settings for CPU and DIMM
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (4 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 05/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 07/20] fix info memory leak OpenBMC Patches
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <john.hc.wang@foxconn.com>

Fill in the threshold settings for CPU and DIMM based on the table from
thermal team
---
 bin/Barreleye.py | 171 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 106 insertions(+), 65 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index ff6690b..9cbf777 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -574,7 +574,8 @@ def convertGpio(name):
 HWMON_CONFIG = {
 	'0-004a' :  {
 		'names' : {
-			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+					'critical_upper' : 40, 'warning_upper' : 36, 'emergency_enabled' : True },
 		}
 	},
 	'6-002d' : {
@@ -630,97 +631,137 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
 		}
 	},
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
+		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
 		}
 	},
 }
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 07/20] fix info memory leak
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (5 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 06/20] " OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:20   ` Stewart Smith
  2016-04-15  7:01 ` [PATCH skeleton v6 08/20] Revert "Fill in the threshold settings for CPU and DIMM" OpenBMC Patches
                   ` (12 subsequent siblings)
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 objects/info.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/objects/info.c b/objects/info.c
index ab2d98c..d872c3f 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -42,6 +42,7 @@ static int i2c_open() {
   fd = open(fn, O_RDWR);
   if (fd == -1) {
     LOG_ERR(errno, "Failed to open i2c device %s", fn);
+    close(fd);
     return -1;
   }
 
@@ -108,6 +109,7 @@ static int i2c_io(int fd) {
   rc = ioctl(fd, I2C_RDWR, &data);
   if (rc < 0) {
     LOG_ERR(errno, "Failed to do raw io");
+    close(fd);
     return -1;
   }
 
@@ -126,6 +128,7 @@ int get_hdd_status(void)
   }
 
   if (i2c_io(fd) < 0) {
+    close(fd);
     return -1;
   }
 
@@ -145,7 +148,7 @@ int get_hdd_status(void)
 
     g_read_tmp[2]=g_read_bytes[2];
     g_read_tmp[3]=g_read_bytes[3];
-
+    close(fd);
 }
 
 int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 08/20] Revert "Fill in the threshold settings for CPU and DIMM"
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (6 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 07/20] fix info memory leak OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 09/20] Add I2C-6 lm75 outlet temperature sensor OpenBMC Patches
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

This reverts commit b78d66784fbd9f28d7252b4983465553d461e456.
---
 bin/Barreleye.py | 171 +++++++++++++++++++++----------------------------------
 1 file changed, 65 insertions(+), 106 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 9cbf777..ff6690b 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -574,8 +574,7 @@ def convertGpio(name):
 HWMON_CONFIG = {
 	'0-004a' :  {
 		'names' : {
-			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-					'critical_upper' : 40, 'warning_upper' : 36, 'emergency_enabled' : True },
+			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
 		}
 	},
 	'6-002d' : {
@@ -631,137 +630,97 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
 		}
 	},
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : 82, 'warning_upper' : 88, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'critical_lower' : 82, 'warning_upper' : 90, 'warning_lower' : 84, 'emergency_enabled' : True },
-		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
-		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 92, 'warning_upper' : 92, 'emergency_enabled' : False },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
 		}
 	},
 }
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 09/20] Add I2C-6 lm75 outlet temperature sensor
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (7 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 08/20] Revert "Fill in the threshold settings for CPU and DIMM" OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap OpenBMC Patches
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

Add lm75 outlet temperature sensor on I2C-6 for Barreleye
---
 bin/Barreleye.py           |  5 +++++
 objects/hwmons_barreleye.c | 15 ++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 9cbf777..71ebf6c 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -620,6 +620,11 @@ HWMON_CONFIG = {
                         'in14_input' : { 'object_path' : 'voltage/P1V35_CPU1_BUF3','poll_interval' : 10000,'scale' : 1,'units' : '' },
 		}
          },
+	'6-0048' : {
+		'names' : {
+                        'temp1_input' : { 'object_path' : 'temperature/outlet','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+		}
+	},
 	'3-0050' : {
 		'names' : {
 			'caps_curr_powercap' : { 'object_path' : 'powercap/curr_cap','poll_interval' : 10000,'scale' : 1,'units' : 'W' },
diff --git a/objects/hwmons_barreleye.c b/objects/hwmons_barreleye.c
index 5acde7c..9cc555b 100644
--- a/objects/hwmons_barreleye.c
+++ b/objects/hwmons_barreleye.c
@@ -20,18 +20,19 @@ typedef struct {
   int fd;
 } HWMON;
 
-#define  NUM_HWMONS 7
+#define  NUM_HWMONS 8
 
 // TODO: Don't hardcode
 //Hardcoded for barreleye
 HWMON hwmons[NUM_HWMONS] = { 
 	(HWMON){"/sys/class/hwmon/hwmon0/temp1_input","temperature/ambient",3000,"C",1000},
-	(HWMON){"/sys/class/hwmon/hwmon1/pwm1","speed/fan0",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon1/pwm2","speed/fan1",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon1/pwm3","speed/fan2",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm1","speed/fan3",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm2","speed/fan4",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm3","speed/fan5",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon1/temp1_input","temperature/outlet",5000,"C",1000},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm1","speed/fan0",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm2","speed/fan1",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm3","speed/fan2",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon3/pwm1","speed/fan3",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon3/pwm2","speed/fan4",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon3/pwm3","speed/fan5",30000,"",1},
 };
 bool is_hwmon_valid(HWMON* hwmon)
 {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (8 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 09/20] Add I2C-6 lm75 outlet temperature sensor OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:21   ` Stewart Smith
  2016-04-15  7:01 ` [PATCH skeleton v6 11/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
                   ` (9 subsequent siblings)
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

After we enable I2C-6 lm75 outlet sensor in device stree, the hwmon ID
of PowerCap won't be 3 anymore. So we have to modify it as real ID.
---
 bin/Sensors.py         | 2 +-
 bin/sensor_manager2.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/Sensors.py b/bin/Sensors.py
index f951eeb..1c6a961 100755
--- a/bin/Sensors.py
+++ b/bin/Sensors.py
@@ -137,7 +137,7 @@ class PowerCap(VirtualSensor):
 	def __init__(self, bus, name):
 		VirtualSensor.__init__(self, bus, name)
 		SensorValue.setValue(self, 0)
-		self.sysfs_attr = "/sys/class/hwmon/hwmon3/user_powercap"
+		self.sysfs_attr = "/sys/class/hwmon/hwmon4/user_powercap"
 	##override setValue method
 	@dbus.service.method(SensorValue.IFACE_NAME,
 		in_signature='v', out_signature='')
diff --git a/bin/sensor_manager2.py b/bin/sensor_manager2.py
index b5aac53..6aaef3e 100755
--- a/bin/sensor_manager2.py
+++ b/bin/sensor_manager2.py
@@ -54,9 +54,9 @@ if __name__ == '__main__':
 
 	obj_path = OBJ_PATH+"/host/PowerCap"
 	sensor_obj = Sensors.PowerCap(bus,obj_path)
-	## hwmon3 is default for master OCC on Barreleye.
+	## hwmon4 is default for master OCC on Barreleye.
 	## should rewrite sensor_manager to remove hardcode
-	sensor_obj.sysfs_attr = "/sys/class/hwmon/hwmon3/user_powercap"
+	sensor_obj.sysfs_attr = "/sys/class/hwmon/hwmon4/user_powercap"
 	root_sensor.add(obj_path,sensor_obj)
 
 	obj_path = OBJ_PATH+"/host/BootProgress"
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 11/20] Fill in the threshold settings for CPU and DIMM
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (9 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 12/20] Add fan control algorithm OpenBMC Patches
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

Fill in the threshold settings for CPU and DIMM based on the
Barreleye_sys_behaivor_Thermal_table_x03 from
thermal team
---
 bin/Barreleye.py | 171 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 106 insertions(+), 65 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 597d93b..38c18b8 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -574,7 +574,8 @@ def convertGpio(name):
 HWMON_CONFIG = {
 	'0-004a' :  {
 		'names' : {
-			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+					'critical_upper' : 40, 'warning_upper' : 36, 'emergency_enabled' : True },
 		}
 	},
 	'6-002d' : {
@@ -635,97 +636,137 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
 		}
 	},
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 90, 'warning_lower' : -99, 'emergency_enabled' : True },
-		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
+			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
+			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
 		}
 	},
 }
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 12/20] Add fan control algorithm
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (10 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 11/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 13/20] Fix skeleton Makefile OpenBMC Patches
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken.sk.lai@mail.foxconn.com>

---
 Makefile                |  10 +-
 bin/Barreleye.py        |  13 +-
 bin/startup_hacks.sh    |   4 +-
 objects/fan_algorithm.c | 566 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 584 insertions(+), 9 deletions(-)
 create mode 100755 objects/fan_algorithm.c

diff --git a/Makefile b/Makefile
index 3b8a2ae..0752813 100755
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ LIBS_info += $(shell pkg-config --libs $(DEPPKGS))
 %.o: objects/pflash/libflash/%.c
 	$(CC) -c -o obj/$@ $< $(CFLAGS) $(INCLUDES)
 
-all: setup libopenbmc_intf power_control led_controller button_power button_reset control_host host_watchdog board_vpd pcie_slot_present flash_bios flasher pflash hwmons_barreleye control_bmc i2craw info
+all: setup libopenbmc_intf power_control led_controller button_power button_reset control_host host_watchdog board_vpd pcie_slot_present flash_bios flasher pflash hwmons_barreleye control_bmc i2craw info fan_algorithm
 
 setup: 
 	mkdir -p obj lib
@@ -80,9 +80,17 @@ i2craw:  $(OBJS2) i2craw.o
 info:   info.o
 	$(CC) -o bin/$@ obj/info.o $(LDFLAGS) $(LIBS_info)
 
+fan_algorithm:   fan_algorithm.o
+	$(CC) -o bin/$@ obj/fan_algorithm.o $(LDFLAGS) $(LIBS_info)
+
 hwmons_barreleye: hwmons_barreleye.o object_mapper.o libopenbmc_intf
 	$(CC) -o bin/$@.exe obj/hwmons_barreleye.o obj/object_mapper.o  $(LDFLAGS) $(LIBS)
 
 control_bmc: control_bmc_obj.o libopenbmc_intf
 	$(CC) -o bin/$@.exe obj/control_bmc_obj.o $(LDFLAGS) $(LIBS)
 
+i2craw:  $(OBJS2) i2craw.o
+        $(CC) -o bin/$@ obj/i2craw.o $(LDFLAGS)
+
+info:   info.o
+        $(CC) -o bin/$@ obj/info.o $(LDFLAGS) $(LIBS_info)
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 597d93b..646177f 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -48,11 +48,6 @@ ENTER_STATE_CALLBACK = {
 			'obj_name'    : '/org/openbmc/control/host0',
 			'interface_name' : 'org.openbmc.control.Host',
 		},
-		'setMax' : {
-			'bus_name'    : 'org.openbmc.control.Fans',
-			'obj_name'    : '/org/openbmc/control/fans',
-			'interface_name' : 'org.openbmc.control.Fans',
-		},
 		'setOn' : {
 			'bus_name'   : 'org.openbmc.control.led',
 			'obj_name'   : '/org/openbmc/control/led/identify',
@@ -210,12 +205,18 @@ APPS = {
 		'monitor_process' : False,
 		'process_name'    : 'discover_system_state.py',
 	},
-        'info' : {
+    'info' : {
                 'system_state'    : 'BMC_STARTING2',
                 'start_process'   : True,
                 'monitor_process' : True,
                 'process_name'    : 'info',
         },
+    'fan_algorithm' : {
+                'system_state'    : 'HOST_POWERED_ON',
+                'start_process'   : True,
+                'monitor_process' : True,
+                'process_name'    : 'fan_algorithm',
+    },
 	'bmc_control' : {
 		'system_state'    : 'BMC_STARTING',
 		'start_process'   : True,
diff --git a/bin/startup_hacks.sh b/bin/startup_hacks.sh
index cf3632a..357a4da 100755
--- a/bin/startup_hacks.sh
+++ b/bin/startup_hacks.sh
@@ -7,8 +7,8 @@ systemctl stop serial-getty@ttyS0
  i2cset -y 0x06 0x20 0x07 0x00
  
  # Turn on all fan LED to BLUE
- i2cset -y 0x06 0x20 0x03 0x55
- i2cset -y 0x06 0x20 0x02 0xaa
+ # i2cset -y 0x06 0x20 0x03 0x55
+ # i2cset -y 0x06 0x20 0x02 0xaa
 
 # Setup VUART
 VUART=/sys/devices/platform/ahb/ahb:apb/1e787000.vuart
diff --git a/objects/fan_algorithm.c b/objects/fan_algorithm.c
new file mode 100755
index 0000000..477b7cb
--- /dev/null
+++ b/objects/fan_algorithm.c
@@ -0,0 +1,566 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <systemd/sd-bus.h>
+#include "i2c-dev.h"
+#include "log.h"
+
+const char *gService = "org.openbmc.Sensors";
+const char *fanService = "org.openbmc.control.Fans";
+
+const char *gfanflagObjPath = "/org/openbmc/sensors/FanParameter/flag";
+const char *gfanCPUvaribleObjPath = "/org/openbmc/sensors/FanParameter/flag";
+const char *gfanDIMMvaribleObjPath = "/org/openbmc/sensors/FanParameter/flag";
+			
+const char *gfanpidObjPath [3] = {"/org/openbmc/sensors/FanParameter/Kp",
+							      "/org/openbmc/sensors/FanParameter/Ki",
+							      "/org/openbmc/sensors/FanParameter/Kd"};
+
+
+const char *gCPU0ObjPath [12] = {"/org/openbmc/sensors/temperature/cpu0/core0",
+								 "/org/openbmc/sensors/temperature/cpu0/core1",
+								 "/org/openbmc/sensors/temperature/cpu0/core2",
+								 "/org/openbmc/sensors/temperature/cpu0/core3",
+								 "/org/openbmc/sensors/temperature/cpu0/core4",
+								 "/org/openbmc/sensors/temperature/cpu0/core5",
+								 "/org/openbmc/sensors/temperature/cpu0/core6",
+								 "/org/openbmc/sensors/temperature/cpu0/core7",
+								 "/org/openbmc/sensors/temperature/cpu0/core8",
+								 "/org/openbmc/sensors/temperature/cpu0/core9",
+								 "/org/openbmc/sensors/temperature/cpu0/core10",
+								 "/org/openbmc/sensors/temperature/cpu0/core11"};
+								
+const char *gCPU1ObjPath [12] = {"/org/openbmc/sensors/temperature/cpu0/core0",
+								 "/org/openbmc/sensors/temperature/cpu0/core1",
+								 "/org/openbmc/sensors/temperature/cpu0/core2",
+								 "/org/openbmc/sensors/temperature/cpu0/core3",
+								 "/org/openbmc/sensors/temperature/cpu0/core4",
+								 "/org/openbmc/sensors/temperature/cpu0/core5",
+								 "/org/openbmc/sensors/temperature/cpu0/core6",
+								 "/org/openbmc/sensors/temperature/cpu0/core7",
+								 "/org/openbmc/sensors/temperature/cpu0/core8",
+								 "/org/openbmc/sensors/temperature/cpu0/core9",
+								 "/org/openbmc/sensors/temperature/cpu0/core10",
+								 "/org/openbmc/sensors/temperature/cpu0/core11"};
+
+const char *gDIMMObjPath [32] = {"/org/openbmc/sensors/temperature/dimm0",
+								 "/org/openbmc/sensors/temperature/dimm1",
+								 "/org/openbmc/sensors/temperature/dimm2",
+								 "/org/openbmc/sensors/temperature/dimm3",
+								 "/org/openbmc/sensors/temperature/dimm4",
+								 "/org/openbmc/sensors/temperature/dimm5",
+								 "/org/openbmc/sensors/temperature/dimm6",
+								 "/org/openbmc/sensors/temperature/dimm7",
+								 "/org/openbmc/sensors/temperature/dimm8",
+								 "/org/openbmc/sensors/temperature/dimm9",
+								 "/org/openbmc/sensors/temperature/dimm10",
+								 "/org/openbmc/sensors/temperature/dimm11",
+								 "/org/openbmc/sensors/temperature/dimm12",
+								 "/org/openbmc/sensors/temperature/dimm13",
+								 "/org/openbmc/sensors/temperature/dimm14",
+								 "/org/openbmc/sensors/temperature/dimm15",
+								 "/org/openbmc/sensors/temperature/dimm16",
+								 "/org/openbmc/sensors/temperature/dimm17",
+								 "/org/openbmc/sensors/temperature/dimm18",
+								 "/org/openbmc/sensors/temperature/dimm19",
+								 "/org/openbmc/sensors/temperature/dimm20",
+								 "/org/openbmc/sensors/temperature/dimm21",
+								 "/org/openbmc/sensors/temperature/dimm22",
+								 "/org/openbmc/sensors/temperature/dimm23",
+								 "/org/openbmc/sensors/temperature/dimm24",
+								 "/org/openbmc/sensors/temperature/dimm25",
+								 "/org/openbmc/sensors/temperature/dimm26",
+								 "/org/openbmc/sensors/temperature/dimm27",
+								 "/org/openbmc/sensors/temperature/dimm28",
+								 "/org/openbmc/sensors/temperature/dimm29",
+								 "/org/openbmc/sensors/temperature/dimm30",
+								 "/org/openbmc/sensors/temperature/dimm31"};
+
+
+const char *gObjPath_Ambient = "/org/openbmc/sensors/temperature/ambient";
+const char *fanObjPath [6] ={"/org/openbmc/sensors/speed/fan0",
+							 "/org/openbmc/sensors/speed/fan1",
+							 "/org/openbmc/sensors/speed/fan2",
+							 "/org/openbmc/sensors/speed/fan3",
+							 "/org/openbmc/sensors/speed/fan4",
+							 "/org/openbmc/sensors/speed/fan5"};
+
+
+
+const char *gIntPath = "org.openbmc.SensorValue";
+
+
+char *gMessage = NULL;
+sd_bus *bus = NULL;
+
+#define MAX_BYTES 255
+
+int g_use_pec = 0;
+int g_has_write = 1;
+int g_n_write = 0;
+uint8_t g_write_bytes[MAX_BYTES];
+uint8_t g_write_color_bytes[MAX_BYTES];
+
+int g_has_read = 1;
+int g_n_read = -1;
+uint8_t g_read_bytes[MAX_BYTES];
+uint8_t g_read_tmp[MAX_BYTES];
+uint8_t g_bus = -1;
+uint8_t g_slave_addr = 0xff;
+double g_Kp = 0.7;
+double g_Ki = -0.025;
+double g_Kd = 1.0;
+int g_CPUVariable = 80;
+int g_DIMMVariable = 75;
+
+int g_Sampling_N = 20;
+int intergral_i = 0;
+int Interal_CPU_Err[20]={0};
+int Interal_DIMM_Err[20]={0};
+
+int g_fanspeed = 0;
+
+
+int Openloopspeed = 0;
+int Closeloopspeed = 0;
+int Finalfanspeed = 0;
+
+static int i2c_open() {
+  int fd;
+  char fn[32];
+  int rc;
+
+  g_bus = 6;
+  snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+  fd = open(fn, O_RDWR);
+  if (fd == -1) {
+    LOG_ERR(errno, "Failed to open i2c device %s", fn);
+	close(fd);
+    return -1;
+  }
+  return fd;
+}
+
+static int SetFanLed(int fd,int color) {
+  struct i2c_rdwr_ioctl_data data;
+  struct i2c_msg msg[2];
+  int n_msg = 0;
+  int rc;
+
+  memset(&msg, 0, sizeof(msg));
+
+  g_slave_addr = 0x20;
+  g_use_pec = 0;
+  g_n_write = 2;
+
+  if(color==1) //blue light
+  {
+  g_write_bytes[0] = 0x03;
+  g_write_bytes[1] = 0x55;
+  g_write_color_bytes[0] = 0x02;
+  g_write_color_bytes[1] = 0xaa;
+  }
+    else //red light
+	{
+    g_write_bytes[0] = 0x03;
+   	g_write_bytes[1] = 0xaa;
+    g_write_color_bytes[0] = 0x02;
+    g_write_color_bytes[1] = 0x55;
+  	}
+  
+  if (1) {
+    msg[n_msg].addr = g_slave_addr;
+    msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+    msg[n_msg].len = g_n_write;
+    msg[n_msg].buf = g_write_bytes;
+    n_msg++;
+  }
+  if (1) {
+	  msg[n_msg].addr = g_slave_addr;
+	  msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+	  msg[n_msg].len = g_n_write;
+	  msg[n_msg].buf = g_write_color_bytes;
+	  n_msg++;
+  }
+  data.msgs = msg;
+  data.nmsgs = n_msg;
+  rc = ioctl(fd, I2C_RDWR, &data);
+  if (rc < 0) {
+    LOG_ERR(errno, "Failed to do raw io");
+	close(fd);
+    return -1;
+  }
+
+  return 0;
+}
+
+
+int CloseLoop (int cpureading,int dimmreading)
+{
+	int i,rc;
+	int flag = 0;
+	double pid [3] = {0};
+	int CPUvarible;
+	int DIMMvarible = 0;
+	
+	int CPU_PWM_speed = 0;
+	static int CPU_PID_value = 0;
+	static int CPU_tracking_error = 0; 
+	static int CPU_integral_error = 0;
+	static int CPU_differential_error = 0;
+	static int CPU_last_error = 0;
+
+	int DIMM_PWM_speed = 0;
+	static int DIMM_PID_value = 0;
+	static int DIMM_tracking_error = 0;
+	static int DIMM_integral_error = 0;
+	static int DIMM_differential_error = 0;
+	static int DIMM_last_error = 0;
+		
+//CPU closeloop
+CPU_tracking_error = cpureading - g_CPUVariable;
+Interal_CPU_Err[intergral_i]=CPU_tracking_error;
+CPU_integral_error = 0;
+for(i=0;i<g_Sampling_N;i++)
+{
+	CPU_integral_error += Interal_CPU_Err[i] ;
+}			
+
+CPU_differential_error = CPU_tracking_error - CPU_last_error;			
+CPU_PID_value = g_Kp * CPU_tracking_error +  g_Ki * CPU_integral_error + g_Kd * CPU_differential_error;
+
+CPU_PWM_speed= CPU_PID_value + g_fanspeed;
+if(CPU_PWM_speed > 100)
+{
+	CPU_PWM_speed = 100;
+}
+if(CPU_PWM_speed < 0)
+{
+	CPU_PWM_speed = 0;
+}
+
+CPU_last_error = CPU_tracking_error;
+
+
+//DIMM closeloop
+
+	DIMM_tracking_error = dimmreading - g_DIMMVariable;
+		Interal_DIMM_Err[intergral_i]=DIMM_tracking_error;
+		intergral_i++;		
+		DIMM_integral_error = 0;
+		for(i=0;i<g_Sampling_N;i++)
+		{
+			DIMM_integral_error += Interal_DIMM_Err[i] ;
+		}	
+		if(intergral_i == g_Sampling_N)
+			intergral_i = 0;
+		
+
+    	DIMM_differential_error = DIMM_tracking_error - DIMM_last_error;			
+		DIMM_PID_value = g_Kp * DIMM_tracking_error +  g_Ki * DIMM_integral_error + g_Kd * DIMM_differential_error;		
+		DIMM_PWM_speed = DIMM_PID_value + g_fanspeed;
+
+		if(DIMM_PWM_speed > 100)
+		{
+			DIMM_PWM_speed = 100;
+		}
+		if(DIMM_PWM_speed < 0)
+		{
+			DIMM_PWM_speed = 0;
+		}
+	
+		DIMM_last_error = DIMM_tracking_error;
+
+	if (DIMM_PWM_speed>CPU_PWM_speed)
+		Closeloopspeed=DIMM_PWM_speed;
+	else
+		Closeloopspeed=CPU_PWM_speed;
+
+	if(intergral_i == g_Sampling_N)
+		intergral_i = 0;
+
+
+}
+
+
+int OpenLoop (int sensorreading)
+{
+
+
+	int speed = 0;
+	float paramA= 0;
+	float paramB= 2; 
+	float paramC= 0;
+	int Low_Amb = 20;
+	int Up_Amb = 40;
+	
+    if (sensorreading >= Up_Amb)
+    {
+    	speed = 100;
+		//printf("## Ambient >=%dC, the Fan duty is %d \n",Up_Amb,speed);	
+    }
+	else if (sensorreading <= Low_Amb)
+    {
+    	speed = 40;
+		//printf("## Ambient <=%dC, the Fan duty is %d \n",Low_Amb,speed);	
+    }
+	else
+	{
+		speed = ( paramA * sensorreading * sensorreading ) + ( paramB * sensorreading ) + paramC;
+		if(speed > 100)
+		{
+			speed = 100;
+		}	
+		if(speed < 40)
+		{
+			speed = 40;
+		}
+	//	printf("The Fan duty is %d \n",speed);
+
+	}
+
+	Openloopspeed=speed;
+
+return 0;
+}
+
+
+
+
+int Fan_control_algorithm(void) {
+
+	sd_bus *bus;
+	sd_bus_slot *slot;
+	int r, Ambient_reading, rc,retry,i;
+	int CPU0_core_temperature[12];
+	int CPU1_core_temperature[12];
+	int DIMM_temperature[32];
+	int HighestCPUtemp = 0;
+	int HighestDIMMtemp = 0;
+	int CPUnocore[2];
+	int fd;
+	int FinalFanSpeed = 0;
+	int CPUtemp=0;
+	
+	r = -1;
+	while(r < 0) {
+	/* Connect to the user bus this time */
+	r = sd_bus_open_system(&bus);
+		if(r < 0){	
+			fprintf(stderr, "fan 1 Failed to connect to system bus: %s\n", strerror(-r));
+		sleep(1);
+			}
+	
+		}
+	// SD Bus error report mechanism.
+	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
+	sd_bus_message *response = NULL, *m = NULL;;
+    sd_bus_error_free(&bus_error);
+    sd_bus_message_unref(response);
+
+
+while(1){
+  	fd = i2c_open();
+	CPUtemp=0;
+	for(i=0;i<12;i++){
+       sd_bus_error_free(&bus_error);
+
+        rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gCPU0ObjPath[i],            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+
+        if(rc < 0)
+        {
+            //fprintf(stderr, "gCPU0ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+           // goto finish;
+           CPU0_core_temperature[i]=0;
+        }
+		else
+		{
+			rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
+			if (rc < 0 )
+			{ 
+         	 // fprintf(stderr, "gCPU0ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+          // goto finish;
+			}
+		}
+	//printf("CPU0 core %d value=[%d] \n",i,CPU0_core_temperature[i]);
+	if(CPU0_core_temperature[i] > HighestCPUtemp )
+		{
+		HighestCPUtemp = CPU0_core_temperature[i];
+		CPUnocore[0]=0;
+		CPUnocore[1]=i;
+		}
+	CPUtemp=CPUtemp+CPU0_core_temperature[i];
+	}
+	
+	for(i=0;i<12;i++){
+       sd_bus_error_free(&bus_error);
+
+        rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gCPU1ObjPath[i],            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+
+        if(rc < 0)
+        {
+            //fprintf(stderr, "gCPU1ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			CPU1_core_temperature[i]=0;
+			//goto finish;
+        }
+		else
+		{
+		rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
+
+		}
+
+
+		if(CPU1_core_temperature[i] > HighestCPUtemp )
+		{
+		HighestCPUtemp = CPU1_core_temperature[i];
+		CPUnocore[0]=1;
+		CPUnocore[1]=i;
+		}
+
+	}
+
+	
+	for(i=0;i<32;i++){
+       sd_bus_error_free(&bus_error);
+
+        rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gDIMMObjPath[i],            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+
+        if(rc < 0)
+        {
+  
+            DIMM_temperature[i]=0;
+        }
+		else
+		{
+		rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
+
+			if (rc < 0 )
+			{ 
+         	  fprintf(stderr, "gDIMMObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+      
+			}
+
+		}
+
+	if(DIMM_temperature[i] > HighestDIMMtemp )
+		HighestDIMMtemp = DIMM_temperature[i];
+	}
+	printf("Highest DIMM temperatur is value %d \n",HighestDIMMtemp);
+
+
+
+	sd_bus_error_free(&bus_error);
+     rc = sd_bus_call_method(bus,                   // On the System Bus
+                                gService,               // Service to contact
+                                gObjPath_Ambient,            // Object path
+                                gIntPath,              // Interface name
+                                "getValue",          // Method to be called
+                                &bus_error,                 // object to return error
+                                &response,                  // Response message on success
+                                NULL);                       // input message (string,byte)
+                                // NULL);                  // First argument to getObjectFromId
+                                //"BOARD_1");             // Second Argument
+
+        if(rc < 0)
+        {
+            fprintf(stderr, "fan2 Failed to resolve fruid to dbus: %s\n", bus_error.message);
+       
+        }
+
+	rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
+	if (rc < 0 )
+	{ 
+           fprintf(stderr, "fan3 Failed to parse response message:[%s]\n", strerror(-rc));
+  
+	}
+
+	  if (CPUtemp==0)
+	  	{
+		HighestCPUtemp=0;
+		HighestDIMMtemp=0;
+	  	}
+
+	CloseLoop(HighestCPUtemp,HighestDIMMtemp);
+	OpenLoop(Ambient_reading);
+
+	
+
+		if(Openloopspeed>Closeloopspeed)
+		g_fanspeed=Openloopspeed;
+		else
+		g_fanspeed=Closeloopspeed;
+	
+	if(g_fanspeed>30) 
+		SetFanLed(fd,1);
+	else
+		SetFanLed(fd,2);
+
+	FinalFanSpeed=g_fanspeed*255;
+	FinalFanSpeed=FinalFanSpeed/100;
+
+	if(HighestCPUtemp==0) //OCC sensor does not enable
+	{
+	FinalFanSpeed=255;
+	}
+
+
+ 	for(i=0;i<6;i++){
+		
+		sd_bus_error_free(&bus_error);
+	rc = sd_bus_call_method(bus,				   // On the System Bus
+							   gService,			   // Service to contact
+							   fanObjPath[i],			// Object path
+							   gIntPath,			  // Interface name
+							   "setValue",			// Method to be called
+							   &bus_error,				   // object to return error
+							   &response,				   // Response message on success
+							   "i",						// input message (string,byte)
+							   FinalFanSpeed);                  // First argument
+
+	  if(rc < 0)
+        {
+            fprintf(stderr, "fanObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+          //  goto finish;
+        }
+
+
+ 	}
+
+	close(fd);
+	sleep(1);
+	
+
+	finish:
+		sd_bus_unref(bus);
+		sleep(1);
+}
+	return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+
+int main(int argc, char *argv[]) {
+
+	return Fan_control_algorithm();
+}
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 13/20] Fix skeleton Makefile
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (11 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 12/20] Add fan control algorithm OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 14/20] Set lower threshold for ambient/CPU/DIMM sensors OpenBMC Patches
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken

From: Ken <ken1029@gmail.com>

---
 Makefile | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/Makefile b/Makefile
index 0752813..22ce5a6 100755
--- a/Makefile
+++ b/Makefile
@@ -88,9 +88,3 @@ hwmons_barreleye: hwmons_barreleye.o object_mapper.o libopenbmc_intf
 
 control_bmc: control_bmc_obj.o libopenbmc_intf
 	$(CC) -o bin/$@.exe obj/control_bmc_obj.o $(LDFLAGS) $(LIBS)
-
-i2craw:  $(OBJS2) i2craw.o
-        $(CC) -o bin/$@ obj/i2craw.o $(LDFLAGS)
-
-info:   info.o
-        $(CC) -o bin/$@ obj/info.o $(LDFLAGS) $(LIBS_info)
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 14/20] Set lower threshold for ambient/CPU/DIMM sensors
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (12 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 13/20] Fix skeleton Makefile OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 15/20] Fix memory leak OpenBMC Patches
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

The default value is 0, so we have to configure it to avoid the critical
assertion while power off.
---
 bin/Barreleye.py | 130 +++++++++++++++++++++++++++----------------------------
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 6e8a8a4..a270f43 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -576,7 +576,7 @@ HWMON_CONFIG = {
 	'0-004a' :  {
 		'names' : {
 			'temp1_input' : { 'object_path' : 'temperature/ambient','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-					'critical_upper' : 40, 'warning_upper' : 36, 'emergency_enabled' : True },
+					'critical_upper' : 40, 'critical_lower' : -100, 'warning_upper' : 36, 'warning_lower' : -99, 'emergency_enabled' : True },
 		}
 	},
 	'6-002d' : {
@@ -637,137 +637,137 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'104' :  { 'object_path' : 'temperature/dimm2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'105' :  { 'object_path' : 'temperature/dimm3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'106' :  { 'object_path' : 'temperature/dimm4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'107' :  { 'object_path' : 'temperature/dimm5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'108' :  { 'object_path' : 'temperature/dimm6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'109' :  { 'object_path' : 'temperature/dimm7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'110' :  { 'object_path' : 'temperature/dimm8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'111' :  { 'object_path' : 'temperature/dimm9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'112' :  { 'object_path' : 'temperature/dimm10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'113' :  { 'object_path' : 'temperature/dimm11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'114' :  { 'object_path' : 'temperature/dimm12','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'115' :  { 'object_path' : 'temperature/dimm13','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'116' :  { 'object_path' : 'temperature/dimm14','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'117' :  { 'object_path' : 'temperature/dimm15','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'94' :  { 'object_path' : 'temperature/membuf0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'95' :  { 'object_path' : 'temperature/membuf1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'96' :  { 'object_path' : 'temperature/membuf2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'97' :  { 'object_path' : 'temperature/membuf3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		}
 	},
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'120' :  { 'object_path' : 'temperature/dimm18','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'121' :  { 'object_path' : 'temperature/dimm19','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'122' :  { 'object_path' : 'temperature/dimm20','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'123' :  { 'object_path' : 'temperature/dimm21','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'124' :  { 'object_path' : 'temperature/dimm22','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'125' :  { 'object_path' : 'temperature/dimm23','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'126' :  { 'object_path' : 'temperature/dimm24','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'127' :  { 'object_path' : 'temperature/dimm25','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'128' :  { 'object_path' : 'temperature/dimm26','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'129' :  { 'object_path' : 'temperature/dimm27','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'130' :  { 'object_path' : 'temperature/dimm28','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'131' :  { 'object_path' : 'temperature/dimm29','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'132' :  { 'object_path' : 'temperature/dimm30','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'133' :  { 'object_path' : 'temperature/dimm31','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 95, 'warning_upper' : 85, 'emergency_enabled' : True },
+			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'98' :  { 'object_path' : 'temperature/membuf4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'99' :  { 'object_path' : 'temperature/membuf5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'100' :  { 'object_path' : 'temperature/membuf6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'101' :  { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 100, 'warning_upper' : 93, 'emergency_enabled' : True },
+			'critical_upper' : 100, 'critical_lower' : -100, 'warning_upper' : 93, 'warning_lower' : -99, 'emergency_enabled' : True },
 		}
 	},
 }
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 15/20] Fix memory leak
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (13 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 14/20] Set lower threshold for ambient/CPU/DIMM sensors OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 16/20] Support FAN tach sensors OpenBMC Patches
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

1. Multi-processes if we call fan_algorithm.py every HOST_POWERED state
2. Occupy the memory if we don't unref sdbus message
---
 bin/Barreleye.py        |   2 +-
 objects/fan_algorithm.c | 615 ++++++++++++++++++++++--------------------------
 objects/info.c          | 558 +++++++++++++++++++++----------------------
 3 files changed, 542 insertions(+), 633 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 6e8a8a4..e05d985 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -212,7 +212,7 @@ APPS = {
                 'process_name'    : 'info',
         },
     'fan_algorithm' : {
-                'system_state'    : 'HOST_POWERED_ON',
+                'system_state'    : 'BMC_READY',
                 'start_process'   : True,
                 'monitor_process' : True,
                 'process_name'    : 'fan_algorithm',
diff --git a/objects/fan_algorithm.c b/objects/fan_algorithm.c
index 477b7cb..1077d55 100755
--- a/objects/fan_algorithm.c
+++ b/objects/fan_algorithm.c
@@ -92,7 +92,6 @@ const char *gIntPath = "org.openbmc.SensorValue";
 
 
 char *gMessage = NULL;
-sd_bus *bus = NULL;
 
 #define MAX_BYTES 255
 
@@ -126,73 +125,72 @@ int Openloopspeed = 0;
 int Closeloopspeed = 0;
 int Finalfanspeed = 0;
 
-static int i2c_open() {
-  int fd;
-  char fn[32];
-  int rc;
-
-  g_bus = 6;
-  snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
-  fd = open(fn, O_RDWR);
-  if (fd == -1) {
-    LOG_ERR(errno, "Failed to open i2c device %s", fn);
-	close(fd);
-    return -1;
-  }
-  return fd;
+static int i2c_open()
+{
+	int rc = 0, fd = -1;
+	char fn[32];
+
+	g_bus = 6;
+	snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+	fd = open(fn, O_RDWR);
+	if (fd == -1) {
+		LOG_ERR(errno, "Failed to open i2c device %s", fn);
+		close(fd);
+		return -1;
+	}
+	return fd;
 }
 
-static int SetFanLed(int fd,int color) {
-  struct i2c_rdwr_ioctl_data data;
-  struct i2c_msg msg[2];
-  int n_msg = 0;
-  int rc;
-
-  memset(&msg, 0, sizeof(msg));
-
-  g_slave_addr = 0x20;
-  g_use_pec = 0;
-  g_n_write = 2;
-
-  if(color==1) //blue light
-  {
-  g_write_bytes[0] = 0x03;
-  g_write_bytes[1] = 0x55;
-  g_write_color_bytes[0] = 0x02;
-  g_write_color_bytes[1] = 0xaa;
-  }
-    else //red light
-	{
-    g_write_bytes[0] = 0x03;
-   	g_write_bytes[1] = 0xaa;
-    g_write_color_bytes[0] = 0x02;
-    g_write_color_bytes[1] = 0x55;
-  	}
+static int SetFanLed(int fd,int color)
+{
+	struct i2c_rdwr_ioctl_data data;
+	struct i2c_msg msg[2];
+	int rc = 0, n_msg = 0;
+
+	memset(&msg, 0, sizeof(msg));
+
+	g_slave_addr = 0x20;
+	g_use_pec = 0;
+	g_n_write = 2;
+
+	if(color == 1) {
+		//blue light
+		g_write_bytes[0] = 0x03;
+		g_write_bytes[1] = 0x55;
+		g_write_color_bytes[0] = 0x02;
+		g_write_color_bytes[1] = 0xaa;
+	} else {
+		//red light
+		g_write_bytes[0] = 0x03;
+		g_write_bytes[1] = 0xaa;
+		g_write_color_bytes[0] = 0x02;
+		g_write_color_bytes[1] = 0x55;
+	}
   
-  if (1) {
-    msg[n_msg].addr = g_slave_addr;
-    msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
-    msg[n_msg].len = g_n_write;
-    msg[n_msg].buf = g_write_bytes;
-    n_msg++;
-  }
-  if (1) {
-	  msg[n_msg].addr = g_slave_addr;
-	  msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
-	  msg[n_msg].len = g_n_write;
-	  msg[n_msg].buf = g_write_color_bytes;
-	  n_msg++;
-  }
-  data.msgs = msg;
-  data.nmsgs = n_msg;
-  rc = ioctl(fd, I2C_RDWR, &data);
-  if (rc < 0) {
-    LOG_ERR(errno, "Failed to do raw io");
-	close(fd);
-    return -1;
-  }
-
-  return 0;
+	if (1) {
+		msg[n_msg].addr = g_slave_addr;
+		msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+		msg[n_msg].len = g_n_write;
+		msg[n_msg].buf = g_write_bytes;
+		n_msg++;
+	}
+	 if (1) {
+		msg[n_msg].addr = g_slave_addr;
+		msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+		msg[n_msg].len = g_n_write;
+		msg[n_msg].buf = g_write_color_bytes;
+		n_msg++;
+	}
+	data.msgs = msg;
+	data.nmsgs = n_msg;
+	rc = ioctl(fd, I2C_RDWR, &data);
+	if (rc < 0) {
+		LOG_ERR(errno, "Failed to do raw io");
+		close(fd);
+		return -1;
+	}
+
+	return 0;
 }
 
 
@@ -218,76 +216,63 @@ int CloseLoop (int cpureading,int dimmreading)
 	static int DIMM_differential_error = 0;
 	static int DIMM_last_error = 0;
 		
-//CPU closeloop
-CPU_tracking_error = cpureading - g_CPUVariable;
-Interal_CPU_Err[intergral_i]=CPU_tracking_error;
-CPU_integral_error = 0;
-for(i=0;i<g_Sampling_N;i++)
-{
-	CPU_integral_error += Interal_CPU_Err[i] ;
-}			
+	//CPU closeloop
+	CPU_tracking_error = cpureading - g_CPUVariable;
+	Interal_CPU_Err[intergral_i] = CPU_tracking_error;
+	CPU_integral_error = 0;
 
-CPU_differential_error = CPU_tracking_error - CPU_last_error;			
-CPU_PID_value = g_Kp * CPU_tracking_error +  g_Ki * CPU_integral_error + g_Kd * CPU_differential_error;
+	for(i=0;i<g_Sampling_N;i++)
+		CPU_integral_error += Interal_CPU_Err[i] ;
 
-CPU_PWM_speed= CPU_PID_value + g_fanspeed;
-if(CPU_PWM_speed > 100)
-{
-	CPU_PWM_speed = 100;
-}
-if(CPU_PWM_speed < 0)
-{
-	CPU_PWM_speed = 0;
-}
+	CPU_differential_error = CPU_tracking_error - CPU_last_error;
+	CPU_PID_value = g_Kp * CPU_tracking_error +  g_Ki * CPU_integral_error + g_Kd * CPU_differential_error;
+	CPU_PWM_speed = CPU_PID_value + g_fanspeed;
 
-CPU_last_error = CPU_tracking_error;
+	if(CPU_PWM_speed > 100)
+		CPU_PWM_speed = 100;
 
+	if(CPU_PWM_speed < 0)
+		CPU_PWM_speed = 0;
 
-//DIMM closeloop
+	CPU_last_error = CPU_tracking_error;
 
+	//DIMM closeloop
 	DIMM_tracking_error = dimmreading - g_DIMMVariable;
-		Interal_DIMM_Err[intergral_i]=DIMM_tracking_error;
-		intergral_i++;		
-		DIMM_integral_error = 0;
-		for(i=0;i<g_Sampling_N;i++)
-		{
-			DIMM_integral_error += Interal_DIMM_Err[i] ;
-		}	
-		if(intergral_i == g_Sampling_N)
-			intergral_i = 0;
+	Interal_DIMM_Err[intergral_i] = DIMM_tracking_error;
+	intergral_i++;
+	DIMM_integral_error = 0;
+
+	for(i=0;i<g_Sampling_N;i++)
+		DIMM_integral_error += Interal_DIMM_Err[i] ;
+
+	if(intergral_i == g_Sampling_N)
+		intergral_i = 0;
 		
 
     	DIMM_differential_error = DIMM_tracking_error - DIMM_last_error;			
-		DIMM_PID_value = g_Kp * DIMM_tracking_error +  g_Ki * DIMM_integral_error + g_Kd * DIMM_differential_error;		
-		DIMM_PWM_speed = DIMM_PID_value + g_fanspeed;
+	DIMM_PID_value = g_Kp * DIMM_tracking_error +  g_Ki * DIMM_integral_error + g_Kd * DIMM_differential_error;
+	DIMM_PWM_speed = DIMM_PID_value + g_fanspeed;
 
-		if(DIMM_PWM_speed > 100)
-		{
-			DIMM_PWM_speed = 100;
-		}
-		if(DIMM_PWM_speed < 0)
-		{
-			DIMM_PWM_speed = 0;
-		}
+	if(DIMM_PWM_speed > 100)
+		DIMM_PWM_speed = 100;
+
+	if(DIMM_PWM_speed < 0)
+		DIMM_PWM_speed = 0;
 	
 		DIMM_last_error = DIMM_tracking_error;
 
-	if (DIMM_PWM_speed>CPU_PWM_speed)
-		Closeloopspeed=DIMM_PWM_speed;
+	if (DIMM_PWM_speed > CPU_PWM_speed)
+		Closeloopspeed = DIMM_PWM_speed;
 	else
-		Closeloopspeed=CPU_PWM_speed;
+		Closeloopspeed = CPU_PWM_speed;
 
 	if(intergral_i == g_Sampling_N)
 		intergral_i = 0;
-
-
 }
 
 
 int OpenLoop (int sensorreading)
 {
-
-
 	int speed = 0;
 	float paramA= 0;
 	float paramB= 2; 
@@ -295,268 +280,220 @@ int OpenLoop (int sensorreading)
 	int Low_Amb = 20;
 	int Up_Amb = 40;
 	
-    if (sensorreading >= Up_Amb)
-    {
-    	speed = 100;
-		//printf("## Ambient >=%dC, the Fan duty is %d \n",Up_Amb,speed);	
-    }
-	else if (sensorreading <= Low_Amb)
-    {
-    	speed = 40;
-		//printf("## Ambient <=%dC, the Fan duty is %d \n",Low_Amb,speed);	
-    }
-	else
-	{
+	if (sensorreading >= Up_Amb) {
+		speed = 100;
+//		printf("## Ambient >=%dC, the Fan duty is %d \n",Up_Amb,speed);
+	} else if (sensorreading <= Low_Amb) {
+		speed = 40;
+//		printf("## Ambient <=%dC, the Fan duty is %d \n",Low_Amb,speed);
+	} else {
 		speed = ( paramA * sensorreading * sensorreading ) + ( paramB * sensorreading ) + paramC;
+
 		if(speed > 100)
-		{
 			speed = 100;
-		}	
+
 		if(speed < 40)
-		{
 			speed = 40;
-		}
-	//	printf("The Fan duty is %d \n",speed);
-
+//		printf("The Fan duty is %d \n",speed);
 	}
 
-	Openloopspeed=speed;
+	Openloopspeed = speed;
 
-return 0;
+	return 0;
 }
 
 
-
-
-int Fan_control_algorithm(void) {
-
-	sd_bus *bus;
-	sd_bus_slot *slot;
-	int r, Ambient_reading, rc,retry,i;
+int Fan_control_algorithm(void)
+{
+	sd_bus *bus = NULL;
+	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
+	sd_bus_message *response = NULL;
+	int Ambient_reading = 0, rc = 0, i = 0;
 	int CPU0_core_temperature[12];
 	int CPU1_core_temperature[12];
 	int DIMM_temperature[32];
 	int HighestCPUtemp = 0;
 	int HighestDIMMtemp = 0;
 	int CPUnocore[2];
-	int fd;
+	int fd = -1;
 	int FinalFanSpeed = 0;
-	int CPUtemp=0;
-	
-	r = -1;
-	while(r < 0) {
-	/* Connect to the user bus this time */
-	r = sd_bus_open_system(&bus);
-		if(r < 0){	
-			fprintf(stderr, "fan 1 Failed to connect to system bus: %s\n", strerror(-r));
-		sleep(1);
-			}
+	int CPUtemp = 0;
 	
+	do {
+		/* Connect to the user bus this time */
+		rc = sd_bus_open_system(&bus);
+		if(rc < 0) {
+			fprintf(stderr, "fan 1 Failed to connect to system bus: %s\n", strerror(-rc));
+			bus = sd_bus_flush_close_unref(bus);
+			sleep(1);
 		}
-	// SD Bus error report mechanism.
-	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
-	sd_bus_message *response = NULL, *m = NULL;;
-    sd_bus_error_free(&bus_error);
-    sd_bus_message_unref(response);
-
-
-while(1){
-  	fd = i2c_open();
-	CPUtemp=0;
-	for(i=0;i<12;i++){
-       sd_bus_error_free(&bus_error);
-
-        rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gCPU0ObjPath[i],            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-
-        if(rc < 0)
-        {
-            //fprintf(stderr, "gCPU0ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
-           // goto finish;
-           CPU0_core_temperature[i]=0;
-        }
-		else
-		{
-			rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
-			if (rc < 0 )
-			{ 
-         	 // fprintf(stderr, "gCPU0ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
-          // goto finish;
+	} while (rc < 0);
+
+	while (1) {
+		CPUtemp = 0;
+		for(i=0; i<12; i++) {
+			rc = sd_bus_call_method(bus,                   // On the System Bus
+						gService,               // Service to contact
+						gCPU0ObjPath[i],            // Object path
+						gIntPath,              // Interface name
+						"getValue",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(rc < 0) {
+//				fprintf(stderr, "gCPU0ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+				CPU0_core_temperature[i] = 0;
+			} else {
+				rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
+				if (rc < 0 ) {
+					fprintf(stderr, "gCPU0ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					CPU0_core_temperature[i] = 0;
+				}
 			}
+//			fprintf(stderr, "CPU0 core %d temperature is %d\n",i ,CPU0_core_temperature[i]);
+			if(CPU0_core_temperature[i] > HighestCPUtemp) {
+				HighestCPUtemp = CPU0_core_temperature[i];
+				CPUnocore[0] = 0;
+				CPUnocore[1] = i;
+			}
+			CPUtemp = CPUtemp + CPU0_core_temperature[i];
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
-	//printf("CPU0 core %d value=[%d] \n",i,CPU0_core_temperature[i]);
-	if(CPU0_core_temperature[i] > HighestCPUtemp )
-		{
-		HighestCPUtemp = CPU0_core_temperature[i];
-		CPUnocore[0]=0;
-		CPUnocore[1]=i;
-		}
-	CPUtemp=CPUtemp+CPU0_core_temperature[i];
-	}
-	
-	for(i=0;i<12;i++){
-       sd_bus_error_free(&bus_error);
-
-        rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gCPU1ObjPath[i],            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-
-        if(rc < 0)
-        {
-            //fprintf(stderr, "gCPU1ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
-			CPU1_core_temperature[i]=0;
-			//goto finish;
-        }
-		else
-		{
-		rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
-
-		}
-
 
-		if(CPU1_core_temperature[i] > HighestCPUtemp )
-		{
-		HighestCPUtemp = CPU1_core_temperature[i];
-		CPUnocore[0]=1;
-		CPUnocore[1]=i;
+		for(i=0; i<12; i++) {
+			rc = sd_bus_call_method(bus,                   // On the System Bus
+						gService,               // Service to contact
+						gCPU1ObjPath[i],            // Object path
+						gIntPath,              // Interface name
+						"getValue",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(rc < 0) {
+//				fprintf(stderr, "gCPU1ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+				CPU1_core_temperature[i] = 0;
+			} else {
+				rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
+				if (rc < 0 ) {
+					fprintf(stderr, "gCPU1ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					CPU1_core_temperature[i] = 0;
+				}
+			}
+//			fprintf(stderr, "CPU1 core %d temperature is %d\n",i ,CPU1_core_temperature[i]);
+			if(CPU1_core_temperature[i] > HighestCPUtemp ) {
+				HighestCPUtemp = CPU1_core_temperature[i];
+				CPUnocore[0] = 1;
+				CPUnocore[1] = i;
+			}
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
-
-	}
-
+//		fprintf(stderr, "Highest CPU temperature = [%d]\n", HighestCPUtemp);
 	
-	for(i=0;i<32;i++){
-       sd_bus_error_free(&bus_error);
-
-        rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gDIMMObjPath[i],            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-
-        if(rc < 0)
-        {
-  
-            DIMM_temperature[i]=0;
-        }
-		else
-		{
-		rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
-
-			if (rc < 0 )
-			{ 
-         	  fprintf(stderr, "gDIMMObjPath Failed to parse response message:[%s]\n", strerror(-rc));
-      
+		for(i=0; i<32; i++) {
+			rc = sd_bus_call_method(bus,                   // On the System Bus
+						gService,               // Service to contact
+						gDIMMObjPath[i],            // Object path
+						gIntPath,              // Interface name
+						"getValue",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(rc < 0) {
+//				fprintf(stderr, "gDIMMObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+				DIMM_temperature[i] = 0;
+			} else {
+				rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
+				if (rc < 0 ) {
+					fprintf(stderr, "gDIMMObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					DIMM_temperature[i] = 0;
+				}
 			}
-
+//			fprintf(stderr, "DIMM %d temperature is %d\n", i, DIMM_temperature[i]);
+			if(DIMM_temperature[i] > HighestDIMMtemp )
+				HighestDIMMtemp = DIMM_temperature[i];
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
+//		fprintf(stderr, "Highest DIMM temperature = [%d]\n",HighestDIMMtemp);
+
+		rc = sd_bus_call_method(bus,                   // On the System Bus
+					gService,               // Service to contact
+					gObjPath_Ambient,            // Object path
+					gIntPath,              // Interface name
+					"getValue",          // Method to be called
+					&bus_error,                 // object to return error
+					&response,                  // Response message on success
+					NULL);                       // input message (string,byte)
+		if(rc < 0) {
+//			fprintf(stderr, "fan2 Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			Ambient_reading = 0;
+		} else {
+			rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
+			if (rc < 0 ) {
+				fprintf(stderr, "fan3 Failed to parse response message:[%s]\n", strerror(-rc));
+				Ambient_reading = 0;
+			}
+		}
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+//		fprintf(stderr, "Highest ambient inlet temperature = [%d]\n", HighestCPUtemp);
 
-	if(DIMM_temperature[i] > HighestDIMMtemp )
-		HighestDIMMtemp = DIMM_temperature[i];
-	}
-	printf("Highest DIMM temperatur is value %d \n",HighestDIMMtemp);
-
-
-
-	sd_bus_error_free(&bus_error);
-     rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gObjPath_Ambient,            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-                                // NULL);                  // First argument to getObjectFromId
-                                //"BOARD_1");             // Second Argument
-
-        if(rc < 0)
-        {
-            fprintf(stderr, "fan2 Failed to resolve fruid to dbus: %s\n", bus_error.message);
-       
-        }
-
-	rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
-	if (rc < 0 )
-	{ 
-           fprintf(stderr, "fan3 Failed to parse response message:[%s]\n", strerror(-rc));
-  
-	}
-
-	  if (CPUtemp==0)
-	  	{
-		HighestCPUtemp=0;
-		HighestDIMMtemp=0;
-	  	}
-
-	CloseLoop(HighestCPUtemp,HighestDIMMtemp);
-	OpenLoop(Ambient_reading);
+		if (CPUtemp == 0)	{
+			HighestCPUtemp = 0;
+			HighestDIMMtemp = 0;
+		}
 
-	
+		CloseLoop(HighestCPUtemp,HighestDIMMtemp);
+		OpenLoop(Ambient_reading);
 
-		if(Openloopspeed>Closeloopspeed)
-		g_fanspeed=Openloopspeed;
+		if(Openloopspeed > Closeloopspeed)
+			g_fanspeed = Openloopspeed;
 		else
-		g_fanspeed=Closeloopspeed;
+			g_fanspeed = Closeloopspeed;
 	
-	if(g_fanspeed>30) 
-		SetFanLed(fd,1);
-	else
-		SetFanLed(fd,2);
-
-	FinalFanSpeed=g_fanspeed*255;
-	FinalFanSpeed=FinalFanSpeed/100;
-
-	if(HighestCPUtemp==0) //OCC sensor does not enable
-	{
-	FinalFanSpeed=255;
-	}
-
+		fd = i2c_open();
+		if (fd == -1) {
+			fprintf(stderr, "Fail to set FAN LED\n");
+		} else {
+			if(g_fanspeed > 30)
+				SetFanLed(fd,1);
+			else
+				SetFanLed(fd,2);
+			close(fd);
+		}
 
- 	for(i=0;i<6;i++){
-		
-		sd_bus_error_free(&bus_error);
-	rc = sd_bus_call_method(bus,				   // On the System Bus
-							   gService,			   // Service to contact
-							   fanObjPath[i],			// Object path
-							   gIntPath,			  // Interface name
-							   "setValue",			// Method to be called
-							   &bus_error,				   // object to return error
-							   &response,				   // Response message on success
-							   "i",						// input message (string,byte)
-							   FinalFanSpeed);                  // First argument
-
-	  if(rc < 0)
-        {
-            fprintf(stderr, "fanObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
-          //  goto finish;
-        }
-
-
- 	}
-
-	close(fd);
-	sleep(1);
+		FinalFanSpeed = g_fanspeed * 255;
+		FinalFanSpeed = FinalFanSpeed / 100;
+
+		if(HighestCPUtemp == 0) //OCC sensor does not enable
+			FinalFanSpeed = 255;
+
+		for(i=0; i<6; i++) {
+			rc = sd_bus_call_method(bus,				   // On the System Bus
+						gService,			   // Service to contact
+						fanObjPath[i],			// Object path
+						gIntPath,			  // Interface name
+						"setValue",			// Method to be called
+						&bus_error,				   // object to return error
+						&response,				   // Response message on success
+						"i",						// input message (string,byte)
+						FinalFanSpeed);                  // First argument
+			if(rc < 0)
+				fprintf(stderr, "fanObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
+		}
 	
-
-	finish:
-		sd_bus_unref(bus);
+finish:
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+		sd_bus_flush(bus);
 		sleep(1);
-}
-	return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+	}
+	bus = sd_bus_flush_close_unref(bus);
+	return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 
diff --git a/objects/info.c b/objects/info.c
index d872c3f..2b98dbb 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -17,7 +17,6 @@ const char *gIntPath_c = "org.openbmc.control.Chassis";
 //const char *chassis_iface = "org.openbmc.SensorValue";
 
 char *gMessage = NULL;
-sd_bus *bus = NULL;
 
 #define MAX_BYTES 255
 
@@ -32,323 +31,296 @@ uint8_t g_read_tmp[MAX_BYTES];
 uint8_t g_bus = -1;
 uint8_t g_slave_addr = 0xff;
 
-static int i2c_open() {
-  int fd;
-  char fn[32];
-  int rc;
-
-  g_bus = 6;
-  snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
-  fd = open(fn, O_RDWR);
-  if (fd == -1) {
-    LOG_ERR(errno, "Failed to open i2c device %s", fn);
-    close(fd);
-    return -1;
-  }
-
-  g_slave_addr = 0x4f;
-  rc = ioctl(fd, I2C_SLAVE, g_slave_addr);
-  if (rc < 0) {
-    LOG_ERR(errno, "Failed to open slave @ address 0x%x", g_slave_addr);
-    close(fd);
-  }
-
-  return fd;
+static int i2c_open()
+{
+	int rc = 0, fd = -1;
+	char fn[32];
+
+	g_bus = 6;
+	snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+	fd = open(fn, O_RDWR);
+	if (fd == -1) {
+		LOG_ERR(errno, "Failed to open i2c device %s", fn);
+		close(fd);
+		return -1;
+	}
+
+	g_slave_addr = 0x4f;
+
+	rc = ioctl(fd, I2C_SLAVE, g_slave_addr);
+	if (rc < 0) {
+		LOG_ERR(errno, "Failed to open slave @ address 0x%x", g_slave_addr);
+		close(fd);
+	}
+
+	return fd;
 }
 
 static int i2c_io(int fd) {
-  struct i2c_rdwr_ioctl_data data;
-  struct i2c_msg msg[2];
-  int n_msg = 0;
-  int rc;
-
-  memset(&msg, 0, sizeof(msg));
-
-  g_slave_addr = 0x5f;
-  g_use_pec = 0;
-  g_n_write = 3;
-  g_write_bytes[0] = 0xfc;
-  g_write_bytes[1] = 0x3;
-  g_write_bytes[2] = 0x0;
-  
-
-  g_n_read = 5;
-  
-
-  if (1) {
-    msg[n_msg].addr = g_slave_addr;
-    msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
-    msg[n_msg].len = g_n_write;
-    msg[n_msg].buf = g_write_bytes;
-    n_msg++;
-  }
-
-  if (1) {
-    msg[n_msg].addr = g_slave_addr;
-    msg[n_msg].flags = I2C_M_RD
-      | ((g_use_pec) ? I2C_CLIENT_PEC : 0)
-      | ((g_n_read == 0) ? I2C_M_RECV_LEN : 0);
-    /*
-     * In case of g_n_read is 0, block length will be added by
-     * the underlying bus driver.
-     */
-    msg[n_msg].len = (g_n_read) ? g_n_read : 256;
-    msg[n_msg].buf = g_read_bytes;
-    if (g_n_read == 0) {
-      /* If we're using variable length block reads, we have to set the
-       * first byte of the buffer to at least one or the kernel complains.
-       */
-      g_read_bytes[0] = 1;
-    }
-    n_msg++;
-  }
-
-  data.msgs = msg;
-  data.nmsgs = n_msg;
-
-  rc = ioctl(fd, I2C_RDWR, &data);
-  if (rc < 0) {
-    LOG_ERR(errno, "Failed to do raw io");
-    close(fd);
-    return -1;
-  }
-
-  return 0;
+	struct i2c_rdwr_ioctl_data data;
+	  struct i2c_msg msg[2];
+	int rc = 0, n_msg = 0;
+
+	memset(&msg, 0, sizeof(msg));
+
+	g_slave_addr = 0x5f;
+	g_use_pec = 0;
+	g_n_write = 3;
+	g_write_bytes[0] = 0xfc;
+	g_write_bytes[1] = 0x3;
+	g_write_bytes[2] = 0x0;
+	g_n_read = 5;
+
+	if (1) {
+		msg[n_msg].addr = g_slave_addr;
+		msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
+		msg[n_msg].len = g_n_write;
+		msg[n_msg].buf = g_write_bytes;
+		n_msg++;
+	}
+
+	if (1) {
+		msg[n_msg].addr = g_slave_addr;
+		msg[n_msg].flags = I2C_M_RD | ((g_use_pec) ? I2C_CLIENT_PEC : 0)
+					| ((g_n_read == 0) ? I2C_M_RECV_LEN : 0);
+		/*
+		* In case of g_n_read is 0, block length will be added by
+		* the underlying bus driver.
+		*/
+		msg[n_msg].len = (g_n_read) ? g_n_read : 256;
+		msg[n_msg].buf = g_read_bytes;
+		if (g_n_read == 0) {
+			/* If we're using variable length block reads, we have to set the
+			* first byte of the buffer to at least one or the kernel complains.
+			*/
+			g_read_bytes[0] = 1;
+		}
+		n_msg++;
+	  }
+
+	data.msgs = msg;
+	data.nmsgs = n_msg;
+
+	rc = ioctl(fd, I2C_RDWR, &data);
+	if (rc < 0) {
+		LOG_ERR(errno, "Failed to do raw io");
+		close(fd);
+		return -1;
+	}
+
+	return 0;
 }
 
 int get_hdd_status(void)
 {
-  int fd, i;
-  char *test;
-  test="Ken";
-  char str[10];
-  fd = i2c_open();
-  if (fd < 0) {
-    return -1;
-  }
-
-  if (i2c_io(fd) < 0) {
-    close(fd);
-    return -1;
-  }
-
-    //printf("Received:\n ");
-    if (g_n_read == 0) {
-      g_n_read = g_read_bytes[0] + 1;
-    }
-    for (i = 0; i < g_n_read; i++) {
-      //printf(" 0x%x", g_read_bytes[i]);
-    }
-    if ((g_read_tmp[2]!=g_read_bytes[2])||(g_read_tmp[3]!=g_read_bytes[3]))
-    {
-    sprintf(str, "HDD change:0x%x,0x%x", g_read_bytes[2], g_read_bytes[3]);
-   
-	send_esel_to_dbus(str, "Low", "assoc", "hack", 3);
-    }
-
-    g_read_tmp[2]=g_read_bytes[2];
-    g_read_tmp[3]=g_read_bytes[3];
-    close(fd);
-}
+	int fd = -1, i = 0;
+	char *test = NULL;
+	test = "Ken";
+	char str[10];
+
+	fd = i2c_open();
+	if (fd < 0)
+		return -1;
+
+	if (i2c_io(fd) < 0) {
+		close(fd);
+		return -1;
+	}
 
-int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) {
+//	printf("Received:\n ");
+	if (g_n_read == 0)
+		g_n_read = g_read_bytes[0] + 1;
 
+#if 0
+	for (i = 0; i < g_n_read; i++)
+		printf(" 0x%x", g_read_bytes[i]);
+#endif
+
+	if ((g_read_tmp[2] != g_read_bytes[2]) || (g_read_tmp[3] != g_read_bytes[3])) {
+		sprintf(str, "HDD change:0x%x,0x%x", g_read_bytes[2], g_read_bytes[3]);
+		send_esel_to_dbus(str, "Low", "assoc", "hack", 3);
+	}
+
+	g_read_tmp[2]=g_read_bytes[2];
+	g_read_tmp[3]=g_read_bytes[3];
+	close(fd);
+}
+
+int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen)
+{
 	sd_bus *mbus = NULL;
-    sd_bus_error error = SD_BUS_ERROR_NULL;
-    sd_bus_message *reply = NULL, *m=NULL;
-    uint16_t x;
-    int r;
-	sd_bus_error_free(&error);
+	sd_bus_error error = SD_BUS_ERROR_NULL;
+	sd_bus_message *reply = NULL, *m = NULL;
+	uint16_t value = 0;
+	int ret = 0;
+
+	fprintf(stderr,"add sel\n");
+	ret = sd_bus_open_system(&mbus);
+	if (ret < 0) {
+		fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-ret));
+		goto finish;
+	}
 
-	printf("add sel\n");
- 	r = sd_bus_open_system(&mbus);
-	if (r < 0) {
-		fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+	ret = sd_bus_message_new_method_call(mbus,&m,
+						"org.openbmc.records.events",
+						"/org/openbmc/records/events",
+						"org.openbmc.recordlog",
+						"acceptHostMessage");
+	if (ret < 0) {
+		fprintf(stderr, "Failed to add the method object: %s\n", strerror(-ret));
 		goto finish;
 	}
 
-    r = sd_bus_message_new_method_call(mbus,&m,
-    									"org.openbmc.records.events",
-    									"/org/openbmc/records/events",
-    									"org.openbmc.recordlog",
-    									"acceptHostMessage");
-    if (r < 0) {
-        fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
-        goto finish;
-    }
-
-    r = sd_bus_message_append(m, "sss", desc, sev, details);
-    if (r < 0) {
-        fprintf(stderr, "Failed add the message strings : %s\n", strerror(-r));
-        goto finish;
-    }
-
-    r = sd_bus_message_append_array(m, 'y', debug, debuglen);
-    if (r < 0) {
-        fprintf(stderr, "Failed to add the raw array of bytes: %s\n", strerror(-r));
-        goto finish;
-    }
-    // Call the IPMI responder on the bus so the message can be sent to the CEC
-    r = sd_bus_call(mbus, m, 0, &error, &reply);
-    if (r < 0) {
-        fprintf(stderr, "Failed to call the method: %s %s\n", __FUNCTION__, strerror(-r));
-        goto finish;
-    }
-    r = sd_bus_message_read(reply, "q", &x);
-    if (r < 0) {
-        fprintf(stderr, "Failed to get a rc from the method: %s\n", strerror(-r));
-    }
+	ret = sd_bus_message_append(m, "sss", desc, sev, details);
+	if (ret < 0) {
+		fprintf(stderr, "Failed add the message strings : %s\n", strerror(-ret));
+		goto finish;
+	}
+
+	ret = sd_bus_message_append_array(m, 'y', debug, debuglen);
+	if (ret < 0) {
+		fprintf(stderr, "Failed to add the raw array of bytes: %s\n", strerror(-ret));
+		goto finish;
+	}
+
+	// Call the IPMI responder on the bus so the message can be sent to the CEC
+	ret = sd_bus_call(mbus, m, 0, &error, &reply);
+	if (ret < 0) {
+		fprintf(stderr, "Failed to call the method: %s %s\n", __FUNCTION__, strerror(-ret));
+		goto finish;
+	}
+	ret = sd_bus_message_read(reply, "q", &value);
+	if (ret < 0) {
+		fprintf(stderr, "Failed to get a rc from the method: %s\n", strerror(-ret));
+	}
 
 finish:
-    sd_bus_error_free(&error);
-    sd_bus_message_unref(m);
-    sd_bus_message_unref(reply);
-    return r;	
+	sd_bus_error_free(&error);
+	m = sd_bus_message_unref(m);
+	reply = sd_bus_message_unref(reply);
+	mbus = sd_bus_flush_close_unref(mbus);
+	return ret;
 }
-int start_system_information(void) {
-
-	sd_bus *bus;
-	sd_bus_slot *slot;
-	int r, x, rc,retry;
-	char *OccStatus;
-    r = -1;
-	while(r < 0) {
+
+int start_system_information(void)
+{
+	sd_bus *bus = NULL;
+	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
+	sd_bus_message *response = NULL;
+	int ret = 0, value = 0;
+	char *OccStatus = NULL;
+
 	/* Connect to the user bus this time */
-	r = sd_bus_open_system(&bus);
-		if(r < 0){	
-			fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+	do {
+		ret = sd_bus_open_system(&bus);
+		if(ret < 0) {
+			fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-ret));
+			bus = sd_bus_flush_close_unref(bus);
+		}
 		sleep(1);
-			}
-	//	goto finish;
+	} while (ret < 0);
 	
+	while (1) {
+		ret = sd_bus_call_method(bus,                   // On the System Bus
+					gService_c,               // Service to contact
+					gObjPath_c,            // Object path
+					gIntPath_c,              // Interface name
+					"getPowerState",          // Method to be called
+					&bus_error,                 // object to return error
+					&response,                  // Response message on success
+					NULL);                       // input message (string,byte)
+		if(ret < 0) {
+//			fprintf(stderr, "Failed to resolve getPowerState to dbus: %s\n", bus_error.message);
+			goto finish;
 		}
-	// SD Bus error report mechanism.
-	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
-	sd_bus_message *response = NULL, *m = NULL;;
-        sd_bus_error_free(&bus_error);
-        sd_bus_message_unref(response);
-//		send_esel_to_dbus("desc", "sev", "assoc", "hack", 3);
-
-while(1){
-       sd_bus_error_free(&bus_error);
-
-
-	   
-       rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService_c,               // Service to contact
-                                gObjPath_c,            // Object path
-                                gIntPath_c,              // Interface name
-                                "getPowerState",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-                                // NULL);                  // First argument to getObjectFromId
-                                //"BOARD_1");             // Second Argument
-        if(rc < 0)
-        {
-            fprintf(stderr, "Failed to resolve getPowerState to dbus: %s\n", bus_error.message);
-	    r = sd_bus_open_system(&bus);
-                if(r < 0){
-                        fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
-                        sleep(1);
-                        }
-
-            goto finish;
-        }
-
-        rc = sd_bus_message_read(response, "i", &x);
-        if (rc < 0 )
-        {
-           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
-           goto finish;
-        }
-        printf("PowerState value=[%d] \n",x);
-	if (x == 0 ) goto finish;
-	get_hdd_status();	
-        sleep(1);
-       sd_bus_error_free(&bus_error);
-       rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gObjPath_o,            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-                                // NULL);                  // First argument to getObjectFromId
-                                //"BOARD_1");             // Second Argument
-        if(rc < 0)
-        {
-            fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
-            goto finish;
-        }
-
-        rc = sd_bus_message_read(response, "v","s", &OccStatus);
-        if (rc < 0 )
-        {
-           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
-           goto finish;
-        }
-        printf("OCCtate value=[%s][%d] \n",OccStatus,strcmp(OccStatus, "Disable"));
+
+		ret = sd_bus_message_read(response, "i", &value);
+		if (ret < 0 ) {
+			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			goto finish;
+		}
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+//		fprintf(stderr,"PowerState value = [%d] \n",value);
+		if (value == 0 )
+			goto finish;
 	
-        if (strcmp(OccStatus, "Disable") != 1 ) goto finish;
-
-        rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService,               // Service to contact
-                                gObjPath,            // Object path
-                                gIntPath,              // Interface name
-                                "getValue",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-                                // NULL);                  // First argument to getObjectFromId
-                                //"BOARD_1");             // Second Argument
-
-        if(rc < 0)
-        {
-            fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
-            goto finish;
-        }
-
-	rc = sd_bus_message_read(response, "v","i", &x);
-	if (rc < 0 )
-	{ 
-           fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
-           goto finish;
-	}
-	printf("CPU value=[%d] \n",x);
-
-	if(x >= 90)
-	{
-	//printf("====Ken poweroff==== \n");
-	send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
-	sd_bus_error_free(&bus_error);
-        rc = sd_bus_call_method(bus,                   // On the System Bus
-                                gService_c,               // Service to contact
-                                gObjPath_c,            // Object path
-                                gIntPath_c,              // Interface name
-                                "powerOff",          // Method to be called
-                                &bus_error,                 // object to return error
-                                &response,                  // Response message on success
-                                NULL);                       // input message (string,byte)
-                                // NULL);                  // First argument to getObjectFromId
-                                //"BOARD_1");             // Second Argument
-
-        if(rc < 0)
-        {
-            fprintf(stderr, "Failed to resolve poweroff to dbus: %s\n", bus_error.message);
-            goto finish;
-        }
+		get_hdd_status();
 
-	}
+		sleep(1);
+
+		ret = sd_bus_call_method(bus,                   // On the System Bus
+					gService,               // Service to contact
+					gObjPath_o,            // Object path
+					gIntPath,              // Interface name
+					"getValue",          // Method to be called
+					&bus_error,                 // object to return error
+					&response,                  // Response message on success
+					NULL);                       // input message (string,byte)
+		if(ret < 0) {
+			fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			goto finish;
+		}
+		ret = sd_bus_message_read(response, "v","s", &OccStatus);
+		if (ret < 0 ) {
+			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			goto finish;
+		}
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+		fprintf(stderr,"OCCState value = [%s][%d] \n",OccStatus,strcmp(OccStatus, "Disable"));
+		if (strcmp(OccStatus, "Disable") != 1 )
+			goto finish;
+
+		ret = sd_bus_call_method(bus,                   // On the System Bus
+					gService,               // Service to contact
+					gObjPath,            // Object path
+					gIntPath,              // Interface name
+					"getValue",          // Method to be called
+					&bus_error,                 // object to return error
+					&response,                  // Response message on success
+					NULL);                       // input message (string,byte)
+		if(ret < 0) {
+			fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			goto finish;
+		}
+		ret = sd_bus_message_read(response, "v","i", &value);
+		if (ret < 0 ) {
+			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			goto finish;
+		}
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+		fprintf(stderr,"CPU value = [%d] \n",value);
+		if(value >= 90) {
+			//printf("====Ken poweroff==== \n");
+			send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
+
+			ret = sd_bus_call_method(bus,                   // On the System Bus
+						gService_c,               // Service to contact
+						gObjPath_c,            // Object path
+						gIntPath_c,              // Interface name
+						"powerOff",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+
+			if(ret < 0) {
+				fprintf(stderr, "Failed to resolve poweroff to dbus: %s\n", bus_error.message);
+				goto finish;
+			}
+			sd_bus_error_free(&bus_error);
+		}
 	
-	sleep(1);
-///		sd_bus_unref(bus);
-	finish:
-		sd_bus_unref(bus);
+finish:
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+		sd_bus_flush(bus);
 		sleep(1);
-}
-	return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+	}
+
+	bus = sd_bus_flush_close_unref(bus);
+	return ret < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 16/20] Support FAN tach sensors
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (14 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 15/20] Fix memory leak OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 17/20] Generate thermaltrip event OpenBMC Patches
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

1. Support FAN tach sensors
2. Remove shut down action from info.
   It'll be done by Emergency ShutDown.
---
 bin/Barreleye.py        | 24 ++++++++++++++++++------
 objects/fan_algorithm.c | 20 ++++++++++----------
 objects/info.c          | 35 +++++++++--------------------------
 3 files changed, 37 insertions(+), 42 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index e05d985..8570db3 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -581,9 +581,15 @@ HWMON_CONFIG = {
 	},
 	'6-002d' : {
 		'names' : {
-			'pwm1' : { 'object_path' : 'speed/fan0','poll_interval' : 10000,'scale' : 1,'units' : '' },
-			'pwm2' : { 'object_path' : 'speed/fan1','poll_interval' : 10000,'scale' : 1,'units' : '' },
-                        'pwm3' : { 'object_path' : 'speed/fan2','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm1' : { 'object_path' : 'speed/fan5','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm2' : { 'object_path' : 'speed/fan4','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm3' : { 'object_path' : 'speed/fan3','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan1_input' : { 'object_path' : 'tach/fan5L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan2_input' : { 'object_path' : 'tach/fan5H','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan3_input' : { 'object_path' : 'tach/fan4L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan4_input' : { 'object_path' : 'tach/fan4H','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan5_input' : { 'object_path' : 'tach/fan3L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan6_input' : { 'object_path' : 'tach/fan3H','poll_interval' : 10000,'scale' : 1,'units' : '' },
                         'in1_input' : { 'object_path' : 'voltage/P1V35_CPU0_BUF4','poll_interval' : 10000,'scale' : 1,'units' : '' },
                         'in2_input' : { 'object_path' : 'voltage/P0V9_CPU0_BUF1','poll_interval' : 10000,'scale' : 1,'units' : '' },
                         'in3_input' : { 'object_path' : 'voltage/P0V9_CPU0_BUF2','poll_interval' : 10000,'scale' : 1,'units' : '' },
@@ -602,9 +608,15 @@ HWMON_CONFIG = {
 	},
 	'6-002e' : {
 		'names' : {
-			'pwm1' : { 'object_path' : 'speed/fan3','poll_interval' : 10000,'scale' : 1,'units' : '' },
-			'pwm2' : { 'object_path' : 'speed/fan4','poll_interval' : 10000,'scale' : 1,'units' : '' },
-			'pwm3' : { 'object_path' : 'speed/fan5','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm1' : { 'object_path' : 'speed/fan2','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm2' : { 'object_path' : 'speed/fan1','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'pwm3' : { 'object_path' : 'speed/fan0','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan1_input' : { 'object_path' : 'tach/fan2L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan2_input' : { 'object_path' : 'tach/fan2H','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan3_input' : { 'object_path' : 'tach/fan1L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan4_input' : { 'object_path' : 'tach/fan1H','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan5_input' : { 'object_path' : 'tach/fan0L','poll_interval' : 10000,'scale' : 1,'units' : '' },
+			'fan6_input' : { 'object_path' : 'tach/fan0H','poll_interval' : 10000,'scale' : 1,'units' : '' },
    			'in1_input' : { 'object_path' : 'voltage/P1V35_CPU1_BUF4','poll_interval' : 10000,'scale' : 1,'units' : '' },
                         'in2_input' : { 'object_path' : 'voltage/P0V9_CPU1_BUF1','poll_interval' : 10000,'scale' : 1,'units' : '' },
                         'in3_input' : { 'object_path' : 'voltage/P0V9_CPU1_BUF2','poll_interval' : 10000,'scale' : 1,'units' : '' },
diff --git a/objects/fan_algorithm.c b/objects/fan_algorithm.c
index 1077d55..9665860 100755
--- a/objects/fan_algorithm.c
+++ b/objects/fan_algorithm.c
@@ -323,7 +323,7 @@ int Fan_control_algorithm(void)
 		/* Connect to the user bus this time */
 		rc = sd_bus_open_system(&bus);
 		if(rc < 0) {
-			fprintf(stderr, "fan 1 Failed to connect to system bus: %s\n", strerror(-rc));
+			fprintf(stderr, "Failed to connect to system bus for fan_algorithm: %s\n", strerror(-rc));
 			bus = sd_bus_flush_close_unref(bus);
 			sleep(1);
 		}
@@ -341,12 +341,12 @@ int Fan_control_algorithm(void)
 						&response,                  // Response message on success
 						NULL);                       // input message (string,byte)
 			if(rc < 0) {
-//				fprintf(stderr, "gCPU0ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+//				fprintf(stderr, "Failed to get CPU 0 temperature from dbus: %s\n", bus_error.message);
 				CPU0_core_temperature[i] = 0;
 			} else {
 				rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
 				if (rc < 0 ) {
-					fprintf(stderr, "gCPU0ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					fprintf(stderr, "Failed to parse GetCpu0Temp response message:[%s]\n", strerror(-rc));
 					CPU0_core_temperature[i] = 0;
 				}
 			}
@@ -371,12 +371,12 @@ int Fan_control_algorithm(void)
 						&response,                  // Response message on success
 						NULL);                       // input message (string,byte)
 			if(rc < 0) {
-//				fprintf(stderr, "gCPU1ObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+//				fprintf(stderr, "Failed to get CPU 1 temperature from dbus: %s\n", bus_error.message);
 				CPU1_core_temperature[i] = 0;
 			} else {
 				rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
 				if (rc < 0 ) {
-					fprintf(stderr, "gCPU1ObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					fprintf(stderr, "Failed to parse GetCpu1Temp response message:[%s]\n", strerror(-rc));
 					CPU1_core_temperature[i] = 0;
 				}
 			}
@@ -401,12 +401,12 @@ int Fan_control_algorithm(void)
 						&response,                  // Response message on success
 						NULL);                       // input message (string,byte)
 			if(rc < 0) {
-//				fprintf(stderr, "gDIMMObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+//				fprintf(stderr, "Failed to get DIMM temperature from dbus: %s\n", bus_error.message);
 				DIMM_temperature[i] = 0;
 			} else {
 				rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
 				if (rc < 0 ) {
-					fprintf(stderr, "gDIMMObjPath Failed to parse response message:[%s]\n", strerror(-rc));
+					fprintf(stderr, "Failed to parse GetDimmTemp response message:[%s]\n", strerror(-rc));
 					DIMM_temperature[i] = 0;
 				}
 			}
@@ -427,12 +427,12 @@ int Fan_control_algorithm(void)
 					&response,                  // Response message on success
 					NULL);                       // input message (string,byte)
 		if(rc < 0) {
-//			fprintf(stderr, "fan2 Failed to resolve fruid to dbus: %s\n", bus_error.message);
+//			fprintf(stderr, "Failed to get ambient temperature from dbus: %s\n", bus_error.message);
 			Ambient_reading = 0;
 		} else {
 			rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
 			if (rc < 0 ) {
-				fprintf(stderr, "fan3 Failed to parse response message:[%s]\n", strerror(-rc));
+				fprintf(stderr, "Failed to parse GetDimmTemp response message:[%s]\n", strerror(-rc));
 				Ambient_reading = 0;
 			}
 		}
@@ -481,7 +481,7 @@ int Fan_control_algorithm(void)
 						"i",						// input message (string,byte)
 						FinalFanSpeed);                  // First argument
 			if(rc < 0)
-				fprintf(stderr, "fanObjPath Failed to resolve fruid to dbus: %s\n", bus_error.message);
+				fprintf(stderr, "Failed to adjust fan speed via dbus: %s\n", bus_error.message);
 			sd_bus_error_free(&bus_error);
 			response = sd_bus_message_unref(response);
 		}
diff --git a/objects/info.c b/objects/info.c
index 2b98dbb..8e08974 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -154,7 +154,7 @@ int send_esel_to_dbus(const char *desc, const char *sev, const char *details, ui
 	uint16_t value = 0;
 	int ret = 0;
 
-	fprintf(stderr,"add sel\n");
+	fprintf(stderr,"Add SEL due to Thermal Trip\n");
 	ret = sd_bus_open_system(&mbus);
 	if (ret < 0) {
 		fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-ret));
@@ -214,7 +214,7 @@ int start_system_information(void)
 	do {
 		ret = sd_bus_open_system(&bus);
 		if(ret < 0) {
-			fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-ret));
+			fprintf(stderr, "Failed to connect to system bus for info: %s\n", strerror(-ret));
 			bus = sd_bus_flush_close_unref(bus);
 		}
 		sleep(1);
@@ -230,13 +230,13 @@ int start_system_information(void)
 					&response,                  // Response message on success
 					NULL);                       // input message (string,byte)
 		if(ret < 0) {
-//			fprintf(stderr, "Failed to resolve getPowerState to dbus: %s\n", bus_error.message);
+			fprintf(stderr, "Failed to get power state from dbus: %s\n", bus_error.message);
 			goto finish;
 		}
 
 		ret = sd_bus_message_read(response, "i", &value);
 		if (ret < 0 ) {
-			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			fprintf(stderr, "Failed to parse GetPowerState response message:[%s]\n", strerror(-ret));
 			goto finish;
 		}
 		sd_bus_error_free(&bus_error);
@@ -258,12 +258,12 @@ int start_system_information(void)
 					&response,                  // Response message on success
 					NULL);                       // input message (string,byte)
 		if(ret < 0) {
-			fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			fprintf(stderr, "Failed to get OCC state from dbus: %s\n", bus_error.message);
 			goto finish;
 		}
 		ret = sd_bus_message_read(response, "v","s", &OccStatus);
 		if (ret < 0 ) {
-			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			fprintf(stderr, "Failed to parse GetOccState response message:[%s]\n", strerror(-ret));
 			goto finish;
 		}
 		sd_bus_error_free(&bus_error);
@@ -281,36 +281,19 @@ int start_system_information(void)
 					&response,                  // Response message on success
 					NULL);                       // input message (string,byte)
 		if(ret < 0) {
-			fprintf(stderr, "Failed to resolve fruid to dbus: %s\n", bus_error.message);
+			fprintf(stderr, "Failed to get CPU core0 temperature from dbus: %s\n", bus_error.message);
 			goto finish;
 		}
 		ret = sd_bus_message_read(response, "v","i", &value);
 		if (ret < 0 ) {
-			fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-ret));
+			fprintf(stderr, "Failed to parse GetCpuCore0Temp response message:[%s]\n", strerror(-ret));
 			goto finish;
 		}
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
 		fprintf(stderr,"CPU value = [%d] \n",value);
-		if(value >= 90) {
-			//printf("====Ken poweroff==== \n");
+		if(value >= 90)
 			send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
-
-			ret = sd_bus_call_method(bus,                   // On the System Bus
-						gService_c,               // Service to contact
-						gObjPath_c,            // Object path
-						gIntPath_c,              // Interface name
-						"powerOff",          // Method to be called
-						&bus_error,                 // object to return error
-						&response,                  // Response message on success
-						NULL);                       // input message (string,byte)
-
-			if(ret < 0) {
-				fprintf(stderr, "Failed to resolve poweroff to dbus: %s\n", bus_error.message);
-				goto finish;
-			}
-			sd_bus_error_free(&bus_error);
-		}
 	
 finish:
 		sd_bus_error_free(&bus_error);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 17/20] Generate thermaltrip event
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (15 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 16/20] Support FAN tach sensors OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:22   ` Stewart Smith
  2016-04-15  7:01 ` [PATCH skeleton v6 18/20] Keep original design to generate " OpenBMC Patches
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

Keep the original design from v2.10
---
 objects/info.c | 121 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 26 deletions(-)

diff --git a/objects/info.c b/objects/info.c
index 8e08974..386133c 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -6,9 +6,37 @@
 #include "i2c-dev.h"
 #include "log.h"
 
+
+#define NUM_CPU_CORE	12
+
 const char *gService = "org.openbmc.Sensors";
-const char *gObjPath = "/org/openbmc/sensors/temperature/cpu0/core0";
-const char *gObjPath_o = "/org/openbmc/sensors/host/OccStatus";
+const char *gCPU0ObjPath[NUM_CPU_CORE] = {"/org/openbmc/sensors/temperature/cpu0/core0",
+						"/org/openbmc/sensors/temperature/cpu0/core1",
+						"/org/openbmc/sensors/temperature/cpu0/core2",
+						"/org/openbmc/sensors/temperature/cpu0/core3",
+						"/org/openbmc/sensors/temperature/cpu0/core4",
+						"/org/openbmc/sensors/temperature/cpu0/core5",
+						"/org/openbmc/sensors/temperature/cpu0/core6",
+						"/org/openbmc/sensors/temperature/cpu0/core7",
+						"/org/openbmc/sensors/temperature/cpu0/core8",
+						"/org/openbmc/sensors/temperature/cpu0/core9",
+						"/org/openbmc/sensors/temperature/cpu0/core10",
+						"/org/openbmc/sensors/temperature/cpu0/core11"};
+
+const char *gCPU1ObjPath[NUM_CPU_CORE] = {"/org/openbmc/sensors/temperature/cpu1/core0",
+						"/org/openbmc/sensors/temperature/cpu1/core1",
+						"/org/openbmc/sensors/temperature/cpu1/core2",
+						"/org/openbmc/sensors/temperature/cpu1/core3",
+						"/org/openbmc/sensors/temperature/cpu1/core4",
+						"/org/openbmc/sensors/temperature/cpu1/core5",
+						"/org/openbmc/sensors/temperature/cpu1/core6",
+						"/org/openbmc/sensors/temperature/cpu1/core7",
+						"/org/openbmc/sensors/temperature/cpu1/core8",
+						"/org/openbmc/sensors/temperature/cpu1/core9",
+						"/org/openbmc/sensors/temperature/cpu1/core10",
+						"/org/openbmc/sensors/temperature/cpu1/core11"};
+
+const char *gObjPath_o = "/org/openbmc/sensors/host/cpu0/OccStatus";
 const char *gIntPath = "org.openbmc.SensorValue";
 
 const char *gService_c = "org.openbmc.control.Chassis";
@@ -207,7 +235,7 @@ int start_system_information(void)
 	sd_bus *bus = NULL;
 	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
 	sd_bus_message *response = NULL;
-	int ret = 0, value = 0;
+	int ret = 0, value = 0, i = 0, HighestCPUtemp = 0, thermaltrip_lock = 0;
 	char *OccStatus = NULL;
 
 	/* Connect to the user bus this time */
@@ -242,13 +270,16 @@ int start_system_information(void)
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
 //		fprintf(stderr,"PowerState value = [%d] \n",value);
-		if (value == 0 )
+		if (value == 0 ) {
+			thermaltrip_lock = 0;
 			goto finish;
+		} else {
+			if (thermaltrip_lock == 1)	//probabily log two thermaltrip events, so block by this flag
+				goto finish;
+		}
 	
 		get_hdd_status();
 
-		sleep(1);
-
 		ret = sd_bus_call_method(bus,                   // On the System Bus
 					gService,               // Service to contact
 					gObjPath_o,            // Object path
@@ -268,37 +299,75 @@ int start_system_information(void)
 		}
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
-		fprintf(stderr,"OCCState value = [%s][%d] \n",OccStatus,strcmp(OccStatus, "Disable"));
+//		fprintf(stderr,"OCCState value = [%s][%d] \n",OccStatus,strcmp(OccStatus, "Disable"));
 		if (strcmp(OccStatus, "Disable") != 1 )
 			goto finish;
 
-		ret = sd_bus_call_method(bus,                   // On the System Bus
-					gService,               // Service to contact
-					gObjPath,            // Object path
-					gIntPath,              // Interface name
-					"getValue",          // Method to be called
-					&bus_error,                 // object to return error
-					&response,                  // Response message on success
-					NULL);                       // input message (string,byte)
-		if(ret < 0) {
-			fprintf(stderr, "Failed to get CPU core0 temperature from dbus: %s\n", bus_error.message);
-			goto finish;
+		for(i=0; i<NUM_CPU_CORE; i++) {
+			ret = sd_bus_call_method(bus,                   // On the System Bus
+						gService,               // Service to contact
+						gCPU0ObjPath[i],            // Object path
+						gIntPath,              // Interface name
+						"getValue",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(ret < 0) {
+//				fprintf(stderr, "Failed to get CPU 0 temperature from dbus: %s\n", bus_error.message);
+				value = 0;
+			} else {
+				ret = sd_bus_message_read(response, "v","i", &value);
+				if (ret < 0 ) {
+					fprintf(stderr, "Failed to parse GetCpu0Temp response message:[%s]\n", strerror(-ret));
+					value = 0;
+				}
+			}
+//			fprintf(stderr, "CPU0 core %d temperature is %d\n",i ,value);
+			if(value > HighestCPUtemp)
+				HighestCPUtemp = value;
+
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
-		ret = sd_bus_message_read(response, "v","i", &value);
-		if (ret < 0 ) {
-			fprintf(stderr, "Failed to parse GetCpuCore0Temp response message:[%s]\n", strerror(-ret));
-			goto finish;
+
+		for(i=0; i<NUM_CPU_CORE; i++) {
+			ret = sd_bus_call_method(bus,                   // On the System Bus
+						gService,               // Service to contact
+						gCPU1ObjPath[i],            // Object path
+						gIntPath,              // Interface name
+						"getValue",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(ret < 0) {
+//				fprintf(stderr, "Failed to get CPU 1 temperature from dbus: %s\n", bus_error.message);
+				value = 0;
+			} else {
+				ret = sd_bus_message_read(response, "v","i", &value);
+				if (ret < 0 ) {
+					fprintf(stderr, "Failed to parse GetCpu1Temp response message:[%s]\n", strerror(-ret));
+					value = 0;
+				}
+			}
+//			fprintf(stderr, "CPU1 core %d temperature is %d\n",i ,value);
+			if(value > HighestCPUtemp )
+				HighestCPUtemp = value;
+
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
-		sd_bus_error_free(&bus_error);
-		response = sd_bus_message_unref(response);
-		fprintf(stderr,"CPU value = [%d] \n",value);
-		if(value >= 90)
+//		fprintf(stderr, "Highest CPU temperature = [%d]\n", HighestCPUtemp);
+
+		if(HighestCPUtemp >= 90) {
+			thermaltrip_lock = 1;
 			send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
+		}
 	
 finish:
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
 		sd_bus_flush(bus);
+		HighestCPUtemp = 0;
 		sleep(1);
 	}
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 18/20] Keep original design to generate thermaltrip event
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (16 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 17/20] Generate thermaltrip event OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 19/20] Support FAN LED feature OpenBMC Patches
  2016-04-15  7:01 ` [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor" OpenBMC Patches
  19 siblings, 0 replies; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

The shutdown action have to execute by info instead of emergency
shutdown, otherwise probably can't log the event in time.
So disable emergency for all CPU core in Barreleye.py.

The bast implementation is do log in EmergencyShutdown function.
Improve in the future.
---
 bin/Barreleye.py | 48 ++++++++++++++++++++++++------------------------
 objects/info.c   | 19 ++++++++++++++++++-
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index dc7b14a..86a5a97 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -649,29 +649,29 @@ HWMON_CONFIG = {
 		},
 		'labels' : {
 		'176' :  { 'object_path' : 'temperature/cpu0/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'177' :  { 'object_path' : 'temperature/cpu0/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'178' :  { 'object_path' : 'temperature/cpu0/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'179' :  { 'object_path' : 'temperature/cpu0/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'180' :  { 'object_path' : 'temperature/cpu0/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'181' :  { 'object_path' : 'temperature/cpu0/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'182' :  { 'object_path' : 'temperature/cpu0/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'183' :  { 'object_path' : 'temperature/cpu0/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'184' :  { 'object_path' : 'temperature/cpu0/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'185' :  { 'object_path' : 'temperature/cpu0/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'186' :  { 'object_path' : 'temperature/cpu0/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'187' :  { 'object_path' : 'temperature/cpu0/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'102' :  { 'object_path' : 'temperature/dimm0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
 			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'103' :  { 'object_path' : 'temperature/dimm1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
@@ -717,29 +717,29 @@ HWMON_CONFIG = {
 	'3-0051' : {
 		'labels' :  {
 		'188' :  { 'object_path' : 'temperature/cpu1/core0','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'189' :  { 'object_path' : 'temperature/cpu1/core1','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'190' :  { 'object_path' : 'temperature/cpu1/core2','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'191' :  { 'object_path' : 'temperature/cpu1/core3','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'192' :  { 'object_path' : 'temperature/cpu1/core4','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'193' :  { 'object_path' : 'temperature/cpu1/core5','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'194' :  { 'object_path' : 'temperature/cpu1/core6','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'195' :  { 'object_path' : 'temperature/cpu1/core7','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'196' :  { 'object_path' : 'temperature/cpu1/core8','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'197' :  { 'object_path' : 'temperature/cpu1/core9','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'198' :  { 'object_path' : 'temperature/cpu1/core10','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'199' :  { 'object_path' : 'temperature/cpu1/core11','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
-			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
+			'critical_upper' : 90, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : False },
 		'118' :  { 'object_path' : 'temperature/dimm16','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
 			'critical_upper' : 95, 'critical_lower' : -100, 'warning_upper' : 85, 'warning_lower' : -99, 'emergency_enabled' : True },
 		'119' :  { 'object_path' : 'temperature/dimm17','poll_interval' : 5000,'scale' : 1000,'units' : 'C',
diff --git a/objects/info.c b/objects/info.c
index 386133c..2da0dbc 100644
--- a/objects/info.c
+++ b/objects/info.c
@@ -360,13 +360,30 @@ int start_system_information(void)
 
 		if(HighestCPUtemp >= 90) {
 			thermaltrip_lock = 1;
-			send_esel_to_dbus("CPU thermal trip", "High", "assoc", "hack", 3);
+			send_esel_to_dbus("thermal shutdown, CPU temperature = 90degC", "High", "assoc", "hack", 3);
+
+			ret = sd_bus_call_method(bus,                   // On the System Bus
+						gService_c,               // Service to contact
+						gObjPath_c,            // Object path
+						gIntPath_c,              // Interface name
+						"powerOff",          // Method to be called
+						&bus_error,                 // object to return error
+						&response,                  // Response message on success
+						NULL);                       // input message (string,byte)
+			if(ret < 0)
+			{
+				fprintf(stderr, "Failed to power off from dbus: %s\n", bus_error.message);
+				goto finish;
+			}
+			sd_bus_error_free(&bus_error);
+			response = sd_bus_message_unref(response);
 		}
 	
 finish:
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
 		sd_bus_flush(bus);
+		OccStatus = NULL;
 		HighestCPUtemp = 0;
 		sleep(1);
 	}
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 19/20] Support FAN LED feature
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (17 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 18/20] Keep original design to generate " OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:23   ` Stewart Smith
  2016-04-15  7:01 ` [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor" OpenBMC Patches
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: johnhcwang

From: johnhcwang <hsienchiang@gmail.com>

---
 objects/fan_algorithm.c | 475 ++++++++++++++++++++++++++----------------------
 1 file changed, 261 insertions(+), 214 deletions(-)

diff --git a/objects/fan_algorithm.c b/objects/fan_algorithm.c
index 9665860..9bb3f4c 100755
--- a/objects/fan_algorithm.c
+++ b/objects/fan_algorithm.c
@@ -6,45 +6,59 @@
 #include "i2c-dev.h"
 #include "log.h"
 
+
+#define NUM_DIMM	32
+#define NUM_FAN		12
+#define NUM_CPU_CORE	12
+#define NUM_PWM		6
+
 const char *gService = "org.openbmc.Sensors";
 const char *fanService = "org.openbmc.control.Fans";
-
-const char *gfanflagObjPath = "/org/openbmc/sensors/FanParameter/flag";
-const char *gfanCPUvaribleObjPath = "/org/openbmc/sensors/FanParameter/flag";
-const char *gfanDIMMvaribleObjPath = "/org/openbmc/sensors/FanParameter/flag";
-			
-const char *gfanpidObjPath [3] = {"/org/openbmc/sensors/FanParameter/Kp",
-							      "/org/openbmc/sensors/FanParameter/Ki",
-							      "/org/openbmc/sensors/FanParameter/Kd"};
-
-
-const char *gCPU0ObjPath [12] = {"/org/openbmc/sensors/temperature/cpu0/core0",
-								 "/org/openbmc/sensors/temperature/cpu0/core1",
-								 "/org/openbmc/sensors/temperature/cpu0/core2",
-								 "/org/openbmc/sensors/temperature/cpu0/core3",
-								 "/org/openbmc/sensors/temperature/cpu0/core4",
-								 "/org/openbmc/sensors/temperature/cpu0/core5",
-								 "/org/openbmc/sensors/temperature/cpu0/core6",
-								 "/org/openbmc/sensors/temperature/cpu0/core7",
-								 "/org/openbmc/sensors/temperature/cpu0/core8",
-								 "/org/openbmc/sensors/temperature/cpu0/core9",
-								 "/org/openbmc/sensors/temperature/cpu0/core10",
-								 "/org/openbmc/sensors/temperature/cpu0/core11"};
+const char *gService_Power = "org.openbmc.control.Chassis";
+const char *gObjPath_Power = "/org/openbmc/control/chassis0";
+const char *gIntPath_Power = "org.openbmc.control.Chassis";
+
+const char *fanInObjPath [NUM_FAN] = {"/org/openbmc/sensors/tach/fan0H",
+				"/org/openbmc/sensors/tach/fan0L",
+				"/org/openbmc/sensors/tach/fan1H",
+				"/org/openbmc/sensors/tach/fan1L",
+				"/org/openbmc/sensors/tach/fan2H",
+				"/org/openbmc/sensors/tach/fan2L",
+				"/org/openbmc/sensors/tach/fan3H",
+				"/org/openbmc/sensors/tach/fan3L",
+				"/org/openbmc/sensors/tach/fan4H",
+				"/org/openbmc/sensors/tach/fan4L",
+				"/org/openbmc/sensors/tach/fan5H",
+				"/org/openbmc/sensors/tach/fan5L",
+				};
+
+const char *gCPU0ObjPath[NUM_CPU_CORE] = {"/org/openbmc/sensors/temperature/cpu0/core0",
+						 "/org/openbmc/sensors/temperature/cpu0/core1",
+						 "/org/openbmc/sensors/temperature/cpu0/core2",
+						 "/org/openbmc/sensors/temperature/cpu0/core3",
+						 "/org/openbmc/sensors/temperature/cpu0/core4",
+						 "/org/openbmc/sensors/temperature/cpu0/core5",
+						 "/org/openbmc/sensors/temperature/cpu0/core6",
+						 "/org/openbmc/sensors/temperature/cpu0/core7",
+						 "/org/openbmc/sensors/temperature/cpu0/core8",
+						 "/org/openbmc/sensors/temperature/cpu0/core9",
+						 "/org/openbmc/sensors/temperature/cpu0/core10",
+						 "/org/openbmc/sensors/temperature/cpu0/core11"};
 								
-const char *gCPU1ObjPath [12] = {"/org/openbmc/sensors/temperature/cpu0/core0",
-								 "/org/openbmc/sensors/temperature/cpu0/core1",
-								 "/org/openbmc/sensors/temperature/cpu0/core2",
-								 "/org/openbmc/sensors/temperature/cpu0/core3",
-								 "/org/openbmc/sensors/temperature/cpu0/core4",
-								 "/org/openbmc/sensors/temperature/cpu0/core5",
-								 "/org/openbmc/sensors/temperature/cpu0/core6",
-								 "/org/openbmc/sensors/temperature/cpu0/core7",
-								 "/org/openbmc/sensors/temperature/cpu0/core8",
-								 "/org/openbmc/sensors/temperature/cpu0/core9",
-								 "/org/openbmc/sensors/temperature/cpu0/core10",
-								 "/org/openbmc/sensors/temperature/cpu0/core11"};
-
-const char *gDIMMObjPath [32] = {"/org/openbmc/sensors/temperature/dimm0",
+const char *gCPU1ObjPath[NUM_CPU_CORE] = {"/org/openbmc/sensors/temperature/cpu1/core0",
+						 "/org/openbmc/sensors/temperature/cpu1/core1",
+						 "/org/openbmc/sensors/temperature/cpu1/core2",
+						 "/org/openbmc/sensors/temperature/cpu1/core3",
+						 "/org/openbmc/sensors/temperature/cpu1/core4",
+						 "/org/openbmc/sensors/temperature/cpu1/core5",
+						 "/org/openbmc/sensors/temperature/cpu1/core6",
+						 "/org/openbmc/sensors/temperature/cpu1/core7",
+						 "/org/openbmc/sensors/temperature/cpu1/core8",
+						 "/org/openbmc/sensors/temperature/cpu1/core9",
+						 "/org/openbmc/sensors/temperature/cpu1/core10",
+						 "/org/openbmc/sensors/temperature/cpu1/core11"};
+
+const char *gDIMMObjPath [NUM_DIMM] = {"/org/openbmc/sensors/temperature/dimm0",
 								 "/org/openbmc/sensors/temperature/dimm1",
 								 "/org/openbmc/sensors/temperature/dimm2",
 								 "/org/openbmc/sensors/temperature/dimm3",
@@ -91,22 +105,6 @@ const char *fanObjPath [6] ={"/org/openbmc/sensors/speed/fan0",
 const char *gIntPath = "org.openbmc.SensorValue";
 
 
-char *gMessage = NULL;
-
-#define MAX_BYTES 255
-
-int g_use_pec = 0;
-int g_has_write = 1;
-int g_n_write = 0;
-uint8_t g_write_bytes[MAX_BYTES];
-uint8_t g_write_color_bytes[MAX_BYTES];
-
-int g_has_read = 1;
-int g_n_read = -1;
-uint8_t g_read_bytes[MAX_BYTES];
-uint8_t g_read_tmp[MAX_BYTES];
-uint8_t g_bus = -1;
-uint8_t g_slave_addr = 0xff;
 double g_Kp = 0.7;
 double g_Ki = -0.025;
 double g_Kd = 1.0;
@@ -120,18 +118,16 @@ int Interal_DIMM_Err[20]={0};
 
 int g_fanspeed = 0;
 
-
 int Openloopspeed = 0;
 int Closeloopspeed = 0;
 int Finalfanspeed = 0;
 
-static int i2c_open()
+static int i2c_open(int bus)
 {
 	int rc = 0, fd = -1;
 	char fn[32];
 
-	g_bus = 6;
-	snprintf(fn, sizeof(fn), "/dev/i2c-%d", g_bus);
+	snprintf(fn, sizeof(fn), "/dev/i2c-%d", bus);
 	fd = open(fn, O_RDWR);
 	if (fd == -1) {
 		LOG_ERR(errno, "Failed to open i2c device %s", fn);
@@ -141,48 +137,30 @@ static int i2c_open()
 	return fd;
 }
 
-static int SetFanLed(int fd,int color)
+#define CMD_OUTPUT_PORT_0 2
+#define PCA9535_ADDR 0x20
+static int SetFanLed(int fd, uint8_t port0, uint8_t port1)
 {
 	struct i2c_rdwr_ioctl_data data;
-	struct i2c_msg msg[2];
-	int rc = 0, n_msg = 0;
+	struct i2c_msg msg[1];
+	int rc = 0, use_pec = 0;
+	uint8_t write_bytes[3];
 
-	memset(&msg, 0, sizeof(msg));
+//	fprintf(stderr,"SetFanLed: port0 = %02X,port1 = %02X\n",port0,port1);
 
-	g_slave_addr = 0x20;
-	g_use_pec = 0;
-	g_n_write = 2;
+	memset(&msg, 0, sizeof(msg));
 
-	if(color == 1) {
-		//blue light
-		g_write_bytes[0] = 0x03;
-		g_write_bytes[1] = 0x55;
-		g_write_color_bytes[0] = 0x02;
-		g_write_color_bytes[1] = 0xaa;
-	} else {
-		//red light
-		g_write_bytes[0] = 0x03;
-		g_write_bytes[1] = 0xaa;
-		g_write_color_bytes[0] = 0x02;
-		g_write_color_bytes[1] = 0x55;
-	}
+	write_bytes[0] = CMD_OUTPUT_PORT_0;
+	write_bytes[1] = port0;
+	write_bytes[2] = port1;
   
-	if (1) {
-		msg[n_msg].addr = g_slave_addr;
-		msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
-		msg[n_msg].len = g_n_write;
-		msg[n_msg].buf = g_write_bytes;
-		n_msg++;
-	}
-	 if (1) {
-		msg[n_msg].addr = g_slave_addr;
-		msg[n_msg].flags = (g_use_pec) ? I2C_CLIENT_PEC : 0;
-		msg[n_msg].len = g_n_write;
-		msg[n_msg].buf = g_write_color_bytes;
-		n_msg++;
-	}
+	msg[0].addr = PCA9535_ADDR;
+	msg[0].flags = (use_pec) ? I2C_CLIENT_PEC : 0;
+	msg[0].len = sizeof(write_bytes);
+	msg[0].buf = write_bytes;
+
 	data.msgs = msg;
-	data.nmsgs = n_msg;
+	data.nmsgs = 1;
 	rc = ioctl(fd, I2C_RDWR, &data);
 	if (rc < 0) {
 		LOG_ERR(errno, "Failed to do raw io");
@@ -302,22 +280,26 @@ int OpenLoop (int sensorreading)
 	return 0;
 }
 
-
+#define FAN_LED_OFF     0xFF
+#define FAN_LED_PORT0_ALL_BLUE  0xAA
+#define FAN_LED_PORT1_ALL_BLUE  0x55
+#define FAN_LED_PORT0_ALL_RED   0x55
+#define FAN_LED_PORT1_ALL_RED   0xAA
+#define PORT0_FAN_LED_RED_MASK  0x02
+#define PORT0_FAN_LED_BLUE_MASK	0x01
+#define PORT1_FAN_LED_RED_MASK  0x40
+#define PORT1_FAN_LED_BLUE_MASK	0x80
 int Fan_control_algorithm(void)
 {
 	sd_bus *bus = NULL;
 	sd_bus_error bus_error = SD_BUS_ERROR_NULL;
 	sd_bus_message *response = NULL;
-	int Ambient_reading = 0, rc = 0, i = 0;
-	int CPU0_core_temperature[12];
-	int CPU1_core_temperature[12];
-	int DIMM_temperature[32];
-	int HighestCPUtemp = 0;
-	int HighestDIMMtemp = 0;
-	int CPUnocore[2];
-	int fd = -1;
-	int FinalFanSpeed = 0;
-	int CPUtemp = 0;
+	int rc = 0, i = 0, fd = -1, offset = 0;
+	int CPU0_core_temperature[NUM_CPU_CORE], CPU1_core_temperature[NUM_CPU_CORE], HighestCPUtemp = 0;
+	int DIMM_temperature[NUM_DIMM], HighestDIMMtemp = 0;
+	int Ambient_reading = 0;
+	int Fan_tach[NUM_FAN], FinalFanSpeed = 255;
+	int Power_state = 0, fan_led_port0 = 0xFF, fan_led_port1 = 0xFF;
 	
 	do {
 		/* Connect to the user bus this time */
@@ -330,147 +312,209 @@ int Fan_control_algorithm(void)
 	} while (rc < 0);
 
 	while (1) {
-		CPUtemp = 0;
-		for(i=0; i<12; i++) {
-			rc = sd_bus_call_method(bus,                   // On the System Bus
-						gService,               // Service to contact
-						gCPU0ObjPath[i],            // Object path
-						gIntPath,              // Interface name
-						"getValue",          // Method to be called
-						&bus_error,                 // object to return error
-						&response,                  // Response message on success
-						NULL);                       // input message (string,byte)
-			if(rc < 0) {
-//				fprintf(stderr, "Failed to get CPU 0 temperature from dbus: %s\n", bus_error.message);
-				CPU0_core_temperature[i] = 0;
-			} else {
-				rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
-				if (rc < 0 ) {
-					fprintf(stderr, "Failed to parse GetCpu0Temp response message:[%s]\n", strerror(-rc));
+		rc = sd_bus_call_method(bus,					// On the System Bus
+					gService_Power,				// Service to contact
+					gObjPath_Power,			 // Object path
+					gIntPath_Power,			   // Interface name
+					"getPowerState",			// Method to be called
+					&bus_error,				  // object to return error
+					&response,				  // Response message on success
+					NULL);					   // input message (string,byte)
+		if(rc < 0) {
+			fprintf(stderr, "Failed to get power state from dbus: %s\n", bus_error.message);
+			goto finish;
+		}
+
+		rc = sd_bus_message_read(response, "i", &Power_state);
+		if (rc < 0 ) {
+			fprintf(stderr, "Failed to parse GetPowerState response message:[%s]\n", strerror(-rc));
+			goto finish;
+		}
+		sd_bus_error_free(&bus_error);
+		response = sd_bus_message_unref(response);
+//		fprintf(stderr,"Power State = [%d]\n",Power_state);
+
+		if (Power_state == 1 ) {
+			for(i=0; i<NUM_CPU_CORE; i++) {
+				rc = sd_bus_call_method(bus,                   // On the System Bus
+							gService,               // Service to contact
+							gCPU0ObjPath[i],            // Object path
+							gIntPath,              // Interface name
+							"getValue",          // Method to be called
+							&bus_error,                 // object to return error
+							&response,                  // Response message on success
+							NULL);                       // input message (string,byte)
+				if(rc < 0) {
+//					fprintf(stderr, "Failed to get CPU 0 temperature from dbus: %s\n", bus_error.message);
 					CPU0_core_temperature[i] = 0;
+				} else {
+					rc = sd_bus_message_read(response, "v","i", &CPU0_core_temperature[i]);
+					if (rc < 0 ) {
+						fprintf(stderr, "Failed to parse GetCpu0Temp response message:[%s]\n", strerror(-rc));
+						CPU0_core_temperature[i] = 0;
+					}
 				}
+//				fprintf(stderr, "CPU0 core %d temperature is %d\n",i ,CPU0_core_temperature[i]);
+				if(CPU0_core_temperature[i] > HighestCPUtemp)
+					HighestCPUtemp = CPU0_core_temperature[i];
+
+				sd_bus_error_free(&bus_error);
+				response = sd_bus_message_unref(response);
 			}
-//			fprintf(stderr, "CPU0 core %d temperature is %d\n",i ,CPU0_core_temperature[i]);
-			if(CPU0_core_temperature[i] > HighestCPUtemp) {
-				HighestCPUtemp = CPU0_core_temperature[i];
-				CPUnocore[0] = 0;
-				CPUnocore[1] = i;
-			}
-			CPUtemp = CPUtemp + CPU0_core_temperature[i];
-			sd_bus_error_free(&bus_error);
-			response = sd_bus_message_unref(response);
-		}
 
-		for(i=0; i<12; i++) {
-			rc = sd_bus_call_method(bus,                   // On the System Bus
-						gService,               // Service to contact
-						gCPU1ObjPath[i],            // Object path
-						gIntPath,              // Interface name
-						"getValue",          // Method to be called
-						&bus_error,                 // object to return error
-						&response,                  // Response message on success
-						NULL);                       // input message (string,byte)
-			if(rc < 0) {
-//				fprintf(stderr, "Failed to get CPU 1 temperature from dbus: %s\n", bus_error.message);
-				CPU1_core_temperature[i] = 0;
-			} else {
-				rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
-				if (rc < 0 ) {
-					fprintf(stderr, "Failed to parse GetCpu1Temp response message:[%s]\n", strerror(-rc));
+			for(i=0; i<NUM_CPU_CORE; i++) {
+				rc = sd_bus_call_method(bus,                   // On the System Bus
+							gService,               // Service to contact
+							gCPU1ObjPath[i],            // Object path
+							gIntPath,              // Interface name
+							"getValue",          // Method to be called
+							&bus_error,                 // object to return error
+							&response,                  // Response message on success
+							NULL);                       // input message (string,byte)
+				if(rc < 0) {
+//					fprintf(stderr, "Failed to get CPU 1 temperature from dbus: %s\n", bus_error.message);
 					CPU1_core_temperature[i] = 0;
+				} else {
+					rc = sd_bus_message_read(response, "v","i", &CPU1_core_temperature[i]);
+					if (rc < 0 ) {
+						fprintf(stderr, "Failed to parse GetCpu1Temp response message:[%s]\n", strerror(-rc));
+						CPU1_core_temperature[i] = 0;
+					}
 				}
+//				fprintf(stderr, "CPU1 core %d temperature is %d\n",i ,CPU1_core_temperature[i]);
+				if(CPU1_core_temperature[i] > HighestCPUtemp )
+					HighestCPUtemp = CPU1_core_temperature[i];
+
+				sd_bus_error_free(&bus_error);
+				response = sd_bus_message_unref(response);
 			}
-//			fprintf(stderr, "CPU1 core %d temperature is %d\n",i ,CPU1_core_temperature[i]);
-			if(CPU1_core_temperature[i] > HighestCPUtemp ) {
-				HighestCPUtemp = CPU1_core_temperature[i];
-				CPUnocore[0] = 1;
-				CPUnocore[1] = i;
-			}
-			sd_bus_error_free(&bus_error);
-			response = sd_bus_message_unref(response);
-		}
-//		fprintf(stderr, "Highest CPU temperature = [%d]\n", HighestCPUtemp);
-	
-		for(i=0; i<32; i++) {
+//			fprintf(stderr, "Highest CPU temperature = [%d]\n", HighestCPUtemp);
+
 			rc = sd_bus_call_method(bus,                   // On the System Bus
 						gService,               // Service to contact
-						gDIMMObjPath[i],            // Object path
+						gObjPath_Ambient,            // Object path
 						gIntPath,              // Interface name
 						"getValue",          // Method to be called
 						&bus_error,                 // object to return error
 						&response,                  // Response message on success
 						NULL);                       // input message (string,byte)
 			if(rc < 0) {
-//				fprintf(stderr, "Failed to get DIMM temperature from dbus: %s\n", bus_error.message);
-				DIMM_temperature[i] = 0;
+				fprintf(stderr, "Failed to get ambient temperature from dbus: %s\n", bus_error.message);
+				Ambient_reading = 0;
 			} else {
-				rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
+				rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
 				if (rc < 0 ) {
 					fprintf(stderr, "Failed to parse GetDimmTemp response message:[%s]\n", strerror(-rc));
-					DIMM_temperature[i] = 0;
+					Ambient_reading = 0;
 				}
 			}
-//			fprintf(stderr, "DIMM %d temperature is %d\n", i, DIMM_temperature[i]);
-			if(DIMM_temperature[i] > HighestDIMMtemp )
-				HighestDIMMtemp = DIMM_temperature[i];
 			sd_bus_error_free(&bus_error);
 			response = sd_bus_message_unref(response);
-		}
-//		fprintf(stderr, "Highest DIMM temperature = [%d]\n",HighestDIMMtemp);
-
-		rc = sd_bus_call_method(bus,                   // On the System Bus
-					gService,               // Service to contact
-					gObjPath_Ambient,            // Object path
-					gIntPath,              // Interface name
-					"getValue",          // Method to be called
-					&bus_error,                 // object to return error
-					&response,                  // Response message on success
-					NULL);                       // input message (string,byte)
-		if(rc < 0) {
-//			fprintf(stderr, "Failed to get ambient temperature from dbus: %s\n", bus_error.message);
-			Ambient_reading = 0;
-		} else {
-			rc = sd_bus_message_read(response, "v","i", &Ambient_reading);
-			if (rc < 0 ) {
-				fprintf(stderr, "Failed to parse GetDimmTemp response message:[%s]\n", strerror(-rc));
-				Ambient_reading = 0;
-			}
-		}
-		sd_bus_error_free(&bus_error);
-		response = sd_bus_message_unref(response);
-//		fprintf(stderr, "Highest ambient inlet temperature = [%d]\n", HighestCPUtemp);
+//			fprintf(stderr, "Highest ambient inlet temperature = [%d]\n", HighestCPUtemp);
+
+			if (HighestCPUtemp > 0 && Ambient_reading > 0) {
+				for(i=0; i<NUM_DIMM; i++) {
+					rc = sd_bus_call_method(bus,                   // On the System Bus
+								gService,               // Service to contact
+								gDIMMObjPath[i],            // Object path
+								gIntPath,              // Interface name
+								"getValue",          // Method to be called
+								&bus_error,                 // object to return error
+								&response,                  // Response message on success
+								NULL);                       // input message (string,byte)
+					if(rc < 0) {
+//						fprintf(stderr, "Failed to get DIMM temperature from dbus: %s\n", bus_error.message);
+						DIMM_temperature[i] = 0;
+					} else {
+						rc = sd_bus_message_read(response, "v","i", &DIMM_temperature[i]);
+						if (rc < 0 ) {
+							fprintf(stderr, "Failed to parse GetDimmTemp response message:[%s]\n", strerror(-rc));
+							DIMM_temperature[i] = 0;
+						}
+					}
+//					fprintf(stderr, "DIMM %d temperature is %d\n", i, DIMM_temperature[i]);
+					if(DIMM_temperature[i] > HighestDIMMtemp )
+						HighestDIMMtemp = DIMM_temperature[i];
+					sd_bus_error_free(&bus_error);
+					response = sd_bus_message_unref(response);
+				}
+//				fprintf(stderr, "Highest DIMM temperature = [%d]\n",HighestDIMMtemp);
 
-		if (CPUtemp == 0)	{
-			HighestCPUtemp = 0;
-			HighestDIMMtemp = 0;
-		}
+				CloseLoop(HighestCPUtemp,HighestDIMMtemp);
+				OpenLoop(Ambient_reading);
 
-		CloseLoop(HighestCPUtemp,HighestDIMMtemp);
-		OpenLoop(Ambient_reading);
+				if(Openloopspeed > Closeloopspeed)
+					g_fanspeed = Openloopspeed;
+				else
+					g_fanspeed = Closeloopspeed;
 
-		if(Openloopspeed > Closeloopspeed)
-			g_fanspeed = Openloopspeed;
-		else
-			g_fanspeed = Closeloopspeed;
-	
-		fd = i2c_open();
-		if (fd == -1) {
-			fprintf(stderr, "Fail to set FAN LED\n");
-		} else {
-			if(g_fanspeed > 30)
-				SetFanLed(fd,1);
-			else
-				SetFanLed(fd,2);
-			close(fd);
-		}
+				FinalFanSpeed = g_fanspeed * 255;
+				FinalFanSpeed = FinalFanSpeed / 100;
 
-		FinalFanSpeed = g_fanspeed * 255;
-		FinalFanSpeed = FinalFanSpeed / 100;
+				if(g_fanspeed > 30) {
+					fan_led_port0 = FAN_LED_PORT0_ALL_BLUE;
+					fan_led_port1 = FAN_LED_PORT1_ALL_BLUE;
+				} else {
+					fan_led_port0 = FAN_LED_PORT0_ALL_RED;
+					fan_led_port1 = FAN_LED_PORT1_ALL_RED;
+				}
+			} else {//HighestCPUtemp == 0 || Ambient_reading == 0
+				FinalFanSpeed = 255;
+				fan_led_port0 = FAN_LED_PORT0_ALL_BLUE;
+				fan_led_port1 = FAN_LED_PORT1_ALL_BLUE;
+			}
 
-		if(HighestCPUtemp == 0) //OCC sensor does not enable
+//			fprintf(stderr,"fan_led compute: port0=%02X,port1=%02X\n",fan_led_port0,fan_led_port1);
+			for(i=0;i<NUM_FAN;i++) {
+				rc = sd_bus_call_method(bus,                               // On the System Bus
+							gService,                               // Service to contact
+							fanInObjPath[i],                        // Object path
+							gIntPath,                          // Interface name
+							"getValue",              // Method to be called
+							&bus_error,                             // object to return error
+							&response,                                      // Response message on success
+							NULL);                                           // input message (string,byte)
+				if(rc < 0) {
+					fprintf(stderr, "Failed to get fan tach from dbus: %s\n", bus_error.message);
+					Fan_tach[i] = 0;
+				} else {
+					rc = sd_bus_message_read(response, "v","i", &Fan_tach[i]);
+					if (rc < 0 ) {
+						fprintf(stderr, "Failed to parse GetFanTach response message:[%s]\n", strerror(-rc));
+						Fan_tach[i] = 0;
+					}
+				}
+				sd_bus_error_free(&bus_error);
+				response = sd_bus_message_unref(response);
+
+				if (Fan_tach[i] == 0) {
+					FinalFanSpeed = 255;
+					if (i <= 3) { //FAN 1 & 2
+						offset = i / 2 * 2;
+						fan_led_port1 &= ~(PORT1_FAN_LED_RED_MASK >> offset); //turn on red led
+						fan_led_port1 |= PORT1_FAN_LED_BLUE_MASK >> offset; //turn off blue led
+//						fprintf(stderr,"i=%d,offset=%d,fan_led_port1=%02X\n",i,offset,fan_led_port1);
+					} else { //FAN 3~6
+						offset = (i - 4) / 2 * 2;
+						fan_led_port0 &= ~(PORT0_FAN_LED_RED_MASK << offset); //turn on red led
+						fan_led_port0 |= PORT0_FAN_LED_BLUE_MASK << offset; //turn off blue led
+//						fprintf(stderr,"i=%d,offset=%d,fan_led_port0=%02X\n",i,offset,fan_led_port0);
+					}
+				}
+			}
+		} else {//Power_state == 0
 			FinalFanSpeed = 255;
+			fan_led_port0 = FAN_LED_OFF;
+			fan_led_port1 = FAN_LED_OFF;
+		}
+
+		fd = i2c_open(6);
+		if (fd != -1) {
+			SetFanLed(fd,fan_led_port0,fan_led_port1);
+			close(fd);
+		}
 
-		for(i=0; i<6; i++) {
+		for(i=0; i<NUM_PWM; i++) {
 			rc = sd_bus_call_method(bus,				   // On the System Bus
 						gService,			   // Service to contact
 						fanObjPath[i],			// Object path
@@ -490,6 +534,9 @@ finish:
 		sd_bus_error_free(&bus_error);
 		response = sd_bus_message_unref(response);
 		sd_bus_flush(bus);
+		HighestCPUtemp = 0;
+		HighestDIMMtemp = 0;
+		Ambient_reading = 0;
 		sleep(1);
 	}
 	bus = sd_bus_flush_close_unref(bus);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor"
  2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
                   ` (18 preceding siblings ...)
  2016-04-15  7:01 ` [PATCH skeleton v6 19/20] Support FAN LED feature OpenBMC Patches
@ 2016-04-15  7:01 ` OpenBMC Patches
  2016-04-20 17:23   ` Stewart Smith
  19 siblings, 1 reply; 27+ messages in thread
From: OpenBMC Patches @ 2016-04-15  7:01 UTC (permalink / raw)
  To: openbmc; +Cc: Ken Lai

From: Ken Lai <ken1029@gmail.com>

This reverts commit 0428fb4215889eaa151f63b4e904bdc61551295f.
---
 bin/Barreleye.py           |  5 -----
 objects/hwmons_barreleye.c | 15 +++++++--------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 86a5a97..ffe515d 100755
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -633,11 +633,6 @@ HWMON_CONFIG = {
                         'in14_input' : { 'object_path' : 'voltage/P1V35_CPU1_BUF3','poll_interval' : 10000,'scale' : 1,'units' : '' },
 		}
          },
-	'6-0048' : {
-		'names' : {
-                        'temp1_input' : { 'object_path' : 'temperature/outlet','poll_interval' : 5000,'scale' : 1000,'units' : 'C' },
-		}
-	},
 	'3-0050' : {
 		'names' : {
 			'caps_curr_powercap' : { 'object_path' : 'powercap/curr_cap','poll_interval' : 10000,'scale' : 1,'units' : 'W' },
diff --git a/objects/hwmons_barreleye.c b/objects/hwmons_barreleye.c
index 9cc555b..5acde7c 100644
--- a/objects/hwmons_barreleye.c
+++ b/objects/hwmons_barreleye.c
@@ -20,19 +20,18 @@ typedef struct {
   int fd;
 } HWMON;
 
-#define  NUM_HWMONS 8
+#define  NUM_HWMONS 7
 
 // TODO: Don't hardcode
 //Hardcoded for barreleye
 HWMON hwmons[NUM_HWMONS] = { 
 	(HWMON){"/sys/class/hwmon/hwmon0/temp1_input","temperature/ambient",3000,"C",1000},
-	(HWMON){"/sys/class/hwmon/hwmon1/temp1_input","temperature/outlet",5000,"C",1000},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm1","speed/fan0",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm2","speed/fan1",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon2/pwm3","speed/fan2",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon3/pwm1","speed/fan3",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon3/pwm2","speed/fan4",30000,"",1},
-	(HWMON){"/sys/class/hwmon/hwmon3/pwm3","speed/fan5",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon1/pwm1","speed/fan0",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon1/pwm2","speed/fan1",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon1/pwm3","speed/fan2",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm1","speed/fan3",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm2","speed/fan4",30000,"",1},
+	(HWMON){"/sys/class/hwmon/hwmon2/pwm3","speed/fan5",30000,"",1},
 };
 bool is_hwmon_valid(HWMON* hwmon)
 {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 03/20] fix info memory leak
  2016-04-15  7:01 ` [PATCH skeleton v6 03/20] fix info memory leak OpenBMC Patches
@ 2016-04-20 17:19   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:19 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: Ken

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Ken <ken1029@gmail.com>

please use full name.

> ---
>  objects/info.c | 2 +-
[ 10 more citation lines. Click/Enter to show. ]
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/objects/info.c b/objects/info.c
> index ab2d98c..76c17d9 100644
> --- a/objects/info.c
> +++ b/objects/info.c
> @@ -145,7 +145,7 @@ int get_hdd_status(void)
>  
>      g_read_tmp[2]=g_read_bytes[2];
>      g_read_tmp[3]=g_read_bytes[3];
> -
> +    close(fd);
>  }

Please squash into previous commit.

-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 07/20] fix info memory leak
  2016-04-15  7:01 ` [PATCH skeleton v6 07/20] fix info memory leak OpenBMC Patches
@ 2016-04-20 17:20   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:20 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: Ken

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Ken <ken1029@gmail.com>
>
> ---
[ 35 more citation lines. Click/Enter to show. ]
>  objects/info.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/objects/info.c b/objects/info.c
> index ab2d98c..d872c3f 100644
> --- a/objects/info.c
> +++ b/objects/info.c
> @@ -42,6 +42,7 @@ static int i2c_open() {
>    fd = open(fn, O_RDWR);
>    if (fd == -1) {
>      LOG_ERR(errno, "Failed to open i2c device %s", fn);
> +    close(fd);
>      return -1;
>    }
>  
> @@ -108,6 +109,7 @@ static int i2c_io(int fd) {
>    rc = ioctl(fd, I2C_RDWR, &data);
>    if (rc < 0) {
>      LOG_ERR(errno, "Failed to do raw io");
> +    close(fd);
>      return -1;
>    }
>  
> @@ -126,6 +128,7 @@ int get_hdd_status(void)
>    }
>  
>    if (i2c_io(fd) < 0) {
> +    close(fd);
>      return -1;
>    }
>  
> @@ -145,7 +148,7 @@ int get_hdd_status(void)
>  
>      g_read_tmp[2]=g_read_bytes[2];
>      g_read_tmp[3]=g_read_bytes[3];
> -
> +    close(fd);
>  }

Please fold into patch that introduced the code.

-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap
  2016-04-15  7:01 ` [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap OpenBMC Patches
@ 2016-04-20 17:21   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:21 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: johnhcwang

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: johnhcwang <hsienchiang@gmail.com>
>
> After we enable I2C-6 lm75 outlet sensor in device stree, the hwmon ID
> of PowerCap won't be 3 anymore. So we have to modify it as real ID.

This looks like a pretty unreliable way to identify the sensor we
want. Surely there's a better way than just relying on them always
coming up in the same order?


-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 17/20] Generate thermaltrip event
  2016-04-15  7:01 ` [PATCH skeleton v6 17/20] Generate thermaltrip event OpenBMC Patches
@ 2016-04-20 17:22   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:22 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: johnhcwang

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: johnhcwang <hsienchiang@gmail.com>
>
> Keep the original design from v2.10
[ 12 more citation lines. Click/Enter to show. ]
> ---
>  objects/info.c | 121
> ++++++++++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 95 insertions(+), 26 deletions(-)
>
> diff --git a/objects/info.c b/objects/info.c
> index 8e08974..386133c 100644
> --- a/objects/info.c
> +++ b/objects/info.c
> @@ -6,9 +6,37 @@
>  #include "i2c-dev.h"
>  #include "log.h"
>  
> +
> +#define NUM_CPU_CORE	12

It would be much better to detect this at runtime. There's likely to at
some point exist a chip with >12 cores.

>  const char *gService = "org.openbmc.Sensors";
> -const char *gObjPath = "/org/openbmc/sensors/temperature/cpu0/core0";
> -const char *gObjPath_o = "/org/openbmc/sensors/host/OccStatus";
> +const char *gCPU0ObjPath[NUM_CPU_CORE] =
> {"/org/openbmc/sensors/temperature/cpu0/core0",

Why not construct with snprintf() at runtime?

> +		if(HighestCPUtemp >= 90) {

Why is this hardcoded here?


-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 19/20] Support FAN LED feature
  2016-04-15  7:01 ` [PATCH skeleton v6 19/20] Support FAN LED feature OpenBMC Patches
@ 2016-04-20 17:23   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:23 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: johnhcwang

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> +const char *fanInObjPath [NUM_FAN] = {"/org/openbmc/sensors/tach/fan0H",
> +				"/org/openbmc/sensors/tach/fan0L",
> +				"/org/openbmc/sensors/tach/fan1H",
[ 7 more citation lines. Click/Enter to show. ]
> +				"/org/openbmc/sensors/tach/fan1L",
> +				"/org/openbmc/sensors/tach/fan2H",
> +				"/org/openbmc/sensors/tach/fan2L",
> +				"/org/openbmc/sensors/tach/fan3H",
> +				"/org/openbmc/sensors/tach/fan3L",
> +				"/org/openbmc/sensors/tach/fan4H",
> +				"/org/openbmc/sensors/tach/fan4L",
> +				"/org/openbmc/sensors/tach/fan5H",
> +				"/org/openbmc/sensors/tach/fan5L",
> +				};

How can we not hardcode all of these?

-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor"
  2016-04-15  7:01 ` [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor" OpenBMC Patches
@ 2016-04-20 17:23   ` Stewart Smith
  0 siblings, 0 replies; 27+ messages in thread
From: Stewart Smith @ 2016-04-20 17:23 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: Ken Lai

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Ken Lai <ken1029@gmail.com>
>
> This reverts commit 0428fb4215889eaa151f63b4e904bdc61551295f.

Perhaps git-rebase and remove the commit instead of adding and removing
it in the same patchset

-- 
Stewart Smith
OPAL Architect, IBM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2016-04-20 17:24 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15  7:01 [PATCH skeleton v6 00/20] Add fan control algorithm OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 01/20] add i2craw tool and hdd status function OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 02/20] Heartbeat Led function OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 03/20] fix info memory leak OpenBMC Patches
2016-04-20 17:19   ` Stewart Smith
2016-04-15  7:01 ` [PATCH skeleton v6 04/20] Setup FUNC_MODE[2:0] OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 05/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 06/20] " OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 07/20] fix info memory leak OpenBMC Patches
2016-04-20 17:20   ` Stewart Smith
2016-04-15  7:01 ` [PATCH skeleton v6 08/20] Revert "Fill in the threshold settings for CPU and DIMM" OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 09/20] Add I2C-6 lm75 outlet temperature sensor OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 10/20] Modify the hard-coded hwmon ID for PowerCap OpenBMC Patches
2016-04-20 17:21   ` Stewart Smith
2016-04-15  7:01 ` [PATCH skeleton v6 11/20] Fill in the threshold settings for CPU and DIMM OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 12/20] Add fan control algorithm OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 13/20] Fix skeleton Makefile OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 14/20] Set lower threshold for ambient/CPU/DIMM sensors OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 15/20] Fix memory leak OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 16/20] Support FAN tach sensors OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 17/20] Generate thermaltrip event OpenBMC Patches
2016-04-20 17:22   ` Stewart Smith
2016-04-15  7:01 ` [PATCH skeleton v6 18/20] Keep original design to generate " OpenBMC Patches
2016-04-15  7:01 ` [PATCH skeleton v6 19/20] Support FAN LED feature OpenBMC Patches
2016-04-20 17:23   ` Stewart Smith
2016-04-15  7:01 ` [PATCH skeleton v6 20/20] Revert "Add I2C-6 lm75 outlet temperature sensor" OpenBMC Patches
2016-04-20 17:23   ` Stewart Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.