Skip to content

Commit 0a1d443

Browse files
committed
Merge tag 'timers-core-2022-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Thomas Gleixner: "Updates for timers, timekeeping and drivers: Core: - The timer_shutdown[_sync]() infrastructure: Tearing down timers can be tedious when there are circular dependencies to other things which need to be torn down. A prime example is timer and workqueue where the timer schedules work and the work arms the timer. What needs to prevented is that pending work which is drained via destroy_workqueue() does not rearm the previously shutdown timer. Nothing in that shutdown sequence relies on the timer being functional. The conclusion was that the semantics of timer_shutdown_sync() should be: - timer is not enqueued - timer callback is not running - timer cannot be rearmed Preventing the rearming of shutdown timers is done by discarding rearm attempts silently. A warning for the case that a rearm attempt of a shutdown timer is detected would not be really helpful because it's entirely unclear how it should be acted upon. The only way to address such a case is to add 'if (in_shutdown)' conditionals all over the place. This is error prone and in most cases of teardown not required all. - The real fix for the bluetooth HCI teardown based on timer_shutdown_sync(). A larger scale conversion to timer_shutdown_sync() is work in progress. - Consolidation of VDSO time namespace helper functions - Small fixes for timer and timerqueue Drivers: - Prevent integer overflow on the XGene-1 TVAL register which causes an never ending interrupt storm. - The usual set of new device tree bindings - Small fixes and improvements all over the place" * tag 'timers-core-2022-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (34 commits) dt-bindings: timer: renesas,cmt: Add r8a779g0 CMT support dt-bindings: timer: renesas,tmu: Add r8a779g0 support clocksource/drivers/arm_arch_timer: Use kstrtobool() instead of strtobool() clocksource/drivers/timer-ti-dm: Fix missing clk_disable_unprepare in dmtimer_systimer_init_clock() clocksource/drivers/timer-ti-dm: Clear settings on probe and free clocksource/drivers/timer-ti-dm: Make timer_get_irq static clocksource/drivers/timer-ti-dm: Fix warning for omap_timer_match clocksource/drivers/arm_arch_timer: Fix XGene-1 TVAL register math error clocksource/drivers/timer-npcm7xx: Enable timer 1 clock before use dt-bindings: timer: nuvoton,npcm7xx-timer: Allow specifying all clocks dt-bindings: timer: rockchip: Add rockchip,rk3128-timer clockevents: Repair kernel-doc for clockevent_delta2ns() clocksource/drivers/ingenic-ost: Define pm functions properly in platform_driver struct clocksource/drivers/sh_cmt: Access registers according to spec vdso/timens: Refactor copy-pasted find_timens_vvar_page() helper into one copy Bluetooth: hci_qca: Fix the teardown problem for real timers: Update the documentation to reflect on the new timer_shutdown() API timers: Provide timer_shutdown[_sync]() timers: Add shutdown mechanism to the internal functions timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown mode ...
2 parents 79ad891 + 18a2078 commit 0a1d443

35 files changed

Lines changed: 536 additions & 304 deletions

File tree

Documentation/RCU/Design/Requirements/Requirements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ unloaded. After a given module has been unloaded, any attempt to call
18581858
one of its functions results in a segmentation fault. The module-unload
18591859
functions must therefore cancel any delayed calls to loadable-module
18601860
functions, for example, any outstanding mod_timer() must be dealt
1861-
with via del_timer_sync() or similar.
1861+
with via timer_shutdown_sync() or similar.
18621862

18631863
Unfortunately, there is no way to cancel an RCU callback; once you
18641864
invoke call_rcu(), the callback function is eventually going to be

Documentation/core-api/local_ops.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Here is a sample module which implements a basic per cpu counter using
191191

192192
static void __exit test_exit(void)
193193
{
194-
del_timer_sync(&test_timer);
194+
timer_shutdown_sync(&test_timer);
195195
}
196196

197197
module_init(test_init);

Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ properties:
2525
- description: The timer interrupt of timer 0
2626

2727
clocks:
28-
maxItems: 1
28+
items:
29+
- description: The reference clock for timer 0
30+
- description: The reference clock for timer 1
31+
- description: The reference clock for timer 2
32+
- description: The reference clock for timer 3
33+
- description: The reference clock for timer 4
34+
minItems: 1
2935

3036
required:
3137
- compatible

Documentation/devicetree/bindings/timer/renesas,cmt.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ properties:
102102
- enum:
103103
- renesas,r8a779a0-cmt0 # 32-bit CMT0 on R-Car V3U
104104
- renesas,r8a779f0-cmt0 # 32-bit CMT0 on R-Car S4-8
105+
- renesas,r8a779g0-cmt0 # 32-bit CMT0 on R-Car V4H
105106
- const: renesas,rcar-gen4-cmt0 # 32-bit CMT0 on R-Car Gen4
106107

107108
- items:
108109
- enum:
109110
- renesas,r8a779a0-cmt1 # 48-bit CMT on R-Car V3U
110111
- renesas,r8a779f0-cmt1 # 48-bit CMT on R-Car S4-8
112+
- renesas,r8a779g0-cmt1 # 48-bit CMT on R-Car V4H
111113
- const: renesas,rcar-gen4-cmt1 # 48-bit CMT on R-Car Gen4
112114

113115
reg:

Documentation/devicetree/bindings/timer/renesas,tmu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ properties:
3838
- renesas,tmu-r8a77995 # R-Car D3
3939
- renesas,tmu-r8a779a0 # R-Car V3U
4040
- renesas,tmu-r8a779f0 # R-Car S4-8
41+
- renesas,tmu-r8a779g0 # R-Car V4H
4142
- const: renesas,tmu
4243

4344
reg:

