How should I deal with a PCI resource not aligned to a page boundary?

Adam Jackson ajax at nwnk.net
Wed Feb 17 12:27:07 PST 2010


On Wed, 2010-02-17 at 12:13 -0500, Alex Villací­s Lasso wrote:
> After writing a somewhat functional xorg driver for the OAK Spitfire 
> OTI64111 video card, I am trying to modify the driver to support the 
> OTI64107 video card, which I have plugged in my test machine. The first 
> strange thing that I notice about this card is that it reports a MMIO 
> region that is not aligned to a page boundary (4096 bytes on this x86 
> PC). Instead it reports an physical address like 0xffeff800, both 
> through lspci and through libpciaccess within my driver code. If I try 
> to map this resource, I get a page-aligned address, but trying to 
> actually use the resource at this mapping has no effect in the card. To 
> get around this, I have done the following: extract the lower bits of 
> the resource with (resource & 0xfff), and use these bits as an offset 
> within the mapping. I do get access to the MMIO by doing this, but it 
> feels like an ugly hack. What is the official way of dealing with this 
> situation? What measures should I take when compiling this for a 
> different architecture, or a 64-bit machine?

I think that's the correct thing to do, the hardware's just being weird.

For arches with a different page size, build the mask with
getpagesize()-1.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20100217/5d2a0a45/attachment.pgp>


More information about the xorg mailing list