mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
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>
This commit is contained in:
parent
47b757fba2
commit
9ff3a5c88e
2 changed files with 5 additions and 0 deletions
|
@ -540,6 +540,9 @@ copy_exit:
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
|
/* is_valid check must proceed before copy of the cache entry. */
|
||||||
|
smp_rmb();
|
||||||
|
|
||||||
ptr = cache_ent->caps_cache;
|
ptr = cache_ent->caps_cache;
|
||||||
|
|
||||||
if (copy_to_user(u64_to_user_ptr(args->addr), ptr, size))
|
if (copy_to_user(u64_to_user_ptr(args->addr), ptr, size))
|
||||||
|
|
|
@ -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)) {
|
cache_ent->id == le32_to_cpu(cmd->capset_id)) {
|
||||||
memcpy(cache_ent->caps_cache, resp->capset_data,
|
memcpy(cache_ent->caps_cache, resp->capset_data,
|
||||||
cache_ent->size);
|
cache_ent->size);
|
||||||
|
/* Copy must occur before is_valid is signalled. */
|
||||||
|
smp_wmb();
|
||||||
atomic_set(&cache_ent->is_valid, 1);
|
atomic_set(&cache_ent->is_valid, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue