]> git.baikalelectronics.ru Git - kernel.git/commit
clocksource/drivers/sh_cmt: Fix wrong setting if don't request IRQ for clock source...
authorPhong Hoang <phong.hoang.wz@renesas.com>
Thu, 22 Apr 2021 12:34:43 +0000 (14:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:47:29 +0000 (09:47 +0200)
commit6468341c67a5c679a6c98450e1cf6e073fe71579
tree80f0d9ac57dd2b622a5bf26b2c33c2d88715e10d
parentc23e47a4965d45e54358bc8a8616efed64627c33
clocksource/drivers/sh_cmt: Fix wrong setting if don't request IRQ for clock source channel

[ Upstream commit be83c3b6e7b8ff22f72827a613bf6f3aa5afadbb ]

If CMT instance has at least two channels, one channel will be used
as a clock source and another one used as a clock event device.
In that case, IRQ is not requested for clock source channel so
sh_cmt_clock_event_program_verify() might work incorrectly.
Besides, when a channel is only used for clock source, don't need to
re-set the next match_value since it should be maximum timeout as
it still is.

On the other hand, due to no IRQ, total_cycles is not counted up
when reaches compare match time (timer counter resets to zero),
so sh_cmt_clocksource_read() returns unexpected value.
Therefore, use 64-bit clocksoure's mask for 32-bit or 16-bit variants
will also lead to wrong delta calculation. Hence, this mask should
correspond to timer counter width, and above function just returns
the raw value of timer counter register.

Fixes: 7e711a9b1ef2 ("clocksource: sh_cmt: Request IRQ for clock event device only")
Fixes: 992c25e1e2bf ("clocksource/drivers/sh_cmt: Fix clocksource width for 32-bit machines")
Signed-off-by: Phong Hoang <phong.hoang.wz@renesas.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210422123443.73334-1-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clocksource/sh_cmt.c