Skip to content

Commit b7ffff4

Browse files
committed
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
2 parents 8bb1f22 + f878d0b commit b7ffff4

File tree

3 files changed

+8
-81
lines changed

3 files changed

+8
-81
lines changed

drivers/virtio/virtio_balloon.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,21 +398,8 @@ static int restore_common(struct virtio_device *vdev)
398398
return 0;
399399
}
400400

401-
static int virtballoon_thaw(struct virtio_device *vdev)
402-
{
403-
return restore_common(vdev);
404-
}
405-
406401
static int virtballoon_restore(struct virtio_device *vdev)
407402
{
408-
struct virtio_balloon *vb = vdev->priv;
409-
410-
/*
411-
* If a request wasn't complete at the time of freezing, this
412-
* could have been set.
413-
*/
414-
vb->need_stats_update = 0;
415-
416403
return restore_common(vdev);
417404
}
418405
#endif
@@ -434,7 +421,6 @@ static struct virtio_driver virtio_balloon_driver = {
434421
#ifdef CONFIG_PM
435422
.freeze = virtballoon_freeze,
436423
.restore = virtballoon_restore,
437-
.thaw = virtballoon_thaw,
438424
#endif
439425
};
440426

drivers/virtio/virtio_pci.c

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -720,24 +720,6 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
720720
}
721721

722722
#ifdef CONFIG_PM
723-
static int virtio_pci_suspend(struct device *dev)
724-
{
725-
struct pci_dev *pci_dev = to_pci_dev(dev);
726-
727-
pci_save_state(pci_dev);
728-
pci_set_power_state(pci_dev, PCI_D3hot);
729-
return 0;
730-
}
731-
732-
static int virtio_pci_resume(struct device *dev)
733-
{
734-
struct pci_dev *pci_dev = to_pci_dev(dev);
735-
736-
pci_restore_state(pci_dev);
737-
pci_set_power_state(pci_dev, PCI_D0);
738-
return 0;
739-
}
740-
741723
static int virtio_pci_freeze(struct device *dev)
742724
{
743725
struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -758,59 +740,24 @@ static int virtio_pci_freeze(struct device *dev)
758740
return ret;
759741
}
760742

761-
static int restore_common(struct device *dev)
762-
{
763-
struct pci_dev *pci_dev = to_pci_dev(dev);
764-
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
765-
int ret;
766-
767-
ret = pci_enable_device(pci_dev);
768-
if (ret)
769-
return ret;
770-
pci_set_master(pci_dev);
771-
vp_finalize_features(&vp_dev->vdev);
772-
773-
return ret;
774-
}
775-
776-
static int virtio_pci_thaw(struct device *dev)
743+
static int virtio_pci_restore(struct device *dev)
777744
{
778745
struct pci_dev *pci_dev = to_pci_dev(dev);
779746
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
780747
struct virtio_driver *drv;
781748
int ret;
782749

783-
ret = restore_common(dev);
784-
if (ret)
785-
return ret;
786-
787750
drv = container_of(vp_dev->vdev.dev.driver,
788751
struct virtio_driver, driver);
789752

790-
if (drv && drv->thaw)
791-
ret = drv->thaw(&vp_dev->vdev);
792-
else if (drv && drv->restore)
793-
ret = drv->restore(&vp_dev->vdev);
794-
795-
/* Finally, tell the device we're all set */
796-
if (!ret)
797-
vp_set_status(&vp_dev->vdev, vp_dev->saved_status);
798-
799-
return ret;
800-
}
801-
802-
static int virtio_pci_restore(struct device *dev)
803-
{
804-
struct pci_dev *pci_dev = to_pci_dev(dev);
805-
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
806-
struct virtio_driver *drv;
807-
int ret;
753+
ret = pci_enable_device(pci_dev);
754+
if (ret)
755+
return ret;
808756

809-
drv = container_of(vp_dev->vdev.dev.driver,
810-
struct virtio_driver, driver);
757+
pci_set_master(pci_dev);
758+
vp_finalize_features(&vp_dev->vdev);
811759

812-
ret = restore_common(dev);
813-
if (!ret && drv && drv->restore)
760+
if (drv && drv->restore)
814761
ret = drv->restore(&vp_dev->vdev);
815762

816763
/* Finally, tell the device we're all set */
@@ -821,12 +768,7 @@ static int virtio_pci_restore(struct device *dev)
821768
}
822769

823770
static const struct dev_pm_ops virtio_pci_pm_ops = {
824-
.suspend = virtio_pci_suspend,
825-
.resume = virtio_pci_resume,
826-
.freeze = virtio_pci_freeze,
827-
.thaw = virtio_pci_thaw,
828-
.restore = virtio_pci_restore,
829-
.poweroff = virtio_pci_suspend,
771+
SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
830772
};
831773
#endif
832774

include/linux/virtio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ struct virtio_driver {
9696
void (*config_changed)(struct virtio_device *dev);
9797
#ifdef CONFIG_PM
9898
int (*freeze)(struct virtio_device *dev);
99-
int (*thaw)(struct virtio_device *dev);
10099
int (*restore)(struct virtio_device *dev);
101100
#endif
102101
};

0 commit comments

Comments
 (0)