# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216026614 -3600
# Node ID caba894b265f446436ec18745b8a0937a140d0ee
# Parent 2463e2ef602f64e091d14303beef1ae10126c3c4
vt-d: Remove the FLR logic in Xen.
The current simple logic has some issues: 1) Dstate transition is not
guaranteed to properly clear the device state; 2) the current code for
PCIe FLR is actually buggy: PCI_EXP_DEVSTA_TRPND doesn't mean the
completion of FLR; according to the PCIe spec, after issuing FLR, we
should wait at least 100ms.
The improved FLR logic will be added into xend.
Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
---
xen/drivers/passthrough/amd/pci_amd_iommu.c | 1
xen/drivers/passthrough/pci.c | 65 ----------------------------
xen/drivers/passthrough/vtd/iommu.c | 1
xen/include/xen/pci.h | 1
4 files changed, 68 deletions(-)
diff -r 2463e2ef602f -r caba894b265f xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Jul 14 10:09:25
2008 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Jul 14 10:10:14
2008 +0100
@@ -507,7 +507,6 @@ static int reassign_device( struct domai
if ( !pdev )
return -ENODEV;
- pdev_flr(pdev);
bdf = (bus << 8) | devfn;
/* supported device? */
iommu = (bdf < ivrs_bdf_entries) ?
diff -r 2463e2ef602f -r caba894b265f xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c Mon Jul 14 10:09:25 2008 +0100
+++ b/xen/drivers/passthrough/pci.c Mon Jul 14 10:10:14 2008 +0100
@@ -161,71 +161,6 @@ void pci_release_devices(struct domain *
}
}
-#define PCI_D3hot (3)
-#define PCI_CONFIG_DWORD_SIZE (64)
-#define PCI_EXP_DEVCAP_FLR (1 << 28)
-#define PCI_EXP_DEVCTL_FLR (1 << 15)
-
-void pdev_flr(struct pci_dev *pdev)
-{
- u8 pos;
- u32 dev_cap, dev_status, pm_ctl;
- int flr = 0;
- u8 dev = PCI_SLOT(pdev->devfn);
- u8 func = PCI_FUNC(pdev->devfn);
-
- pos = pci_find_cap_offset(pdev->bus, dev, func, PCI_CAP_ID_EXP);
- if ( pos != 0 )
- {
- dev_cap = pci_conf_read32(pdev->bus, dev, func, pos + PCI_EXP_DEVCAP);
- if ( dev_cap & PCI_EXP_DEVCAP_FLR )
- {
- pci_conf_write32(pdev->bus, dev, func,
- pos + PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_FLR);
- do {
- dev_status = pci_conf_read32(pdev->bus, dev, func,
- pos + PCI_EXP_DEVSTA);
- } while ( dev_status & PCI_EXP_DEVSTA_TRPND );
-
- flr = 1;
- }
- }
-
- /* If this device doesn't support function level reset,
- * program device from D0 t0 D3hot, and then return to D0
- * to implement function level reset
- */
- if ( flr == 0 )
- {
- pos = pci_find_cap_offset(pdev->bus, dev, func, PCI_CAP_ID_PM);
- if ( pos != 0 )
- {
- int i;
- u32 config[PCI_CONFIG_DWORD_SIZE];
- for ( i = 0; i < PCI_CONFIG_DWORD_SIZE; i++ )
- config[i] = pci_conf_read32(pdev->bus, dev, func, i*4);
-
- /* Enter D3hot without soft reset */
- pm_ctl = pci_conf_read32(pdev->bus, dev, func, pos + PCI_PM_CTRL);
- pm_ctl |= PCI_PM_CTRL_NO_SOFT_RESET;
- pm_ctl &= ~PCI_PM_CTRL_STATE_MASK;
- pm_ctl |= PCI_D3hot;
- pci_conf_write32(pdev->bus, dev, func, pos + PCI_PM_CTRL, pm_ctl);
- mdelay(10);
-
- /* From D3hot to D0 */
- pci_conf_write32(pdev->bus, dev, func, pos + PCI_PM_CTRL, 0);
- mdelay(10);
-
- /* Write saved configurations to device */
- for ( i = 0; i < PCI_CONFIG_DWORD_SIZE; i++ )
- pci_conf_write32(pdev->bus, dev, func, i*4, config[i]);
-
- flr = 1;
- }
- }
-}
-
static void dump_pci_devices(unsigned char ch)
{
struct pci_dev *pdev;
diff -r 2463e2ef602f -r caba894b265f xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c Mon Jul 14 10:09:25 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c Mon Jul 14 10:10:14 2008 +0100
@@ -1382,7 +1382,6 @@ static int reassign_device_ownership(
if ( !(pdev = pci_lock_domain_pdev(source, bus, devfn)) )
return -ENODEV;
- pdev_flr(pdev);
drhd = acpi_find_matched_drhd_unit(bus, devfn);
pdev_iommu = drhd->iommu;
domain_context_unmap(bus, devfn);
diff -r 2463e2ef602f -r caba894b265f xen/include/xen/pci.h
--- a/xen/include/xen/pci.h Mon Jul 14 10:09:25 2008 +0100
+++ b/xen/include/xen/pci.h Mon Jul 14 10:10:14 2008 +0100
@@ -56,7 +56,6 @@ struct pci_dev *pci_lock_pdev(int bus, i
struct pci_dev *pci_lock_pdev(int bus, int devfn);
struct pci_dev *pci_lock_domain_pdev(struct domain *d, int bus, int devfn);
-void pdev_flr(struct pci_dev *pdev);
void pci_release_devices(struct domain *d);
int pci_add_device(u8 bus, u8 devfn);
int pci_remove_device(u8 bus, u8 devfn);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|