PCI rework

Jesse Barnes jbarnes at virtuousgeek.org
Sun Apr 30 11:06:50 PDT 2006


On Sunday, April 30, 2006 5:22 am, Mark Kettenis wrote:
> Matthieu Herb, asked me to have a look at libpciaccess some time ago.
> My conclusion then was that it is too tightly bound to Linux.  It
> takes the Linux sysfs pci access interface as a model instead of the
> actual pci hardware.  I especially feel the support to map memory
> associated with the PCI BAR's does not belong in the library.  It is
> not impossible to implement the libpciaccess backend for other
> operating systems, but it would be rather awkward.

X already assumes it can mmap memory BARs, do you think it needs to 
change too?  It seems to me that the interface provided by libpciaccess 
is fairly flexible, easy to use, and easily ported to new platforms (it 
should be, it's based on the Linux internal PCI interfaces which have 
prooven highly portable).  Do you have other examples where you think 
Linux specific implementation details have crept into the interface?

> Looking at your patch I see that changes to the drivers are mostly
> changes like:
>
> -    *pucByte = pciReadByte(pMga->PciTag,ulOffset);
> +    pci_device_cfg_read_u8( pMga->PciInfo, pucByte, ulOffset );
>
> So basically this is just replacing the current interfaces with the
> equivalent libpciaccess interfaces.  Why not keep the current current
> interfaces and reimplement them to use libpciaccess in the
> Linux-specific Xorg code?

Note that the prototype is different in that it takes a full pci info 
structure rather than just a tag.  This gives arch specific 
implementations more flexibility and eases porting.

> I really don't see any major flaws in the 
> current xf86Pci.h interfaces, but I agree that some of the
> implementation could use some cleanup.

I disagree with this, the xf86Pci interface is pretty screwy:
  o X does things with PCI devices it has no business doing (e.g.
    remapping BARs)
  o the distinction between mapping domain and regular PCI memory is
    arbitrary and should be removed
  o the PCI device discovery code needed by drivers is unnecessarily
    complex
  o ROM mapping is hard to port and buggy in some cases

libpciaccess directly addresses some of the above problems and makes the 
others much easier to fix.  And its fundamental direction is correct as 
well:  X should *not* have a big PCI abstraction layer of its own, it 
should use the underlying OS via an external library for PCI related 
operations.

> Oh, and I really think you shouldn't change the coding style.  Those
> extra spaces after the the '(' are just plain ugly ;-).

Agreed. :)

Jesse



More information about the xorg mailing list