updated to work on all platforms (actually map sure that the physical
address we are trying to access is mapped before accessing it.) --HG-- extra : convert_revision : 104341334a3d2bb812a6b0b6277ab353f8f9b39e
This commit is contained in:
parent
3512904c74
commit
fe3a86e2ef
1 changed files with 28 additions and 10 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
#include <asm/page.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
|
@ -70,18 +71,34 @@ static int __init devtime_start(void)
|
||||||
devSum = 0;
|
devSum = 0;
|
||||||
devCnt = count;
|
devCnt = count;
|
||||||
|
|
||||||
printk("Preparing to read %#llx %d times.\n", addr, count);
|
addr = ioremap(addr, PAGE_SIZE);
|
||||||
|
/**
|
||||||
t1 = cycleCounter(trash);
|
* Make sure that the remapping actually worked. On alpha we have
|
||||||
for (x=0; x < count; x++)
|
* linear addressing, so its not a problem. But it can fail in x86
|
||||||
|
* if physical memory is mapped to this address.
|
||||||
|
*/
|
||||||
|
if (addr)
|
||||||
{
|
{
|
||||||
trash = readl(addr);
|
printk("Preparing to read %#llx %d times.\n", addr, count);
|
||||||
t2 = cycleCounter(trash);
|
|
||||||
devSum += t2 - t1;
|
|
||||||
t1 = t2;
|
|
||||||
}
|
|
||||||
|
|
||||||
printk("Read Address %#llx %ld times. Average latency %ld.\n", addr, devCnt, devSum/devCnt);
|
t1 = cycleCounter(trash);
|
||||||
|
for (x=0; x < count; x++)
|
||||||
|
{
|
||||||
|
trash = readl(addr);
|
||||||
|
t2 = cycleCounter(trash);
|
||||||
|
devSum += t2 - t1;
|
||||||
|
t1 = t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unmap the address.
|
||||||
|
*/
|
||||||
|
iounmap(addr);
|
||||||
|
|
||||||
|
printk("Read Address %#llx %ld times. Average latency %ld.\n", addr, devCnt, devSum/devCnt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printk("Unable to remap address. Please try again later.\n");
|
||||||
} else {
|
} else {
|
||||||
dev = dev_get_by_name("eth0");
|
dev = dev_get_by_name("eth0");
|
||||||
if (dev)
|
if (dev)
|
||||||
|
@ -90,6 +107,7 @@ static int __init devtime_start(void)
|
||||||
dev->mem_end, dev->base_addr);
|
dev->mem_end, dev->base_addr);
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
}
|
}
|
||||||
|
dev = 0;
|
||||||
dev = dev_get_by_name("eth1");
|
dev = dev_get_by_name("eth1");
|
||||||
if (dev)
|
if (dev)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue