]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
clocksource/drivers/sh_cmt: Fixup for 64-bit machines
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Sat, 8 Sep 2018 20:54:05 +0000 (23:54 +0300)
committerKhalid Elmously <khalid.elmously@canonical.com>
Thu, 28 Nov 2019 04:59:27 +0000 (23:59 -0500)
commit19aaef71a766e9e5e089198ac595bbe002d7e8d8
tree1ee66efa1f99a3195149b413c451089497167fca
parent5aeccf8d387cb0d350863765813d3354a658b0b3
clocksource/drivers/sh_cmt: Fixup for 64-bit machines

BugLink: https://bugs.launchpad.net/bugs/1854216
[ Upstream commit 22627c6f3ed3d9d0df13eec3c831b08f8186c38e ]

When trying to use CMT for clockevents on R-Car gen3 SoCs, I noticed
that 'max_delta_ns' for the broadcast timer (CMT) was shown as 1000 in
/proc/timer_list. It turned out that when calculating it, the driver did
1 << 32 (causing what I think was undefined behavior) resulting in a zero
delta, later clamped to 1000 by cev_delta2ns(). The root cause turned out
to be that the driver abused *unsigned long* for the CMT register values
(which are 16/32-bit), so that the calculation of 'ch->max_match_value'
in sh_cmt_setup_channel() used the wrong branch. Using more proper 'u32'
instead fixed 'max_delta_ns' and even fixed the switching an active
clocksource to CMT (which caused the system to turn non-interactive
before).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/clocksource/sh_cmt.c