Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+9 -82
-14
drivers/virtio/virtio_balloon.c
··· 398 398 return 0; 399 399 } 400 400 401 - static int virtballoon_thaw(struct virtio_device *vdev) 402 - { 403 - return restore_common(vdev); 404 - } 405 - 406 401 static int virtballoon_restore(struct virtio_device *vdev) 407 402 { 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 - 416 403 return restore_common(vdev); 417 404 } 418 405 #endif ··· 421 434 #ifdef CONFIG_PM 422 435 .freeze = virtballoon_freeze, 423 436 .restore = virtballoon_restore, 424 - .thaw = virtballoon_thaw, 425 437 #endif 426 438 }; 427 439
+9 -67
drivers/virtio/virtio_pci.c
··· 720 720 } 721 721 722 722 #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 - 741 723 static int virtio_pci_freeze(struct device *dev) 742 724 { 743 725 struct pci_dev *pci_dev = to_pci_dev(dev); ··· 740 758 return ret; 741 759 } 742 760 743 - static int restore_common(struct device *dev) 744 - { 745 - struct pci_dev *pci_dev = to_pci_dev(dev); 746 - struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 747 - int ret; 748 - 749 - ret = pci_enable_device(pci_dev); 750 - if (ret) 751 - return ret; 752 - pci_set_master(pci_dev); 753 - vp_finalize_features(&vp_dev->vdev); 754 - 755 - return ret; 756 - } 757 - 758 - static int virtio_pci_thaw(struct device *dev) 759 - { 760 - struct pci_dev *pci_dev = to_pci_dev(dev); 761 - struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 762 - struct virtio_driver *drv; 763 - int ret; 764 - 765 - ret = restore_common(dev); 766 - if (ret) 767 - return ret; 768 - 769 - drv = container_of(vp_dev->vdev.dev.driver, 770 - struct virtio_driver, driver); 771 - 772 - if (drv && drv->thaw) 773 - ret = drv->thaw(&vp_dev->vdev); 774 - else if (drv && drv->restore) 775 - ret = drv->restore(&vp_dev->vdev); 776 - 777 - /* Finally, tell the device we're all set */ 778 - if (!ret) 779 - vp_set_status(&vp_dev->vdev, vp_dev->saved_status); 780 - 781 - return ret; 782 - } 783 - 784 761 static int virtio_pci_restore(struct device *dev) 785 762 { 786 763 struct pci_dev *pci_dev = to_pci_dev(dev); ··· 750 809 drv = container_of(vp_dev->vdev.dev.driver, 751 810 struct virtio_driver, driver); 752 811 753 - ret = restore_common(dev); 754 - if (!ret && drv && drv->restore) 812 + ret = pci_enable_device(pci_dev); 813 + if (ret) 814 + return ret; 815 + 816 + pci_set_master(pci_dev); 817 + vp_finalize_features(&vp_dev->vdev); 818 + 819 + if (drv && drv->restore) 755 820 ret = drv->restore(&vp_dev->vdev); 756 821 757 822 /* Finally, tell the device we're all set */ ··· 768 821 } 769 822 770 823 static const struct dev_pm_ops virtio_pci_pm_ops = { 771 - .suspend = virtio_pci_suspend, 772 - .resume = virtio_pci_resume, 773 - .freeze = virtio_pci_freeze, 774 - .thaw = virtio_pci_thaw, 775 - .restore = virtio_pci_restore, 776 - .poweroff = virtio_pci_suspend, 824 + SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) 777 825 }; 778 826 #endif 779 827
-1
include/linux/virtio.h
··· 96 96 void (*config_changed)(struct virtio_device *dev); 97 97 #ifdef CONFIG_PM 98 98 int (*freeze)(struct virtio_device *dev); 99 - int (*thaw)(struct virtio_device *dev); 100 99 int (*restore)(struct virtio_device *dev); 101 100 #endif 102 101 };