From: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
To: mst@redhat.com, virtualization@lists.linux-foundation.org
Cc: borntraeger@de.ibm.com
Subject: [PATCH v4 RFC 3/3] virtio_ccw: set 'device_lost' on CIO_GONE notification
Date: Fri, 13 Dec 2013 14:13:30 +0100 [thread overview]
Message-ID: <1386940410-44943-4-git-send-email-graalfs@linux.vnet.ibm.com> (raw)
In-Reply-To: <1386940410-44943-1-git-send-email-graalfs@linux.vnet.ibm.com>
When a CIO_GONE notification is received the device_lost flag is
set in the virtio_device. This flag should be tested by a backend
in order to be able to prevent triggering final I/O to a device that
is not reachable any more.
The notification is ignored in case remove or set_offline is already
running. The virtio_device pointer might point to freed memory in that
case.
Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/s390/kvm/virtio_ccw.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index b939a7f..a468b9c 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/io.h>
#include <linux/kvm_para.h>
+#include <linux/notifier.h>
#include <asm/setup.h>
#include <asm/irq.h>
#include <asm/cio.h>
@@ -1085,8 +1086,26 @@ out_free:
static int virtio_ccw_cio_notify(struct ccw_device *cdev, int event)
{
- /* TODO: Check whether we need special handling here. */
- return 0;
+ int rc;
+ struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
+
+ /*
+ * Make sure vcdev is set
+ * i.e. set_offline/remove callback not already running
+ */
+ if (!vcdev)
+ return NOTIFY_DONE;
+
+ switch (event) {
+ case CIO_GONE:
+ atomic_inc(&vcdev->vdev.device_lost);
+ rc = NOTIFY_DONE;
+ break;
+ default:
+ rc = NOTIFY_DONE;
+ break;
+ }
+ return rc;
}
static struct ccw_device_id virtio_ids[] = {
--
1.8.3.1
next prev parent reply other threads:[~2013-12-13 13:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 13:13 [PATCH v4 RFC 0/3] virtio: add 'device_lost' to virtio_device Heinz Graalfs
2013-12-13 13:13 ` [PATCH v4 RFC 1/3] virtio_ccw: fix vcdev pointer handling issues Heinz Graalfs
2013-12-13 13:13 ` [PATCH v4 RFC 2/3] virtio: introduce 'device_lost' flag in virtio_device Heinz Graalfs
2013-12-13 13:13 ` Heinz Graalfs [this message]
2013-12-17 3:42 ` [PATCH v4 RFC 0/3] virtio: add 'device_lost' to virtio_device Rusty Russell
2013-12-17 14:01 ` Heinz Graalfs
2013-12-19 0:19 ` Rusty Russell
2013-12-23 8:39 ` Heinz Graalfs
2014-01-13 12:12 ` Fwd: " Heinz Graalfs
2014-01-15 2:18 ` Rusty Russell
2014-01-23 4:51 ` Rusty Russell
2014-01-28 16:12 ` Heinz Graalfs
2014-01-29 6:31 ` Rusty Russell
2014-02-18 10:58 ` Heinz Graalfs
2014-02-20 8:03 ` Rusty Russell
2014-02-20 15:39 ` Heinz Graalfs
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=1386940410-44943-4-git-send-email-graalfs@linux.vnet.ibm.com \
--to=graalfs@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.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).