From: William Breathitt Gray <william.gray@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Fabrice Gasnier" <fabrice.gasnier@st.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
linux-pwm@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
kernel@pengutronix.de
Subject: Re: [PATCH 3/3] pwm: Make capture support optional
Date: Thu, 17 Nov 2022 17:19:39 -0500 [thread overview]
Message-ID: <Y3aze3B6/e5uWS/H@fedora> (raw)
In-Reply-To: <20220622170945.n7eyrnuezs52itt3@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 5369 bytes --]
On Wed, Jun 22, 2022 at 07:09:45PM +0200, Uwe Kleine-König wrote:
> Hello Thierry,
>
> On Wed, Jun 22, 2022 at 03:46:32PM +0200, Thierry Reding wrote:
> > On Mon, May 23, 2022 at 07:45:02PM +0200, Uwe Kleine-König wrote:
> > > The only code making use of the capture functionality is the sysfs code
> > > in the PWM framework. I suspect there are no real users and would like to
> > > deprecate it in favor of the counter framework. So introduce a kconfig
> > > symbol to remove the capture support and make the sysfs file a stub.
> > >
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > ---
> > > drivers/pwm/Kconfig | 12 ++++++++++++
> > > drivers/pwm/core.c | 3 ++-
> > > drivers/pwm/pwm-sti.c | 4 ++++
> > > drivers/pwm/pwm-stm32.c | 4 ++++
> > > drivers/pwm/sysfs.c | 4 ++++
> > > include/linux/pwm.h | 5 +++++
> > > 6 files changed, 31 insertions(+), 1 deletion(-)
> >
> > I've applied patches 1-2 for now, but I'm not convinced about this yet.
> >
> > The PWM capture is something that's typically useful for applications
> > served from userspace, which is why only the sysfs implementation
> > exists. So anything that's based on another framework is likely not
> > going to have in-kernel users either. Can you specify exactly how this
> > alternative implementation would look like and how it would be an
> > improvement over the current implementation?
>
> The counter framework would generate a continous stream of events while
> you measure and from the timestamps of the events you can determine
> period and duty cycle. So this is even more flexible because pwm-capture
> only supports one-shot mode while with the counter stuff you can stop
> to measure whenever you want to. Having said that, I didn't actually use
> the counter framework for something like that, but that's how I think it
> works and the framework has users.
>
> Other than that I have no better reasoning than the commit log. It's
> some time ago something happend in pwm that concerns the capture
> functionality[1] and the 13 new drivers since then all didn't implement
> capture support. Also the capture stuff was done by an ST employee for
> an ST driver, so that might not even be an active user but just a
> developer fulfilling a management roadmap such that the marketing
> department can advertise capture support. (Added Fabrice Gasnier to Cc:,
> maybe he will comment.)
>
> I don't know of any user of this, but of course I cannot rule out there
> are users I just don't know of. So the suggestion here looks reasonable
> to me: There is a Kconfig item now, people who don't use capture can
> disable it and the ones who rely on it set it =y. I expect that when
> this switch hits the distribution kernels it will initially be off. Then
> either people will wail to enable it. Or they don't and in a few years
> we can be even more convinced there are no active users.
>
> Best regards
> Uwe
>
> [1] ab3a89784783 ("pwm: stm32: Use input prescaler to improve period capture") from 2018
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | https://www.pengutronix.de/ |
Hi all,
I want to give some context about the Counter subsystem as I think that
will help in deciding whether to deprecate the existing PWM capture
code.
Support for PWM input capture was added in 2018 as part of the 4.18
merge window, but the Counter subsystem was added later in 2019.
Although ST engineers involved with STM32 were at the center of
discussions steering the requirements of the nascent Counter subsystem,
the Counter events (capture) system just wasn't ready at the time the
pwm-stm32 patch introducing capture support was accepted [0].
The Counter events system enables drivers to push device events on
demand to a kfifo that userspace can pop via a respective character
device node [1]. Each event is timestamped at the moment of capture, and
userspace has the freedom to select what particular data should be
captured (count value, signal value, supported extensions, etc.). The
system really is quite flexible to what a particular user desires to
capture from the device.
As an example, suppose a Counter event is pushed to capture the current
count value every time a change-of-state is detected for a signal. Each
event will have a timestamp of when that change-of-state occurred. We
get a time delta by comparing the timestamps between two events. Because
events are in a kfifo, userspace can skip and combine events as desired.
This is how you can determine period and duty cycle, among many other
data computations.
Of course there may be current users of the existing PWM capture system,
so it shouldn't be removed outright. However, given that now the PWM
capture system functionality is essentially provided by the Counter
events system in a more flexible and extensible manner, I think it makes
sense to deprecate support for PWM capture and encourage users to
migrate to the Counter interface for such functionality.
William Breathitt Gray
[0] https://lore.kernel.org/r/1526456161-27865-4-git-send-email-fabrice.gasnier@st.com/
[1] https://docs.kernel.org/driver-api/generic-counter.html#counter-character-device
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2022-11-17 22:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 17:45 [PATCH 1/3] pwm: Reorder header file to get rid of struct pwm_capture forward declaration Uwe Kleine-König
2022-05-23 17:45 ` [PATCH 2/3] pwm: Drop unused forward declaration from pwm.h Uwe Kleine-König
2022-05-23 17:45 ` [PATCH 3/3] pwm: Make capture support optional Uwe Kleine-König
2022-06-22 13:46 ` Thierry Reding
2022-06-22 17:09 ` Uwe Kleine-König
2022-09-30 15:43 ` Uwe Kleine-König
2022-10-06 13:10 ` Thierry Reding
2022-10-06 14:35 ` Uwe Kleine-König
2022-10-07 9:58 ` Thierry Reding
2022-11-17 22:19 ` William Breathitt Gray [this message]
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=Y3aze3B6/e5uWS/H@fedora \
--to=william.gray@linaro.org \
--cc=fabrice.gasnier@st.com \
--cc=kernel@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-pwm@vger.kernel.org \
--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 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.