Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'fortglx/3.14/time' of git://git.linaro.org/people/john.stultz/linux into timers/core

Pull timekeeping updates from John Stultz.

Signed-off-by: Ingo Molnar <mingo@kernel.org>

+80 -28
+51 -1
drivers/rtc/rtc-cmos.c
··· 34 34 #include <linux/interrupt.h> 35 35 #include <linux/spinlock.h> 36 36 #include <linux/platform_device.h> 37 - #include <linux/mod_devicetable.h> 38 37 #include <linux/log2.h> 39 38 #include <linux/pm.h> 40 39 #include <linux/of.h> 41 40 #include <linux/of_platform.h> 41 + #include <linux/dmi.h> 42 42 43 43 /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ 44 44 #include <asm-generic/rtc.h> ··· 377 377 return 0; 378 378 } 379 379 380 + /* 381 + * Do not disable RTC alarm on shutdown - workaround for b0rked BIOSes. 382 + */ 383 + static bool alarm_disable_quirk; 384 + 385 + static int __init set_alarm_disable_quirk(const struct dmi_system_id *id) 386 + { 387 + alarm_disable_quirk = true; 388 + pr_info("rtc-cmos: BIOS has alarm-disable quirk. "); 389 + pr_info("RTC alarms disabled\n"); 390 + return 0; 391 + } 392 + 393 + static const struct dmi_system_id rtc_quirks[] __initconst = { 394 + /* https://bugzilla.novell.com/show_bug.cgi?id=805740 */ 395 + { 396 + .callback = set_alarm_disable_quirk, 397 + .ident = "IBM Truman", 398 + .matches = { 399 + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 400 + DMI_MATCH(DMI_PRODUCT_NAME, "4852570"), 401 + }, 402 + }, 403 + /* https://bugzilla.novell.com/show_bug.cgi?id=812592 */ 404 + { 405 + .callback = set_alarm_disable_quirk, 406 + .ident = "Gigabyte GA-990XA-UD3", 407 + .matches = { 408 + DMI_MATCH(DMI_SYS_VENDOR, 409 + "Gigabyte Technology Co., Ltd."), 410 + DMI_MATCH(DMI_PRODUCT_NAME, "GA-990XA-UD3"), 411 + }, 412 + }, 413 + /* http://permalink.gmane.org/gmane.linux.kernel/1604474 */ 414 + { 415 + .callback = set_alarm_disable_quirk, 416 + .ident = "Toshiba Satellite L300", 417 + .matches = { 418 + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 419 + DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"), 420 + }, 421 + }, 422 + {} 423 + }; 424 + 380 425 static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) 381 426 { 382 427 struct cmos_rtc *cmos = dev_get_drvdata(dev); ··· 429 384 430 385 if (!is_valid_irq(cmos->irq)) 431 386 return -EINVAL; 387 + 388 + if (alarm_disable_quirk) 389 + return 0; 432 390 433 391 spin_lock_irqsave(&rtc_lock, flags); 434 392 ··· 1204 1156 if (retval == 0) 1205 1157 platform_driver_registered = true; 1206 1158 } 1159 + 1160 + dmi_check_system(rtc_quirks); 1207 1161 1208 1162 if (retval == 0) 1209 1163 return 0;
+1
kernel/time/tick-common.c
··· 85 85 86 86 do_timer(1); 87 87 write_sequnlock(&jiffies_lock); 88 + update_wall_time(); 88 89 } 89 90 90 91 update_process_times(user_mode(get_irq_regs()));
+1
kernel/time/tick-internal.h
··· 155 155 #endif 156 156 157 157 extern void do_timer(unsigned long ticks); 158 + extern void update_wall_time(void);
+1
kernel/time/tick-sched.c
··· 86 86 tick_next_period = ktime_add(last_jiffies_update, tick_period); 87 87 } 88 88 write_sequnlock(&jiffies_lock); 89 + update_wall_time(); 89 90 } 90 91 91 92 /*
+26 -27
kernel/time/timekeeping.c
··· 77 77 tk->wall_to_monotonic = wtm; 78 78 set_normalized_timespec(&tmp, -wtm.tv_sec, -wtm.tv_nsec); 79 79 tk->offs_real = timespec_to_ktime(tmp); 80 - tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tk->tai_offset, 0)); 80 + tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0)); 81 81 } 82 82 83 83 static void tk_set_sleep_time(struct timekeeper *tk, struct timespec t) ··· 90 90 } 91 91 92 92 /** 93 - * timekeeper_setup_internals - Set up internals to use clocksource clock. 93 + * tk_setup_internals - Set up internals to use clocksource clock. 94 94 * 95 + * @tk: The target timekeeper to setup. 95 96 * @clock: Pointer to clocksource. 96 97 * 97 98 * Calculates a fixed cycle/nsec interval for a given clocksource/adjustment ··· 596 595 static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) 597 596 { 598 597 tk->tai_offset = tai_offset; 599 - tk->offs_tai = ktime_sub(tk->offs_real, ktime_set(tai_offset, 0)); 598 + tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0)); 600 599 } 601 600 602 601 /** ··· 611 610 raw_spin_lock_irqsave(&timekeeper_lock, flags); 612 611 write_seqcount_begin(&timekeeper_seq); 613 612 __timekeeping_set_tai_offset(tk, tai_offset); 613 + timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); 614 614 write_seqcount_end(&timekeeper_seq); 615 615 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 616 616 clock_was_set(); ··· 1025 1023 timekeeping_suspend_time = 1026 1024 timespec_add(timekeeping_suspend_time, delta_delta); 1027 1025 } 1026 + 1027 + timekeeping_update(tk, TK_MIRROR); 1028 1028 write_seqcount_end(&timekeeper_seq); 1029 1029 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 1030 1030 ··· 1134 1130 * we can adjust by 1. 1135 1131 */ 1136 1132 error >>= 2; 1137 - /* 1138 - * XXX - In update_wall_time, we round up to the next 1139 - * nanosecond, and store the amount rounded up into 1140 - * the error. This causes the likely below to be unlikely. 1141 - * 1142 - * The proper fix is to avoid rounding up by using 1143 - * the high precision tk->xtime_nsec instead of 1144 - * xtime.tv_nsec everywhere. Fixing this will take some 1145 - * time. 1146 - */ 1147 1133 if (likely(error <= interval)) 1148 1134 adj = 1; 1149 1135 else ··· 1249 1255 static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) 1250 1256 { 1251 1257 u64 nsecps = (u64)NSEC_PER_SEC << tk->shift; 1252 - unsigned int action = 0; 1258 + unsigned int clock_set = 0; 1253 1259 1254 1260 while (tk->xtime_nsec >= nsecps) { 1255 1261 int leap; ··· 1271 1277 1272 1278 __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); 1273 1279 1274 - clock_was_set_delayed(); 1275 - action = TK_CLOCK_WAS_SET; 1280 + clock_set = TK_CLOCK_WAS_SET; 1276 1281 } 1277 1282 } 1278 - return action; 1283 + return clock_set; 1279 1284 } 1280 1285 1281 1286 /** ··· 1287 1294 * Returns the unconsumed cycles. 1288 1295 */ 1289 1296 static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, 1290 - u32 shift) 1297 + u32 shift, 1298 + unsigned int *clock_set) 1291 1299 { 1292 1300 cycle_t interval = tk->cycle_interval << shift; 1293 1301 u64 raw_nsecs; ··· 1302 1308 tk->cycle_last += interval; 1303 1309 1304 1310 tk->xtime_nsec += tk->xtime_interval << shift; 1305 - accumulate_nsecs_to_secs(tk); 1311 + *clock_set |= accumulate_nsecs_to_secs(tk); 1306 1312 1307 1313 /* Accumulate raw time */ 1308 1314 raw_nsecs = (u64)tk->raw_interval << shift; ··· 1353 1359 * update_wall_time - Uses the current clocksource to increment the wall time 1354 1360 * 1355 1361 */ 1356 - static void update_wall_time(void) 1362 + void update_wall_time(void) 1357 1363 { 1358 1364 struct clocksource *clock; 1359 1365 struct timekeeper *real_tk = &timekeeper; 1360 1366 struct timekeeper *tk = &shadow_timekeeper; 1361 1367 cycle_t offset; 1362 1368 int shift = 0, maxshift; 1363 - unsigned int action; 1369 + unsigned int clock_set = 0; 1364 1370 unsigned long flags; 1365 1371 1366 1372 raw_spin_lock_irqsave(&timekeeper_lock, flags); ··· 1395 1401 maxshift = (64 - (ilog2(ntp_tick_length())+1)) - 1; 1396 1402 shift = min(shift, maxshift); 1397 1403 while (offset >= tk->cycle_interval) { 1398 - offset = logarithmic_accumulation(tk, offset, shift); 1404 + offset = logarithmic_accumulation(tk, offset, shift, 1405 + &clock_set); 1399 1406 if (offset < tk->cycle_interval<<shift) 1400 1407 shift--; 1401 1408 } ··· 1414 1419 * Finally, make sure that after the rounding 1415 1420 * xtime_nsec isn't larger than NSEC_PER_SEC 1416 1421 */ 1417 - action = accumulate_nsecs_to_secs(tk); 1422 + clock_set |= accumulate_nsecs_to_secs(tk); 1418 1423 1419 1424 write_seqcount_begin(&timekeeper_seq); 1420 1425 /* Update clock->cycle_last with the new value */ ··· 1430 1435 * updating. 1431 1436 */ 1432 1437 memcpy(real_tk, tk, sizeof(*tk)); 1433 - timekeeping_update(real_tk, action); 1438 + timekeeping_update(real_tk, clock_set); 1434 1439 write_seqcount_end(&timekeeper_seq); 1435 1440 out: 1436 1441 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 1442 + if (clock_set) 1443 + clock_was_set(); 1437 1444 } 1438 1445 1439 1446 /** ··· 1580 1583 void do_timer(unsigned long ticks) 1581 1584 { 1582 1585 jiffies_64 += ticks; 1583 - update_wall_time(); 1584 1586 calc_global_load(ticks); 1585 1587 } 1586 1588 ··· 1694 1698 1695 1699 if (tai != orig_tai) { 1696 1700 __timekeeping_set_tai_offset(tk, tai); 1697 - update_pvclock_gtod(tk, true); 1698 - clock_was_set_delayed(); 1701 + timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); 1699 1702 } 1700 1703 write_seqcount_end(&timekeeper_seq); 1701 1704 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 1705 + 1706 + if (tai != orig_tai) 1707 + clock_was_set(); 1702 1708 1703 1709 ntp_notify_cmos_timer(); 1704 1710 ··· 1737 1739 write_seqlock(&jiffies_lock); 1738 1740 do_timer(ticks); 1739 1741 write_sequnlock(&jiffies_lock); 1742 + update_wall_time(); 1740 1743 }