Skip to content

Commit d4fa4e7

Browse files
mlankhorstdanvet
authored andcommitted
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: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20210323155059.628690-22-maarten.lankhorst@linux.intel.com
1 parent fe83ce1 commit d4fa4e7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/gpu/drm/i915/gem/i915_gem_clflush.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,8 @@ static void __do_clflush(struct drm_i915_gem_object *obj)
2727
static int clflush_work(struct dma_fence_work *base)
2828
{
2929
struct clflush *clflush = container_of(base, typeof(*clflush), base);
30-
struct drm_i915_gem_object *obj = clflush->obj;
31-
int err;
3230

33-
err = i915_gem_object_pin_pages(obj);
34-
if (err)
35-
return err;
36-
37-
__do_clflush(obj);
38-
i915_gem_object_unpin_pages(obj);
31+
__do_clflush(clflush->obj);
3932

4033
return 0;
4134
}
@@ -44,6 +37,7 @@ static void clflush_release(struct dma_fence_work *base)
4437
{
4538
struct clflush *clflush = container_of(base, typeof(*clflush), base);
4639

40+
i915_gem_object_unpin_pages(clflush->obj);
4741
i915_gem_object_put(clflush->obj);
4842
}
4943

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

60+
if (__i915_gem_object_get_pages(obj) < 0) {
61+
kfree(clflush);
62+
return NULL;
63+
}
64+
6665
dma_fence_work_init(&clflush->base, &clflush_ops);
6766
clflush->obj = i915_gem_object_get(obj); /* obj <-> clflush cycle */
6867

0 commit comments

Comments
 (0)