Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Guenter Roeck" <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Thierry Reding <thierry.reding@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org,
	Markus Niebel <Markus.Niebel@ew.tq-group.com>
Subject: Re: [PATCH v3 6/6] hwmon: pwm-fan: Add hwmon_pwm_enable attribute
Date: Wed, 18 May 2022 08:55:23 +0200	[thread overview]
Message-ID: <10084894.nUPlyArG6x@steina-w> (raw)
In-Reply-To: <c8f3e1b3-23e4-1dcb-7da3-e21a01062e9d@roeck-us.net>

Am Dienstag, 17. Mai 2022, 19:32:11 CEST schrieb Guenter Roeck:
> On 5/17/22 09:57, Uwe Kleine-König wrote:
> > Hello,
> > 
> > [dropping Bartlomiej Zolnierkiewicz from Cc as the address bounces]
> > 
> > On Tue, May 17, 2022 at 09:32:24AM -0700, Guenter Roeck wrote:
> >> On 5/17/22 07:53, Uwe Kleine-König wrote:
> >>> Hello,
> >>> 
> >>> On Tue, May 17, 2022 at 04:26:20PM +0200, Alexander Stein wrote:
> >>>> This adds the enable attribute which is used to differentiate if PWM
> >>>> duty
> >>>> means to switch off regulator and PWM or to keep them enabled but
> >>>> at inactive PWM output level.
> >>>> 
> >>>> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> >>>> ---
> >>>> 
> >>>>    Documentation/hwmon/pwm-fan.rst | 10 ++++
> >>>>    drivers/hwmon/pwm-fan.c         | 95
> >>>>    +++++++++++++++++++++++++++++----
> >>>>    2 files changed, 95 insertions(+), 10 deletions(-)
> >>>> 
> >>>> diff --git a/Documentation/hwmon/pwm-fan.rst
> >>>> b/Documentation/hwmon/pwm-fan.rst index 82fe96742fee..0083480068d1
> >>>> 100644
> >>>> --- a/Documentation/hwmon/pwm-fan.rst
> >>>> +++ b/Documentation/hwmon/pwm-fan.rst
> >>>> @@ -18,3 +18,13 @@ the hwmon's sysfs interface.
> >>>> 
> >>>>    The fan rotation speed returned via the optional 'fan1_input' is
> >>>>    extrapolated from the sampled interrupts from the tachometer signal
> >>>>    within 1 second.>>>> 
> >>>> +
> >>>> +The driver provides the following sensor accesses in sysfs:
> >>>> +
> >>>> +=============== =======
> >>>> =======================================================
> >>>> +fan1_input	ro	fan tachometer speed in RPM
> >>>> +pwm1_enable	rw	keep enable mode, defines behaviour when 
pwm1=0
> >>>> +			0=switch off regulator and disable PWM
> >>>> +			1=keep regulator enabled and set PWM to 
inactive level
> >>> 
> >>> Is the pwm1_enable supposed to be set to 0 if that only does the right
> >>> thing if the PWM emits low after pwm_disable()? The question I raised in
> >>> v2 about "what is the meaning of disable?" hasn't evolved, has it?
> >>> 
> >>> I still think it's unfortunate, that "pwm1_enable" has an effect on the
> >>> regulator.
> >> 
> >> Trying to understand. Are you saying that you are ok with affecting the
> >> regulator when setting pwm := 0 (even though that doesn't really mean
> >> "disable pwm output"), but not with making the behavior explicit by
> >> using pwm1_enable ?
> > 
> > Not sure about being ok with affecting the regulator when setting
> > pwm := 0. I don't know enough about pwm-fans to have a strong opinion
> > for that.

In my case (422J fan) just supplying voltage with inactive PWM results in a 
minimum rotation speed. So these two settings are coupled here.

> > Some questions to refine the semantics and my opinion:
> > 
> > There are fans without a regulator? (I think: yes)
> > 
> > A fan with a regulator always stops if the regulator is off?
> > (Hmm, there might be problems with shared regulators that only go off
> > when all consumers are off? What about always-on regulators, these don't
> > go off on the last consumer calling disable, right?)

IMHO this is something the system integrator shall manage. Is it possible to 
disable the regulator? No for shared/always-on ones. In this case stopping the 
fan needs to be done by setting PWM to inactive level and keep regulator on 
(pwm1_enable=1). If this results in a minimum rotation speed as it would using 
a 422J, it's pretty much impossible to actually stop the fan in such a system.

> > Having said that I think the sane behaviour is:
> > 
> > The intention of pwm := 0 is to stop the fan. So disabling the regulator
> > (if available) sounds right.
> 
> There are fans (eg at least some CPU fans) which never stop, even with
> pwm=0. How do you suggest to handle those ?

If it's impossible to stop the fan from the hardware side (e.g. always-on 
regulators), then software only can do this much.
Maybe adding those 4 states Uwe mentioned in [1] is not a bad idea. This way 
it's possible to configure the exact behavior one would want/need. This also 
can handle the cases where a disabled PWM has no/wrong defined state.

Best regards
Alexander

[1] https://lore.kernel.org/all/
20220517170658.u3dpe6gglsihh6n6@pengutronix.de/



  reply	other threads:[~2022-05-18  6:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 14:26 [PATCH v3 0/6] hwmon: pwm-fan: switch regulator dynamically Alexander Stein
2022-05-17 14:26 ` [PATCH v3 1/6] hwmon: pwm-fan: Refactor fan power on/off Alexander Stein
2022-05-17 14:26 ` [PATCH v3 2/6] hwmon: pwm-fan: Simplify enable/disable check Alexander Stein
2022-05-17 14:26 ` [PATCH v3 3/6] hwmon: pwm-fan: Dynamically switch off regulator if PWM duty is 0 Alexander Stein
2022-05-17 14:26 ` [PATCH v3 4/6] hwmon: pwm-fan: Remove internal duplicated pwm_state Alexander Stein
2022-05-17 14:26 ` [PATCH v3 5/6] hwmon: pwm-fan: Move PWM enable into separate function Alexander Stein
2022-05-17 14:26 ` [PATCH v3 6/6] hwmon: pwm-fan: Add hwmon_pwm_enable attribute Alexander Stein
2022-05-17 14:53   ` Uwe Kleine-König
2022-05-17 16:32     ` Guenter Roeck
2022-05-17 16:57       ` Uwe Kleine-König
2022-05-17 17:32         ` Guenter Roeck
2022-05-18  6:55           ` Alexander Stein [this message]
2022-05-17 16:38   ` Guenter Roeck
2022-05-17 17:06     ` Uwe Kleine-König
2022-05-18  7:06       ` (EXT) " Alexander Stein
2022-05-18 14:20         ` 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=10084894.nUPlyArG6x@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=Markus.Niebel@ew.tq-group.com \
    --cc=corbet@lwn.net \
    --cc=jdelvare@suse.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox