pci: Arch hook to determine config space size

Arnd Bergmann arnd at arndb.de
Tue Feb 1 07:51:04 EST 2005


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 at de.ibm.com>

--- 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050131/97d5360f/attachment.pgp 


More information about the Linuxppc64-dev mailing list