Skip to contentSkip to conversation

robustified adm1021

DISCUSSION Mark Studebaker 2 participants 8 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Couldn't find the thread, but there was some discussion about how i2c-core returns failures as -1 and the chip drivers just take that, cast it to a u8, and that gets converted by libsensors and reported as the value.

Also I think that adm1021 was a driver that tended to get intermittent errors.

So I took adm1021 and modified update_client to return the old value if the read failed, as a demonstration. Comments welcome.

This behavior or something similar should be our practice going forward for non-ISA chip drivers.

mds

#1 lore raw

Thanks for the good comments.

As I recall a user was complaining about a bad reading, which caused an out-of-limits value, and some userspace sw decided to shut the system down based on one reading.

You are correct that my change handles transient failures but also hides permanent failures.

Since there is no way to get a consistent failure indication through libsensors now (0xff could become anything), perhaps a new standard /proc entry (fail?), which is cleared-on-read, could be used. Fail could be either 0/1 or a bitmask like alarms?

Or, in the driver, only return 0xff for a reading after repeated read failures.

Another alternative is to let the i2c adapter do the fail indication... no, probably not good.

adm1021 and lm75 now in linus' tree...

Quoted 29 lines · Ky?sti M?lkki
Quoted 4 lines · Mark Studebaker

Couldn't find the thread, but there was some discussion about how i2c-core returns failures as -1 and the chip drivers just take that, cast it to a u8, and that gets converted by libsensors and reported as the value.

I think I complained about returning -1 for any errors from i2c-core, even when adapter returned something worth repeating to user, like timeout or hw failure etc. I have not looked if something tests for -1 explicitly, and put some choices in i2c-algo-biths.

While the adm change is trivial, it leaves userland with less chance of detecting bus/chip game over situation. The pitfall is that monitoring daemon will choose to draw a straight line and not notify sysadmin nor do any fan(cy) pwm.

With /proc there is little to do but give clearly incorrect reading or invent new alarm set if some access failed. Without PEC, bad values come through anyway and need sanity checking for RRD/MRTG/logging. For this type of sysadmin utility, I feel reliability must come first.

Whether sensor access over /proc is convenient or (ever) acceptable in Linus's tree is worth considering. Today the choice might be devfs.

--
Ky?sti M?lkki
[email protected]

#2 lore raw
In reply to Mark Studebaker
Quoted 12 lines · Ky?sti M?lkki
Quoted 7 lines · Mark D. Studebaker

You are correct that my change handles transient failures but also hides permanent failures.

Since there is no way to get a consistent failure indication through libsensors now (0xff could become anything), perhaps a new standard /proc entry (fail?), which is cleared-on-read, could be used. Fail could be either 0/1 or a bitmask like alarms?

Quoted 5 lines

I did not understand the cleared-on-read. If you mean entry for "new, valid data available", it does not survive several readers well. SNMP style of a serial incrementing every time there is "new & valid data" is better, but does not work for a single run of sensors.

My idea was a /proc entry, "fail", which was a bitmask with exactly the same bit assignments as "alarms" and "beeps". And when somebody read "fail", the bits would be cleared by the driver until the next read failure.
You are right it doesn't survive for several readers.

Another idea I had was that, on read failure, the driver would
set the appropriate "alarms" bit in /proc.
In other words the "alarms" entry in /proc would be the logical OR of the alarms register in the chip and the driver's internal "fail" bit register. This wouldn't require any new /proc entries, and works with "sensors" and other libsensors programs unchanged.
What do you think of that?

Quoted 7 lines

Maybe bitmask. 0 for ok, 1 uninitialized, 2 nak, 4 pec, 8 stuck? Even with some sensor code in 2.5 tree now, I would check with LKML response of using sysctls for sensors access in the first place before extending it to handle failures like this. I never understood the choice of using sysctl instead of /dev for this, not that I care or volunteer to port to devfs but still.

I'm not volunteering either.
The lm75 and adm1021 drivers were accepted, and i2c-proc has been in the kernel for quite a while. I'm not at all inclined to stir things up on LKML.

Quoted 9 lines
Quoted 3 lines

Or, in the driver, only return 0xff for a reading after repeated read failures.

Daemon still needs to have some tolerance to avoid shutdown from a single bit error. As you noted, 0xff could become anything in libsensors, maybe even within the normal range of the meter.

agreed. Any daemon that takes drastic action on one reading is not too good.

Quoted 11 lines
Quoted 3 lines

Another alternative is to let the i2c adapter do the fail indication... no, probably not good.

Well it does return negative already, which is nice. And print something in log which is good for aftermath. The point with return values from adapter is that different actions need be taken for failures and bus arbitration. Sometimes nak is normal operation, like client FIFO full or EEP writing.

So you'd like i2c-core to return different negative values for different error conditions (that is, pass through the bus driver error code) rather than return -1 for everything?
That sounds fine to me.

#3 lore raw
In reply to Mark Studebaker

actually I meant alarms = chip | fail.
So the 'sensors' program would say "ALARM" if the read failed - no changes to 'sensors' required.

Quoted 34 lines · Ky?sti M?lkki
Quoted 7 lines · Mark Studebaker

Another idea I had was that, on read failure, the driver would set the appropriate "alarms" bit in /proc. In other words the "alarms" entry in /proc would be the logical OR of the alarms register in the chip and the driver's internal "fail" bit register.
This wouldn't require any new /proc entries, and works with "sensors" and other libsensors programs unchanged.
What do you think of that?

