Commit 10690b8a authored by Jouni Högander's avatar Jouni Högander

drm/i915/display: Add intel_fb_bo_framebuffer_fini

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: default avatarJouni Högander <jouni.hogander@intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231207083451.2184562-1-jouni.hogander@intel.com
parent 7054b551
...@@ -1889,6 +1889,8 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb) ...@@ -1889,6 +1889,8 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
intel_frontbuffer_put(intel_fb->frontbuffer); intel_frontbuffer_put(intel_fb->frontbuffer);
intel_fb_bo_framebuffer_fini(intel_fb_obj(fb));
kfree(intel_fb); kfree(intel_fb);
} }
...@@ -1989,13 +1991,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -1989,13 +1991,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
int ret = -EINVAL; int ret = -EINVAL;
int i; 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); ret = intel_fb_bo_framebuffer_init(intel_fb, obj, mode_cmd);
if (ret) if (ret)
return ret;
intel_fb->frontbuffer = intel_frontbuffer_get(obj);
if (!intel_fb->frontbuffer) {
ret = -ENOMEM;
goto err; goto err;
}
ret = -EINVAL; ret = -EINVAL;
if (!drm_any_plane_has_format(&dev_priv->drm, if (!drm_any_plane_has_format(&dev_priv->drm,
...@@ -2004,7 +2008,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2004,7 +2008,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
drm_dbg_kms(&dev_priv->drm, drm_dbg_kms(&dev_priv->drm,
"unsupported pixel format %p4cc / modifier 0x%llx\n", "unsupported pixel format %p4cc / modifier 0x%llx\n",
&mode_cmd->pixel_format, mode_cmd->modifier[0]); &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, 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, ...@@ -2015,7 +2019,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ? mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ?
"tiled" : "linear", "tiled" : "linear",
mode_cmd->pitches[0], max_stride); mode_cmd->pitches[0], max_stride);
goto err; goto err_frontbuffer_put;
} }
/* FIXME need to adjust LINOFF/TILEOFF accordingly. */ /* FIXME need to adjust LINOFF/TILEOFF accordingly. */
...@@ -2023,7 +2027,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2023,7 +2027,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
drm_dbg_kms(&dev_priv->drm, drm_dbg_kms(&dev_priv->drm,
"plane 0 offset (0x%08x) must be 0\n", "plane 0 offset (0x%08x) must be 0\n",
mode_cmd->offsets[0]); mode_cmd->offsets[0]);
goto err; goto err_frontbuffer_put;
} }
drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd); 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, ...@@ -2034,7 +2038,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
if (mode_cmd->handles[i] != mode_cmd->handles[0]) { if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n", drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n",
i); i);
goto err; goto err_frontbuffer_put;
} }
stride_alignment = intel_fb_stride_alignment(fb, i); stride_alignment = intel_fb_stride_alignment(fb, i);
...@@ -2042,7 +2046,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2042,7 +2046,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
drm_dbg_kms(&dev_priv->drm, drm_dbg_kms(&dev_priv->drm,
"plane %d pitch (%d) must be at least %u byte aligned\n", "plane %d pitch (%d) must be at least %u byte aligned\n",
i, fb->pitches[i], stride_alignment); i, fb->pitches[i], stride_alignment);
goto err; goto err_frontbuffer_put;
} }
if (intel_fb_is_gen12_ccs_aux_plane(fb, i)) { if (intel_fb_is_gen12_ccs_aux_plane(fb, i)) {
...@@ -2053,7 +2057,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2053,7 +2057,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
"ccs aux plane %d pitch (%d) must be %d\n", "ccs aux plane %d pitch (%d) must be %d\n",
i, i,
fb->pitches[i], ccs_aux_stride); 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, ...@@ -2062,7 +2066,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
ret = intel_fill_fb_info(dev_priv, intel_fb); ret = intel_fill_fb_info(dev_priv, intel_fb);
if (ret) if (ret)
goto err; goto err_frontbuffer_put;
if (intel_fb_uses_dpt(fb)) { if (intel_fb_uses_dpt(fb)) {
struct i915_address_space *vm; struct i915_address_space *vm;
...@@ -2071,7 +2075,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2071,7 +2075,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
if (IS_ERR(vm)) { if (IS_ERR(vm)) {
drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n"); drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n");
ret = PTR_ERR(vm); ret = PTR_ERR(vm);
goto err; goto err_frontbuffer_put;
} }
intel_fb->dpt_vm = vm; intel_fb->dpt_vm = vm;
...@@ -2088,8 +2092,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -2088,8 +2092,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
err_free_dpt: err_free_dpt:
if (intel_fb_uses_dpt(fb)) if (intel_fb_uses_dpt(fb))
intel_dpt_destroy(intel_fb->dpt_vm); intel_dpt_destroy(intel_fb->dpt_vm);
err: err_frontbuffer_put:
intel_frontbuffer_put(intel_fb->frontbuffer); intel_frontbuffer_put(intel_fb->frontbuffer);
err:
intel_fb_bo_framebuffer_fini(obj);
return ret; return ret;
} }
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
#include "intel_fb.h" #include "intel_fb.h"
#include "intel_fb_bo.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, int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
struct drm_i915_gem_object *obj, struct drm_i915_gem_object *obj,
struct drm_mode_fb_cmd2 *mode_cmd) struct drm_mode_fb_cmd2 *mode_cmd)
......
...@@ -12,6 +12,8 @@ struct drm_i915_gem_object; ...@@ -12,6 +12,8 @@ struct drm_i915_gem_object;
struct drm_i915_private; struct drm_i915_private;
struct intel_framebuffer; 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, int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
struct drm_i915_gem_object *obj, struct drm_i915_gem_object *obj,
struct drm_mode_fb_cmd2 *mode_cmd); struct drm_mode_fb_cmd2 *mode_cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment