Re: [Hampshire] Sys fs, PCI & mmap

Top Page

Reply to this message
Author: James Courtier-Dutton
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Sys fs, PCI & mmap
On 31/10/2007, Bond, Peter <PBond@???> wrote:
> > Just write a small kernel module that does a mmio mapping the physical
> > memory on the card into the virtual memory of the userspace
> > application.
> > You do need a kernel module driver loaded to do this task though.
> > There would simply be a few IOCTL calls so that userspace can request
> > a pointer to the virtual memory location, and also to release the
> > memory.
> >
> > Take a look at some of the PCI passthru code in qemu. qemu is a
> > userspace app and can be used to passthru mmio from the hardware into
> > the qemu vm.
>
> >From a while back...
>
> Having managed to get the PCI analyser back up and running, it appears that using devmem2 on the base address as reported in the /sys/bus/pci/devices/.../resource file, it does indeed result in reads across the PCI bus at the expected address (and return the data that I expect to see there); however, writes are not currently showing any accesses at all. My guess at the moment is the mapping that is going on - may be caching, I need to investigate further - I'll have a look at what Qemu does too.
>
> Note that this is not using a custom kernel module to handle the mapping, just what is provided by sysfs.
>
> Hope this is of some use to someone!
>


It sounds like you are coming up against write-posting.
All reads happen immediately to a mmio section.
All writes are delayed until the next read.
So, to write a value, do the following:
write the value to location X
read the value back from location X
To write two values, do the following:
write a value to location X
write a value to location Y
read a value from either location X or location Y.

This is all standard PCI programming, not linux specific.

James