Subject: Re: mpc8541 pci1 ioport allocation address space problem

From: Benjamin Herrenschmidt <[email-masked]>
Date: Mon, 22 Sep 2008 15:47:44 +1000

On Sat, 2008-09-20 at 19:16 +0800, Wang Jian wrote:
> Hi,
> 
> Here I have a 8541 dev board, with 2 e1000 attached to pci0 and a
> homebrewed addon board inserted into pci1. I am trying to make it work
> under 2.6.26-rc8 (2.6.26 broken so I am working at rc8).
> 
> The ioports allocation reads
> 
> $ cat /proc/ioports
> 00000000-000fffff : /pci@e0008000
>   00001000-0000103f : 0000:00:0a.0
>   00001040-0000107f : 0000:00:0b.0
> ffefe000-ffffdfff : /pci@e0009000
>   ffeff000-ffeff00f : 0001:01:0a.0
>   ffeff010-ffeff01f : 0001:01:0b.0
>   ffeff020-ffeff02f : 0001:01:0c.0
>   ffeff030-ffeff03f : 0001:01:0d.0
> 
> The port allocation for pci1 looks ridiculous. The addon board doesn't work.
> 
> After poking around, I find pci_process_bridge_OF_ranges() in
> arch/powerpc/kernel/pci-common.c

 .../...

This is expected and should work. Depending on the relative
physical addresses of IO space and the order in which the bridges are
discovered, the bridge IO ports will look at either positive or negative
values. This should be fine, as port numbers are supposed to be 32 bits
and in-kernel arithmetic should do the right thing... I suppose unless a
driver stores those in a 64 bits integer and doesn't sign extend.

I would like to change that whole thing to something more similar to
64 bits where I reserve a portion of the address space for IO ports,
though address space on 32 bits platforms is scarce, but nothing I have
time to toy with right now.

Cheers,
Ben.