aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/alarmtimer.c17
-rw-r--r--kernel/time/posix-cpu-timers.c14
-rw-r--r--kernel/time/timekeeping.c2
3 files changed, 22 insertions, 11 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 0b8ff7d257ea..ec09ce9a6012 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -28,6 +28,7 @@
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/freezer.h> 29#include <linux/freezer.h>
30#include <linux/compat.h> 30#include <linux/compat.h>
31#include <linux/module.h>
31 32
32#include "posix-timers.h" 33#include "posix-timers.h"
33 34
@@ -56,9 +57,9 @@ static ktime_t freezer_delta;
56static DEFINE_SPINLOCK(freezer_delta_lock); 57static DEFINE_SPINLOCK(freezer_delta_lock);
57#endif 58#endif
58 59
60#ifdef CONFIG_RTC_CLASS
59static struct wakeup_source *ws; 61static struct wakeup_source *ws;
60 62
61#ifdef CONFIG_RTC_CLASS
62/* rtc timer and device for setting alarm wakeups at suspend */ 63/* rtc timer and device for setting alarm wakeups at suspend */
63static struct rtc_timer rtctimer; 64static struct rtc_timer rtctimer;
64static struct rtc_device *rtcdev; 65static struct rtc_device *rtcdev;
@@ -89,6 +90,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
89{ 90{
90 unsigned long flags; 91 unsigned long flags;
91 struct rtc_device *rtc = to_rtc_device(dev); 92 struct rtc_device *rtc = to_rtc_device(dev);
93 struct wakeup_source *__ws;
92 94
93 if (rtcdev) 95 if (rtcdev)
94 return -EBUSY; 96 return -EBUSY;
@@ -98,13 +100,25 @@ static int alarmtimer_rtc_add_device(struct device *dev,
98 if (!device_may_wakeup(rtc->dev.parent)) 100 if (!device_may_wakeup(rtc->dev.parent))
99 return -1; 101 return -1;
100 102
103 __ws = wakeup_source_register("alarmtimer");
104
101 spin_lock_irqsave(&rtcdev_lock, flags); 105 spin_lock_irqsave(&rtcdev_lock, flags);
102 if (!rtcdev) { 106 if (!rtcdev) {
107 if (!try_module_get(rtc->owner)) {
108 spin_unlock_irqrestore(&rtcdev_lock, flags);
109 return -1;
110 }
111
103 rtcdev = rtc; 112 rtcdev = rtc;
104 /* hold a reference so it doesn't go away */ 113 /* hold a reference so it doesn't go away */
105 get_device(dev); 114 get_device(dev);
115 ws = __ws;
116 __ws = NULL;
106 } 117 }
107 spin_unlock_irqrestore(&rtcdev_lock, flags); 118 spin_unlock_irqrestore(&rtcdev_lock, flags);
119
120 wakeup_source_unregister(__ws);
121
108 return 0; 122 return 0;
109} 123}
110 124
@@ -860,7 +874,6 @@ static int __init alarmtimer_init(void)
860 error = PTR_ERR(pdev); 874 error = PTR_ERR(pdev);
861 goto out_drv; 875 goto out_drv;
862 } 876 }
863 ws = wakeup_source_register("alarmtimer");
864 return 0; 877 return 0;
865 878
866out_drv: 879out_drv:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index a3bd5dbe0dc4..8585ad6e472a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -799,7 +799,6 @@ static void check_thread_timers(struct task_struct *tsk,
799 struct list_head *firing) 799 struct list_head *firing)
800{ 800{
801 struct list_head *timers = tsk->cpu_timers; 801 struct list_head *timers = tsk->cpu_timers;
802 struct signal_struct *const sig = tsk->signal;
803 struct task_cputime *tsk_expires = &tsk->cputime_expires; 802 struct task_cputime *tsk_expires = &tsk->cputime_expires;
804 u64 expires; 803 u64 expires;
805 unsigned long soft; 804 unsigned long soft;
@@ -823,10 +822,9 @@ static void check_thread_timers(struct task_struct *tsk,
823 /* 822 /*
824 * Check for the special case thread timers. 823 * Check for the special case thread timers.
825 */ 824 */
826 soft = READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_cur); 825 soft = task_rlimit(tsk, RLIMIT_RTTIME);
827 if (soft != RLIM_INFINITY) { 826 if (soft != RLIM_INFINITY) {
828 unsigned long hard = 827 unsigned long hard = task_rlimit_max(tsk, RLIMIT_RTTIME);
829 READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
830 828
831 if (hard != RLIM_INFINITY && 829 if (hard != RLIM_INFINITY &&
832 tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) { 830 tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
@@ -847,7 +845,8 @@ static void check_thread_timers(struct task_struct *tsk,
847 */ 845 */
848 if (soft < hard) { 846 if (soft < hard) {
849 soft += USEC_PER_SEC; 847 soft += USEC_PER_SEC;
850 sig->rlim[RLIMIT_RTTIME].rlim_cur = soft; 848 tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur =
849 soft;
851 } 850 }
852 if (print_fatal_signals) { 851 if (print_fatal_signals) {
853 pr_info("RT Watchdog Timeout (soft): %s[%d]\n", 852 pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
@@ -938,11 +937,10 @@ static void check_process_timers(struct task_struct *tsk,
938 SIGPROF); 937 SIGPROF);
939 check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime, 938 check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
940 SIGVTALRM); 939 SIGVTALRM);
941 soft = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur); 940 soft = task_rlimit(tsk, RLIMIT_CPU);
942 if (soft != RLIM_INFINITY) { 941 if (soft != RLIM_INFINITY) {
943 unsigned long psecs = div_u64(ptime, NSEC_PER_SEC); 942 unsigned long psecs = div_u64(ptime, NSEC_PER_SEC);
944 unsigned long hard = 943 unsigned long hard = task_rlimit_max(tsk, RLIMIT_CPU);
945 READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
946 u64 x; 944 u64 x;
947 if (psecs >= hard) { 945 if (psecs >= hard) {
948 /* 946 /*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 7e7e61c00d61..8ea4fb315719 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2064,7 +2064,7 @@ void update_wall_time(void)
2064 goto out; 2064 goto out;
2065 2065
2066 /* Do some additional sanity checking */ 2066 /* Do some additional sanity checking */
2067 timekeeping_check_update(real_tk, offset); 2067 timekeeping_check_update(tk, offset);
2068 2068
2069 /* 2069 /*
2070 * With NO_HZ we may have to accumulate many cycle_intervals 2070 * With NO_HZ we may have to accumulate many cycle_intervals