From: jsg Date: Fri, 31 Mar 2023 01:39:50 +0000 (+0000) Subject: drm/i915/fbdev: lock the fbdev obj before vma pin X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7c68c5c82374187b471be9c6d2f2c58b2d130aea;p=openbsd drm/i915/fbdev: lock the fbdev obj before vma pin From Tejas Upadhyay 9595d71b2a274fe365240b53ce5d03c071c3e6e0 in linux-6.1.y/6.1.22 ed00eba03474adbf525ff03d69705d8c78b76456 in mainline linux --- diff --git a/sys/dev/pci/drm/i915/display/intel_fbdev.c b/sys/dev/pci/drm/i915/display/intel_fbdev.c index de32600fd7a..e9941533afc 100644 --- a/sys/dev/pci/drm/i915/display/intel_fbdev.c +++ b/sys/dev/pci/drm/i915/display/intel_fbdev.c @@ -212,6 +212,7 @@ static int intelfb_create(struct drm_fb_helper *helper, bool prealloc = false; void __iomem *vaddr; struct drm_i915_gem_object *obj; + struct i915_gem_ww_ctx ww; int ret; mutex_lock(&ifbdev->hpd_lock); @@ -293,13 +294,24 @@ static int intelfb_create(struct drm_fb_helper *helper, info->fix.smem_len = vma->size; } - vaddr = i915_vma_pin_iomap(vma); - if (IS_ERR(vaddr)) { - drm_err(&dev_priv->drm, - "Failed to remap framebuffer into virtual memory (%pe)\n", vaddr); - ret = PTR_ERR(vaddr); - goto out_unpin; + for_i915_gem_ww(&ww, ret, false) { + ret = i915_gem_object_lock(vma->obj, &ww); + + if (ret) + continue; + + vaddr = i915_vma_pin_iomap(vma); + if (IS_ERR(vaddr)) { + drm_err(&dev_priv->drm, + "Failed to remap framebuffer into virtual memory (%pe)\n", vaddr); + ret = PTR_ERR(vaddr); + continue; + } } + + if (ret) + goto out_unpin; + info->screen_base = vaddr; info->screen_size = vma->size;