aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rpmsg/virtio_rpmsg_bus.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2015-03-12 11:54:41 +1030
committerRusty Russell <rusty@rustcorp.com.au>2015-03-13 15:55:42 +1030
commit71e4b8bf0482fc7d70e9d4c10b13c207a285d58a (patch)
tree435db3fcf8c9e28fdc331b64fb0f4effb80b3138 /drivers/rpmsg/virtio_rpmsg_bus.c
parent9p/trans_virtio: fix hot-unplug (diff)
downloadlinux-dev-71e4b8bf0482fc7d70e9d4c10b13c207a285d58a.tar.xz
linux-dev-71e4b8bf0482fc7d70e9d4c10b13c207a285d58a.zip
virtio_rpmsg: set DRIVER_OK before using device
virtio spec requires that all drivers set DRIVER_OK before using devices. While rpmsg isn't yet included in the virtio 1 spec, previous spec versions also required this. virtio rpmsg violates this rule: is calls kick before setting DRIVER_OK. The fix isn't trivial since simply calling virtio_device_ready earlier would mean we might get an interrupt in parallel with adding buffers. Instead, split kick out to prepare+notify calls. prepare before virtio_device_ready - when we know we won't get interrupts. notify right afterwards. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/rpmsg/virtio_rpmsg_bus.c')
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 92f6af6da699..73354ee27877 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -951,6 +951,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
void *bufs_va;
int err = 0, i;
size_t total_buf_space;
+ bool notify;
vrp = kzalloc(sizeof(*vrp), GFP_KERNEL);
if (!vrp)
@@ -1030,8 +1031,22 @@ static int rpmsg_probe(struct virtio_device *vdev)
}
}
+ /*
+ * Prepare to kick but don't notify yet - we can't do this before
+ * device is ready.
+ */
+ notify = virtqueue_kick_prepare(vrp->rvq);
+
+ /* From this point on, we can notify and get callbacks. */
+ virtio_device_ready(vdev);
+
/* tell the remote processor it can start sending messages */
- virtqueue_kick(vrp->rvq);
+ /*
+ * this might be concurrent with callbacks, but we are only
+ * doing notify, not a full kick here, so that's ok.
+ */
+ if (notify)
+ virtqueue_notify(vrp->rvq);
dev_info(&vdev->dev, "rpmsg host is online\n");