Skip to contentSkip to conversation

envctrl framework and envctrltwo (UE250) driver

RFC/PATCH Eric Brower 2 participants 7 messages Feb 22, 2005 – Feb 24, 2005 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Attached is a patch against a somewhat dated BK 2.6.10 that provides the following:

1) a basic framework for supporting SUNW,envctrl environmental
monitoring flavors
2) an implementation of the framework for basic SUNW,envctrltwo
(UE250) support

I am using the term "framework" very lightly here.

This demonstrates use of the in-kernel I2C subsystem rather than the current roll-your-own support found in the envctrl and bbc_envctrl drivers. There are a few shortcomings with using the in-kernel I2C but these can perhaps be ironed-out over time. As well, it addresses issue brought up many months ago related to how the monitoring kernel thread is started/stopped and how the shutdown functions are invoked-- basically a freshening. I believe it would be easy to move the existing envctrl driver (should be renamed envctrl-i2c or somesuch) to this framework as well and I might be convinced to do so if there is any interest.

As for the in-kernel I2C shortcomings (as I understand them; correct me if you know better):

First, the UE250 is a multi-master I2C bus; this is unlike (so far as I know) other envctrl implementations. The in-kernel I2C subsystem doesn't handle multimaster, but I've included an I2C patch to support detection of lost arbitration and I've passed this on to the lmsensors folks (still awaiting a response). This lost arbitration detection and recovery could be tightened up a bit, but seems relatively stable.

Second, and related to the first, there does not seem to be a way within the I2C subsystem to send multiple I2C messages with dyamic content in a bus-atomic fashion, which is required for proper multimaster operation. I have no workaround for this, though the I2C API could be easily modified to accomodate such an extension, I believe. For the moment, our heavy locking (see below) and collision detection give us a level of protection but it doesn't make me sleep well at night.

Second, the in-kernel I2C isn't written to support use while in_interrupt() (it uses semaphores for restricting access), which is a requirement of the SUNW,envctrltwo (if we use interrupts...). As a workaround, I've wrapped all I2C bus access calls with spinlocks.

Fourth, I don't see any easy way to leverage the use of the already-written chip drivers. Implementing support for them was trivial, and it is not clear to me how a kernel module could probe existing chip drivers and retain a handle to them for in-kernel access.

This driver is relatively rough, but has been running on my E250 for quite a while under a bit of I2C bus stress. I'd like to see reports from folks with dual CPUs, though. Please note that I needed to upgrade my BK 2.6 to include SYM53C8XX version 2.1.18n, but that may just be due to my setup. I've excessively abused sysfs for access to sensors data in this driver. I'd appreciate any feedback.

Thanks,
E

===== arch/sparc64/Kconfig 1.61 vs edited =====

arch/sparc64/Kconfig +8 -1
@@ -418,7 +418,7 @@
 	  macro in lp.c and the PARPORT_MAX macro in parport.h.
 
 config ENVCTRL
-	tristate "SUNW, envctrl support"
+	tristate "SUNW,envctrl support"
 	depends on PCI
 	help
 	  Kernel support for temperature and fan monitoring on Sun SME
@@ -426,6 +426,13 @@
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called envctrl.
+
+config ENVCTRLTWO
+	tristate "SUNW,envctrltwo environmental monitoring support"
+	depends on I2C_ENVCTRL
+	help
+	  This driver provides environmental monitoring and front status
+	  panel support for systems with SUNW,envctrltwo (Ultra Enterprise 250)
 
 config DISPLAY7SEG
 	tristate "7-Segment Display support"

===== arch/sparc64/defconfig 1.155 vs edited =====

arch/sparc64/defconfig +1 -0
@@ -115,6 +115,7 @@
 CONFIG_PARPORT_1284=y
 CONFIG_PRINTER=m
 CONFIG_ENVCTRL=m
+CONFIG_ENVCTRLTWO=m
 CONFIG_DISPLAY7SEG=m
 # CONFIG_CMDLINE_BOOL is not set
 

===== arch/sparc64/kernel/Makefile 1.30 vs edited =====

arch/sparc64/kernel/Makefile +3 -0
@@ -23,6 +23,9 @@
 obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o
 obj-$(CONFIG_US2E_FREQ) += us2e_cpufreq.o
 obj-$(CONFIG_KPROBES) += kprobes.o
+obj-$(CONFIG_ENVCTRLTWO) += envctrltwo.o
+
+envctrltwo-objs := env_lib.o env_envctrltwo.o
 
 ifdef CONFIG_SUNOS_EMUL
   obj-y += sys_sunos32.o sunos_ioctl32.o

===== arch/sparc64/kernel/env_envctrltwo.c 1.1 vs edited =====

arch/sparc64/kernel/env_envctrltwo.c +1012 -0

1,012 lines not on this page · raw message

===== arch/sparc64/kernel/env_envctrltwo.h 1.1 vs edited =====

arch/sparc64/kernel/env_envctrltwo.h +54 -0

54 lines not on this page · raw message

===== arch/sparc64/kernel/env_lib.c 1.1 vs edited =====

arch/sparc64/kernel/env_lib.c +181 -0

181 lines not on this page · raw message

===== arch/sparc64/kernel/env_lib.h 1.1 vs edited =====

arch/sparc64/kernel/env_lib.h +54 -0

54 lines not on this page · raw message

===== drivers/i2c/algos/i2c-algo-pcf.c 1.16 vs edited =====

drivers/i2c/algos/i2c-algo-pcf.c +41 -3

93 lines not on this page · raw message

===== drivers/i2c/busses/Kconfig 1.67 vs edited =====

drivers/i2c/busses/Kconfig +12 -0
@@ -476,4 +476,16 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-pca-isa.
 
+config I2C_ENVCTRL
+	tristate "Sun Microsystems envctrl I2C bus nexus driver"
+	depends on SPARC64 && PCI
+	select I2C_ALGOPCF
+	help
+	  This driver provides access to the PCF8584 I2C bus nexus
+	  used for environmental monitoring on certain Sun Microsystems
+	  platforms.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-envctrl.
+
 endmenu

===== drivers/i2c/busses/Makefile 1.40 vs edited =====

drivers/i2c/busses/Makefile +1 -0
@@ -9,6 +9,7 @@
 obj-$(CONFIG_I2C_AMD756_S4882)	+= i2c-amd756-s4882.o
 obj-$(CONFIG_I2C_AMD8111)	+= i2c-amd8111.o
 obj-$(CONFIG_I2C_ELEKTOR)	+= i2c-elektor.o
+obj-$(CONFIG_I2C_ENVCTRL)	+= i2c-envctrl.o
 obj-$(CONFIG_I2C_HYDRA)		+= i2c-hydra.o
 obj-$(CONFIG_I2C_I801)		+= i2c-i801.o
 obj-$(CONFIG_I2C_I810)		+= i2c-i810.o

===== drivers/i2c/busses/i2c-envctrl.c 1.1 vs edited =====

drivers/i2c/busses/i2c-envctrl.c +254 -0

254 lines not on this page · raw message

===== include/asm-sparc64/i2c-envctrl.h 1.1 vs edited =====

include/asm-sparc64/i2c-envctrl.h +21 -0
@@ -0,0 +1,21 @@
+#ifndef _SPARC64_I2C_ENVCTRL
+#define _SPARC64_I2C_ENVCTRL
+
+enum pcf_envctrl_types {
+	TYPE_UNKNOWN = 0,
+	TYPE_ENVCTRL = 1,
+	TYPE_ENVCTRLTWO,
+	TYPE_RASCTRL,
+	TYPE_I2C,
+};
+typedef enum pcf_envctrl_types pcf_envctrl_type_t;
+
+struct pcf_envctrl_nexus {
+	pcf_envctrl_type_t	 type;
+	int			 i2c_id;
+	struct linux_ebus_device *edev;
+};
+
+extern struct pcf_envctrl_nexus * pcf_envctrl_get_nexus(void);
+
+#endif /* _SPARC64_I2C_ENVCTRL */
#1 lore raw

DaveM, et. al,

It occurred to me that we had spoken a long while back about coalescing the logic for system LED blinking into one location (one timer, I suppose). This driver does not do that, but we could speak about how you'd like that done were this driver at some point considered for inclusion in the kernel.

E

Quoted 63 lines · Eric Brower

Attached is a patch against a somewhat dated BK 2.6.10 that provides the following:

1) a basic framework for supporting SUNW,envctrl environmental
monitoring flavors
2) an implementation of the framework for basic SUNW,envctrltwo
(UE250) support

I am using the term "framework" very lightly here.

This demonstrates use of the in-kernel I2C subsystem rather than the current roll-your-own support found in the envctrl and bbc_envctrl drivers. There are a few shortcomings with using the in-kernel I2C but these can perhaps be ironed-out over time. As well, it addresses issue brought up many months ago related to how the monitoring kernel thread is started/stopped and how the shutdown functions are invoked-- basically a freshening. I believe it would be easy to move the existing envctrl driver (should be renamed envctrl-i2c or somesuch) to this framework as well and I might be convinced to do so if there is any interest.

As for the in-kernel I2C shortcomings (as I understand them; correct me if you know better):

First, the UE250 is a multi-master I2C bus; this is unlike (so far as I know) other envctrl implementations. The in-kernel I2C subsystem doesn't handle multimaster, but I've included an I2C patch to support detection of lost arbitration and I've passed this on to the lmsensors folks (still awaiting a response). This lost arbitration detection and recovery could be tightened up a bit, but seems relatively stable.

Second, and related to the first, there does not seem to be a way within the I2C subsystem to send multiple I2C messages with dyamic content in a bus-atomic fashion, which is required for proper multimaster operation. I have no workaround for this, though the I2C API could be easily modified to accomodate such an extension, I believe. For the moment, our heavy locking (see below) and collision detection give us a level of protection but it doesn't make me sleep well at night.

Second, the in-kernel I2C isn't written to support use while in_interrupt() (it uses semaphores for restricting access), which is a requirement of the SUNW,envctrltwo (if we use interrupts...). As a workaround, I've wrapped all I2C bus access calls with spinlocks.

Fourth, I don't see any easy way to leverage the use of the already-written chip drivers. Implementing support for them was trivial, and it is not clear to me how a kernel module could probe existing chip drivers and retain a handle to them for in-kernel access.

This driver is relatively rough, but has been running on my E250 for quite a while under a bit of I2C bus stress. I'd like to see reports from folks with dual CPUs, though. Please note that I needed to upgrade my BK 2.6 to include SYM53C8XX version 2.1.18n, but that may just be due to my setup. I've excessively abused sysfs for access to sensors data in this driver. I'd appreciate any feedback.

Thanks,
E

Signature · 1 line
E
#2 lore raw
In reply to Eric Brower
Quoted 7 lines · On Tue, 22 Feb 2005 14:27:58 -0800 Eric Brower <[email protected]> wrote:

DaveM, et. al,

It occurred to me that we had spoken a long while back about coalescing the logic for system LED blinking into one location (one timer, I suppose). This driver does not do that, but we could speak about how you'd like that done were this driver at some point considered for inclusion in the kernel.

Don't worry about it for the time being.

I'll review your envctrl stuff soon, it looks really nice.

#3 lore raw
In reply to Eric Brower

I'm hesitant to provide a patch to a patch, but there was a tiny buglet in how the Thermal Error LED was represented in sysfs. A patchlet is attached, but I can resend an entire new patch if necessary. There are probably a few others lurking in there... :)

E

Quoted 15 lines · David S. Miller
Quoted 7 lines · On Tue, 22 Feb 2005 14:27:58 -0800 Eric Brower <[email protected]> wrote:

DaveM, et. al,

It occurred to me that we had spoken a long while back about coalescing the logic for system LED blinking into one location (one timer, I suppose). This driver does not do that, but we could speak about how you'd like that done were this driver at some point considered for inclusion in the kernel.

Don't worry about it for the time being.

I'll review your envctrl stuff soon, it looks really nice.

Signature · 1 line
E
sparc64/kernel/env_envctrltwo.c renamed from sparc64/kernel/env_envctrltwo.c.old +2 -2
@@ -46,7 +46,7 @@
 #include "env_lib.h"
 
 #define ENV2_DEVNAME	"envctrltwo"
-#define ENV2_VERSION    "0.2.0"
+#define ENV2_VERSION    "0.3.0"
 
 #define ENV2_DEBUG_THERMS (0) /* dump thermisters found and values probed  */
 #define ENV2_DEBUG_FAN    (0) /* user fanspeed control via sysfs - DANGER! */
@@ -676,7 +676,7 @@
 	ret += sprintf(buf + ret, "DISK ERROR: [%s]\n", 
 		stat & ENV2_LED_DISKERR ? "OFF" : "ON");
 	ret += sprintf(buf + ret, "TEMP ERROR: [%s]\n", 
-		stat & ENV2_LED_DISKERR ? "OFF" : "ON");
+		stat & ENV2_LED_TEMPERR ? "OFF" : "ON");
 	ret += sprintf(buf + ret, "PS ERROR:   [%s]\n", 
 		stat & ENV2_LED_PSERR ? "OFF" : "ON");
 
#4 lore raw
In reply to Eric Brower
Quoted 4 lines · On Wed, 23 Feb 2005 20:10:30 -0800 Eric Brower <[email protected]> wrote:

I'm hesitant to provide a patch to a patch, but there was a tiny buglet in how the Thermal Error LED was represented in sysfs. A patchlet is attached, but I can resend an entire new patch if necessary. There are probably a few others lurking in there... :)

This relative patch is fine, you don't need to resend the rest.

#5 lore raw
In reply to Eric Brower
Quoted 7 lines · On Tue, 22 Feb 2005 10:07:55 -0800 Eric Brower <[email protected]> wrote:

Attached is a patch against a somewhat dated BK 2.6.10 that provides the following:

1) a basic framework for supporting SUNW,envctrl environmental
monitoring flavors
2) an implementation of the framework for basic SUNW,envctrltwo
(UE250) support

I like this a lot. But I'd like to see the I2C layer maintainer take your lost-arbitration changes in before I merge in your envctrl driver. Ok?

It looks like [email protected] is the most active in this area, perhaps contacting him might get a quicker response than the lm-sensors folks.

#6 lore raw
In reply to Eric Brower

Will do-- I'll keep you posted. The last copyright holder didn't have any issues with the patch; I've not heard back from the lm78 folks.

Thanks,
E

Quoted 18 lines · David S. Miller
Quoted 7 lines · On Tue, 22 Feb 2005 10:07:55 -0800 Eric Brower <[email protected]> wrote:

Attached is a patch against a somewhat dated BK 2.6.10 that provides the following:

1) a basic framework for supporting SUNW,envctrl environmental
monitoring flavors
2) an implementation of the framework for basic SUNW,envctrltwo
(UE250) support

I like this a lot. But I'd like to see the I2C layer maintainer take your lost-arbitration changes in before I merge in your envctrl driver. Ok?

It looks like [email protected] is the most active in this area, perhaps contacting him might get a quicker response than the lm-sensors folks.

Signature · 1 line
E