virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Virtualization List <virtualization@lists.linux-foundation.org>
Cc: Amit Shah <amit.shah@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [RFC PATCH 2/8] virtio-pci: add PM notification handlers for restore, freeze, thaw, poweroff
Date: Thu, 28 Jul 2011 20:05:07 +0530	[thread overview]
Message-ID: <0d7a31302c2467936f70c3aaecd47b8720891f4d.1311863438.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1311863438.git.amit.shah@redhat.com>
In-Reply-To: <cover.1311863438.git.amit.shah@redhat.com>

Handle restore and freeze notification from the PM core.  Expose these
to individual virtio drivers that can quiesce and resume vq operations.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 drivers/virtio/virtio_pci.c |   34 ++++++++++++++++++++++++++++++++++
 include/linux/virtio.h      |    4 ++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 3879c3e..579681f 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -704,9 +704,43 @@ static int virtio_pci_resume(struct device *dev)
 	return 0;
 }
 
+static int virtio_pci_freeze(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;
+
+	drv = container_of(vp_dev->vdev.dev.driver,
+			   struct virtio_driver, driver);
+
+	if (drv && drv->freeze)
+		return drv->freeze(&vp_dev->vdev);
+
+	return 0;
+}
+
+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;
+
+	drv = container_of(vp_dev->vdev.dev.driver,
+			   struct virtio_driver, driver);
+
+	if (drv && drv->restore)
+		return drv->restore(&vp_dev->vdev);
+
+	return 0;
+}
+
 static const struct dev_pm_ops virtio_pci_pm_ops = {
 	.suspend = virtio_pci_suspend,
 	.resume  = virtio_pci_resume,
+	.freeze  = virtio_pci_freeze,
+	.thaw    = virtio_pci_restore,
+	.restore = virtio_pci_restore,
+	.poweroff = virtio_pci_suspend,
 };
 #endif
 
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 7108857..9afb662 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -141,6 +141,10 @@ struct virtio_driver {
 	int (*probe)(struct virtio_device *dev);
 	void (*remove)(struct virtio_device *dev);
 	void (*config_changed)(struct virtio_device *dev);
+#ifdef CONFIG_PM
+	int (*freeze)(struct virtio_device *dev);
+	int (*restore)(struct virtio_device *dev);
+#endif
 };
 
 int register_virtio_driver(struct virtio_driver *drv);
-- 
1.7.6

  parent reply	other threads:[~2011-07-28 14:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 14:35 [RFC PATCH 0/8] virtio: Support for hibernation (S4) Amit Shah
2011-07-28 14:35 ` [RFC PATCH 1/8] virtio: pci: switch to new PM API Amit Shah
2011-07-28 14:35 ` Amit Shah [this message]
2011-07-28 14:35 ` [RFC PATCH 3/8] virtio-pci: save/restore config space across S4 Amit Shah
2011-07-29  4:07   ` Michael S. Tsirkin
2011-07-29  4:20     ` Amit Shah
2011-07-28 14:35 ` [RFC PATCH 4/8] virtio: console: Ignore port name update request if name already set Amit Shah
2011-07-29  4:19   ` Michael S. Tsirkin
2011-07-29  4:26     ` Amit Shah
2011-07-29  4:27       ` Michael S. Tsirkin
2011-07-28 14:35 ` [RFC PATCH 5/8] virtio: console: Use wait_event_freezable instead of _interruptible Amit Shah
2011-07-28 14:35 ` [RFC PATCH 6/8] virtio: console: Add freeze and restore handlers to support S4 Amit Shah
2011-07-28 14:35 ` [RFC PATCH 7/8] virtio: block: Add freeze, " Amit Shah
2011-07-28 14:35 ` [RFC PATCH 8/8] virtio: net: " Amit Shah
2011-07-29  4:13   ` Michael S. Tsirkin
2011-07-29  4:28     ` Amit Shah
2011-07-29  4:31       ` Michael S. Tsirkin
2011-07-29  5:08         ` Amit Shah
2011-08-10 10:53 ` [RFC PATCH 0/8] virtio: Support for hibernation (S4) Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d7a31302c2467936f70c3aaecd47b8720891f4d.1311863438.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).