All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Buloz <Gilles.Buloz@kontron.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Subject: Re: hwmon: (nct7802) buggy VSEN1/2/3 alarm
Date: Mon, 25 Nov 2019 16:44:44 +0000	[thread overview]
Message-ID: <5DDC04FB.1030705@kontron.com> (raw)
In-Reply-To: <6cde95e5-0ab3-016f-b67d-73db8c16ff71@roeck-us.net>

Le 25/11/2019 15:31, Guenter Roeck a écrit :
> On 11/25/19 5:13 AM, Gilles Buloz wrote:
>> Hi Guenter,
>>
>> According to the NCT7802Y datasheet, the REG_VOLTAGE_LIMIT_LSB definition is wrong and leads to wrong threshold registers used. It
>> should be :
>> static const u8 REG_VOLTAGE_LIMIT_LSB[2][5] = {
>>           { 0x46, 0x00, 0x40, 0x42, 0x44 },
>>           { 0x45, 0x00, 0x3f, 0x41, 0x43 },
>> };
>> With this definition, the right bit is set in "Voltage SMI Status Register @0x1e" for each threshold reached (using i2cget to check)
>>
>
> Good catch. Care to send a patch ?
As a fix for this is only useful with a fix for the problem below, maybe a single patch for both would be better.
>> But I'm unable to get any "ALARM" reported by the command "sensors" for VSEN1/2/3 = in2,in3,in4 because status for in0 is read
>> before (unless I set "ignore in0" in sensors file). The problem is that status bits in "Voltage SMI Status Register @0x1e" are
>> cleared when reading, and a read is done for each inX processed, so only the first inX has a chance to get its alarm bit set.
>> For this problem I don't see how to fix this easily; just to let you know ...
>>
> One possible fix would be to cache each alarm register and to clear the cache
> either after reading it (bitwise) or after a timeout. The latter is probably
> better to avoid stale information.
As we have status registers cleared at byte level and we want them to be cleared at bit level when each bit is read, I think a cache 
would be better. I suggest this :
- have a cached value for each status register, by default at 0x00
- when reading a register to get a bit, "OR" its byte value with its cached value, then use its cached value for processing.
- then clear the bit that has been processed from the cached value.

I think a timeout would not be obvious to set : at least the time for sensors to read all info (including when terminal is a serial 
line and output is slower) and to deal with possible latencies, but not too long...
>
> Guenter
> .
>

  reply	other threads:[~2019-11-25 16:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 13:13 hwmon: (nct7802) buggy VSEN1/2/3 alarm Gilles Buloz
2019-11-25 14:31 ` Guenter Roeck
2019-11-25 16:44   ` Gilles Buloz [this message]
2019-11-25 17:35     ` Guenter Roeck
2019-11-25 18:06       ` Gilles Buloz
2019-11-26 10:03         ` Gilles Buloz
2019-11-26 12:22           ` Guenter Roeck
2019-11-26 16:47             ` Gilles Buloz
2019-11-26 18:20               ` Guenter Roeck
2019-11-27 10:42                 ` Gilles Buloz
2019-11-27 14:41                 ` Gilles Buloz
2019-11-27 19:32                   ` Guenter Roeck
2019-11-28 10:47                     ` Gilles Buloz
2019-11-28 15:22                       ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5DDC04FB.1030705@kontron.com \
    --to=gilles.buloz@kontron.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.