]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
clk: ingenic: Fix round_rate misbehaving with non-integer dividers
authorPaul Cercueil <paul@crapouillou.net>
Mon, 28 Jan 2019 02:09:20 +0000 (23:09 -0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitb752844ce3e5b47d5ac92c1134a10542202e0099
tree7a08d5d19b27fb46908e54a7b594d38aeececabe
parent9d3d612504213e910378acb74d2d9a0ff83a7e59
clk: ingenic: Fix round_rate misbehaving with non-integer dividers

BugLink: https://bugs.launchpad.net/bugs/1837952
commit bc5d922c93491878c44c9216e9d227c7eeb81d7f upstream.

Take a parent rate of 180 MHz, and a requested rate of 4.285715 MHz.
This results in a theorical divider of 41.999993 which is then rounded
up to 42. The .round_rate function would then return (180 MHz / 42) as
the clock, rounded down, so 4.285714 MHz.

Calling clk_set_rate on 4.285714 MHz would round the rate again, and
give a theorical divider of 42,0000028, now rounded up to 43, and the
rate returned would be (180 MHz / 43) which is 4.186046 MHz, aka. not
what we requested.

Fix this by rounding up the divisions.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Maarten ter Huurne <maarten@treewalker.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/clk/ingenic/cgu.c