Skip to content

Commit

Permalink
Disabled timeout for kernel versions < 2.6.16.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsylve committed Dec 23, 2016
1 parent 7b92b93 commit 08046a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 16 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ char * path = 0;
int dio = 0;
int port = 0;
int localhostonly = 0;
long timeout = 1000;

extern struct resource iomem_resource;

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; \
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -218,13 +230,16 @@ 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) {
DBG("Reading is too slow. Skipping Range...");
write_padding(res->end - i + 1 - is);
break;
}
#endif

}
}

Expand Down

0 comments on commit 08046a1

Please sign in to comment.