Commit 3a32497f authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Provide full mb() around clflush

clflush is an unserialised instruction and the IA manual strongly advises
you to serialise it with a mb. To be cautious, apply one before and one
after, so that it is serialised with both writes and reads without
worrying too much about the required direction.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180706174926.4712-1-chris@chris-wilson.co.uk
parent 8b293eb5
...@@ -42,11 +42,21 @@ static int cpu_set(struct drm_i915_gem_object *obj, ...@@ -42,11 +42,21 @@ static int cpu_set(struct drm_i915_gem_object *obj,
page = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT); page = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT);
map = kmap_atomic(page); map = kmap_atomic(page);
if (needs_clflush & CLFLUSH_BEFORE)
if (needs_clflush & CLFLUSH_BEFORE) {
mb();
clflush(map+offset_in_page(offset) / sizeof(*map)); clflush(map+offset_in_page(offset) / sizeof(*map));
mb();
}
map[offset_in_page(offset) / sizeof(*map)] = v; map[offset_in_page(offset) / sizeof(*map)] = v;
if (needs_clflush & CLFLUSH_AFTER)
if (needs_clflush & CLFLUSH_AFTER) {
mb();
clflush(map+offset_in_page(offset) / sizeof(*map)); clflush(map+offset_in_page(offset) / sizeof(*map));
mb();
}
kunmap_atomic(map); kunmap_atomic(map);
i915_gem_obj_finish_shmem_access(obj); i915_gem_obj_finish_shmem_access(obj);
...@@ -68,8 +78,13 @@ static int cpu_get(struct drm_i915_gem_object *obj, ...@@ -68,8 +78,13 @@ static int cpu_get(struct drm_i915_gem_object *obj,
page = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT); page = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT);
map = kmap_atomic(page); map = kmap_atomic(page);
if (needs_clflush & CLFLUSH_BEFORE)
if (needs_clflush & CLFLUSH_BEFORE) {
mb();
clflush(map+offset_in_page(offset) / sizeof(*map)); clflush(map+offset_in_page(offset) / sizeof(*map));
mb();
}
*v = map[offset_in_page(offset) / sizeof(*map)]; *v = map[offset_in_page(offset) / sizeof(*map)];
kunmap_atomic(map); kunmap_atomic(map);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment