All of lore.kernel.org
 help / color / mirror / Atom feed
* Return code of i2c transaction ignored in lm87
@ 2005-05-19  6:25 James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: James Olin Oden @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi All,

I was reading through the lm87 code and noted (unless I am missing
something...highly possible) that an error return code from the I2C layer 
seems to be ignored.  First off, am I reading this right, and secondly
is this on purpose (i.e. is there some reason that this is the right thing 
to do that I am not getting)?

Thanks...james

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (3 preceding siblings ...)
  2005-05-19  6:25 ` Mark Studebaker
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>I was reading through the lm87 code and noted (unless I am missing
>something...highly possible) that an error return code from the I2C layer
>seems to be ignored.  First off, am I reading this right, and secondly
>is this on purpose (i.e. is there some reason that this is the right thing
>to do that I am not getting)?

Please review the 50 other chip drivers. If you can find one which *does*
handle i2c-layer errors properly, let me know ;) [1]

More seriously, no, you're not missing anything. All our drivers are
shamelessly ignoring errors. This has been reported many times, see for
example these tickets:
http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticketQ7
http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket…5
And there's probably more in both the ticket base and the mailing-list
archive.

The (bad) reason behind this is that most likely, if there are read
errors, the driver will be unusable anyway.

[1] The only driver handling the errors correctly as far as I know is the
w83l785ts. I implemented it because there is a popular Asus board using
this chip and Asus' C.O.P. "feature" interacts with the chip
repeatedly, causing frequent (as in a few percents) read errors.
Detecting such errors and retrying reading fixes the problem in most
cases.

A similar method could be implemented in other chips, but when people
complain, we usually spend time trying to fix their bus (either driver
or hardware) instead, since that's what is really needed.

At any rate, I would not work on this in 2.4 anymore, but more likely in
2.6, where having more "serious" drivers would be welcome.

Thanks,
Jean Delvare

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` James Olin Oden
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Mark Studebaker
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


[please remember to CC the mailing list on reply]

>Would a 2.4 patch be acceptable that merely returns a read or write error
>to the thing trying to read the sensor information.

The drivers architecture will hardly let you implement this. I dont think
you even have the possibility to return a non-zero error code in procfs
(callback functions return void IIRC). In 2.6 it's better since
callback functions can return an error value. However, in both cases
(2.4 and 2.6) the registers are read all at once in a different function
(mainly to ensure that the chip will get some rest from times to times)
so if an error occurs, it occurs in that common update function, *not*
in the reader callback function, so you cannot just return -1 and
consider that the read failed. The register which failed may not be the
one you are reading at that moment. You would have to keep track of
whether each register read succeeded or failed. Although not unfeasable,
this would be a very important change and I don't think it's
acceptable in 2.4/CVS. I'm not even sure I would like this in 2.6...

So all in all the only case (for now) where we could easily notify errors
to the caller is when writing to sysfs files. For now we only notify
input errors (requested value not acceptable for the given feature) but
write errors could be notified that way too.

> The reason I ask is
>because for the short term I still have to live with 2.4, and in two
>places I am going to see these sort of errors.  The first is conjecture,
>but one type of system gets spurious (like once a day) really off values
>from sensors (like even the thresholds it reads back change) and then
>it corrects itself after about 30 seconds.  This is likely after perusing
>the I2C stuff a bug in our hardware, which when this system I can't get
>changed.  My work around was to cache sensors output and if the thresholds
>changed from one reading to the next, I keep the old readings (an utterly
>abysmal hack I know).  In the other case we have an I2C mux that will
>allow occasional on demand access to the I2C mux by another device.  The
>hope was rather than getting sensors to support the PCA9541 (which really
>doesn't support arbitration anyway) we would simply allow for errors
>on the bus during those brief periods (once in 3 months) that someone
>might access the I2C bus from this other device.
>
>In both cases, I would rather simply get read/write errors when accessing
>the sensors proc stuff, and make the users space software respond to the
>error.

As said above, I doubt you'll be able to do that, at least easily. But
let me know if you see a way I missed. Like Greg, I can be convinced
with patches ;)

