From: Conor Dooley <conor.dooley@microchip.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
"Douglas Anderson" <dianders@chromium.org>,
Pavel Machek <pavel@ucw.cz>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
Kevin Hilman <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
"Heiko Stuebner" <heiko@sntech.de>,
Palmer Dabbelt <palmer@dabbelt.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
Michael Walle <michael@walle.cc>,
"Orson Zhai" <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Fabrice Gasnier <fabrice.gasnier@foss.st.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Chen-Yu Tsai <wens@csie.org>,
Samuel Holland <samuel@sholland.org>,
Hammer Hsieh <hammerh0314@gmail.com>,
Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
Sean Anderson <sean.anderson@seco.com>,
Michal Simek <michal.simek@xilinx.com>,
Bjorn Andersson <andersson@kernel.org>,
Stephen Boyd <swboyd@chromium.org>,
Matthias Kaehlcke <mka@chromium.org>,
Satya Priya <quic_c_skakit@quicinc.com>,
<linux-pwm@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>, <linux-leds@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<chrome-platform@lists.linux.dev>,
<linux-amlogic@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-rpi-kernel@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>,
<linux-riscv@lists.infradead.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-sunxi@lists.linux.dev>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Marijn Suijten <marijn.suijten@somainline.org>
Subject: Re: [PATCH v2 00/11] pwm: Allow .get_state to fail
Date: Thu, 1 Dec 2022 11:11:51 +0000 [thread overview]
Message-ID: <Y4iL9xf5bJM5pyeR@wendy> (raw)
In-Reply-To: <20221130152148.2769768-1-u.kleine-koenig@pengutronix.de>
Hey Uwe!
On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote:
> Hello,
>
> I forgot about this series and was remembered when I talked to Conor
> Dooley about how .get_state() should behave in an error case.
In the context of "my" driver, get_state() the proposal was to fail with
-ETIMEDOUT rather than block a caller, potentially, for seconds or
report a potentially "random" state.
Specifically, values writen to the registers that control the PWM duty
cycle are not visible to the cpu until the changes have propagated to
the waveform at the start of a new period.
The timeout would occur if the bit that signifies that the "shadow
registers" contain a value which has not yet propagated. This bit is
per PWM "controller" and not per PWM channel.
Returning from apply() without waiting, possibly for seconds, for the
writes to become visible could cause get_state() to see anything between
the new and old states, inclusive!
If anyone cares at all, the discussion is here:
https://lore.kernel.org/linux-pwm/20221110093512.333881-1-conor.dooley@microchip.com/T/#m800eeabad29067940a5684e54106fd0bb7261944
> In v1 Thierry had the concern:
>
> | That raises the question about what to do in these cases. If we return
> | an error, that could potentially throw off consumers. So perhaps the
> | closest would be to return a disabled PWM?
> | Or perhaps it'd be up to the
> | consumer to provide some fallback configuration for invalidly configured
> | or unconfigured PWMs.
>
> .get_state() is only called in pwm_device_request on a pwm_state that a
> consumer might see. Before my series a consumer might have seen a
> partial modified pwm_state (because .get_state() might have modified
> .period, then stumbled and returned silently). The last patch ensures
> that this partial modification isn't given out to the consumer. Instead
> they now see the same as if .get_state wasn't implemented at all.
Getting the same thing as if get_state() did not exist seems
preferable to me in this context than "lying" and pretending that a PWM
is disabled or potentially inconsistent reports from get_state() that I
mentioned above.
TL;DR, I quite like the ability to return an error and not mislead the
caller.
Thanks for sending a v2 of this so quickly :)
Conor.
next prev parent reply other threads:[~2022-12-01 11:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König
2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König
2022-11-30 18:36 ` Heiko Stübner
2022-12-01 1:17 ` Baolin Wang
2022-12-01 2:41 ` Tzung-Bi Shih
2022-12-01 8:03 ` Neil Armstrong
2022-12-01 9:30 ` nobuhiro1.iwamatsu
2022-12-01 10:22 ` Andre Przywara
2022-12-01 13:16 ` Uwe Kleine-König
2022-12-01 14:17 ` Andre Przywara
2022-12-01 10:43 ` Dave Stevenson
2022-12-01 15:37 ` Doug Anderson
2022-12-05 20:50 ` Jernej Škrabec
2022-12-05 22:30 ` Pavel Machek
2022-11-30 15:21 ` [PATCH v2 08/11] pwm: mtk-disp: Propagate errors in .get_state() to the caller Uwe Kleine-König
2022-12-01 13:11 ` AngeloGioacchino Del Regno
2022-12-01 11:11 ` Conor Dooley [this message]
2022-12-01 13:19 ` [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König
2022-12-01 13:28 ` Conor Dooley
2022-12-09 21:47 ` Andy Shevchenko
2022-12-10 9:18 ` Uwe Kleine-König
2022-12-10 20:57 ` Andy Shevchenko
2022-12-10 22:41 ` Uwe Kleine-König
2022-12-11 13:31 ` Andy Shevchenko
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=Y4iL9xf5bJM5pyeR@wendy \
--to=conor.dooley@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bleung@chromium.org \
--cc=brgl@bgdev.pl \
--cc=chrome-platform@lists.linux.dev \
--cc=claudiu.beznea@microchip.com \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=f.fainelli@gmail.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=festevam@gmail.com \
--cc=groeck@chromium.org \
--cc=hammerh0314@gmail.com \
--cc=heiko@sntech.de \
--cc=jbrunet@baylibre.com \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-leds@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=marijn.suijten@somainline.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=matthias.bgg@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mhiramat@kernel.org \
--cc=michael@walle.cc \
--cc=michal.simek@xilinx.com \
--cc=mka@chromium.org \
--cc=nicolas.ferre@microchip.com \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=orsonzhai@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pavel@ucw.cz \
--cc=quic_c_skakit@quicinc.com \
--cc=rjui@broadcom.com \
--cc=rostedt@goodmis.org \
--cc=s.hauer@pengutronix.de \
--cc=samuel@sholland.org \
--cc=sbranden@broadcom.com \
--cc=sean.anderson@seco.com \
--cc=shawnguo@kernel.org \
--cc=swboyd@chromium.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wens@csie.org \
--cc=zhang.lyra@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).