linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: "Guenter Roeck" <linux@roeck-us.net>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
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: (EXT) Re: [PATCH v3 6/6] hwmon: pwm-fan: Add hwmon_pwm_enable attribute
Date: Wed, 18 May 2022 09:06:54 +0200	[thread overview]
Message-ID: <3435664.iIbC2pHGDl@steina-w> (raw)
In-Reply-To: <20220517170658.u3dpe6gglsihh6n6@pengutronix.de>

Am Dienstag, 17. Mai 2022, 19:06:58 CEST schrieb Uwe Kleine-König:
> * PGP Signed by an unknown key
> 
> Hello,
> 
> [dropped Bartlomiej Zolnierkiewicz from Cc:]
> 
> On Tue, May 17, 2022 at 09:38:56AM -0700, Guenter Roeck wrote:
> > On 5/17/22 07:26, 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
> > 
> > Unless I am missing something, I think we have (at least) three
> > conditions to handle:
> > 
> > - regulator disabled (independent of pwm value)
> > - regulator enabled, pwm output disabled if pwm=0
> > - regulator enabled, pwm output enabled and set to 0 (or, if inverted,
> > 
> >   to maximum) if pwm=0
> 
> What is your expectation for a disabled PWM?
> https://lore.kernel.org/linux-pwm/20220517150555.404363-1-u.kleine-koenig@pe
> ngutronix.de might be relevant. If you assume that a pwm might output the
> active level after disabling, the case "regulator enabled, pwm output
> disabled if pwm=0" sounds wrong.
> 
> Would "pwm1_disable_on_zero" be a better name than "pwm1_enable"? The
> latter is completely unintuitive to me.

I guess Guenter suggested 'pwm1_enable' as it already exists as a predefined, 
optional attribute, avoiding adding a new custom attribute.
Reading Documentation/hwmon/w83627ehf.rst or Documentation/hwmon/nzxt-
smart2.rst I get the impression their meaning is pretty unrestricted.
If you are concerned by using 'pwm1_enable', what about 'pwm1_mode'?

> Maybe go for
> 
>  0 -> keep pwm and regulator on
>  1 -> disable pwm, keep regulator on
>  2 -> keep pwm on, disable regulator
>  3 -> disable pwm and regulator
> 
> (so one bit for pwm and one for regulator), even if 1 is
> wrong/unusual/dangerous?

I tend to like this approach, as it can handle all combinations. You can 
decide whether you want to actually shutdown the PWM fan, or keep it enabled 
but without providing any PWM. This can mean the fan still runs at the lowest 
speed. It also addresses the scenarios where regulator cannot be disabled at 
all.

Best regards,
Alexander



  reply	other threads:[~2022-05-18  7:07 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
2022-05-17 16:38   ` Guenter Roeck
2022-05-17 17:06     ` Uwe Kleine-König
2022-05-18  7:06       ` Alexander Stein [this message]
2022-05-18 14:20         ` (EXT) " 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=3435664.iIbC2pHGDl@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;
as well as URLs for NNTP newsgroup(s).