[PATCH v2 0/1] pwm: meson: fix scheduling while atomic issue

From: Martin Blumenstingl
Date: Mon Apr 01 2019 - 13:58:25 EST


Back in January a "BUG: scheduling while atomic" error showed up during
boot on my Meson8b Odroid-C1 (which uses a PWM regulator as CPU supply).
The call trace comes down to:
__mutex_lock
clk_prepare_lock
clk_core_get_rate
meson_pwm_apply
..
dev_pm_opp_set_rate
..

Jerome has also seen the same problem but from pwm-leds (instead of a
pwm-regulator). He posted a patch which replaces the spinlock with a
mutex. That works. I believe we can optimize this by reducing the time
where the lock is held - that also allows to keep the spin-lock.

Analyzing this issue helped me understand the pwm-meson driver better.
My plan is to send some cleanups after this single fix is merged. The
goal of these cleanups is to re-use more of the goodies from the PWM
core in the pwm-meson driver as well as to address issues spotted by
Uwe Kleine-KÃnig (these issues violate the PWM API, but none of these
result in breakage of the boards/.dts that we currently have). These
follow-up patches can be found here: [1].

Dependencies: none

Target version: please queue this for -fixes so it makes it's way into
v5.1-rc (so we can get it backported from there, because this issue has
existed since the pwm-meson driver was introduced).


changes since v1 at [2]:
- added comment about usage of the spinlock as suggested by
Uwe Kleine-KÃnig (thank you)
- collected Uwe Kleine-KÃnig's Reviewed-by


[0] http://lists.infradead.org/pipermail/linux-amlogic/2019-January/009690.html
[1] https://github.com/xdarklight/linux/commits/meson-pwm-for-5.2-v1
[2] https://patchwork.kernel.org/cover/10867757/


Martin Blumenstingl (1):
pwm: meson: use the spin-lock only to protect register modifications

drivers/pwm/pwm-meson.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

--
2.21.0