libpciaccess porting problems

Ian Romanick idr at us.ibm.com
Mon Feb 25 10:36:48 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark Kettenis wrote:
| I'm trying to port libpciaccess to OpenBSD and I'm running into a
| nasty problem.
|
| On OpenBSD one can map device memory using /dev/xf86.  This device has
| exclusive open semantics to prevent conflicting access from multiple
| processes.  This means that the device can be opened only once.
| Because the mapping of PCI BARs has been moved into libpciaccess, the
| libpciaccess code has to open /dev/xf86.  But the xserver code itself
| also has to open /dev/xf86 to map VGA resources that are not mapped by
| PCI BARs.  This doesn't work, because libpciaccess gets there first
| and the xserver code loses.

Unexpected this is, and unfortunate.  (Sorry, it's Monday.)

| I need to find a way to get libpciaccess and xserver to share the file
| descriptor for /dev/xf86.  I see a couple of possibilities:
|
| * Modify the pci_system_init() interface to make it possible to pass
|   OS-specific arguments.
|
| * Add an OpenBSD-specific interface to libpciaccess to set the
|   /dev/xf86 file descriptor.
|
| * Turn libpciaccess into a Xorg module such that it can access xserver
|   internal symbols.
|
| Having xserver pass the file descriptor to libpciaccess is also
| necessary for another reason.  On OpenBSD the X server uses privilige
| seperation where the X server starts as root, opens /dev/xf86, forks,
| and then drops root priviliges.  If we do that before initializing
| libpciaccess, it won't be possible to for the library to open
| /dev/xf86.

Of the 3, I absolutely NAK option 3.  libpciaccess is intended to be
useful for things outside X.org.

I'm not 100% sure that option 2 would work.  The set-dev-mem-descriptor
function would have to be called before pci_system_init, I believe, and
that's not a great design.

That leaves option 1.  I think adding a pci_system_init_dev_mem would
work.  At some point we may want to implement full /dev/mem support on
other systems (e.g., older Linux kernels), and this entry point would be
useful there.  My gut tells me that this function should take a pointer
to the mmap'ed region instead of the file descriptor, but I guess that's
ultimately up to the person writing the code. :)

| What solution would people prefer?  Alternative solutions are also
| welcome.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHwwq7X1gOwKyEAw8RAq9tAJ0bND2f8zsrosyXccuPBw2F4i/SkgCggJCh
9Oa+7oTy+B2jJCQAd36uQr8=
=hwl+
-----END PGP SIGNATURE-----



More information about the xorg mailing list