Commit b7ffff4b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 's3-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console

Pull virtio S3 support patches from Amit Shah:
 "Turns out S3 is not different from S4 for virtio devices: the device
  is assumed to be reset, so the host and guest state are to be assumed
  to be out of sync upon resume.  We handle the S4 case with exactly the
  same scenario, so just point the suspend/resume routines to the
  freeze/restore ones.

  Once that is done, we also use the PM API's macro to initialise the
  sleep functions.

  A couple of cleanups are included: there's no need for special thaw
  processing in the balloon driver, so that's addressed in patches 1 and
  2.

  Testing: both S3 and S4 support have been tested using these patches
  using a similar method used earlier during S4 patch development: a
  guest is started with virtio-blk as the only disk, a virtio network
  card, a virtio-serial port and a virtio balloon device.  Ping from
  guest to host, dd /dev/zero to a file on the disk, and IO from the
  host on the virtio-serial port, all at once, while exercising S4 and
  S3 (separately) were tested.  They all continue to work fine after
  resume.  virtio balloon values too were tested by inflating and
  deflating the balloon."

Pulling from Amit, since Rusty is off getting married (and presumably
shaving people).

* 's3-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console:
  virtio-pci: switch to PM ops macro to initialise PM functions
  virtio-pci: S3 support
  virtio-pci: drop restore_common()
  virtio: drop thaw PM operation
  virtio: balloon: Allow stats update after restore from S4
parents 8bb1f229 f878d0be
...@@ -398,21 +398,8 @@ static int restore_common(struct virtio_device *vdev) ...@@ -398,21 +398,8 @@ static int restore_common(struct virtio_device *vdev)
return 0; return 0;
} }
static int virtballoon_thaw(struct virtio_device *vdev)
{
return restore_common(vdev);
}
static int virtballoon_restore(struct virtio_device *vdev) static int virtballoon_restore(struct virtio_device *vdev)
{ {
struct virtio_balloon *vb = vdev->priv;
/*
* If a request wasn't complete at the time of freezing, this
* could have been set.
*/
vb->need_stats_update = 0;
return restore_common(vdev); return restore_common(vdev);
} }
#endif #endif
...@@ -434,7 +421,6 @@ static struct virtio_driver virtio_balloon_driver = { ...@@ -434,7 +421,6 @@ static struct virtio_driver virtio_balloon_driver = {
#ifdef CONFIG_PM #ifdef CONFIG_PM
.freeze = virtballoon_freeze, .freeze = virtballoon_freeze,
.restore = virtballoon_restore, .restore = virtballoon_restore,
.thaw = virtballoon_thaw,
#endif #endif
}; };
......
...@@ -720,24 +720,6 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev) ...@@ -720,24 +720,6 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int virtio_pci_suspend(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
pci_save_state(pci_dev);
pci_set_power_state(pci_dev, PCI_D3hot);
return 0;
}
static int virtio_pci_resume(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
pci_restore_state(pci_dev);
pci_set_power_state(pci_dev, PCI_D0);
return 0;
}
static int virtio_pci_freeze(struct device *dev) static int virtio_pci_freeze(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
...@@ -758,59 +740,24 @@ static int virtio_pci_freeze(struct device *dev) ...@@ -758,59 +740,24 @@ static int virtio_pci_freeze(struct device *dev)
return ret; return ret;
} }
static int restore_common(struct device *dev) static int virtio_pci_restore(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
int ret;
ret = pci_enable_device(pci_dev);
if (ret)
return ret;
pci_set_master(pci_dev);
vp_finalize_features(&vp_dev->vdev);
return ret;
}
static int virtio_pci_thaw(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
struct virtio_driver *drv; struct virtio_driver *drv;
int ret; int ret;
ret = restore_common(dev);
if (ret)
return ret;
drv = container_of(vp_dev->vdev.dev.driver, drv = container_of(vp_dev->vdev.dev.driver,
struct virtio_driver, driver); struct virtio_driver, driver);
if (drv && drv->thaw) ret = pci_enable_device(pci_dev);
ret = drv->thaw(&vp_dev->vdev); if (ret)
else if (drv && drv->restore)
ret = drv->restore(&vp_dev->vdev);
/* Finally, tell the device we're all set */
if (!ret)
vp_set_status(&vp_dev->vdev, vp_dev->saved_status);
return ret; return ret;
}
static int virtio_pci_restore(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
struct virtio_driver *drv;
int ret;
drv = container_of(vp_dev->vdev.dev.driver, pci_set_master(pci_dev);
struct virtio_driver, driver); vp_finalize_features(&vp_dev->vdev);
ret = restore_common(dev); if (drv && drv->restore)
if (!ret && drv && drv->restore)
ret = drv->restore(&vp_dev->vdev); ret = drv->restore(&vp_dev->vdev);
/* Finally, tell the device we're all set */ /* Finally, tell the device we're all set */
...@@ -821,12 +768,7 @@ static int virtio_pci_restore(struct device *dev) ...@@ -821,12 +768,7 @@ static int virtio_pci_restore(struct device *dev)
} }
static const struct dev_pm_ops virtio_pci_pm_ops = { static const struct dev_pm_ops virtio_pci_pm_ops = {
.suspend = virtio_pci_suspend, SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
.resume = virtio_pci_resume,
.freeze = virtio_pci_freeze,
.thaw = virtio_pci_thaw,
.restore = virtio_pci_restore,
.poweroff = virtio_pci_suspend,
}; };
#endif #endif
......
...@@ -96,7 +96,6 @@ struct virtio_driver { ...@@ -96,7 +96,6 @@ struct virtio_driver {
void (*config_changed)(struct virtio_device *dev); void (*config_changed)(struct virtio_device *dev);
#ifdef CONFIG_PM #ifdef CONFIG_PM
int (*freeze)(struct virtio_device *dev); int (*freeze)(struct virtio_device *dev);
int (*thaw)(struct virtio_device *dev);
int (*restore)(struct virtio_device *dev); int (*restore)(struct virtio_device *dev);
#endif #endif
}; };
......
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