Re: pci: Arch hook to determine config space size

From: Arnd Bergmann
Date: Mon Jan 31 2005 - 16:13:08 EST


On Maandag 31 Januar 2005 20:29, Matthew Wilcox wrote:
> Thanks for copying linux-pci.  I hate this patch.
>
> Basically, ppc64's config ops are broken and need to check the offset
> being read.

To make things worse, simply allowing the larger config space will
silently access the wrong device. The least that needs to be done
is to pass the correct address to the firmware.
This patch should do the right thing, though I don't have any PCIe
card to test with.

Note that at least for the rtas pci config access, the bus/devfn
values come from the device tree, which makes it somewhat harder
to screw them up, and rtas ought to check for obviously wrong
addresses as well.

Signed-off-by: Arnd Bergmann <arndb@xxxxxxxxxx>

--- linux-mm.orig/arch/ppc64/kernel/pSeries_pci.c 2005-01-28 07:21:15.000000000 -0500
+++ linux-mm/arch/ppc64/kernel/pSeries_pci.c 2005-01-31 15:56:10.244983464 -0500
@@ -63,7 +63,8 @@
if (where & (size - 1))
return PCIBIOS_BAD_REGISTER_NUMBER;

- addr = (dn->busno << 16) | (dn->devfn << 8) | where;
+ addr = ((where & 0xf00) << 20) | (dn->busno << 16)
+ | (dn->devfn << 8) | (where & 0x0ff);
buid = dn->phb->buid;
if (buid) {
ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval,
@@ -111,7 +112,8 @@
if (where & (size - 1))
return PCIBIOS_BAD_REGISTER_NUMBER;

- addr = (dn->busno << 16) | (dn->devfn << 8) | where;
+ addr = ((where & 0xf00) << 20) | (dn->busno << 16)
+ | (dn->devfn << 8) | (where & 0x0ff);
buid = dn->phb->buid;
if (buid) {
ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val);


Attachment: pgp00000.pgp
Description: signature