Skip to content

Commit 860afd8

Browse files
author
Jocelyn Falempe
committed
drm/i915/display: handle migration for dpt
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041690 Upstream Status: git://anongit.freedesktop.org/drm/drm commit 5769f64 Author: Matthew Auld <matthew.auld@intel.com> AuthorDate: Tue Oct 4 14:19:13 2022 +0100 Commit: Matthew Auld <matthew.auld@intel.com> CommitDate: Wed Oct 5 09:02:38 2022 +0100 On platforms like DG2, it looks like the dpt path here is missing the migrate-to-lmem step on discrete platforms. v2: - Move the vma_pin() under the for_i915_gem_ww(), otherwise the object can be moved after dropping the lock and then doing the pin. Fixes: 33e7a97 ("drm/i915/xelpd: First stab at DPT support") Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Jianshui Yu <jianshui.yu@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Nirmoy Das <nirmoy.das@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20221004131916.233474-2-matthew.auld@intel.com Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
1 parent 31e59f3 commit 860afd8

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

drivers/gpu/drm/i915/display/intel_fb_pin.c

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,55 @@ intel_pin_fb_obj_dpt(struct drm_framebuffer *fb,
2626
struct drm_device *dev = fb->dev;
2727
struct drm_i915_private *dev_priv = to_i915(dev);
2828
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
29+
struct i915_gem_ww_ctx ww;
2930
struct i915_vma *vma;
3031
u32 alignment;
3132
int ret;
3233

34+
/*
35+
* We are not syncing against the binding (and potential migrations)
36+
* below, so this vm must never be async.
37+
*/
38+
GEM_WARN_ON(vm->bind_async_flags);
39+
3340
if (WARN_ON(!i915_gem_object_is_framebuffer(obj)))
3441
return ERR_PTR(-EINVAL);
3542

3643
alignment = 4096 * 512;
3744

3845
atomic_inc(&dev_priv->gpu_error.pending_fb_pin);
3946

40-
ret = i915_gem_object_lock_interruptible(obj, NULL);
41-
if (!ret) {
47+
for_i915_gem_ww(&ww, ret, true) {
48+
ret = i915_gem_object_lock(obj, &ww);
49+
if (ret)
50+
continue;
51+
52+
if (HAS_LMEM(dev_priv)) {
53+
ret = i915_gem_object_migrate(obj, &ww, INTEL_REGION_LMEM_0);
54+
if (ret)
55+
continue;
56+
}
57+
4258
ret = i915_gem_object_set_cache_level(obj, I915_CACHE_NONE);
43-
i915_gem_object_unlock(obj);
44-
}
45-
if (ret) {
46-
vma = ERR_PTR(ret);
47-
goto err;
48-
}
59+
if (ret)
60+
continue;
4961

50-
vma = i915_vma_instance(obj, vm, view);
51-
if (IS_ERR(vma))
52-
goto err;
62+
vma = i915_vma_instance(obj, vm, view);
63+
if (IS_ERR(vma)) {
64+
ret = PTR_ERR(vma);
65+
continue;
66+
}
5367

54-
if (i915_vma_misplaced(vma, 0, alignment, 0)) {
55-
ret = i915_vma_unbind_unlocked(vma);
56-
if (ret) {
57-
vma = ERR_PTR(ret);
58-
goto err;
68+
if (i915_vma_misplaced(vma, 0, alignment, 0)) {
69+
ret = i915_vma_unbind(vma);
70+
if (ret)
71+
continue;
5972
}
60-
}
6173

62-
ret = i915_vma_pin(vma, 0, alignment, PIN_GLOBAL);
74+
ret = i915_vma_pin_ww(vma, &ww, 0, alignment, PIN_GLOBAL);
75+
if (ret)
76+
continue;
77+
}
6378
if (ret) {
6479
vma = ERR_PTR(ret);
6580
goto err;

0 commit comments

Comments
 (0)