android_kernel_motorola_sm6375/drivers/clk
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Maxime Ripard e427cd0ad5 clk: Enforce that disjoints limits are invalid
[ Upstream commit 10c46f2ea914202482d19cf80dcc9c321c9ff59b ]

If we were to have two users of the same clock, doing something like:

clk_set_rate_range(user1, 1000, 2000);
clk_set_rate_range(user2, 3000, 4000);

The second call would fail with -EINVAL, preventing from getting in a
situation where we end up with impossible limits.

However, this is never explicitly checked against and enforced, and
works by relying on an undocumented behaviour of clk_set_rate().

Indeed, on the first clk_set_rate_range will make sure the current clock
rate is within the new range, so it will be between 1000 and 2000Hz. On
the second clk_set_rate_range(), it will consider (rightfully), that our
current clock is outside of the 3000-4000Hz range, and will call
clk_core_set_rate_nolock() to set it to 3000Hz.

clk_core_set_rate_nolock() will then call clk_calc_new_rates() that will
eventually check that our rate 3000Hz rate is outside the min 3000Hz max
2000Hz range, will bail out, the error will propagate and we'll
eventually return -EINVAL.

This solely relies on the fact that clk_calc_new_rates(), and in
particular clk_core_determine_round_nolock(), won't modify the new rate
allowing the error to be reported. That assumption won't be true for all
drivers, and most importantly we'll break that assumption in a later
patch.

It can also be argued that we shouldn't even reach the point where we're
calling clk_core_set_rate_nolock().

Let's make an explicit check for disjoints range before we're doing
anything.

Signed-off-by: Maxime Ripard <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Stephen Boyd <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
2022-04-15 14:18:35 +02:00
..
actions clk: actions: Terminate clk_div_table with sentinel element 2022-04-15 14:18:19 +02:00
analogbits
at91 clk: at91: check pmc node status before registering syscore ops 2021-11-17 09:48:42 +01:00
axis
axs10x
bcm clk: bcm-2835: Remove rounding up the dividers 2022-01-27 09:19:29 +01:00
berlin
davinci clk: davinci: Use the correct size when allocating memory 2020-09-23 12:40:38 +02:00
h8300
hisilicon
imgtec
imx clk: imx7d: Remove audio_mclk_root_clk 2022-04-15 14:18:18 +02:00
ingenic clk: jz4725b: fix mmc0 clock gating 2022-03-02 11:41:00 +01:00
keystone clk: keystone: sci-clk: fix parsing assigned-clock data during probe 2020-10-29 09:57:54 +01:00
loongson1 clk: loongson1: Terminate clk_div_table with sentinel element 2022-04-15 14:18:19 +02:00
mediatek clk: mediatek: add UART0 clock support 2020-10-29 09:57:54 +01:00
meson clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB 2022-01-27 09:19:47 +01:00
microchip
mmp
mvebu clk: mvebu: ap-cpu-clk: Fix a memory leak in error handling paths 2021-11-17 09:48:41 +01:00
mxs
nxp
pistachio
pxa
qcom clk: qcom: gcc-msm8994: Fix gpll4 width 2022-04-15 14:18:21 +02:00
renesas clk: renesas: r8a77995: Add ZA2 clock 2021-07-19 08:53:09 +02:00
rockchip clk: rockchip: Initialize hw to error to avoid undefined behavior 2020-10-29 09:57:54 +01:00
samsung clk: exynos7: Mark aclk_fsys1_200 as critical 2021-05-19 10:08:33 +02:00
sifive
sirf clk: clk-atlas6: fix return value check in atlas6_clk_init() 2020-08-21 13:05:34 +02:00
socfpga clk: socfpga: arria10: Fix memory leak of socfpga_clk on error return 2021-05-11 14:04:10 +02:00
spear
sprd
st
sunxi
sunxi-ng clk: sunxi-ng: h6: Fix clock divider range on some clocks 2021-03-04 10:26:29 +01:00
tegra clk: tegra: tegra124-emc: Fix missing put_device() call in emc_ensure_emc_driver 2022-04-15 14:18:19 +02:00
ti clocksource/drivers/timer-ti-dm: Handle dra7 timer wrap errata i940 2021-06-23 14:41:31 +02:00
uniphier clk: uniphier: Fix fixed-rate initialization 2022-04-15 14:17:58 +02:00
ux500
versatile
x86
zte
zynq
zynqmp clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback 2021-05-14 09:44:24 +02:00
clk-asm9260.c
clk-aspeed.c
clk-aspeed.h
clk-ast2600.c clk/ast2600: Fix soc revision for AHB 2021-11-26 10:47:17 +01:00
clk-axi-clkgen.c
clk-axm5516.c
clk-bd718x7.c
clk-bulk.c
clk-cdce706.c
clk-cdce925.c
clk-clps711x.c clk: clps711x: Terminate clk_div_table with sentinel element 2022-04-15 14:18:19 +02:00
clk-composite.c
clk-conf.c
clk-cs2000-cp.c
clk-devres.c clk: fix leak on devm_clk_bulk_get_all() unwind 2021-08-12 13:21:00 +02:00
clk-divider.c
clk-efm32gg.c
clk-fixed-factor.c
clk-fixed-mmio.c
clk-fixed-rate.c
clk-fractional-divider.c
clk-gate.c
clk-gemini.c
clk-gpio.c
clk-hi655x.c
clk-highbank.c
clk-hsdk-pll.c
clk-lochnagar.c
clk-max9485.c
clk-max77686.c
clk-milbeaut.c
clk-moxart.c
clk-multiplier.c
clk-mux.c
clk-nomadik.c
clk-npcm7xx.c
clk-nspire.c
clk-oxnas.c
clk-palmas.c
clk-pwm.c
clk-qoriq.c
clk-rk808.c
clk-s2mps11.c clk: s2mps11: Fix a resource leak in error handling paths in the probe function 2020-12-30 11:51:29 +01:00
clk-scmi.c
clk-scpi.c
clk-si514.c
clk-si544.c
clk-si570.c
clk-si5341.c clk: si5341: fix reported clk_rate when output divider is 2 2022-04-15 14:18:35 +02:00
clk-si5351.c
clk-si5351.h
clk-stm32f4.c clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell 2022-01-27 09:19:39 +01:00
clk-stm32h7.c
clk-stm32mp1.c
clk-tango4.c
clk-twl6040.c
clk-u300.c
clk-versaclock5.c
clk-vt8500.c
clk-wm831x.c
clk-xgene.c
clk.c clk: Enforce that disjoints limits are invalid 2022-04-15 14:18:35 +02:00
clk.h
clkdev.c
Kconfig
Makefile