Skip to content

Commit 621084c

Browse files
committed
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
2 parents 81388c2 + 5233841 commit 621084c

File tree

6 files changed

+16
-40
lines changed

6 files changed

+16
-40
lines changed

arch/arm64/include/asm/vdso/vsyscall.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ int __arm64_get_clock_mode(struct timekeeper *tk)
3030
}
3131
#define __arch_get_clock_mode __arm64_get_clock_mode
3232

33-
static __always_inline
34-
int __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-
4033
static __always_inline
4134
void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk)
4235
{

arch/mips/include/asm/vdso/vsyscall.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ int __mips_get_clock_mode(struct timekeeper *tk)
2828
}
2929
#define __arch_get_clock_mode __mips_get_clock_mode
3030

31-
static __always_inline
32-
int __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-
3831
/* The asm-generic header needs to be included after the definitions above */
3932
#include <asm-generic/vdso/vsyscall.h>
4033

drivers/clocksource/sh_mtu2.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
328328
return 0;
329329
}
330330

331+
static const unsigned int sh_mtu2_channel_offsets[] = {
332+
0x300, 0x380, 0x000,
333+
};
334+
331335
static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
332336
struct sh_mtu2_device *mtu)
333337
{
334-
static const unsigned int channel_offsets[] = {
335-
0x300, 0x380, 0x000,
336-
};
337338
char name[6];
338339
int irq;
339340
int ret;
@@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
356357
return ret;
357358
}
358359

359-
ch->base = mtu->mapbase + channel_offsets[index];
360+
ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index];
360361
ch->index = index;
361362

362363
return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
@@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
408409
}
409410

410411
/* 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));
412418

413419
mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
414420
GFP_KERNEL);

drivers/clocksource/timer-mediatek.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,12 @@ static int __init mtk_syst_init(struct device_node *node)
268268

269269
ret = timer_of_init(node, &to);
270270
if (ret)
271-
goto err;
271+
return ret;
272272

273273
clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
274274
TIMER_SYNC_TICKS, 0xffffffff);
275275

276276
return 0;
277-
err:
278-
timer_of_cleanup(&to);
279-
return ret;
280277
}
281278

282279
static int __init mtk_gpt_init(struct device_node *node)
@@ -293,7 +290,7 @@ static int __init mtk_gpt_init(struct device_node *node)
293290

294291
ret = timer_of_init(node, &to);
295292
if (ret)
296-
goto err;
293+
return ret;
297294

298295
/* Configure clock source */
299296
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)
311308
mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
312309

313310
return 0;
314-
err:
315-
timer_of_cleanup(&to);
316-
return ret;
317311
}
318312
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
319313
TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);

include/asm-generic/vdso/vsyscall.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ static __always_inline int __arch_get_clock_mode(struct timekeeper *tk)
2525
}
2626
#endif /* __arch_get_clock_mode */
2727

28-
#ifndef __arch_use_vsyscall
29-
static __always_inline int __arch_use_vsyscall(struct vdso_data *vdata)
30-
{
31-
return 1;
32-
}
33-
#endif /* __arch_use_vsyscall */
34-
3528
#ifndef __arch_update_vsyscall
3629
static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata,
3730
struct timekeeper *tk)

kernel/time/vsyscall.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ void update_vsyscall(struct timekeeper *tk)
110110
nsec = nsec + tk->wall_to_monotonic.tv_nsec;
111111
vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec);
112112

113-
if (__arch_use_vsyscall(vdata))
114-
update_vdso_data(vdata, tk);
113+
update_vdso_data(vdata, tk);
115114

116115
__arch_update_vsyscall(vdata, tk);
117116

@@ -124,10 +123,8 @@ void update_vsyscall_tz(void)
124123
{
125124
struct vdso_data *vdata = __arch_get_k_vdso_data();
126125

127-
if (__arch_use_vsyscall(vdata)) {
128-
vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest;
129-
vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
130-
}
126+
vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest;
127+
vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
131128

132129
__arch_sync_vdso_data(vdata);
133130
}

0 commit comments

Comments
 (0)