From: Luis R. Rodriguez Date: Thu, 28 Mar 2013 02:16:56 +0000 (-0700) Subject: compat: backport ktime_get_monotonic_offset() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9bf65ad978d3619b7bab6dab361dd84cbabf5594;p=openwrt%2Fstaging%2Fblogic.git compat: backport ktime_get_monotonic_offset() The commit a80b83b7 exported ktime_get_monotonic_offset() but note that this was already in place on the header files declared as extern, it was just never exported. To work around the double possible declaration issue with older kernels fortunately the LINUX_BACKPORT() macro comes to the rescue by encofring our version to be declared and used in backport code. Note that this was added due to commit c61eef72 added as of v3.8 for DRM drivers that need access to timestamps that do no do not jump, unfortunately for older kernels we can't port that since it requires access to a static variable on the kernel, so just use the timestamps that jump. mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains a80b83b7 v3.5-rc6~10^2~15^2~30 mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains c61eef72 v3.8-rc1~42^2~170 commit a80b83b7b8456e9b475346c2e01d7e210883208c Author: John Stultz Date: Fri Feb 3 00:19:07 2012 -0800 Input: add infrastructure for selecting clockid for event time stamps As noted by Arve and others, since wall time can jump backwards, it is difficult to use for input because one cannot determine if one event occurred before another or for how long a key was pressed. However, the timestamp field is part of the kernel ABI, and cannot be changed without possibly breaking existing users. This patch adds a new IOCTL that allows a clockid to be set in the evdev_client struct that will specify which time base to use for event timestamps (ie: CLOCK_MONOTONIC instead of CLOCK_REALTIME). For now we only support CLOCK_MONOTONIC and CLOCK_REALTIME, but in the future we could support other clockids if appropriate. The default remains CLOCK_REALTIME, so we don't change the ABI. Signed-off-by: John Stultz Reviewed-by: Daniel Kurtz Signed-off-by: Dmitry Torokhov commit c61eef726a78ae77b6ce223d01ea2130f465fe5c Author: Imre Deak Date: Tue Oct 23 18:53:26 2012 +0000 drm: add support for monotonic vblank timestamps Jumps in the vblank and page flip event timestamps cause trouble for clients, so we should avoid them. The timestamp we get currently with gettimeofday can jump, so use instead monotonic timestamps. For backward compatibility use a module flag to revert back to using gettimeofday timestamps. Add also a DRM_CAP_TIMESTAMP_MONOTONIC flag that is simply a read only version of the module flag, so that clients can query this without depending on sysfs. Signed-off-by: Imre Deak Signed-off-by: Dave Airlie Signed-off-by: Luis R. Rodriguez --- diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c index 01509fa1afcd..d7f1c2751a86 100644 --- a/compat/compat-3.5.c +++ b/compat/compat-3.5.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Luis R. Rodriguez + * Copyright 2012-2013 Luis R. Rodriguez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -10,6 +10,7 @@ #include #include +#include /* * Commit 7a4e7408c5cadb240e068a662251754a562355e3 @@ -28,3 +29,17 @@ int overflowgid = DEFAULT_OVERFLOWGID; EXPORT_SYMBOL_GPL(overflowuid); EXPORT_SYMBOL_GPL(overflowgid); #endif + +/* + * We can't access the timekeeper static variable + * on older kernels so we're shit out of luck and + * have to rely on time that might jump. Upgrade + * if you want timestamps that don't jump, this + * important for DRM vblank and page flip event + * timestamps. + */ +ktime_t ktime_get_monotonic_offset(void) +{ + return ktime_get(); +} +EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 28a120902e0c..57b06b04f975 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -294,6 +294,9 @@ do { \ #define net_dbg_ratelimited(fmt, ...) \ net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) +#define ktime_get_monotonic_offset LINUX_BACKPORT(ktime_get_monotonic_offset) +extern ktime_t ktime_get_monotonic_offset(void); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ #endif /* LINUX_3_5_COMPAT_H */