summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2017-07-22 14:33:45 +0000
committerkettenis <kettenis@openbsd.org>2017-07-22 14:33:45 +0000
commitebbbc3a6cf6b55a12c8e3a415ac3de213e07668e (patch)
treeb4051f0b15065eb066be6988fab3a6bb7a90a177
parentAdd missing RCS IDs and zap redundant SRCS from Makefile. (diff)
downloadwireguard-openbsd-ebbbc3a6cf6b55a12c8e3a415ac3de213e07668e.tar.xz
wireguard-openbsd-ebbbc3a6cf6b55a12c8e3a415ac3de213e07668e.zip
Introduce jiffies, a volatile unsigned long version of our ticks variable
for use by the linux compatibility APIs in drm(4). While I hate infecting code in sys/kern with this, untangling all the of having different types and different signedness is too much for me right now. The best strategy may be to change ticks itself to be long but that needs some careful auditing. ok deraadt@
-rw-r--r--sys/dev/pci/drm/drmP.h4
-rw-r--r--sys/dev/pci/drm/drm_linux.h15
-rw-r--r--sys/kern/kern_clock.c6
3 files changed, 13 insertions, 12 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 9cb8b7e0fcd..f04240a6737 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.214 2017/07/19 22:05:58 kettenis Exp $ */
+/* $OpenBSD: drmP.h,v 1.215 2017/07/22 14:33:45 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -122,8 +122,6 @@ struct fb_image;
#define DRM_WAKEUP(x) wakeup(x)
-extern int ticks;
-
#define drm_msleep(x) mdelay(x)
extern struct cfdriver drm_cd;
diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h
index e6137080bb4..be718addcc3 100644
--- a/sys/dev/pci/drm/drm_linux.h
+++ b/sys/dev/pci/drm/drm_linux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.h,v 1.57 2017/07/17 17:57:27 kettenis Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.58 2017/07/22 14:33:45 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -839,8 +839,7 @@ timespec_sub(struct timespec t1, struct timespec t2)
#define time_in_range(x, min, max) ((x) >= (min) && (x) <= (max))
-extern int ticks;
-#define jiffies ticks
+extern volatile unsigned long jiffies;
#undef HZ
#define HZ hz
@@ -858,10 +857,10 @@ round_jiffies_up_relative(unsigned long j)
return roundup(j, hz);
}
-#define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz)
-#define jiffies_to_usecs(x) (((int64_t)(x)) * 1000000 / hz)
-#define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000)
-#define nsecs_to_jiffies64(x) (((int64_t)(x)) * hz / 1000000000)
+#define jiffies_to_msecs(x) (((uint64_t)(x)) * 1000 / hz)
+#define jiffies_to_usecs(x) (((uint64_t)(x)) * 1000000 / hz)
+#define msecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000)
+#define nsecs_to_jiffies64(x) (((uint64_t)(x)) * hz / 1000000000)
#define get_jiffies_64() jiffies
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0)
@@ -886,7 +885,7 @@ timespec_to_ns(const struct timespec *ts)
return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec);
}
-static inline int
+static inline unsigned long
timespec_to_jiffies(const struct timespec *ts)
{
long long to_ticks;
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 310260a3b8c..2aef10f72c5 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_clock.c,v 1.92 2017/04/05 03:59:13 deraadt Exp $ */
+/* $OpenBSD: kern_clock.c,v 1.93 2017/07/22 14:33:45 kettenis Exp $ */
/* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */
/*-
@@ -103,6 +103,8 @@ int psratio; /* ratio: prof / stat */
void *softclock_si;
+volatile unsigned long jiffies; /* XXX Linux API for drm(4) */
+
/*
* Initialize clock frequencies and start both clocks running.
*/
@@ -116,6 +118,7 @@ initclocks(void)
panic("initclocks: unable to register softclock intr");
ticks = INT_MAX - (15 * 60 * hz);
+ jiffies = ULONG_MAX - (10 * 60 * hz);
/*
* Set divisors to 1 (normal case) and let the machine-specific
@@ -194,6 +197,7 @@ hardclock(struct clockframe *frame)
tc_ticktock();
ticks++;
+ jiffies++;
/*
* Update real-time timeout queue.