From aba85bbc1d1ca6960f14e7e7ccf3520541e2c7ea Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 25 Mar 2009 20:50:39 +0100 Subject: [PATCH] hdt: Workaround for PXE detection Impact: The PCI device matching could fails in some cases In some cases, trying to find the exact bus/dev/fun/vendor/product fails reported by the pxe rom fails. In such case, that workaround will only look at the vendor/product id --- com32/hdt/hdt-common.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index f6f82c7..d067d11 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -297,6 +297,8 @@ int detect_pxe(struct s_hardware *hardware) } /* Let's try to find the associated pci device */ detect_pci(hardware); + + /* The firt pass try to find the exact pci device */ hardware->pxe.pci_device = NULL; hardware->pxe.pci_device_pos = 0; struct pci_device *pci_device; @@ -313,8 +315,34 @@ int detect_pxe(struct s_hardware *hardware) hardware->pxe.pci_device = pci_device; hardware->pxe.pci_device_pos = pci_number; + return 0; } } + + /* If we reach that part, it means the pci device pointed by + * the pxe rom wasn't found in our list. + * Let's try to find the device only by its pci ids. + * The pci device we'll match is maybe not exactly the good one + * as we can have the same pci id several times. + * At least, the pci id, the vendor/product will be right. + * That's clearly a workaround for some weird cases. + * This should happend very unlikely */ + hardware->pxe.pci_device = NULL; + hardware->pxe.pci_device_pos = 0; + pci_number = 0; + for_each_pci_func(pci_device, hardware->pci_domain) { + pci_number++; + if ((pci_device->vendor == + hardware->pxe.vendor_id) + && (pci_device->product == + hardware->pxe.product_id)) { + hardware->pxe.pci_device = pci_device; + hardware->pxe.pci_device_pos = + pci_number; + return 0; + } + } + } } return 0; -- 2.7.4