summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-11-10 15:03:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-11-10 15:03:58 -0500
commit621084cd3d8cb31aa43a3e4cc37e27e3ddaab561 (patch)
tree2ab46086ac6e3618d657d733e69170ce037223a6
parent81388c2b3fb16972c699aab8a4f80ba85d0f9360 (diff)
parent52338415cf4d4064ae6b8dd972dadbda841da4fa (diff)
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "A small set of fixes for timekeepoing and clocksource drivers: - VDSO data was updated conditional on the availability of a VDSO capable clocksource. This causes the VDSO functions which do not depend on a VDSO capable clocksource to operate on stale data. Always update unconditionally. - Prevent a double free in the mediatek driver - Use the proper helper in the sh_mtu2 driver so it won't attempt to initialize non-existing interrupts" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: timekeeping/vsyscall: Update VDSO data unconditionally clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name() clocksource/drivers/mediatek: Fix error handling
-rw-r--r--arch/arm64/include/asm/vdso/vsyscall.h7
-rw-r--r--arch/mips/include/asm/vdso/vsyscall.h7
-rw-r--r--drivers/clocksource/sh_mtu2.c16
-rw-r--r--drivers/clocksource/timer-mediatek.c10
-rw-r--r--include/asm-generic/vdso/vsyscall.h7
-rw-r--r--kernel/time/vsyscall.c9
6 files changed, 16 insertions, 40 deletions
diff --git a/arch/arm64/include/asm/vdso/vsyscall.h b/arch/arm64/include/asm/vdso/vsyscall.h
index 0c731bfc7c8c..0c20a7c1bee5 100644
--- a/arch/arm64/include/asm/vdso/vsyscall.h
+++ b/arch/arm64/include/asm/vdso/vsyscall.h
@@ -31,13 +31,6 @@ int __arm64_get_clock_mode(struct timekeeper *tk)
31#define __arch_get_clock_mode __arm64_get_clock_mode 31#define __arch_get_clock_mode __arm64_get_clock_mode
32 32
33static __always_inline 33static __always_inline
34int __arm64_use_vsyscall(struct vdso_data *vdata)
35{
36 return !vdata[CS_HRES_COARSE].clock_mode;
37}
38#define __arch_use_vsyscall __arm64_use_vsyscall
39
40static __always_inline
41void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk) 34void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk)
42{ 35{
43 vdata[CS_HRES_COARSE].mask = VDSO_PRECISION_MASK; 36 vdata[CS_HRES_COARSE].mask = VDSO_PRECISION_MASK;
diff --git a/arch/mips/include/asm/vdso/vsyscall.h b/arch/mips/include/asm/vdso/vsyscall.h
index 195314732233..00d41b94ba31 100644
--- a/arch/mips/include/asm/vdso/vsyscall.h
+++ b/arch/mips/include/asm/vdso/vsyscall.h
@@ -28,13 +28,6 @@ int __mips_get_clock_mode(struct timekeeper *tk)
28} 28}
29#define __arch_get_clock_mode __mips_get_clock_mode 29#define __arch_get_clock_mode __mips_get_clock_mode
30 30
31static __always_inline
32int __mips_use_vsyscall(struct vdso_data *vdata)
33{
34 return (vdata[CS_HRES_COARSE].clock_mode != VDSO_CLOCK_NONE);
35}
36#define __arch_use_vsyscall __mips_use_vsyscall
37
38/* The asm-generic header needs to be included after the definitions above */ 31/* The asm-generic header needs to be included after the definitions above */
39#include <asm-generic/vdso/vsyscall.h> 32#include <asm-generic/vdso/vsyscall.h>
40 33
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 354b27d14a19..62812f80b5cc 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
328 return 0; 328 return 0;
329} 329}
330 330
331static const unsigned int sh_mtu2_channel_offsets[] = {
332 0x300, 0x380, 0x000,
333};
334
331static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, 335static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
332 struct sh_mtu2_device *mtu) 336 struct sh_mtu2_device *mtu)
333{ 337{
334 static const unsigned int channel_offsets[] = {
335 0x300, 0x380, 0x000,
336 };
337 char name[6]; 338 char name[6];
338 int irq; 339 int irq;
339 int ret; 340 int ret;
@@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
356 return ret; 357 return ret;
357 } 358 }
358 359
359 ch->base = mtu->mapbase + channel_offsets[index]; 360 ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index];
360 ch->index = index; 361 ch->index = index;
361 362
362 return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev)); 363 return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
@@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
408 } 409 }
409 410
410 /* Allocate and setup the channels. */ 411 /* Allocate and setup the channels. */
411 mtu->num_channels = 3; 412 ret = platform_irq_count(pdev);
413 if (ret < 0)
414 goto err_unmap;
415
416 mtu->num_channels = min_t(unsigned int, ret,
417 ARRAY_SIZE(sh_mtu2_channel_offsets));
412 418
413 mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels), 419 mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
414 GFP_KERNEL); 420 GFP_KERNEL);
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index a562f491b0f8..9318edcd8963 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -268,15 +268,12 @@ static int __init mtk_syst_init(struct device_node *node)
268 268
269 ret = timer_of_init(node, &to); 269 ret = timer_of_init(node, &to);
270 if (ret) 270 if (ret)
271 goto err; 271 return ret;
272 272
273 clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), 273 clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
274 TIMER_SYNC_TICKS, 0xffffffff); 274 TIMER_SYNC_TICKS, 0xffffffff);
275 275
276 return 0; 276 return 0;
277err:
278 timer_of_cleanup(&to);
279 return ret;
280} 277}
281 278
282static int __init mtk_gpt_init(struct device_node *node) 279static int __init mtk_gpt_init(struct device_node *node)
@@ -293,7 +290,7 @@ static int __init mtk_gpt_init(struct device_node *node)
293 290
294 ret = timer_of_init(node, &to); 291 ret = timer_of_init(node, &to);
295 if (ret) 292 if (ret)
296 goto err; 293 return ret;
297 294
298 /* Configure clock source */ 295 /* Configure clock source */
299 mtk_gpt_setup(&to, TIMER_CLK_SRC, GPT_CTRL_OP_FREERUN); 296 mtk_gpt_setup(&to, TIMER_CLK_SRC, GPT_CTRL_OP_FREERUN);
@@ -311,9 +308,6 @@ static int __init mtk_gpt_init(struct device_node *node)
311 mtk_gpt_enable_irq(&to, TIMER_CLK_EVT); 308 mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
312 309
313 return 0; 310 return 0;
314err:
315 timer_of_cleanup(&to);
316 return ret;
317} 311}
318TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init); 312TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
319TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init); 313TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h
index e94b19782c92..ce4103208619 100644
--- a/include/asm-generic/vdso/vsyscall.h
+++ b/include/asm-generic/vdso/vsyscall.h
@@ -25,13 +25,6 @@ static __always_inline int __arch_get_clock_mode(struct timekeeper *tk)
25} 25}
26#endif /* __arch_get_clock_mode */ 26#endif /* __arch_get_clock_mode */
27 27
28#ifndef __arch_use_vsyscall
29static __always_inline int __arch_use_vsyscall(struct vdso_data *vdata)
30{
31 return 1;
32}
33#endif /* __arch_use_vsyscall */
34
35#ifndef __arch_update_vsyscall 28#ifndef __arch_update_vsyscall
36static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata, 29static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata,
37 struct timekeeper *tk) 30 struct timekeeper *tk)
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index 4bc37ac3bb05..5ee0f7709410 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -110,8 +110,7 @@ void update_vsyscall(struct timekeeper *tk)
110 nsec = nsec + tk->wall_to_monotonic.tv_nsec; 110 nsec = nsec + tk->wall_to_monotonic.tv_nsec;
111 vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec); 111 vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec);
112 112
113 if (__arch_use_vsyscall(vdata)) 113 update_vdso_data(vdata, tk);
114 update_vdso_data(vdata, tk);
115 114
116 __arch_update_vsyscall(vdata, tk); 115 __arch_update_vsyscall(vdata, tk);
117 116
@@ -124,10 +123,8 @@ void update_vsyscall_tz(void)
124{ 123{
125 struct vdso_data *vdata = __arch_get_k_vdso_data(); 124 struct vdso_data *vdata = __arch_get_k_vdso_data();
126 125
127 if (__arch_use_vsyscall(vdata)) { 126 vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest;
128 vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest; 127 vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
129 vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
130 }
131 128
132 __arch_sync_vdso_data(vdata); 129 __arch_sync_vdso_data(vdata);
133} 130}