uncached user space mapping with mmap() ???
Hi there,
I am trying to access a hardware timer implemented in an FPGA from user space. I implemented a simple mmap() functionality (taken from Runbini's Linux Device Driver)
int simple_remap_mmap(struct file *filp, struct vm_area_struct *vma)
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
if (offset >= __pa(high_memory) || (filp->f_flags & O_SYNC)) {
vma->vm_flags |= VM_IO;
}
vma->vm_flags |= VM_RESERVED;
if (remap_page_range(vma->vm_start, offset,
vma->vm_end-vma->vm_start, vma->vm_page_prot))
return -EAGAIN;
return 0;
}I just learned that
Quoted 4 lines
getting an uncached user space mapping is architecture dependent. On ARM, however, passing
pgprot_noncached(vma->vm_page_prot)toremap_page_range()will alter the page protections such that the mapping will be uncached.
How could I do this on an MPC8xx?
Thanks a million!
--
Steven Scholz
imc Measurement & Control imc Meßsysteme GmbH Voltastr. 5 Voltastr. 5 13355 Berlin 13355 Berlin Germany Deutschland
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 1 line · Steven Scholz
How could I do this on an MPC8xx?
Open /dev/mem and just map the physical address of your registers. You don't even need your own driver. If you are mapping outside of the range of real memory, the mem driver will automatically give you uncached access.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Hi there,
thanks very much for all your help.
I used the stuff Stéphane suggested. But I have to ask again about mapping of huge memory areas:
Let's say the peripheral has 32 MB address range staring at BASE. At address GRAM 1MB of external SDRAM is located.
I use a simple test loop
p = (unsigned short *)
ioremap(base + GRAM, 32MB);
START ();
while (Retries--) {
for (i = 0; i < Size; i++) {
pData[i] = *p;
}
}
STOP ();When I map only the the GRAM I get a throughput of
IoremapTest... 8.0 s => 2049.4 kW/s
But when I map the whole address range
p = (unsigned short *) ioremap(BASE, imcdevif_iosize);
and move the pointer
p += GRAM;
before entering the test loop I only get
IoremapTest... 8.4 s => 1944.8 kW/s
How is that???
Is it always better to map only the small part I am going to use?
Thanks a million!
--
Steven Scholz
imc Measurement & Control imc Meßsysteme GmbH Voltastr. 5 Voltastr. 5 13355 Berlin 13355 Berlin Germany Deutschland
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Steven Scholz wrote:
| Is it always better to map only the small part I am going to use?
Of course it is always best to map only the small range that you are going to use and there will not necessarily be only one TLB mapping (I am here referring to your comments on ARM Linux Kernel List) etc. etc. However here especially I am inclined to repeat what they said on the other list - these figures are so close that they might differ for other reasons and so on. Did you repeat this in a controlled way many times?
You will need to answer the questions Russell King posted in order for us to work through this and figure out where the difference lies.
Cheers,
Jon.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 8 lines · Jon Masters
| Is it always better to map only the small part I am going to use?
Of course it is always best to map only the small range that you are going to use and there will not necessarily be only one TLB mapping (I am here referring to your comments on ARM Linux Kernel List) etc. etc. However here especially I am inclined to repeat what they said on the other list - these figures are so close that they might differ for other reasons and so on. Did you repeat this in a controlled way many times?
Yes. The thruput is calculated after repeating the loop 1000 times (Retries = 1000).
Quoted 2 lines
You will need to answer the questions Russell King posted in order for us to work through this and figure out where the difference lies.
I am just about to do it.
--
Steven Scholz
imc Measurement & Control imc Meßsysteme GmbH Voltastr. 5 Voltastr. 5 13355 Berlin 13355 Berlin Germany Deutschland
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Steven Scholz wrote:
| Yes. The thruput is calculated after repeating the loop 1000 times | (Retries = 1000).
That is not an accurate measurement though because you really need to repeat this a few times on the host from a cold start under similar conditions for people to actually see much difference in these figures - within a single run you might well see a small delta between the two.
|> You will need to answer the questions Russell King posted in order for |> us to work through this and figure out where the difference lies.
| I am just about to do it.
Ok.
Jon.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/