From: John Fastabend <john.fastabend@gmail.com>
To: jasowang@redhat.com, mst@redhat.com
Cc: john.r.fastabend@intel.com, netdev@vger.kernel.org,
john.fastabend@gmail.com, alexei.starovoitov@gmail.com,
daniel@iogearbox.net
Subject: [net PATCH v4 5/6] virtio: add pci_down/pci_up configuration
Date: Sun, 15 Jan 2017 16:01:19 -0800 [thread overview]
Message-ID: <20170116000119.28980.89712.stgit@john-Precision-Tower-5810> (raw)
In-Reply-To: <20170115235528.28980.85142.stgit@john-Precision-Tower-5810>
In virtio_net we need to do a full reset of the device to support
queue reconfiguration and also we can trigger this via ethtool
commands. So instead of open coding this in net driver push this
into generic code in virtio. This also avoid exporting a handful
of internal virtio routines.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
drivers/virtio/virtio.c | 14 ++++++++++++--
drivers/virtio/virtio_balloon.c | 4 ----
drivers/virtio/virtio_input.c | 4 ----
include/linux/virtio.h | 5 +----
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 7062bb0..681fcfb 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -339,7 +339,6 @@ void unregister_virtio_device(struct virtio_device *dev)
}
EXPORT_SYMBOL_GPL(unregister_virtio_device);
-#ifdef CONFIG_PM_SLEEP
int virtio_device_freeze(struct virtio_device *dev)
{
struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
@@ -400,7 +399,18 @@ int virtio_device_restore(struct virtio_device *dev)
return ret;
}
EXPORT_SYMBOL_GPL(virtio_device_restore);
-#endif
+
+int virtio_device_reset(struct virtio_device *dev)
+{
+ int err;
+
+ err = virtio_device_freeze(dev);
+ if (err)
+ return err;
+
+ return virtio_device_restore(dev);
+}
+EXPORT_SYMBOL_GPL(virtio_device_reset);
static int virtio_init(void)
{
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 181793f..4ca6220 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -620,7 +620,6 @@ static void virtballoon_remove(struct virtio_device *vdev)
kfree(vb);
}
-#ifdef CONFIG_PM_SLEEP
static int virtballoon_freeze(struct virtio_device *vdev)
{
struct virtio_balloon *vb = vdev->priv;
@@ -649,7 +648,6 @@ static int virtballoon_restore(struct virtio_device *vdev)
update_balloon_size(vb);
return 0;
}
-#endif
static unsigned int features[] = {
VIRTIO_BALLOON_F_MUST_TELL_HOST,
@@ -666,10 +664,8 @@ static int virtballoon_restore(struct virtio_device *vdev)
.probe = virtballoon_probe,
.remove = virtballoon_remove,
.config_changed = virtballoon_changed,
-#ifdef CONFIG_PM_SLEEP
.freeze = virtballoon_freeze,
.restore = virtballoon_restore,
-#endif
};
module_virtio_driver(virtio_balloon_driver);
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index 350a2a5..d3517e2 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -328,7 +328,6 @@ static void virtinput_remove(struct virtio_device *vdev)
kfree(vi);
}
-#ifdef CONFIG_PM_SLEEP
static int virtinput_freeze(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
@@ -356,7 +355,6 @@ static int virtinput_restore(struct virtio_device *vdev)
virtinput_fill_evt(vi);
return 0;
}
-#endif
static unsigned int features[] = {
/* none */
@@ -374,10 +372,8 @@ static int virtinput_restore(struct virtio_device *vdev)
.id_table = id_table,
.probe = virtinput_probe,
.remove = virtinput_remove,
-#ifdef CONFIG_PM_SLEEP
.freeze = virtinput_freeze,
.restore = virtinput_restore,
-#endif
};
module_virtio_driver(virtio_input_driver);
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index d5eb547..ff69f9a 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -138,10 +138,9 @@ static inline struct virtio_device *dev_to_virtio(struct device *_dev)
void virtio_break_device(struct virtio_device *dev);
void virtio_config_changed(struct virtio_device *dev);
-#ifdef CONFIG_PM_SLEEP
int virtio_device_freeze(struct virtio_device *dev);
int virtio_device_restore(struct virtio_device *dev);
-#endif
+int virtio_device_reset(struct virtio_device *dev);
/**
* virtio_driver - operations for a virtio I/O driver
@@ -167,10 +166,8 @@ struct virtio_driver {
void (*scan)(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
};
static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)
next prev parent reply other threads:[~2017-01-16 0:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 23:59 [net PATCH v4 0/6] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-15 23:59 ` [net PATCH v4 1/6] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-15 23:59 ` [net PATCH v4 2/6] virtio_net: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-01-17 16:57 ` David Miller
2017-01-17 19:03 ` John Fastabend
2017-01-16 0:00 ` [net PATCH v4 3/6] virtio_net: factor out xdp handler for readability John Fastabend
2017-01-16 0:00 ` [net PATCH v4 4/6] virtio_net: remove duplicate queue pair binding in XDP John Fastabend
2017-01-16 0:01 ` John Fastabend [this message]
2017-01-16 3:57 ` [net PATCH v4 5/6] virtio: add pci_down/pci_up configuration Jason Wang
2017-01-16 4:04 ` John Fastabend
2017-01-17 18:45 ` John Fastabend
2017-01-16 0:01 ` [net PATCH v4 6/6] virtio_net: XDP support for adjust_head John Fastabend
2017-01-16 5:48 ` Jason Wang
2017-01-16 5:51 ` [net PATCH v4 0/6] virtio_net XDP fixes and adjust_header support Jason Wang
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=20170116000119.28980.89712.stgit@john-Precision-Tower-5810 \
--to=john.fastabend@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jasowang@redhat.com \
--cc=john.r.fastabend@intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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