ia64/linux-2.6.18-xen.hg

changeset 823:589a78a593f3

PCI: restore saved SR-IOV state

Restore the volatile registers in the SR-IOV capability after the
D3->D0 transition.

Signed-off-by: Yu Zhao <yu.zhao@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 18 11:39:18 2009 +0000 (2009-03-18)
parents fb46e5625c61
children 7544e16acfe9
files drivers/pci/iov.c drivers/pci/pci.c drivers/pci/pci.h
line diff
     1.1 --- a/drivers/pci/iov.c	Wed Mar 18 11:39:04 2009 +0000
     1.2 +++ b/drivers/pci/iov.c	Wed Mar 18 11:39:18 2009 +0000
     1.3 @@ -125,6 +125,25 @@ static void sriov_release(struct pci_dev
     1.4  	dev->sriov = NULL;
     1.5  }
     1.6  
     1.7 +static void sriov_restore_state(struct pci_dev *dev)
     1.8 +{
     1.9 +	int i;
    1.10 +	u16 ctrl;
    1.11 +	struct pci_sriov *iov = dev->sriov;
    1.12 +
    1.13 +	pci_read_config_word(dev, iov->pos + PCI_SRIOV_CTRL, &ctrl);
    1.14 +	if (ctrl & PCI_SRIOV_CTRL_VFE)
    1.15 +		return;
    1.16 +
    1.17 +	for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++)
    1.18 +		pci_update_resource(dev, i);
    1.19 +
    1.20 +	pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz);
    1.21 +	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
    1.22 +	if (iov->ctrl & PCI_SRIOV_CTRL_VFE)
    1.23 +		msleep(100);
    1.24 +}
    1.25 +
    1.26  /**
    1.27   * pci_iov_init - initialize the IOV capability
    1.28   * @dev: the PCI device
    1.29 @@ -173,3 +192,13 @@ int pci_iov_resource_bar(struct pci_dev 
    1.30  	return dev->sriov->pos + PCI_SRIOV_BAR +
    1.31  		4 * (resno - PCI_IOV_RESOURCES);
    1.32  }
    1.33 +
    1.34 +/**
    1.35 + * pci_restore_iov_state - restore the state of the IOV capability
    1.36 + * @dev: the PCI device
    1.37 + */
    1.38 +void pci_restore_iov_state(struct pci_dev *dev)
    1.39 +{
    1.40 +	if (dev->is_physfn)
    1.41 +		sriov_restore_state(dev);
    1.42 +}
     2.1 --- a/drivers/pci/pci.c	Wed Mar 18 11:39:04 2009 +0000
     2.2 +++ b/drivers/pci/pci.c	Wed Mar 18 11:39:18 2009 +0000
     2.3 @@ -562,6 +562,8 @@ pci_restore_state(struct pci_dev *dev)
     2.4  	pci_restore_pcix_state(dev);
     2.5  	pci_restore_msi_state(dev);
     2.6  	pci_restore_msix_state(dev);
     2.7 +	pci_restore_iov_state(dev);
     2.8 +
     2.9  	return 0;
    2.10  }
    2.11  
     3.1 --- a/drivers/pci/pci.h	Wed Mar 18 11:39:04 2009 +0000
     3.2 +++ b/drivers/pci/pci.h	Wed Mar 18 11:39:18 2009 +0000
     3.3 @@ -154,6 +154,7 @@ extern int pci_iov_init(struct pci_dev *
     3.4  extern void pci_iov_release(struct pci_dev *dev);
     3.5  extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
     3.6  				enum pci_bar_type *type);
     3.7 +extern void pci_restore_iov_state(struct pci_dev *dev);
     3.8  #else
     3.9  static inline int pci_iov_init(struct pci_dev *dev)
    3.10  {
    3.11 @@ -168,4 +169,7 @@ static inline int pci_iov_resource_bar(s
    3.12  {
    3.13  	return 0;
    3.14  }
    3.15 +static inline void pci_restore_iov_state(struct pci_dev *dev)
    3.16 +{
    3.17 +}
    3.18  #endif /* CONFIG_PCI_IOV */