From: Fam Zheng <famz@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
"Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org,
Paolo Bonzini <pbonzini@redhat.com>,
Jason Wang <jasowang@redhat.com>
Subject: [PATCH] virtio: Remove virtio device during shutdown
Date: Wed, 11 Mar 2015 16:09:17 +0800 [thread overview]
Message-ID: <1426061357-4440-1-git-send-email-famz@redhat.com> (raw)
Currently shutdown is nop for virtio devices, but the core code could
remove things behind us such as MSI-X handler etc. For example in the
case of virtio-scsi-pci, the device may still try to send interupts,
which will be on IRQ lines seeing MSI-X disabled. Those interrupts will
be unhandled, and may cause flood.
Remove the device in "shutdown" callback to allow device drivers clean
up things.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
drivers/virtio/virtio.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 5ce2aa4..12f1f1e 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -269,6 +269,19 @@ static int virtio_dev_remove(struct device *_d)
return 0;
}
+static void virtio_dev_shutdown(struct device *_d)
+{
+ struct virtio_device *dev = dev_to_virtio(_d);
+ struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
+
+ virtio_config_disable(dev);
+
+ drv->remove(dev);
+
+ /* Driver should have reset device. */
+ WARN_ON_ONCE(dev->config->get_status(dev));
+}
+
static struct bus_type virtio_bus = {
.name = "virtio",
.match = virtio_dev_match,
@@ -276,6 +289,7 @@ static struct bus_type virtio_bus = {
.uevent = virtio_uevent,
.probe = virtio_dev_probe,
.remove = virtio_dev_remove,
+ .shutdown = virtio_dev_shutdown,
};
bool virtio_device_is_legacy_only(struct virtio_device_id id)
--
1.9.3
next reply other threads:[~2015-03-11 8:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 8:09 Fam Zheng [this message]
2015-03-11 9:06 ` Michael S. Tsirkin
2015-03-11 10:11 ` Fam Zheng
2015-03-12 16:22 ` Michael S. Tsirkin
2015-03-12 16:39 ` Paolo Bonzini
2015-03-12 23:35 ` Fam Zheng
2015-03-13 14:17 ` Michael S. Tsirkin
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=1426061357-4440-1-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rusty@rustcorp.com.au \
--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
all inboxes | Powered by JetHome®