libpciaccess question

Jesse Barnes jbarnes at virtuousgeek.org
Wed Jul 2 11:16:12 PDT 2008


On Wednesday, July 02, 2008 10:41 am Adam Jackson wrote:
> On Wed, 2008-07-02 at 10:57 -0600, Sebastian Kuzminsky wrote:
> > Hi there, sorry to mail you directly but I couldnt find the proper
> > mailing list for asking about libpciaccess.
>
> xorg at lists.freedesktop.org is probably the best place.  I've cc'd the
> list since this is probably a generally interesting question.
>
> > I'm trying to use libpciaccess to write a userspace utility to work with
> > some PCI cards, and I need to peek & poke some IO BARs.  I'm on Ubuntu
> > 7.10, which has libpciaccess 0.8.0.
> >
> > I can map in memory BARs fine, but the mmap() in
> > pci_device_linux_sysfs_map_region() fails with EINVAL when I try to map
> > IO BARs.  Is this is a limitation of the sysfs regionX files
> > corresponding to IO BARs, that they're not mmappable?
>
> I'm reasonably sure they're not mmapable.  Doing so would essentially
> require that the kernel set up a fake map, trap all read or write access
> to it, and disassemble the faulting instruction to deduce the i/o cycle
> size and address and translate that to an i/o instruction.  (That's my
> understanding anyway.)  The PCI config space is not mmap'able for much
> the same reason.
>
> The config space is supported through the normal read/write syscalls
> though, and the same could reasonably be done for the IO BARs I suspect,
> but right now there's no code for that in pciaccess.  Which seems like
> failing.

Right, the Linux sysfs resource files unfortunately allow some platform 
specifics to creep in.  On some platforms you can mmap both memory and I/O 
regions, others only allow you to do memory regions, and some don't let you 
map either (alpha has special requirements).

It would definitely be nice to extend libpciaccess to abstract this away a 
bit, but no one's done that yet, afaik.

Jesse



More information about the xorg mailing list