>When we move to 2.6 I would be more than willing at looking at the retry
>approach.  For now though in 2.4 I would be happy if I could just have the
>error propagated down.  Also, at some point one has to give up retrying
>and pass an error back, so it would not be totally wasted work.
>
>Does this seem like an acceptable approach to a patch to the LM87 chip
>driver?

Actually I would consider the retry method in 2.4 as well (because I
don't see any other easy way). As you noticed, there's a moment
you'll have to give up, and the only way I can think of is returning
the old value (if it exists, and probably 0 if it doesn't). That's
what the w83l785ts driver does IIRC. And fill the logs with endless
screams, of course.

Thanks,
Jean Delvare

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (2 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Mark Studebaker
  2005-05-19  6:25 ` Jean Delvare
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Mark Studebaker @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

A clarification:

The w83l785ts error handling is in the 2.6 kernel version only.

The adm1021 driver has error handling in the 2.4 kernel version only.

mds


Jean Delvare wrote:
>>I was reading through the lm87 code and noted (unless I am missing
>>something...highly possible) that an error return code from the I2C layer
>>seems to be ignored.  First off, am I reading this right, and secondly
>>is this on purpose (i.e. is there some reason that this is the right thing
>>to do that I am not getting)?
> 
> 
> Please review the 50 other chip drivers. If you can find one which *does*
> handle i2c-layer errors properly, let me know ;) [1]
> 
> More seriously, no, you're not missing anything. All our drivers are
> shamelessly ignoring errors. This has been reported many times, see for
> example these tickets:
> http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticketQ7
> http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket…5
> And there's probably more in both the ticket base and the mailing-list
> archive.
> 
> The (bad) reason behind this is that most likely, if there are read
> errors, the driver will be unusable anyway.
> 
> [1] The only driver handling the errors correctly as far as I know is the
> w83l785ts. I implemented it because there is a popular Asus board using
> this chip and Asus' C.O.P. "feature" interacts with the chip
> repeatedly, causing frequent (as in a few percents) read errors.
> Detecting such errors and retrying reading fixes the problem in most
> cases.
> 
> A similar method could be implemented in other chips, but when people
> complain, we usually spend time trying to fix their bus (either driver
> or hardware) instead, since that's what is really needed.
> 
> At any rate, I would not work on this in 2.4 anymore, but more likely in
> 2.6, where having more "serious" drivers would be welcome.
> 
> Thanks,
> Jean Delvare
> 
> 

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: James Olin Oden @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Fri, 25 Jun 2004, Jean Delvare wrote:

> [please remember to CC the mailing list on reply]
> 
> >Would a 2.4 patch be acceptable that merely returns a read or write error
> >to the thing trying to read the sensor information.
> 
> The drivers architecture will hardly let you implement this. I dont think
> you even have the possibility to return a non-zero error code in procfs
> (callback functions return void IIRC). In 2.6 it's better since
> callback functions can return an error value. However, in both cases
> (2.4 and 2.6) the registers are read all at once in a different function
> (mainly to ensure that the chip will get some rest from times to times)
> so if an error occurs, it occurs in that common update function, *not*
> in the reader callback function, so you cannot just return -1 and
> consider that the read failed. The register which failed may not be the
> one you are reading at that moment. You would have to keep track of
> whether each register read succeeded or failed. Although not unfeasable,
> this would be a very important change and I don't think it's
> acceptable in 2.4/CVS. I'm not even sure I would like this in 2.6...
> 
How about this (and I am assuming I will eventually have to produce a 
patch with the lm87 driver and drill it down into lib sensors for any real 
by in).  The routine that reads all the sensor data detects that there is 
error when reading one of the registers.  In the event of such an error it 
sets a value to one in the chips structure (or a bit).  If the read was 
succesful it sets it to zero.  A new proc entry is created called perhaps
readerror (please give me a better name).  Whenever someone is scanning 
the the proc values they can check this proc entry to see if the last read 
of the registers had no errors.  If it did not then all is well, if it did
then the program can act appropriately (ultimately, I would hope sensors 
the program would return an error and print one).  Also, when an error on 
a read is detected the syslog is notified.

I haven't thought through writes yet, but how does that sound for making 
read errors visable to user space?  This would not have to be implemented 
for all sensors either but if the mechansim was agreed upon implentation 
could occur as individuals cared.

Cheers...james

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` James Olin Oden
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> A clarification:
> 
> The w83l785ts error handling is in the 2.6 kernel version only.
> 
> The adm1021 driver has error handling in the 2.4 kernel version only.

Thanks for the clarification. I thought I had ported the w83l785ts error
handling back to 2.4 but actually you're right, I didn't. And I didn't
remember that the adm1021 had partial error handling as well, in 2.4.

I may backport the w83l785ts error handling later today if I find some
time to do so.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (4 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` James Olin Oden
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> How about this (and I am assuming I will eventually have to produce a 
> patch with the lm87 driver and drill it down into lib sensors for any
> real by in).  The routine that reads all the sensor data detects that
> there is error when reading one of the registers.  In the event of
> such an error it sets a value to one in the chips structure (or a
> bit).  If the read was succesful it sets it to zero.  A new proc entry
> is created called perhaps readerror (please give me a better name). 
> Whenever someone is scanning the the proc values they can check this
> proc entry to see if the last read of the registers had no errors.  If
> it did not then all is well, if it did then the program can act
> appropriately (ultimately, I would hope sensors the program would
> return an error and print one).  Also, when an error on a read is
> detected the syslog is notified.
> 
> I haven't thought through writes yet, but how does that sound for
> making read errors visable to user space?  This would not have to be
> implemented for all sensors either but if the mechansim was agreed
> upon implentation could occur as individuals cared.

Mmm, I don't see much benefit over what is done in w83l785ts.

With your method, the user application will be told that some of the
values are wrong, but not which ones. So every value will have to be
ignored. Second, every application will have to do it. I guess that the
application will return the old value instead in this case, which means
it'll have to remember it. All in all you want to do at the chip level
in user-space what my method (as implemented in the w83l785ts driver)
does at feature level in kernel-space, so it's finer grained and not
every application has to handle it. Since our chip drivers already cache
the old values, the amount of additional code needed is low.

Please take a look at what is done in w83l785ts and tell me why it
woudln't solve you problem, if it actually doesn't.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (5 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` James Olin Oden
  2005-05-19  6:25 ` James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: James Olin Oden @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Sun, 27 Jun 2004, Jean Delvare wrote:

> > How about this (and I am assuming I will eventually have to produce a 
> > patch with the lm87 driver and drill it down into lib sensors for any
> > real by in).  The routine that reads all the sensor data detects that
> > there is error when reading one of the registers.  In the event of
> > such an error it sets a value to one in the chips structure (or a
> > bit).  If the read was succesful it sets it to zero.  A new proc entry
> > is created called perhaps readerror (please give me a better name). 
> > Whenever someone is scanning the the proc values they can check this
> > proc entry to see if the last read of the registers had no errors.  If
> > it did not then all is well, if it did then the program can act
> > appropriately (ultimately, I would hope sensors the program would
> > return an error and print one).  Also, when an error on a read is
> > detected the syslog is notified.
> > 
> > I haven't thought through writes yet, but how does that sound for
> > making read errors visable to user space?  This would not have to be
> > implemented for all sensors either but if the mechansim was agreed
> > upon implentation could occur as individuals cared.
> 
> Mmm, I don't see much benefit over what is done in w83l785ts.
>
Oh, I was just trying to come up with a middle of the road approach that 
could go into to 2.4, and also I wanted some way for userlevel stuff to 
know that the error occured.  
 
> With your method, the user application will be told that some of the
> values are wrong, but not which ones. So every value will have to be
> ignored. 
Agreed, its not optimal.  OTOH, in my case when I have seen the bus errors
it tends to span long enough that all the values tend to  be hosed.
But that is not necessarily the case all the time.

> Second, every application will have to do it. I guess that the
> application will return the old value instead in this case, which means
> it'll have to remember it. All in all you want to do at the chip level
> in user-space what my method (as implemented in the w83l785ts driver)
> does at feature level in kernel-space, so it's finer grained and not
> every application has to handle it. Since our chip drivers already cache
> the old values, the amount of additional code needed is low.
> 
> Please take a look at what is done in w83l785ts and tell me why it
> woudln't solve you problem, if it actually doesn't.
> 
I will definately take a look at this.  Again, I was just trying to find 
some middle ground that might be acceptable in 2, and as said above I 
do want some sort of exposure to user space (for application alarming 
purposes, so that real bugs with our I2C hardware don't get missed, 
and perhaps can be fixed).  Also, be aware, I am very new to this sensors 
stuff,  so lame brained ideas are quite possible (-;

Many Thanks...james

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (6 preceding siblings ...)
  2005-05-19  6:25 ` James Olin Oden
@ 2005-05-19  6:25 ` James Olin Oden
  2005-05-19  6:25 ` Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: James Olin Oden @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Sun, 27 Jun 2004, Jean Delvare wrote:

<snip> 
> With your method, the user application will be told that some of the
> values are wrong, but not which ones. So every value will have to be
> ignored. Second, every application will have to do it. I guess that the
> application will return the old value instead in this case, which means
> it'll have to remember it. All in all you want to do at the chip level
> in user-space what my method (as implemented in the w83l785ts driver)
> does at feature level in kernel-space, so it's finer grained and not
> every application has to handle it. Since our chip drivers already cache
> the old values, the amount of additional code needed is low.
> 
> Please take a look at what is done in w83l785ts and tell me why it
> woudln't solve you problem, if it actually doesn't.
> 
Just took a look, and that seems very reasonable.  If I did this in 
the LM87 driver would this be an acceptable patch?

I still would like some way of notifing user space of such an error, 
but if I had too, I could follow the syslog and get this (hackish, but
it would work).  OTOH, if I took the aproach of the w83l785ts (what a name 
(-;), but yet also added an error proc entry so that a user space app
could (if they choose) detect the error would this be a bad thing?

Thanks...james
> Thanks.
> 
> 

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

* Return code of i2c transaction ignored in lm87
  2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
                   ` (7 preceding siblings ...)
  2005-05-19  6:25 ` James Olin Oden
@ 2005-05-19  6:25 ` Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> > Please take a look at what is done in w83l785ts and tell me why it
> > woudln't solve you problem, if it actually doesn't.
> > 
> Just took a look, and that seems very reasonable.  If I did this in 
> the LM87 driver would this be an acceptable patch?

Yes, it certainly would.

> I still would like some way of notifing user space of such an error, 
> but if I had too, I could follow the syslog and get this (hackish, but
> it would work).  OTOH, if I took the aproach of the w83l785ts (what a
> name (-;), but yet also added an error proc entry so that a user space
> app could (if they choose) detect the error would this be a bad thing?

Blame Winbond for the chip name! ;)

I wouldn't call it "a bad thing" but I merely don't see any benefit. OK,
the user-space app will know that read errors occured and some values
are "old" values. Eventually it'll let the user now. And then what?

What's more, the retry code in the driver should solve all intermitent
read errors. If errors are permanent then there won't be any readings at
all and the user will notice anyway. Your own problem may differ but
these are the two common (and still rare) cases users will encounter.

So I wouldn't support such a change, sorry.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

end of thread, other threads:[~2005-05-19  6:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19  6:25 Return code of i2c transaction ignored in lm87 James Olin Oden
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` James Olin Oden
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Mark Studebaker
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` James Olin Oden
2005-05-19  6:25 ` James Olin Oden
2005-05-19  6:25 ` Jean Delvare

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.