All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	kernel@pengutronix.de, Vladimir Zapolskiy <vz@mleia.com>
Subject: Re: [PATCH] pwm: lpc18xx-sct: don't reconfigure PWM in .request and .free
Date: Fri, 16 Nov 2018 11:45:03 +0100	[thread overview]
Message-ID: <20181116104503.he6rykrsqt4whacs@pengutronix.de> (raw)
In-Reply-To: <20181116100114.GB28631@ulmo>

Hello Thierry,

On Fri, Nov 16, 2018 at 11:01:14AM +0100, Thierry Reding wrote:
> On Fri, Nov 16, 2018 at 11:22:49AM +0200, Vladimir Zapolskiy wrote:
> > On 11/16/2018 08:52 AM, Uwe Kleine-König wrote:
> > > Regarding the .request case: The consumer might be interested in taking
> > > over the configured state from the boot loader. So the initially
> > > configured state should be retained.
> > > 
> > > For the free case the PWM consumer is responsible to disable the PWM
> > > before calling pwm_release and there are three subcases to consider:
> > > 
> > 
> > the changes are fine per se, but please split them into two.
> > 
> > Probably pwm_disable() misusage began spreading from commit 54b2a999a1675.
> 
> It's not really misusage to call pwm_disable(). It's basically just a
> shortcut for ->disable() or the atomic equivalent for it.

I'd say that pwm_disable() is not a shortcut but the long way round to
.disable() at best.

And that calling pwm_disable() from the low level driver doesn't result
in problems is just luck because the pwm framework is such a thin
wrapper. If it would do locking, .free might already hold the lock and
pwm_disable might try to grab it again. If it would do more checking
that only a caller of pwm_get calls pwm_disable, the check would trigger
because the consumer already called pwm_put and the lowlevel driver
didn't use pwm_get.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

WARNING: multiple messages have this Message-ID (diff)
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pwm: lpc18xx-sct: don't reconfigure PWM in .request and .free
Date: Fri, 16 Nov 2018 11:45:03 +0100	[thread overview]
Message-ID: <20181116104503.he6rykrsqt4whacs@pengutronix.de> (raw)
In-Reply-To: <20181116100114.GB28631@ulmo>

Hello Thierry,

On Fri, Nov 16, 2018 at 11:01:14AM +0100, Thierry Reding wrote:
> On Fri, Nov 16, 2018 at 11:22:49AM +0200, Vladimir Zapolskiy wrote:
> > On 11/16/2018 08:52 AM, Uwe Kleine-K?nig wrote:
> > > Regarding the .request case: The consumer might be interested in taking
> > > over the configured state from the boot loader. So the initially
> > > configured state should be retained.
> > > 
> > > For the free case the PWM consumer is responsible to disable the PWM
> > > before calling pwm_release and there are three subcases to consider:
> > > 
> > 
> > the changes are fine per se, but please split them into two.
> > 
> > Probably pwm_disable() misusage began spreading from commit 54b2a999a1675.
> 
> It's not really misusage to call pwm_disable(). It's basically just a
> shortcut for ->disable() or the atomic equivalent for it.

I'd say that pwm_disable() is not a shortcut but the long way round to
.disable() at best.

And that calling pwm_disable() from the low level driver doesn't result
in problems is just luck because the pwm framework is such a thin
wrapper. If it would do locking, .free might already hold the lock and
pwm_disable might try to grab it again. If it would do more checking
that only a caller of pwm_get calls pwm_disable, the check would trigger
because the consumer already called pwm_put and the lowlevel driver
didn't use pwm_get.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2018-11-16 10:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 19:45 is pwm_put supposed to stop a PWM? Uwe Kleine-König
2018-10-29 11:48 ` Thierry Reding
2018-11-03 14:49   ` Uwe Kleine-König
2018-11-14  9:30     ` Uwe Kleine-König
2018-11-14 11:50       ` Thierry Reding
2018-11-15  8:42         ` Uwe Kleine-König
2018-11-15 15:43           ` Thierry Reding
2018-11-15 20:46             ` Uwe Kleine-König
2018-11-16  6:52         ` [PATCH] pwm: lpc18xx-sct: don't reconfigure PWM in .request and .free Uwe Kleine-König
2018-11-16  6:52           ` Uwe Kleine-König
2018-11-16  7:02           ` Uwe Kleine-König
2018-11-16  7:02             ` Uwe Kleine-König
2018-11-16  9:22           ` Vladimir Zapolskiy
2018-11-16  9:22             ` Vladimir Zapolskiy
2018-11-16  9:48             ` Uwe Kleine-König
2018-11-16  9:48               ` Uwe Kleine-König
2018-11-16 10:01             ` Thierry Reding
2018-11-16 10:01               ` Thierry Reding
2018-11-16 10:45               ` Uwe Kleine-König [this message]
2018-11-16 10:45                 ` Uwe Kleine-König
2018-11-16 10:05           ` Thierry Reding
2018-11-16 10:05             ` Thierry Reding
2018-11-19 19:55             ` Uwe Kleine-König
2018-11-19 19:55               ` Uwe Kleine-König
2018-11-20 15:42               ` Thierry Reding
2018-11-20 15:42                 ` Thierry Reding

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=20181116104503.he6rykrsqt4whacs@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vz@mleia.com \
    /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.