summaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2015-03-12 12:56:43 +1030
committerRusty Russell <rusty@rustcorp.com.au>2015-03-13 15:55:43 +1030
commit87e7bf1450c9f6bd0927f63ebc0fe2d12e8bc83d (patch)
treea4292d97cd9671365d410c6c840d162c5a0da99b /drivers/virtio
parent71e4b8bf0482fc7d70e9d4c10b13c207a285d58a (diff)
downloadop-kernel-dev-87e7bf1450c9f6bd0927f63ebc0fe2d12e8bc83d.zip
op-kernel-dev-87e7bf1450c9f6bd0927f63ebc0fe2d12e8bc83d.tar.gz
virtio_mmio: generation support
virtio_mmio currently lacks generation support which makes multi-byte field access racy. Fix by getting the value at offset 0xfc for version 2 devices. Nothing we can do for version 1, so return generation id 0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_mmio.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index cad5698..9c877d2 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -174,6 +174,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
writeb(ptr[i], vm_dev->base + VIRTIO_MMIO_CONFIG + offset + i);
}
+static u32 vm_generation(struct virtio_device *vdev)
+{
+ struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+ if (vm_dev->version == 1)
+ return 0;
+ else
+ return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
+}
+
static u8 vm_get_status(struct virtio_device *vdev)
{
struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
@@ -440,6 +450,7 @@ static const char *vm_bus_name(struct virtio_device *vdev)
static const struct virtio_config_ops virtio_mmio_config_ops = {
.get = vm_get,
.set = vm_set,
+ .generation = vm_generation,
.get_status = vm_get_status,
.set_status = vm_set_status,
.reset = vm_reset,
OpenPOWER on IntegriCloud