[Skiboot] [PATCH] pci: Do a dummy config write to devices to establish bus number

Gavin Shan gwshan at linux.vnet.ibm.com
Thu Jun 9 15:43:50 AEST 2016


On Thu, Jun 09, 2016 at 12:34:57AM +1000, Benjamin Herrenschmidt wrote:
>On PCI Express, devices need to know their own bus number in order
>to provide the correct source identification (aka RID) in upstream
>packets they might send, such as error messages or DMAs.
>
>However while devices know (and hard wire) their own device and
>function number, they know nothing about bus numbers by default, those
>are decoded by bridges for routing. All they know is that if their
>parent bridge sends a "type 0" configuration access, they should decode
>it provided the device and function numbers match.
>
>The PCIe spec thus defines that when a device receive such a configuration
>access and it's a write, it should "capture" the bus number in the source
>field of the packet, and re-use as the originator bus number of all
>subsequent outgoing requests.
>
>In order to ensure that a device has this bus number firmly established
>before it's likely to send error packets upstream, we should thus do a
>dummy configuration write to it as soon as possible after probing.
>
>Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Reviewed-by: Gavin Shan <gwshan at linux.vnet.ibm.com>

>---
>
>diff --git a/core/pci.c b/core/pci.c
>index 9b238d0..bce65fb 100644
>--- a/core/pci.c
>+++ b/core/pci.c
>@@ -156,6 +156,13 @@ static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren
> 	}
> 	if (had_crs)
> 		PCIDBG(phb, bdfn, "Probe success after CRS\n");
>+
>+	/* Perform a dummy write to the device in order for it to
>+	 * capture it's own bus number, so any subsequent error
>+	 * messages will be properly tagged
>+	 */
>+	pci_cfg_write32(phb, bdfn, 0, &vdid);
>+

Ben, I guess it's vdid, not &vdid though the target register is read-only.

Thanks,
Gavin

> 	pd = zalloc(sizeof(struct pci_device));
> 	if (!pd) {
> 		PCIERR(phb, bdfn,"Failed to allocate structure pci_device !\n");
>_______________________________________________
>Skiboot mailing list
>Skiboot at lists.ozlabs.org
>https://lists.ozlabs.org/listinfo/skiboot



More information about the Skiboot mailing list