Documentation/devicetree/bindings/timer/rockchip,rk-timer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ properties:
1818
- enum:
1919
- rockchip,rv1108-timer
2020
- rockchip,rk3036-timer
21+
- rockchip,rk3128-timer
2122
- rockchip,rk3188-timer
2223
- rockchip,rk3228-timer
2324
- rockchip,rk3229-timer

Documentation/kernel-hacking/locking.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ you might do the following::
967967

968968
while (list) {
969969
struct foo *next = list->next;
970-
del_timer(&list->timer);
970+
timer_delete(&list->timer);
971971
kfree(list);
972972
list = next;
973973
}
@@ -981,7 +981,7 @@ the lock after we spin_unlock_bh(), and then try to free
981981
the element (which has already been freed!).
982982

983983
This can be avoided by checking the result of
984-
del_timer(): if it returns 1, the timer has been deleted.
984+
timer_delete(): if it returns 1, the timer has been deleted.
985985
If 0, it means (in this case) that it is currently running, so we can
986986
do::
987987

@@ -990,7 +990,7 @@ do::
990990

991991
while (list) {
992992
struct foo *next = list->next;
993-
if (!del_timer(&list->timer)) {
993+
if (!timer_delete(&list->timer)) {
994994
/* Give timer a chance to delete this */
995995
spin_unlock_bh(&list_lock);
996996
goto retry;
@@ -1005,9 +1005,12 @@ do::
10051005
Another common problem is deleting timers which restart themselves (by
10061006
calling add_timer() at the end of their timer function).
10071007
Because this is a fairly common case which is prone to races, you should
1008-
use del_timer_sync() (``include/linux/timer.h``) to
1009-
handle this case. It returns the number of times the timer had to be
1010-
deleted before we finally stopped it from adding itself back in.
1008+
use timer_delete_sync() (``include/linux/timer.h``) to handle this case.
1009+
1010+
Before freeing a timer, timer_shutdown() or timer_shutdown_sync() should be
1011+
called which will keep it from being rearmed. Any subsequent attempt to
1012+
rearm the timer will be silently ignored by the core code.
1013+
10111014

10121015
Locking Speed
10131016
=============
@@ -1335,7 +1338,7 @@ lock.
13351338

13361339
- kfree()
13371340

1338-
- add_timer() and del_timer()
1341+
- add_timer() and timer_delete()
13391342

13401343
Mutex API reference
13411344
===================

Documentation/timers/hrtimers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ existing timer wheel code, as it is mature and well suited. Sharing code
118118
was not really a win, due to the different data structures. Also, the
119119
hrtimer functions now have clearer behavior and clearer names - such as
120120
hrtimer_try_to_cancel() and hrtimer_cancel() [which are roughly
121-
equivalent to del_timer() and del_timer_sync()] - so there's no direct
121+
equivalent to timer_delete() and timer_delete_sync()] - so there's no direct
122122
1:1 mapping between them on the algorithmic level, and thus no real
123123
potential for code sharing either.
124124

Documentation/translations/it_IT/kernel-hacking/locking.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ potreste fare come segue::
990990

991991
while (list) {
992992
struct foo *next = list->next;
993-
del_timer(&list->timer);
993+
timer_delete(&list->timer);
994994
kfree(list);
995995
list = next;
996996
}
@@ -1003,7 +1003,7 @@ e prenderà il *lock* solo dopo spin_unlock_bh(), e cercherà
10031003
di eliminare il suo oggetto (che però è già stato eliminato).
10041004

10051005
Questo può essere evitato controllando il valore di ritorno di
1006-
del_timer(): se ritorna 1, il temporizzatore è stato già
1006+
timer_delete(): se ritorna 1, il temporizzatore è stato già
10071007
rimosso. Se 0, significa (in questo caso) che il temporizzatore è in
10081008
esecuzione, quindi possiamo fare come segue::
10091009

@@ -1012,7 +1012,7 @@ esecuzione, quindi possiamo fare come segue::
10121012

10131013
while (list) {
10141014
struct foo *next = list->next;
1015-
if (!del_timer(&list->timer)) {
1015+
if (!timer_delete(&list->timer)) {
10161016
/* Give timer a chance to delete this */
10171017
spin_unlock_bh(&list_lock);
10181018
goto retry;
@@ -1026,10 +1026,8 @@ esecuzione, quindi possiamo fare come segue::
10261026
Un altro problema è l'eliminazione dei temporizzatori che si riavviano
10271027
da soli (chiamando add_timer() alla fine della loro esecuzione).
10281028
Dato che questo è un problema abbastanza comune con una propensione
1029-
alle corse critiche, dovreste usare del_timer_sync()
1030-
(``include/linux/timer.h``) per gestire questo caso. Questa ritorna il
1031-
numero di volte che il temporizzatore è stato interrotto prima che
1032-
fosse in grado di fermarlo senza che si riavviasse.
1029+
alle corse critiche, dovreste usare timer_delete_sync()
1030+
(``include/linux/timer.h``) per gestire questo caso.
10331031

10341032
Velocità della sincronizzazione
10351033
===============================
@@ -1374,7 +1372,7 @@ contesto, o trattenendo un qualsiasi *lock*.
13741372

13751373
- kfree()
13761374

1377-
- add_timer() e del_timer()
1375+
- add_timer() e timer_delete()
13781376

13791377
Riferimento per l'API dei Mutex
13801378
===============================

Documentation/translations/zh_CN/core-api/local_ops.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ UP之间没有不同的行为,在你的架构的 ``local.h`` 中包括 ``asm-g
185185

186186
static void __exit test_exit(void)
187187
{
188-
del_timer_sync(&test_timer);
188+
timer_shutdown_sync(&test_timer);
189189
}
190190

191191
module_init(test_init);

0 commit comments

Comments
 (0)