]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915/display: Add intel_fb_bo_framebuffer_fini
authorJouni Högander <jouni.hogander@intel.com>
Thu, 7 Dec 2023 08:34:51 +0000 (10:34 +0200)
committerJouni Högander <jouni.hogander@intel.com>
Thu, 7 Dec 2023 15:31:02 +0000 (17:31 +0200)
Xe needs intel_fb_bo_framebuffer_fini for taking care of unpinning the fb
and taking reference.  In i915 this can be empty.

Also move intel_frontbuffer_get to be done after
intel_fb_bo_framebuffer_init to have reasonable sequences:

intel_fb_bo_framebuffer_init
intel_frontbuffer_get
...
intel_frontbuffer_put
intel_fb_bo_framebuffer_fini

v2: Empty function instead of define

Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231207083451.2184562-1-jouni.hogander@intel.com
drivers/gpu/drm/i915/display/intel_fb.c
drivers/gpu/drm/i915/display/intel_fb_bo.c
drivers/gpu/drm/i915/display/intel_fb_bo.h

index 32a7ee1c5b343cc9d4110f7a2dd03b3844f0e0d7..4f9d2e57a770ac3a5bba466139e682e544f3d0d8 100644 (file)
@@ -1889,6 +1889,8 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
 
        intel_frontbuffer_put(intel_fb->frontbuffer);
 
+       intel_fb_bo_framebuffer_fini(intel_fb_obj(fb));
+
        kfree(intel_fb);
 }
 
@@ -1989,13 +1991,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
        int ret = -EINVAL;
        int i;
 
-       intel_fb->frontbuffer = intel_frontbuffer_get(obj);
-       if (!intel_fb->frontbuffer)
-               return -ENOMEM;
-
        ret = intel_fb_bo_framebuffer_init(intel_fb, obj, mode_cmd);
        if (ret)
+               return ret;
+
+       intel_fb->frontbuffer = intel_frontbuffer_get(obj);
+       if (!intel_fb->frontbuffer) {
+               ret = -ENOMEM;
                goto err;
+       }
 
        ret = -EINVAL;
        if (!drm_any_plane_has_format(&dev_priv->drm,
@@ -2004,7 +2008,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                drm_dbg_kms(&dev_priv->drm,
                            "unsupported pixel format %p4cc / modifier 0x%llx\n",
                            &mode_cmd->pixel_format, mode_cmd->modifier[0]);
-               goto err;
+               goto err_frontbuffer_put;
        }
 
        max_stride = intel_fb_max_stride(dev_priv, mode_cmd->pixel_format,
@@ -2015,7 +2019,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                            mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ?
                            "tiled" : "linear",
                            mode_cmd->pitches[0], max_stride);
-               goto err;
+               goto err_frontbuffer_put;
        }
 
        /* FIXME need to adjust LINOFF/TILEOFF accordingly. */
@@ -2023,7 +2027,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                drm_dbg_kms(&dev_priv->drm,
                            "plane 0 offset (0x%08x) must be 0\n",
                            mode_cmd->offsets[0]);
-               goto err;
+               goto err_frontbuffer_put;
        }
 
        drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd);
@@ -2034,7 +2038,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
                        drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n",
                                    i);
-                       goto err;
+                       goto err_frontbuffer_put;
                }
 
                stride_alignment = intel_fb_stride_alignment(fb, i);
@@ -2042,7 +2046,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                        drm_dbg_kms(&dev_priv->drm,
                                    "plane %d pitch (%d) must be at least %u byte aligned\n",
                                    i, fb->pitches[i], stride_alignment);
-                       goto err;
+                       goto err_frontbuffer_put;
                }
 
                if (intel_fb_is_gen12_ccs_aux_plane(fb, i)) {
@@ -2053,7 +2057,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                                            "ccs aux plane %d pitch (%d) must be %d\n",
                                            i,
                                            fb->pitches[i], ccs_aux_stride);
-                               goto err;
+                               goto err_frontbuffer_put;
                        }
                }
 
@@ -2062,7 +2066,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
 
        ret = intel_fill_fb_info(dev_priv, intel_fb);
        if (ret)
-               goto err;
+               goto err_frontbuffer_put;
 
        if (intel_fb_uses_dpt(fb)) {
                struct i915_address_space *vm;
@@ -2071,7 +2075,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
                if (IS_ERR(vm)) {
                        drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n");
                        ret = PTR_ERR(vm);
-                       goto err;
+                       goto err_frontbuffer_put;
                }
 
                intel_fb->dpt_vm = vm;
@@ -2088,8 +2092,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
 err_free_dpt:
        if (intel_fb_uses_dpt(fb))
                intel_dpt_destroy(intel_fb->dpt_vm);
-err:
+err_frontbuffer_put:
        intel_frontbuffer_put(intel_fb->frontbuffer);
+err:
+       intel_fb_bo_framebuffer_fini(obj);
        return ret;
 }
 
index ce86eff7b226ae7e90e027efa9f21047d6ed67f5..4be09541e50950c8e0744095a2ab6147f6caf1e8 100644 (file)
 #include "intel_fb.h"
 #include "intel_fb_bo.h"
 
+void intel_fb_bo_framebuffer_fini(struct drm_i915_gem_object *obj)
+{
+       /* Nothing to do for i915 */
+}
+
 int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
                                 struct drm_i915_gem_object *obj,
                                 struct drm_mode_fb_cmd2 *mode_cmd)
index dd06ceec8601b7f01d437b9ae5060a07ca54494e..232bf898b0138976a4a337e295d5700c5536f3e1 100644 (file)
@@ -12,6 +12,8 @@ struct drm_i915_gem_object;
 struct drm_i915_private;
 struct intel_framebuffer;
 
+void intel_fb_bo_framebuffer_fini(struct drm_i915_gem_object *obj);
+
 int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
                                 struct drm_i915_gem_object *obj,
                                 struct drm_mode_fb_cmd2 *mode_cmd);