linux-stable/drivers/char
Marek Vasut 067e296679 hwrng: stm32 - repair clock handling
[ Upstream commit c819d7b836 ]

The clock management in this driver does not seem to be correct. The
struct hwrng .init callback enables the clock, but there is no matching
.cleanup callback to disable the clock. The clock get disabled as some
later point by runtime PM suspend callback.

Furthermore, both runtime PM and sleep suspend callbacks access registers
first and disable clock which are used for register access second. If the
IP is already in RPM suspend and the system enters sleep state, the sleep
callback will attempt to access registers while the register clock are
already disabled. This bug has been fixed once before already in commit
9bae54942b ("hwrng: stm32 - fix pm_suspend issue"), and regressed in
commit ff4e46104f ("hwrng: stm32 - rework power management sequences") .

Fix this slightly differently, disable register clock at the end of .init
callback, this way the IP is disabled after .init. On every access to the
IP, which really is only stm32_rng_read(), do pm_runtime_get_sync() which
is already done in stm32_rng_read() to bring the IP from RPM suspend, and
pm_runtime_mark_last_busy()/pm_runtime_put_sync_autosuspend() to put it
back into RPM suspend.

Change sleep suspend/resume callbacks to enable and disable register clock
around register access, as those cannot use the RPM suspend/resume callbacks
due to slightly different initialization in those sleep callbacks. This way,
the register access should always be performed with clock surely enabled.

Fixes: ff4e46104f ("hwrng: stm32 - rework power management sequences")
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-30 09:49:02 +02:00
..
agp char/agp: Remove frontend code 2023-12-06 10:08:41 +01:00
hw_random hwrng: stm32 - repair clock handling 2024-05-30 09:49:02 +02:00
ipmi ipmi: Remove usage of the deprecated ida_simple_xx() API 2023-12-19 06:33:45 -06:00
mwave
tpm tpm,tpm_tis: Avoid warning splat at shutdown 2024-04-03 15:32:19 +02:00
xilinx_hwicap char: xilinx_hwicap: Fix NULL vs IS_ERR() bug 2024-03-26 18:17:30 -04:00
xillybus char: xillybus: make XILLYBUS_OF depend on HAS_IOMEM 2023-08-04 15:39:39 +02:00
Kconfig arch: Remove Itanium (IA-64) architecture 2023-09-11 08:13:17 +00:00
Makefile arch: Remove Itanium (IA-64) architecture 2023-09-11 08:13:17 +00:00
adi.c
apm-emulation.c apm-emulation: drop unexpected word "the" in the comments 2022-06-27 16:15:27 +02:00
applicom.c applicom: Fix PCI device refcount leak in applicom_init() 2023-01-20 13:05:39 +01:00
applicom.h
bsr.c char: Explicitly include correct DT includes 2023-07-30 18:15:27 +02:00
ds1620.c
dsp56k.c dsp56k: make dsp56k_class a static const structure 2023-06-23 10:27:08 +02:00
dtlk.c
hangcheck-timer.c
hpet.c Char/Misc and other driver changes for 6.7-rc1 2023-11-03 14:51:08 -10:00
lp.c char: lp: make lp_class a static const structure 2023-06-23 10:27:11 +02:00
mem.c Char/Misc and other driver changes for 6.7-rc1 2023-11-03 14:51:08 -10:00
misc.c char: misc: make misc_class a static const structure 2023-06-23 10:27:15 +02:00
nsc_gpio.c
nvram.c
nwbutton.c
nwbutton.h
nwflash.c
pc8736x_gpio.c
powernv-op-panel.c
ppdev.c ppdev: Remove usage of the deprecated ida_simple_xx() API 2024-01-04 16:43:20 +01:00
ps3flash.c
random.c random: handle creditable entropy from atomic process context 2024-04-27 17:12:48 +02:00
scx200_gpio.c
sonypi.c char: convert to new timestamp accessors 2023-10-18 13:26:16 +02:00
tlclk.c
toshiba.c
ttyprintk.c tty: ttyprintk: convert to u8 and size_t 2023-12-08 12:02:38 +01:00
uv_mmtimer.c
virtio_console.c tty: hvc: convert to u8 and size_t 2023-12-08 12:02:37 +01:00