Commit d4fa4e70 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Daniel Vetter

drm/i915: Rework clflush to work correctly without obj->mm.lock.

Pin in the caller, not in the work itself. This should also
work better for dma-fence annotations.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210323155059.628690-22-maarten.lankhorst@linux.intel.com
parent fe83ce1e
...@@ -27,15 +27,8 @@ static void __do_clflush(struct drm_i915_gem_object *obj) ...@@ -27,15 +27,8 @@ static void __do_clflush(struct drm_i915_gem_object *obj)
static int clflush_work(struct dma_fence_work *base) static int clflush_work(struct dma_fence_work *base)
{ {
struct clflush *clflush = container_of(base, typeof(*clflush), base); struct clflush *clflush = container_of(base, typeof(*clflush), base);
struct drm_i915_gem_object *obj = clflush->obj;
int err;
err = i915_gem_object_pin_pages(obj); __do_clflush(clflush->obj);
if (err)
return err;
__do_clflush(obj);
i915_gem_object_unpin_pages(obj);
return 0; return 0;
} }
...@@ -44,6 +37,7 @@ static void clflush_release(struct dma_fence_work *base) ...@@ -44,6 +37,7 @@ static void clflush_release(struct dma_fence_work *base)
{ {
struct clflush *clflush = container_of(base, typeof(*clflush), base); struct clflush *clflush = container_of(base, typeof(*clflush), base);
i915_gem_object_unpin_pages(clflush->obj);
i915_gem_object_put(clflush->obj); i915_gem_object_put(clflush->obj);
} }
...@@ -63,6 +57,11 @@ static struct clflush *clflush_work_create(struct drm_i915_gem_object *obj) ...@@ -63,6 +57,11 @@ static struct clflush *clflush_work_create(struct drm_i915_gem_object *obj)
if (!clflush) if (!clflush)
return NULL; return NULL;
if (__i915_gem_object_get_pages(obj) < 0) {
kfree(clflush);
return NULL;
}
dma_fence_work_init(&clflush->base, &clflush_ops); dma_fence_work_init(&clflush->base, &clflush_ops);
clflush->obj = i915_gem_object_get(obj); /* obj <-> clflush cycle */ clflush->obj = i915_gem_object_get(obj); /* obj <-> clflush cycle */
......
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