Skip to contentSkip to conversation

ibmaem: New driver for power/energy meters in IBM System X hardware

PATCH In review Darrick J. Wong 2 participants 4 messages Mar 28, 2008 – Apr 24, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 ibmaem: New driver for power/energy meters in IBM System X hardware

New driver to read energy, power, and temperature meters in various IBM System X hardware.

---

 Documentation/hwmon/ibmaem |   37 +
 drivers/hwmon/Kconfig      |   14 +
 drivers/hwmon/Makefile     |    1 
 drivers/hwmon/ibmaem.c     | 1151 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1203 insertions(+), 0 deletions(-)
Documentation/hwmon/ibmaem new file +37 -0
new file mode 100644
index 0000000..238e87d
@@ -0,0 +1,37 @@
+Kernel driver ibmaem
+===========
+
+Supported systems:
+  * Any recent IBM System X server with Active Energy Manager support.
+    This includes the x3350, x3550, x3650, x3655, x3755, x3850 M2,
+    x3950 M2, and certain HS2x/LS2x/QS2x blades.  The IPMI host interface
+    driver ("ipmi-si") needs to be loaded for this driver to do anything.
+    Prefix: 'ibmaem'
+    Datasheet: Not available
+
+Author: Darrick J. Wong
+
+Description
+-----------
+
+This driver implements sensor reading support for the energy and power
+meters available on various IBM System X hardware through the BMC.  All
+sensor banks will be exported as platform devices; this driver can talk
+to both v1 and v2 interfaces.  This driver is completely separate from the
+older ibmpex driver.
+
+The v1 AEM interface has a simple set of features to monitor energy use.
+There is a register that displays an estimate of raw energy consumption
+since the last BMC reset, and a power sensor that returns average power
+use over a configurable interval.
+
+The v2 AEM interface is a bit more sophisticated, being able to present
+a wider range of energy and power use registers, the power cap as
+set by the AEM software, and temperature sensors.
+
+Special Features
+----------------
+
+The "power_cap" value displays the current system power cap, as set by
+the Active Energy Manager software.  Setting the power cap from the host
+is not currently supported.
drivers/hwmon/Kconfig +14 -0
index 4dc76bc..00ff533 100644
@@ -330,6 +330,20 @@ config SENSORS_CORETEMP
 	  sensor inside your CPU. Supported all are all known variants
 	  of Intel Core family.
 
+config SENSORS_IBMAEM
+	tristate "IBM Active Energy Manager temperature/power sensors and control"
+	select IPMI_SI
+	depends on IPMI_HANDLER
+	help
+	  If you say yes here you get support for the temperature and
+	  power sensors and capping hardware in various IBM System X
+	  servers that support Active Energy Manager.  This includes
+	  the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2,
+	  and certain HS2x/LS2x/QS2x blades.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called ibmaem.
+
 config SENSORS_IBMPEX
 	tristate "IBM PowerExecutive temperature/power sensors"
 	select IPMI_SI
drivers/hwmon/Makefile +1 -0
index 3bdb05a..d098677 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_SENSORS_GL518SM)	+= gl518sm.o
 obj-$(CONFIG_SENSORS_GL520SM)	+= gl520sm.o
 obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
 obj-$(CONFIG_SENSORS_I5K_AMB)	+= i5k_amb.o
+obj-$(CONFIG_SENSORS_IBMAEM)	+= ibmaem.o
 obj-$(CONFIG_SENSORS_IBMPEX)	+= ibmpex.o
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_K8TEMP)	+= k8temp.o
drivers/hwmon/ibmaem.c new file +1151 -0

1,151 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw
Quoted 2 lines · Darrick J. Wong

New driver to read energy, power, and temperature meters in various IBM System X hardware.

<snip>

Quoted 48 lines
drivers/hwmon/ibmaem.c new file +48 -0
+/* sysfs support functions */
+/* Discover sensors on an AEM device */
+#define AEM_FIND_SENSORS(type) \
+static int type##_find_sensors(struct type##_data *data) \
+{ \
+	struct aem_ro_sensor_template *ro; \
+	struct aem_rw_sensor_template *rw; \
+	int err, idx; \
+\
+	/* Set up read-only sensors */ \
+	ro = type##_ro_sensors; \
+	idx = 0; \
+	while (ro->label) { \
+		data->sensors[idx].dev_attr.attr.name = ro->label; \
+		data->sensors[idx].dev_attr.attr.mode = S_IRUGO; \
+		data->sensors[idx].dev_attr.show = ro->show; \
+		data->sensors[idx].index = ro->index; \
+\
+		err = device_create_file(&data->fw.pdev->dev, \
+					 &data->sensors[idx].dev_attr); \
+		if (err) { \
+			data->sensors[idx].dev_attr.attr.name = NULL; \
+			goto exit_remove; \
+		} \
+		idx++; \
+		ro++; \
+	} \
+\
+	/* Set up read-write sensors */ \
+	rw = type##_rw_sensors; \
+	while (rw->label) { \
+		data->sensors[idx].dev_attr.attr.name = rw->label; \
+		data->sensors[idx].dev_attr.attr.mode = S_IRUGO | S_IWUSR; \
+		data->sensors[idx].dev_attr.show = rw->show; \
+		data->sensors[idx].dev_attr.store = rw->set; \
+		data->sensors[idx].index = rw->index; \
+\
+		err = device_create_file(&data->fw.pdev->dev, \
+					 &data->sensors[idx].dev_attr); \
+		if (err) { \
+			data->sensors[idx].dev_attr.attr.name = NULL; \
+			goto exit_remove; \
+		} \
+		idx++; \
+		rw++; \
+	} \
+\
+	err = device_create_file(&data->fw.pdev->dev, \

drivers/hwmon/ibmaem.c line 993

Quoted 10 lines
drivers/hwmon/ibmaem.c new file +10 -0
+			&sensor_dev_attr_name.dev_attr); \
+	if (err) \
+		goto exit_remove; \
+\
+	return 0; \
+\
+exit_remove: \
+	type##_remove_sensors(data); \
+	return err; \
+} 

It really shouldn't be necessary to have all of these macro functions. In this above macro, you would just have to pass the ro and rw structures along with a remove function pointer. Since all of your types have common members, you could just have a common substructure and pass that around.

Regards,

Anthony Liguori

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
Quoted 5 lines · Anthony Liguori

It really shouldn't be necessary to have all of these macro functions. In this above macro, you would just have to pass the ro and rw structures along with a remove function pointer. Since all of your types have common members, you could just have a common substructure and pass that around.

Hmm... it isn't too difficult to refactor the registration function to make it easier to look at, though I'd rather keep the AEM1 and AEM2 guts separate rather than aggressively eliminating macros by making the AEM1 structs a subset of the AEM2 structs.

--D

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw

PATCH v2 1/1 ibmaem: New driver for power/energy meters in IBM System X hardware

In reply to Anthony Liguori

Refactor the registration function to shrink the macros. Let me know if more aggressive de-macroing is desirable.
---
New driver to support IBM Active Energy Manager sensors.

---

 Documentation/hwmon/ibmaem |   37 +
 drivers/hwmon/Kconfig      |   14 +
 drivers/hwmon/Makefile     |    1 
 drivers/hwmon/ibmaem.c     | 1157 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1209 insertions(+), 0 deletions(-)
Documentation/hwmon/ibmaem new file +37 -0
new file mode 100644
index 0000000..2fefaf5
@@ -0,0 +1,37 @@
+Kernel driver ibmaem
+===========
+
+Supported systems:
+  * Any recent IBM System X server with Active Energy Manager support.
+    This includes the x3350, x3550, x3650, x3655, x3755, x3850 M2,
+    x3950 M2, and certain HS2x/LS2x/QS2x blades.  The IPMI host interface
+    driver ("ipmi-si") needs to be loaded for this driver to do anything.
+    Prefix: 'ibmaem'
+    Datasheet: Not available
+
+Author: Darrick J. Wong
+
+Description
+-----------
+
+This driver implements sensor reading support for the energy and power
+meters available on various IBM System X hardware through the BMC.  All
+sensor banks will be exported as platform devices; this driver can talk
+to both v1 and v2 interfaces.  This driver is completely separate from the
+older ibmpex driver.
+
+The v1 AEM interface has a simple set of features to monitor energy use.
+There is a register that displays an estimate of raw energy consumption
+since the last BMC reset, and a power sensor that returns average power
+use over a configurable interval.
+
+The v2 AEM interface is a bit more sophisticated, being able to present
+a wider range of energy and power use registers, the power cap as
+set by the AEM software, and temperature sensors.
+
+Special Features
+----------------
+
+The "power_cap" value displays the current system power cap, as set by
+the Active Energy Manager software.  Setting the power cap from the host
+is not currently supported.
drivers/hwmon/Kconfig +14 -0
index 4dc76bc..00ff533 100644
@@ -330,6 +330,20 @@ config SENSORS_CORETEMP
 	  sensor inside your CPU. Supported all are all known variants
 	  of Intel Core family.
 
+config SENSORS_IBMAEM
+	tristate "IBM Active Energy Manager temperature/power sensors and control"
+	select IPMI_SI
+	depends on IPMI_HANDLER
+	help
+	  If you say yes here you get support for the temperature and
+	  power sensors and capping hardware in various IBM System X
+	  servers that support Active Energy Manager.  This includes
+	  the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2,
+	  and certain HS2x/LS2x/QS2x blades.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called ibmaem.
+
 config SENSORS_IBMPEX
 	tristate "IBM PowerExecutive temperature/power sensors"
 	select IPMI_SI
drivers/hwmon/Makefile +1 -0
index 3bdb05a..d098677 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_SENSORS_GL518SM)	+= gl518sm.o
 obj-$(CONFIG_SENSORS_GL520SM)	+= gl520sm.o
 obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
 obj-$(CONFIG_SENSORS_I5K_AMB)	+= i5k_amb.o
+obj-$(CONFIG_SENSORS_IBMAEM)	+= ibmaem.o
 obj-$(CONFIG_SENSORS_IBMPEX)	+= ibmpex.o
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_K8TEMP)	+= k8temp.o
drivers/hwmon/ibmaem.c new file +905 -0

905 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors