From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sven Van Asbroeck <thesven73@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Clemens Gruber <clemens.gruber@pqgruber.com>,
linux-pwm@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
David Jander <david@protonic.nl>
Subject: Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API
Date: Tue, 8 Dec 2020 21:25:26 +0100 [thread overview]
Message-ID: <20201208202526.va32uvkf6rm57a4w@pengutronix.de> (raw)
In-Reply-To: <CAGngYiUP7BBF4i8YFXREA291dBTc4JytAFV9AoSjzMYTW7MyjQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]
Hello Sven,
On Tue, Dec 08, 2020 at 01:15:10PM -0500, Sven Van Asbroeck wrote:
> On Tue, Dec 8, 2020 at 11:57 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> >
> > Is this really that complicated? I sounds to me like the only thing that
> > you need is to have some sort of usage count for the prescaler. Whenever
> > you want to use the prescaler you check that usage count. If it is zero,
> > then you can just set it to whatever you need. If it isn't zero, that
> > means somebody else is already using it and you can't change it, which
> > means you have to check if you're trying to request the value that's
> > already set. If so, you can succeed, but otherwise you'll have to fail.
>
> +1
> I think your suggestion is an elegant solution to get the required behaviour.
>
> One possible complication is synchronization. The sysfs interface has a lock
> protecting against concurrent pwm_apply() calls. But the in-kernel
> API (e.g. pwm_apply_state()) doesn't seem to. This is not normally a problem
> when pwm bits are strictly separated. But in this case we have shared state
> (prescale value and use count), so we probably need to protect pwm_apply()
> with a mutex?
Right, you need a lock. You can look at pwm-imx-tpm.c which has a
similar limitation.
> Not sure if it is currently possible *in practice* for two regulator consumer
> drivers to call pwm_apply() from different threads. But Linux is slowly moving
> towards asynchronous probing.
You must assume that there is concurrent access to different channels of
your hardware.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-12-08 20:26 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 19:36 [PATCH v4 1/4] pwm: pca9685: Switch to atomic API Clemens Gruber
2020-12-07 19:36 ` [PATCH v4 2/4] pwm: pca9685: Set full OFF bits in probe Clemens Gruber
2020-12-07 19:36 ` [PATCH v4 3/4] pwm: pca9685: Support staggered output ON times Clemens Gruber
2020-12-07 19:38 ` [PATCH v4 4/4] dt-bindings: pwm: pca9685: Add nxp,staggered-outputs property Clemens Gruber
2020-12-07 22:00 ` [PATCH v4 1/4] pwm: pca9685: Switch to atomic API Uwe Kleine-König
2020-12-07 22:34 ` Sven Van Asbroeck
2020-12-07 23:24 ` Clemens Gruber
2020-12-08 9:17 ` Uwe Kleine-König
2020-12-07 23:13 ` Clemens Gruber
2020-12-08 9:10 ` Uwe Kleine-König
2020-12-08 10:12 ` Clemens Gruber
2020-12-08 13:44 ` Thierry Reding
2020-12-08 14:44 ` Sven Van Asbroeck
2020-12-08 16:57 ` Thierry Reding
2020-12-08 18:15 ` Sven Van Asbroeck
2020-12-08 20:25 ` Uwe Kleine-König [this message]
2020-12-08 18:26 ` Uwe Kleine-König
2020-12-08 20:54 ` Clemens Gruber
2020-12-09 17:02 ` Thierry Reding
2020-12-10 9:01 ` Uwe Kleine-König
2020-12-10 17:10 ` Thierry Reding
2020-12-10 20:39 ` Uwe Kleine-König
2020-12-11 8:33 ` Thierry Reding
2020-12-11 10:34 ` Uwe Kleine-König
2020-12-14 14:28 ` Thierry Reding
2020-12-14 16:09 ` Clemens Gruber
2020-12-14 16:27 ` Sven Van Asbroeck
2020-12-14 16:44 ` Sven Van Asbroeck
2020-12-10 20:54 ` Clemens Gruber
2020-12-10 21:37 ` Sven Van Asbroeck
2020-12-07 23:22 ` Sven Van Asbroeck
2020-12-07 23:56 ` Clemens Gruber
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=20201208202526.va32uvkf6rm57a4w@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=clemens.gruber@pqgruber.com \
--cc=david@protonic.nl \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=thesven73@gmail.com \
--cc=thierry.reding@gmail.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 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).