diff options
author | David Riley <davidriley@chromium.org> | 2019-06-10 23:18:10 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-06-11 09:03:32 +0200 |
commit | 9ff3a5c88e1f1ab17a31402b96d45abe14aab9d7 (patch) | |
tree | 5f224e0d93cd493283881dd7ee567c86a20ee202 /drivers/gpu/drm/virtio | |
parent | drm/amd: drop use of drmP.h in remaining files (diff) | |
download | linux-9ff3a5c88e1f1ab17a31402b96d45abe14aab9d7.tar.xz linux-9ff3a5c88e1f1ab17a31402b96d45abe14aab9d7.zip |
drm/virtio: Add memory barriers for capset cache.
After data is copied to the cache entry, atomic_set is used indicate
that the data is the entry is valid without appropriate memory barriers.
Similarly the read side was missing the corresponding memory barriers.
Signed-off-by: David Riley <davidriley@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20190610211810.253227-5-davidriley@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/virtio')
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_ioctl.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_vq.c | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 9f43b160e1bb..c0ba1ead740f 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -540,6 +540,9 @@ copy_exit: if (!ret) return -EBUSY; + /* is_valid check must proceed before copy of the cache entry. */ + smp_rmb(); + ptr = cache_ent->caps_cache; if (copy_to_user(u64_to_user_ptr(args->addr), ptr, size)) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5de38b2ee9ac..6c1a90717535 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -593,6 +593,8 @@ static void virtio_gpu_cmd_capset_cb(struct virtio_gpu_device *vgdev, cache_ent->id == le32_to_cpu(cmd->capset_id)) { memcpy(cache_ent->caps_cache, resp->capset_data, cache_ent->size); + /* Copy must occur before is_valid is signalled. */ + smp_wmb(); atomic_set(&cache_ent->is_valid, 1); break; } |