Skip to content

Commit

Permalink
drm/i915: Rework clflush to work correctly without obj->mm.lock.
Browse files Browse the repository at this point in the history
Pin in the caller, not in the work itself. This should also
work better for dma-fence annotations.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Thomas Hellström <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
mlankhorst authored and danvet committed Mar 24, 2021
1 parent fe83ce1 commit d4fa4e7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/gpu/drm/i915/gem/i915_gem_clflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ static void __do_clflush(struct drm_i915_gem_object *obj)
static int clflush_work(struct dma_fence_work *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);
if (err)
return err;

__do_clflush(obj);
i915_gem_object_unpin_pages(obj);
__do_clflush(clflush->obj);

return 0;
}
Expand All @@ -44,6 +37,7 @@ static void clflush_release(struct dma_fence_work *base)
{
struct clflush *clflush = container_of(base, typeof(*clflush), base);

i915_gem_object_unpin_pages(clflush->obj);
i915_gem_object_put(clflush->obj);
}

Expand All @@ -63,6 +57,11 @@ static struct clflush *clflush_work_create(struct drm_i915_gem_object *obj)
if (!clflush)
return NULL;

if (__i915_gem_object_get_pages(obj) < 0) {
kfree(clflush);
return NULL;
}

dma_fence_work_init(&clflush->base, &clflush_ops);
clflush->obj = i915_gem_object_get(obj); /* obj <-> clflush cycle */

Expand Down

0 comments on commit d4fa4e7

Please sign in to comment.