From 08046a1b16f062b69e42a4414da62d1571502a49 Mon Sep 17 00:00:00 2001 From: Joe Sylve Date: Fri, 23 Dec 2016 14:09:40 -0600 Subject: [PATCH] Disabled timeout for kernel versions < 2.6.16. --- src/lime.h | 4 ++++ src/main.c | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lime.h b/src/lime.h index a1a0d53..a7a0f36 100644 --- a/src/lime.h +++ b/src/lime.h @@ -55,6 +55,10 @@ #define DBG(fmt, args...) do {} while(0) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#define LIME_SUPPORTS_TIMING +#endif + //structures typedef struct { diff --git a/src/main.c b/src/main.c index 3004c31..e923321 100644 --- a/src/main.c +++ b/src/main.c @@ -50,7 +50,6 @@ char * path = 0; int dio = 0; int port = 0; int localhostonly = 0; -long timeout = 1000; extern struct resource iomem_resource; @@ -58,7 +57,11 @@ module_param(path, charp, S_IRUGO); module_param(dio, int, S_IRUGO); module_param(format, charp, S_IRUGO); module_param(localhostonly, int, S_IRUGO); + +#ifdef LIME_SUPPORTS_TIMING +long timeout = 1000; module_param(timeout, long, S_IRUGO); +#endif #define RETRY_IF_INTURRUPTED(f) ({ \ ssize_t err; \ @@ -84,6 +87,10 @@ int init_module (void) DBG(" FORMAT: %s", format); DBG(" LOCALHOSTONLY: %u", localhostonly); +#ifdef LIME_SUPPORTS_TIMING + DBG(" TIMEOUT: %lu", timeout); +#endif + memset(zero_page, 0, sizeof(zero_page)); if (!strcmp(format, "raw")) mode = LIME_MODE_RAW; @@ -188,12 +195,17 @@ static void write_range(struct resource * res) { void * v; ssize_t s; + +#ifdef LIME_SUPPORTS_TIMING ktime_t start,end; +#endif DBG("Writing range %llx - %llx.", res->start, res->end); for (i = res->start; i <= res->end; i += is) { +#ifdef LIME_SUPPORTS_TIMING start = ktime_get_real(); +#endif p = pfn_to_page((i) >> PAGE_SHIFT); @@ -218,6 +230,7 @@ static void write_range(struct resource * res) { } } +#ifdef LIME_SUPPORTS_TIMING end = ktime_get_real(); if (timeout > 0 && ktime_to_ms(ktime_sub(end, start)) > timeout) { @@ -225,6 +238,8 @@ static void write_range(struct resource * res) { write_padding(res->end - i + 1 - is); break; } +#endif + } }