From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: linux-pwm@vger.kernel.org
Cc: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org,
"Michael Hennerich" <michael.hennerich@analog.com>,
"Trevor Gamblin" <tgamblin@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
linux-stm32@st-md-mailman.stormreply.com,
"Kent Gibson" <warthog618@gmail.com>,
"David Lechner" <dlechner@baylibre.com>
Subject: [PATCH v4 0/7] pwm: New abstraction and userspace API
Date: Fri, 6 Sep 2024 17:42:56 +0200 [thread overview]
Message-ID: <cover.1725635013.git.u.kleine-koenig@baylibre.com> (raw)
Hello,
here comes v4 of the series to add support for duty offset in PWM
waveforms. For a single PWM output there is no gain, but if you have a
chip with two (or more) outputs and both operate with the same period,
you can generate an output like:
______ ______ ______ ______
PWM #0 ___/ \_______/ \_______/ \_______/ \_______
__ __ __ __
PWM #1 _____/ \___________/ \___________/ \___________/ \_________
^ ^ ^ ^
The opportunity for a new abstraction is/should be used to also improve
precision of the API functions, which implies that the rules for
lowlevel drivers are more strict for the new callbacks.
Changes since v3, which is available from
https://lore.kernel.org/linux-pwm/cover.1722261050.git.u.kleine-koenig@baylibre.com/
include:
- Drop PWM_IOCTL_GET_NUM_PWMS ioctl (patch #4), suggestion by David
Lechner
- Define members of userspace API struct using __u32 instead of
unsigned int; thanks to Kent Gibson for the suggestion (patch #4)
- Ensure that pwm_apply_state_{atomic,might_sleep}() don't return 1
Noticed by Fabrice Gasnier
- Rebased to current pwm/for-next.
(fixing a missing +1 noticed by Fabrice)
- Dropped Tested-by: from Trevor
While the axi-pwmgen driver didn't change, there were considerable
changes in the core. So I dropped it.
- add some missing EXPORT_SYMBOL_GPL for the new API functions
- Add kernel doc comments for the new API functions
- debug message in stm32_pwm_round_waveform_fromhw (another suggestion
by Fabrice)
I also updated the branch pwm/chardev in
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git to
match this v4.
I'm aware of two issues in this series:
- Triggers a lockdep warning in the pwm-meson driver. This affects the
new pwm locking vs the clk framework's prepare lock. I think this is
a false positive and to fix it, only changes in the clk framework are
necessary.
- The functions pwm_set_waveform_might_sleep() and
pwm_round_waveform_might_sleep() have an unusual return value
convention: They return 0 on success, 1 if the requested waveform
cannot be implemented without breaking the rounding rules, or a
negative errno if an error occurs.
Fabrice rightfully pointed out this to be surprised by this and
suggested to use at least a define for it.
I couldn't find a decision that I'm entirely happy with here. My
conflicts are:
- I want a constant that now and in the future only means "cannot be
done due to the rounding rules in the pwm framework". So the
options are:
* Introduce a new ESOMETHING and return -ESOMETHING
I think that's hard to motivate and also myself doubt this
would be sensible. As below, the question for a good name is
unresolved.
* return 1
This is what was done in the earlier revisions and also here.
- When keeping the return 1 semantics (and also for a new
ESOMETHING):
I agree that a name instead of a plain 1 would be nice, but I
couldn't come up with a name I liked. Given that this can be
introduced later without breaking anything, I don't consider that
very urgent.
My candidates were PWM_REQUIRES_BROKEN_ROUNDING,
PWM_REQUIRES_FORBIDDEN_ROUNDING and PWM_ERR_ROUNDING.
These are too long or/and imprecise.
If you have a good idea, please tell.
Still I'd like to get that forward and (unless a new and relevant issue
pops up until then) intend to put it into next after the next merge
window. Nevertheless I'm open for suggestions to further improve this
series.
Best regards
Uwe
Uwe Kleine-König (7):
pwm: Add more locking
pwm: New abstraction for PWM waveforms
pwm: Provide new consumer API functions for waveforms
pwm: Add support for pwmchip devices for faster and easier userspace
access
pwm: Add tracing for waveform callbacks
pwm: axi-pwmgen: Implementation of the waveform callbacks
pwm: stm32: Implementation of the waveform callbacks
drivers/pwm/core.c | 867 +++++++++++++++++++++++++++++++++--
drivers/pwm/pwm-axi-pwmgen.c | 154 +++++--
drivers/pwm/pwm-stm32.c | 612 ++++++++++++++++---------
include/linux/pwm.h | 58 ++-
include/trace/events/pwm.h | 134 +++++-
include/uapi/linux/pwm.h | 24 +
6 files changed, 1545 insertions(+), 304 deletions(-)
create mode 100644 include/uapi/linux/pwm.h
base-commit: cf6631b07b907d4c644ca42f7cc234e7149290a2
--
2.45.2
next reply other threads:[~2024-09-06 15:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 15:42 Uwe Kleine-König [this message]
2024-09-06 15:42 ` [PATCH v4 1/7] pwm: Add more locking Uwe Kleine-König
2024-09-06 19:54 ` David Lechner
2024-09-17 16:01 ` Uwe Kleine-König
2024-09-06 15:42 ` [PATCH v4 2/7] pwm: New abstraction for PWM waveforms Uwe Kleine-König
2024-09-06 17:50 ` Trevor Gamblin
2024-09-06 20:33 ` David Lechner
2024-09-06 15:42 ` [PATCH v4 3/7] pwm: Provide new consumer API functions for waveforms Uwe Kleine-König
2024-09-06 21:22 ` David Lechner
2024-09-08 12:01 ` Uwe Kleine-König
2024-09-06 15:43 ` [PATCH v4 4/7] pwm: Add support for pwmchip devices for faster and easier userspace access Uwe Kleine-König
2024-09-06 22:26 ` David Lechner
2024-09-08 14:59 ` Uwe Kleine-König
2024-09-09 20:53 ` David Lechner
2024-09-17 17:10 ` Uwe Kleine-König
2024-09-18 9:21 ` Uwe Kleine-König
2024-09-07 1:58 ` Kent Gibson
2024-09-06 15:43 ` [PATCH v4 5/7] pwm: Add tracing for waveform callbacks Uwe Kleine-König
2024-09-06 15:43 ` [PATCH v4 6/7] pwm: axi-pwmgen: Implementation of the " Uwe Kleine-König
2024-09-06 17:44 ` Trevor Gamblin
2024-09-06 15:43 ` [PATCH v4 7/7] pwm: stm32: " Uwe Kleine-König
2024-09-06 18:08 ` [PATCH v4 0/7] pwm: New abstraction and userspace API Trevor Gamblin
2024-09-06 19:06 ` David Lechner
2024-09-08 11:32 ` Uwe Kleine-König
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=cover.1725635013.git.u.kleine-koenig@baylibre.com \
--to=u.kleine-koenig@baylibre.com \
--cc=alexandre.torgue@foss.st.com \
--cc=dlechner@baylibre.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mhiramat@kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.com \
--cc=rostedt@goodmis.org \
--cc=tgamblin@baylibre.com \
--cc=warthog618@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