From: Kevin Lo <kevlo@kevlo.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] w83l786ng driver bug, questions, and 1st round patch
Date: Sun, 01 Dec 2013 15:20:04 +0000 [thread overview]
Message-ID: <529B53A4.1040707@kevlo.org> (raw)
In-Reply-To: <CABhEY3OZAkB=NxDj-QSjWATQAPG-Akhr2a0CHTB7wahLJVH6aQ@mail.gmail.com>
Jean Delvare wrote:
> Hi Brian,
>
> On Fri, 29 Nov 2013 23:57:49 -0800, Brian Carnes wrote:
>
[snip]
> Indeed, Richard (Cc'd) noticed some problems with fan speed control
> back then, but he did not provide enough details for investigation. The
> bug you found could well explain these problems, and Richard would
> probably be interested in testing your fix.
>
>> Patch addressing just problem #1:
>> --- a/w83l786ng.c
>> +++ b/w83l786ng.c
>> @@ -523,7 +523,7 @@ store_pwm_enable(struct device *dev, struct
>> device_attribute *attr,
>> mutex_lock(&data->update_lock);
>> reg = w83l786ng_read_value(client, W83L786NG_REG_FAN_CFG);
>> data->pwm_enable[nr] = val;
>> - reg &= ~(0x02 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
>> + reg &= ~(0x03 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
>> reg |= (val - 1) << W83L786NG_PWM_ENABLE_SHIFT[nr];
>> w83l786ng_write_value(client, W83L786NG_REG_FAN_CFG, reg);
>> mutex_unlock(&data->update_lock);
>> @@ -790,7 +790,7 @@ static struct w83l786ng_data
>> *w83l786ng_update_device(struct device *dev)
>> ((pwmcfg >> W83L786NG_PWM_MODE_SHIFT[i]) & 1)
>> ? 0 : 1;
>> data->pwm_enable[i] >> - ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 2)
>> + 1;
>> + ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3)
>> + 1;
>> data->pwm[i] = w83l786ng_read_value(client,
>> W83L786NG_REG_PWM[i]);
>> }
>> -----PATCH END-----
>>
>> In short:
>> chunk 1 used to clear just bit 2 (so no modes 3 or 4), then always OR in
>> bit 1.
>> Once set, no going back! Now we clear both bits, and then OR in the mode.
>> chunk 2 used to always request bit 2 (which this driver always set to zero),
>> and add one. Thus you always appeared to be in "mode 1", unless the
>> hardware
>> was in mode 3 or 4 by means other than the driver, then you would
>> appear to be in mode 3...
>> Now the driver will correctly report the mode (1, 2, 3, or 4).
> Yes, I came up to the same conclusion, your patch is correct. It should
> be backported to the stable kernel series as well. However formatting
> was destroyed by your e-mail client. Please resend with long line
> wrapping disabled (or as an attachment if you can't manage to do that.)
> You also must add your Signed-off-by line to it as explained in
> Documentation/SubmittingPatches section 12.
>
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches#n307
First off, I'm sorry that I don't have any hardware with a w83l786ng chip.
Second, your patch looks correct to me after reading the datasheet and
the code. Thanks for fixing it.
>
>> Transcript after loading patched module:
>>
>> $ sudo rmmod w83l786ng
>> $ sudo insmod ./w83l786ng.ko
>> $ cat pwm1_enable pwm2_enable
>> 1
>> 1
>> $ i2cget -f -y 0 0x2e 0x80
>> 0x00
>> $ echo 1 > pwm1_enable
>> $ cat pwm1_enable pwm2_enable
>> 1
>> 1
>> $ i2cget -f -y 0 0x2e 0x80
>> 0x00
>> $ echo 2 > pwm1_enable
>> $ cat pwm1_enable pwm2_enable
>> 2
>> 1
>> $ i2cget -f -y 0 0x2e 0x80
>> 0x04
>> $ echo 1 > pwm1_enable
>> $ cat pwm1_enable pwm2_enable
>> 1
>> 1
>> $ i2cget -f -y 0 0x2e 0x80
>> 0x00
>>
>> Which is the expected behaviour.
> Indeed. Thanks for finding and fixing this bug. Please resend your
> patch as explained above and I'll be happy to apply it, forward it to
> the stable kernel maintainers, and make the updated driver available in
> a stand-alone flavor.
Kevin
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2013-12-01 15:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 7:57 [lm-sensors] w83l786ng driver bug, questions, and 1st round patch Brian Carnes
2013-12-01 9:38 ` Jean Delvare
2013-12-01 15:20 ` Kevin Lo [this message]
2013-12-01 17:20 ` Guenter Roeck
2013-12-02 5:21 ` Brian Carnes
2013-12-02 9:17 ` Jean Delvare
2013-12-11 14:33 ` Jean Delvare
2013-12-12 4:58 ` 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=529B53A4.1040707@kevlo.org \
--to=kevlo@kevlo.org \
--cc=lm-sensors@vger.kernel.org \
/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.