aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/virtio/virtio_pci.c')
-rw-r--r--drivers/virtio/virtio_pci.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 3d1463c6b120..d34ebfa604f3 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -57,9 +57,6 @@ struct virtio_pci_device
57 /* Vectors allocated, excluding per-vq vectors if any */ 57 /* Vectors allocated, excluding per-vq vectors if any */
58 unsigned msix_used_vectors; 58 unsigned msix_used_vectors;
59 59
60 /* Status saved during hibernate/restore */
61 u8 saved_status;
62
63 /* Whether we have vector per vq */ 60 /* Whether we have vector per vq */
64 bool per_vq_vectors; 61 bool per_vq_vectors;
65}; 62};
@@ -211,12 +208,8 @@ static bool vp_notify(struct virtqueue *vq)
211static irqreturn_t vp_config_changed(int irq, void *opaque) 208static irqreturn_t vp_config_changed(int irq, void *opaque)
212{ 209{
213 struct virtio_pci_device *vp_dev = opaque; 210 struct virtio_pci_device *vp_dev = opaque;
214 struct virtio_driver *drv;
215 drv = container_of(vp_dev->vdev.dev.driver,
216 struct virtio_driver, driver);
217 211
218 if (drv && drv->config_changed) 212 virtio_config_changed(&vp_dev->vdev);
219 drv->config_changed(&vp_dev->vdev);
220 return IRQ_HANDLED; 213 return IRQ_HANDLED;
221} 214}
222 215
@@ -768,16 +761,9 @@ static int virtio_pci_freeze(struct device *dev)
768{ 761{
769 struct pci_dev *pci_dev = to_pci_dev(dev); 762 struct pci_dev *pci_dev = to_pci_dev(dev);
770 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 763 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
771 struct virtio_driver *drv;
772 int ret; 764 int ret;
773 765
774 drv = container_of(vp_dev->vdev.dev.driver, 766 ret = virtio_device_freeze(&vp_dev->vdev);
775 struct virtio_driver, driver);
776
777 ret = 0;
778 vp_dev->saved_status = vp_get_status(&vp_dev->vdev);
779 if (drv && drv->freeze)
780 ret = drv->freeze(&vp_dev->vdev);
781 767
782 if (!ret) 768 if (!ret)
783 pci_disable_device(pci_dev); 769 pci_disable_device(pci_dev);
@@ -788,27 +774,14 @@ static int virtio_pci_restore(struct device *dev)
788{ 774{
789 struct pci_dev *pci_dev = to_pci_dev(dev); 775 struct pci_dev *pci_dev = to_pci_dev(dev);
790 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 776 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
791 struct virtio_driver *drv;
792 int ret; 777 int ret;
793 778
794 drv = container_of(vp_dev->vdev.dev.driver,
795 struct virtio_driver, driver);
796
797 ret = pci_enable_device(pci_dev); 779 ret = pci_enable_device(pci_dev);
798 if (ret) 780 if (ret)
799 return ret; 781 return ret;
800 782
801 pci_set_master(pci_dev); 783 pci_set_master(pci_dev);
802 vp_finalize_features(&vp_dev->vdev); 784 return virtio_device_restore(&vp_dev->vdev);
803
804 if (drv && drv->restore)
805 ret = drv->restore(&vp_dev->vdev);
806
807 /* Finally, tell the device we're all set */
808 if (!ret)
809 vp_set_status(&vp_dev->vdev, vp_dev->saved_status);
810
811 return ret;
812} 785}
813 786
814static const struct dev_pm_ops virtio_pci_pm_ops = { 787static const struct dev_pm_ops virtio_pci_pm_ops = {