summaryrefslogtreecommitdiffstats
path: root/arch/um/kernel
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2020-12-02 20:58:04 +0100
committerRichard Weinberger <richard@nod.at>2020-12-13 22:22:37 +0100
commit49da38a3ef330b7a1643e12c51913d58158e5abe (patch)
tree80b644e00334100084a64bb455d03a68555b7c1c /arch/um/kernel
parentum: Simplify IRQ handling code (diff)
downloadlinux-49da38a3ef330b7a1643e12c51913d58158e5abe.tar.xz
linux-49da38a3ef330b7a1643e12c51913d58158e5abe.zip
um: Simplify os_idle_sleep() and sleep longer
There really is no reason to pass the amount of time we should sleep, especially since it's just hard-coded to one second. Additionally, one second isn't really all that long, and as we are expecting to be woken up by a signal, we can sleep longer and avoid doing some work every second, so replace the current clock_nanosleep() with just an empty select() that can _only_ be woken up by a signal. We can also remove the deliver_alarm() since we don't need to do that when we got e.g. SIGIO that woke us up, and if we got SIGALRM the signal handler will actually (have) run, so it's just unnecessary extra work. Similarly, in time-travel mode, just program the wakeup event from idle to be S64_MAX, which is basically the most you could ever simulate to. Of course, you should already have an event in the list that's earlier and will cause a wakeup, normally that's the regular timer interrupt, though in suspend it may (later) also be an RTC event. Since actually getting to this point would be a bug and you can't ever get out again, panic() on it in the time control code. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/process.c11
-rw-r--r--arch/um/kernel/time.c12
2 files changed, 14 insertions, 9 deletions
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 0fcdc374a9a1..a85c48ac2b27 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -205,13 +205,10 @@ void initial_thread_cb(void (*proc)(void *), void *arg)
static void um_idle_sleep(void)
{
- unsigned long long duration = UM_NSEC_PER_SEC;
-
- if (time_travel_mode != TT_MODE_OFF) {
- time_travel_sleep(duration);
- } else {
- os_idle_sleep(duration);
- }
+ if (time_travel_mode != TT_MODE_OFF)
+ time_travel_sleep();
+ else
+ os_idle_sleep();
}
void arch_cpu_idle(void)
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 8dafc3f2add4..8e8eb8ba04a4 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -46,6 +46,9 @@ static void time_travel_set_time(unsigned long long ns)
if (unlikely(ns < time_travel_time))
panic("time-travel: time goes backwards %lld -> %lld\n",
time_travel_time, ns);
+ else if (unlikely(ns >= S64_MAX))
+ panic("The system was going to sleep forever, aborting");
+
time_travel_time = ns;
}
@@ -399,9 +402,14 @@ static void time_travel_oneshot_timer(struct time_travel_event *e)
deliver_alarm();
}
-void time_travel_sleep(unsigned long long duration)
+void time_travel_sleep(void)
{
- unsigned long long next = time_travel_time + duration;
+ /*
+ * Wait "forever" (using S64_MAX because there are some potential
+ * wrapping issues, especially with the current TT_MODE_EXTERNAL
+ * controller application.
+ */
+ unsigned long long next = S64_MAX;
if (time_travel_mode == TT_MODE_BASIC)
os_timer_disable();