Might be the easiest solution, if you mean alarms = chip|(fail<<8) ?

Quoted 3 lines

The lm75 and adm1021 drivers were accepted, and i2c-proc has been in the kernel for quite a while. I'm not at all inclined to stir things up on LKML.

While sensors don't use the client->driver->command() method at all, it is crucial for video4linux drivers. I would like to have something like:

/dev/i2c/host0/bus0/50-eeprom

                 ../61-tuner
                 ../80-msp3400

/dev/wbr/tuner -> /dev/i2c/host0/bus0/61-tuner
/dev/wbr/demod -> /dev/i2c/host0/bus0/80-msp3400

Here, wbr could stand for wideband receiver. I need some use for the analog tuner card in a few years time.

#4 lore raw
In reply to Mark Studebaker
Quoted 4 lines · Mark Studebaker

Couldn't find the thread, but there was some discussion about how i2c-core returns failures as -1 and the chip drivers just take that, cast it to a u8, and that gets converted by libsensors and reported as the value.

I think I complained about returning -1 for any errors from i2c-core, even when adapter returned something worth repeating to user, like timeout or hw failure etc. I have not looked if something tests for -1 explicitly, and put some choices in i2c-algo-biths.

While the adm change is trivial, it leaves userland with less chance of detecting bus/chip game over situation. The pitfall is that monitoring daemon will choose to draw a straight line and not notify sysadmin nor do any fan(cy) pwm.

With /proc there is little to do but give clearly incorrect reading or invent new alarm set if some access failed. Without PEC, bad values come through anyway and need sanity checking for RRD/MRTG/logging. For this type of sysadmin utility, I feel reliability must come first.

Whether sensor access over /proc is convenient or (ever) acceptable in Linus's tree is worth considering. Today the choice might be devfs.

Signature · 2 lines
  Ky?sti M?lkki
  [email protected]
#5 lore raw
In reply to Mark Studebaker
Quoted 7 lines · Mark D. Studebaker

You are correct that my change handles transient failures but also hides permanent failures.

Since there is no way to get a consistent failure indication through libsensors now (0xff could become anything), perhaps a new standard /proc entry (fail?), which is cleared-on-read, could be used. Fail could be either 0/1 or a bitmask like alarms?

I did not understand the cleared-on-read. If you mean entry for "new, valid data available", it does not survive several readers well. SNMP style of a serial incrementing every time there is "new & valid data" is better, but does not work for a single run of sensors.

Maybe bitmask. 0 for ok, 1 uninitialized, 2 nak, 4 pec, 8 stuck? Even with some sensor code in 2.5 tree now, I would check with LKML response of using sysctls for sensors access in the first place before extending it to handle failures like this. I never understood the choice of using sysctl instead of /dev for this, not that I care or volunteer to port to devfs but still.

Quoted 2 lines

Or, in the driver, only return 0xff for a reading after repeated read failures.

Daemon still needs to have some tolerance to avoid shutdown from a single bit error. As you noted, 0xff could become anything in libsensors, maybe even within the normal range of the meter.

Quoted 2 lines

Another alternative is to let the i2c adapter do the fail indication... no, probably not good.

Well it does return negative already, which is nice. And print something in log which is good for aftermath. The point with return values from adapter is that different actions need be taken for failures and bus arbitration. Sometimes nak is normal operation, like client FIFO full or EEP writing.

Signature · 2 lines
  Ky?sti M?lkki
  [email protected]
#6 lore raw
In reply to Mark Studebaker
Quoted 7 lines · Mark Studebaker

Another idea I had was that, on read failure, the driver would set the appropriate "alarms" bit in /proc. In other words the "alarms" entry in /proc would be the logical OR of the alarms register in the chip and the driver's internal "fail" bit register.
This wouldn't require any new /proc entries, and works with "sensors" and other libsensors programs unchanged.
What do you think of that?

Might be the easiest solution, if you mean alarms = chip|(fail<<8) ?

Quoted 3 lines

The lm75 and adm1021 drivers were accepted, and i2c-proc has been in the kernel for quite a while. I'm not at all inclined to stir things up on LKML.

While sensors don't use the client->driver->command() method at all, it is crucial for video4linux drivers. I would like to have something like:

/dev/i2c/host0/bus0/50-eeprom

                 ../61-tuner
                 ../80-msp3400

/dev/wbr/tuner -> /dev/i2c/host0/bus0/61-tuner
/dev/wbr/demod -> /dev/i2c/host0/bus0/80-msp3400

Here, wbr could stand for wideband receiver. I need some use for the analog tuner card in a few years time.

Signature · 2 lines
  Ky?sti M?lkki
  [email protected]
#7 lore raw
In reply to Mark Studebaker
Quoted 3 lines · Mark Studebaker

actually I meant alarms = chip | fail.
So the 'sensors' program would say "ALARM" if the read failed - no changes to 'sensors' required.

Cannot think of anything to argue there, for a single reader case. Maybe add retry in the i2c read part, in case chip inserts wait states the host does not accept. A retry from /proc is not effective for some seconds.

Is there a reason why limits are read from chip in update? Seems to be the case with most drivers.

If a measurement goes out of limits and returns chip's ALARM status is set and cleared on /proc update. With two or more unsynchronised readers, a reader may miss this update and transient failures. Maybe I could write a reader daemon to handle chip access and have libsensors talk with it.

Signature · 2 lines
  Ky?sti M?lkki
  [email protected]