linux/drivers/char/hw_random
Marek Vasut c819d7b836 hwrng: stm32 - repair clock handling
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>
2024-04-26 17:26:10 +08:00
..
amd-rng.c hwrng: Enable COMPILE_TEST for more drivers 2023-08-04 17:09:26 +08:00
arm_smccc_trng.c hwrng: arm-smccc-trng - don't set drvdata 2023-07-22 13:59:39 +12:00
atmel-rng.c hwrng: atmel - Convert to platform remove callback returning void 2023-12-15 17:52:53 +08:00
ba431-rng.c hwrng: ba431 - use dev_err_probe after failed registration 2023-07-22 13:59:37 +12:00
bcm2835-rng.c hwrng: bcm2835 - Fix hwrng throughput regression 2023-09-15 18:29:45 +08:00
cavium-rng-vf.c hwrng: core - treat default_quality as a maximum and default to 1024 2022-11-18 16:59:34 +08:00
cavium-rng.c hwrng: cavium - Check health status while reading random data 2021-11-20 15:02:07 +11:00
cctrng.c hwrng: cctrng - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
cctrng.h hwrng: cctrng - introduce Arm CryptoCell driver 2020-04-16 16:49:20 +10:00
cn10k-rng.c hwrng: cn10k - use dev_err_probe 2023-07-28 18:20:25 +08:00
core.c hwrng: core - Convert sprintf/snprintf to sysfs_emit 2024-04-02 10:49:38 +08:00
exynos-trng.c hwrng: exynos - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
geode-rng.c hwrng: geode - fix accessing registers 2023-09-15 18:29:46 +08:00
hisi-rng.c hwrng: hisi - use dev_err_probe 2024-03-08 19:23:24 +08:00
histb-rng.c hwrng: histb - Move driver to drivers/char/hw_random/histb-rng.c 2023-05-12 18:48:01 +08:00
imx-rngc.c hwrng: imx-rngc - reasonable timeout for initial seed 2023-09-20 13:15:29 +08:00
ingenic-rng.c hwrng: ingenic - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
ingenic-trng.c hwrng: Explicitly include correct DT includes 2023-08-04 17:09:26 +08:00
intel-rng.c hwrng: rename 'mod_init' & 'mod_exit' functions to be module-specific 2021-07-16 15:49:36 +08:00
iproc-rng200.c hwrng: iproc-rng200 - Implement suspend and resume calls 2023-08-18 17:01:09 +08:00
ixp4xx-rng.c hwrng: ixp4xx - Make use of the helper function devm_platform_ioremap_resource() 2021-09-17 11:06:14 +08:00
jh7110-trng.c hwrng: starfive - Add runtime pm ops 2023-12-22 12:30:19 +08:00
Kconfig arch: Remove Itanium (IA-64) architecture 2023-09-11 08:13:17 +00:00
ks-sa-rng.c hwrng: ks-sa - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
Makefile hwrng: histb - Move driver to drivers/char/hw_random/histb-rng.c 2023-05-12 18:48:01 +08:00
meson-rng.c hwrng: meson - add support for S4 2023-10-05 18:16:31 +08:00
mpfs-rng.c hwrng: mpfs - removed unneeded call to platform_set_drvdata() 2023-09-15 18:29:45 +08:00
mtk-rng.c hwrng: mtk - add mt7986 support 2022-10-21 19:15:35 +08:00
mxc-rnga.c hwrng: mxc-rnga - Drop usage of platform_driver_probe() 2024-04-02 10:49:39 +08:00
n2-asm.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
n2-drv.c Normalise "name (ad@dr)" MODULE_AUTHORs to "name <ad@dr>" 2024-03-06 13:07:39 -08:00
n2rng.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nomadik-rng.c hwrng: nomadik - add MODULE_DESCRIPTION 2023-09-15 18:29:45 +08:00
npcm-rng.c hwrng: npcm - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
octeon-rng.c hwrng: octeon - Fix warnings on 32-bit platforms 2023-09-15 18:29:46 +08:00
omap3-rom-rng.c hwrng: Explicitly include correct DT includes 2023-08-04 17:09:26 +08:00
omap-rng.c hwrng: omap - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
optee-rng.c hwrng: optee - remove redundant initialization to variable rng_size 2022-04-29 13:44:58 +08:00
pasemi-rng.c hwrng: Explicitly include correct DT includes 2023-08-04 17:09:26 +08:00
pic32-rng.c hwrng: Explicitly include correct DT includes 2023-08-04 17:09:26 +08:00
powernv-rng.c random: do not include <asm/archrandom.h> from random.h 2022-12-20 03:13:45 +01:00
pseries-rng.c char: hw_random: pseries-rng: Demote non-conformant kernel-doc header 2021-05-21 10:09:30 +02:00
s390-trng.c random: do not include <asm/archrandom.h> from random.h 2022-12-20 03:13:45 +01:00
st-rng.c hwrng: st - add MODULE_DESCRIPTION 2023-09-15 18:29:45 +08:00
stm32-rng.c hwrng: stm32 - repair clock handling 2024-04-26 17:26:10 +08:00
timeriomem-rng.c hwrng: timeriomem - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
via-rng.c hwrng: via - Fix comment typo 2022-07-22 16:22:04 +08:00
virtio-rng.c hwrng: virtio - Remove usage of the deprecated ida_simple_xx() API 2023-12-15 17:52:53 +08:00
xgene-rng.c hwrng: xgene - Convert to platform remove callback returning void 2023-12-15 17:52:54 +08:00
xiphera-trng.c hwrng: xiphera - removed unnneded platform_set_drvdata() 2023-09-15 18:29:45 +08:00