]> git.baikalelectronics.ru Git - kernel.git/commit
clk: meson: mpll: fix division by zero in rate_from_params
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Sat, 1 Apr 2017 13:02:24 +0000 (15:02 +0200)
committerJerome Brunet <jbrunet@baylibre.com>
Fri, 7 Apr 2017 15:45:21 +0000 (17:45 +0200)
commitce8771f07a33a1026b0dd097086d6a832d8e0c6a
treeb593c7e8f91f8fd14ec7e36039cf817d20fb5129
parent1f5eab08b9099630754ca5f83268c99e161d1114
clk: meson: mpll: fix division by zero in rate_from_params

According to the public datasheet all register bits in HHI_MPLL_CNTL7,
HHI_MPLL_CNTL8 and HHI_MPLL_CNTL9 default to zero. On all GX SoCs these
seem to be initialized by the bootloader to some default value.
However, on my Meson8 board they are not initialized, leading to a
division by zero in rate_from_params as the math is:
(parent_rate * SDM_DEN) / ((SDM_DEN * 0) + 0)

According to the datasheet, the minimum n2 value is 4. The rate provided
by the clock when n2 is less than this minimum is unpredictable. In such
case, we report an error.

Although the rate_from_params function was only introduced recently the
original bug has been there for much longer. It was only exposed
recently when the MPLL clocks were added to the Meson8b clock driver.

Fixes: a229acbec4 ("clk: meson: add mpll support")
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
drivers/clk/meson/clk-mpll.c