kraxel / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
e108932
When we do an FLR, or D0->D3_hot we may lose the BARs as the
e108932
device has turned itself off (and on). This means the device cannot
e108932
function unless the pci_restore_state is called - which it is
e108932
when the PCI device is unbound from the Xen PCI backend driver.
e108932
For PV guests it ends up calling pci_enable_device / pci_enable_msi[x]
e108932
which does the proper steps
e108932
e108932
That however is not happening if a HVM guest is run as QEMU
e108932
deals with PCI configuration space. QEMU also requires that the
e108932
device be "parked"  under the ownership of a pci-stub driver to
e108932
guarantee that the PCI device is not being used. Hence we
e108932
follow the same incantation as pci_reset_function does - by
e108932
doing an FLR, then restoring the PCI configuration space.
e108932
e108932
The result of this patch is that when you run lspci, you get
e108932
now this:
e108932
e108932
-       Region 0: [virtual] Memory at fe8c0000 (32-bit, non-prefetchable) [size=128K]
e108932
-       Region 1: [virtual] Memory at fe800000 (32-bit, non-prefetchable) [size=512K]
e108932
+       Region 0: Memory at fe8c0000 (32-bit, non-prefetchable) [size=128K]
e108932
+       Region 1: Memory at fe800000 (32-bit, non-prefetchable) [size=512K]
e108932
        Region 2: I/O ports at c000 [size=32]
e108932
-       Region 3: [virtual] Memory at fe8e0000 (32-bit, non-prefetchable) [size=16K]
e108932
+       Region 3: Memory at fe8e0000 (32-bit, non-prefetchable) [size=16K]
e108932
e108932
The [virtual] means that lspci read those entries from SysFS but when
e108932
it read them from the device it got a different value (0xfffffff).
e108932
e108932
CC: stable@vger.kernel.org # only for v3.4 and v3.5
e108932
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
e108932
---
e108932
 drivers/xen/xen-pciback/pci_stub.c |    1 +
e108932
 1 files changed, 1 insertions(+), 0 deletions(-)
e108932
e108932
diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
e108932
index acec6fa..e5a0c13 100644
e108932
--- a/drivers/xen/xen-pciback/pci_stub.c
e108932
+++ b/drivers/xen/xen-pciback/pci_stub.c
e108932
@@ -362,6 +362,7 @@ static int __devinit pcistub_init_device(struct pci_dev *dev)
e108932
 	else {
e108932
 		dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");
e108932
 		__pci_reset_function_locked(dev);
e108932
+		pci_restore_state(dev);
e108932
 	}
e108932
 	/* Now disable the device (this also ensures some private device
e108932
 	 * data is setup before we export)
e108932
-- 
e108932
1.7.7.6
e108932
e108932
--
e108932
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
e108932
the body of a message to majordomo@vger.kernel.org
e108932
More majordomo info at  http://vger.kernel.org/majordomo-info.html
e108932
Please read the FAQ at  http://www.tux.org/lkml/