From: Brian Norris <briannorris@chromium.org>
To: Marek Vasut <marex@denx.de>
Cc: linux-pwm@vger.kernel.org,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>
Subject: Re: [PATCH] pwm: sysfs: Do not apply state to already disabled PWMs
Date: Mon, 15 May 2023 11:26:39 -0700 [thread overview]
Message-ID: <ZGJ5X5UG6+TyqPpl@google.com> (raw)
In-Reply-To: <20230512164736.53615-1-marex@denx.de>
Hi,
On Fri, May 12, 2023 at 06:47:36PM +0200, Marek Vasut wrote:
> If the PWM is exported but not enabled, do not call pwm_class_apply_state().
> First of all, in this case, period may still be unconfigured and this would
> make pwm_class_apply_state() return -EINVAL, and then suspend would fail.
> Second, it makes little sense to apply state onto PWM that is not enabled
> before suspend.
>
> Failing case:
> "
> $ echo 1 > /sys/class/pwm/pwmchip4/export
> $ echo mem > /sys/power/state
> ...
> pwm pwmchip4: PM: dpm_run_callback(): pwm_class_suspend+0x1/0xa8 returns -22
> pwm pwmchip4: PM: failed to suspend: error -22
> PM: Some devices failed to suspend, or early wake event detected
> "
>
> Working case:
> "
> $ echo 1 > /sys/class/pwm/pwmchip4/export
> $ echo 100 > /sys/class/pwm/pwmchip4/pwm1/period
> $ echo 10 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle
> $ echo mem > /sys/power/state
> ...
> "
>
> Do not call pwm_class_apply_state() in case the PWM is disabled
> to fix this issue.
>
> Fixes: 7fd4edc57bbae ("pwm: sysfs: Add suspend/resume support")
My first thought was that this still belongs as:
Fixes: ef2bf4997f7d ("pwm: Improve args checking in pwm_apply_state()")
but then I realized sysfs suspend/resume support was added *after* that,
so indeed, your Fixes tag makes the most sense.
And yes, I think this solution (addressing sysfs.c directly) is best
too:
Reviewed-by: Brian Norris <briannorris@chromium.org>
Side question: I wonder if this belongs in linux-stable. It's definitely
a bug fix, but the bug has been around a while, with a
{under,non}-specified ABI, and it's easy enough to work around I
suppose. But inevitably, *any* patch with a Fixes tag gets picked up by
somebody's cherry-picking bot, so maybe it doesn't matter...
...Anyway, I guess I'm saying it's probably going to go to linux-stable,
whether we want it to or not; and maybe that's OK :)
Thanks,
Brian
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Brian Norris <briannorris@chromium.org>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Cc: linux-pwm@vger.kernel.org
> ---
> drivers/pwm/sysfs.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
next prev parent reply other threads:[~2023-05-15 18:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 16:47 [PATCH] pwm: sysfs: Do not apply state to already disabled PWMs Marek Vasut
2023-05-15 14:14 ` Uwe Kleine-König
2023-05-15 18:26 ` Brian Norris [this message]
2023-05-15 19:50 ` Marek Vasut
2023-06-23 14:51 ` 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=ZGJ5X5UG6+TyqPpl@google.com \
--to=briannorris@chromium.org \
--cc=geert+renesas@glider.be \
--cc=linux-pwm@vger.kernel.org \
--cc=marex@denx.de \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=yoshihiro.shimoda.uh@renesas.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.