Commit 38cc1302 authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Greg Kroah-Hartman

PCI : add extremely specialized __pci_reenable_device for default resume

Original patch was posted as "PCI : Move pci_fixup_device and is_enabled".
This 3 of 3 patches does:

  - add __pci_reenable_device
    (recover former change of 1st patch)
Signed-off-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9fb625c3
...@@ -324,8 +324,7 @@ static int pci_default_resume(struct pci_dev *pci_dev) ...@@ -324,8 +324,7 @@ static int pci_default_resume(struct pci_dev *pci_dev)
/* restore the PCI config space */ /* restore the PCI config space */
pci_restore_state(pci_dev); pci_restore_state(pci_dev);
/* if the device was enabled before suspend, reenable */ /* if the device was enabled before suspend, reenable */
if (atomic_read(&pci_dev->enable_cnt)) retval = __pci_reenable_device(pci_dev);
retval = pci_enable_device(pci_dev);
/* if the device was busmaster before the suspend, make it busmaster again */ /* if the device was busmaster before the suspend, make it busmaster again */
if (pci_dev->is_busmaster) if (pci_dev->is_busmaster)
pci_set_master(pci_dev); pci_set_master(pci_dev);
......
...@@ -676,6 +676,36 @@ pci_restore_state(struct pci_dev *dev) ...@@ -676,6 +676,36 @@ pci_restore_state(struct pci_dev *dev)
return 0; return 0;
} }
static int do_pci_enable_device(struct pci_dev *dev, int bars)
{
int err;
err = pci_set_power_state(dev, PCI_D0);
if (err < 0 && err != -EIO)
return err;
err = pcibios_enable_device(dev, bars);
if (err < 0)
return err;
pci_fixup_device(pci_fixup_enable, dev);
return 0;
}
/**
* __pci_reenable_device - Resume abandoned device
* @dev: PCI device to be resumed
*
* Note this function is a backend of pci_default_resume and is not supposed
* to be called by normal code, write proper resume handler and use it instead.
*/
int
__pci_reenable_device(struct pci_dev *dev)
{
if (atomic_read(&dev->enable_cnt))
return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
return 0;
}
/** /**
* pci_enable_device_bars - Initialize some of a device for use * pci_enable_device_bars - Initialize some of a device for use
* @dev: PCI device to be initialized * @dev: PCI device to be initialized
...@@ -693,15 +723,8 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) ...@@ -693,15 +723,8 @@ pci_enable_device_bars(struct pci_dev *dev, int bars)
if (atomic_add_return(1, &dev->enable_cnt) > 1) if (atomic_add_return(1, &dev->enable_cnt) > 1)
return 0; /* already enabled */ return 0; /* already enabled */
err = pci_set_power_state(dev, PCI_D0); err = do_pci_enable_device(dev, bars);
if (err < 0 && err != -EIO)
goto err_out;
err = pcibios_enable_device(dev, bars);
if (err < 0) if (err < 0)
goto err_out;
pci_fixup_device(pci_fixup_enable, dev);
err_out:
atomic_dec(&dev->enable_cnt); atomic_dec(&dev->enable_cnt);
return err; return err;
} }
......
/* Functions internal to the PCI core code */ /* Functions internal to the PCI core code */
extern int __must_check __pci_reenable_device(struct pci_dev *);
extern int pci_uevent(struct device *dev, char **envp, int num_envp, extern int pci_uevent(struct device *dev, char **envp, int num_envp,
char *buffer, int buffer_size); char *buffer, int buffer_size);
extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment