Skip to content

Commit 10690b8

Browse files
committed
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: Jouni Högander <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7054b55 commit 10690b8

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,8 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
18891889

18901890
intel_frontbuffer_put(intel_fb->frontbuffer);
18911891

1892+
intel_fb_bo_framebuffer_fini(intel_fb_obj(fb));
1893+
18921894
kfree(intel_fb);
18931895
}
18941896

@@ -1989,13 +1991,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
19891991
int ret = -EINVAL;
19901992
int i;
19911993

1992-
intel_fb->frontbuffer = intel_frontbuffer_get(obj);
1993-
if (!intel_fb->frontbuffer)
1994-
return -ENOMEM;
1995-
19961994
ret = intel_fb_bo_framebuffer_init(intel_fb, obj, mode_cmd);
19971995
if (ret)
1996+
return ret;
1997+
1998+
intel_fb->frontbuffer = intel_frontbuffer_get(obj);
1999+
if (!intel_fb->frontbuffer) {
2000+
ret = -ENOMEM;
19982001
goto err;
2002+
}
19992003

20002004
ret = -EINVAL;
20012005
if (!drm_any_plane_has_format(&dev_priv->drm,
@@ -2004,7 +2008,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20042008
drm_dbg_kms(&dev_priv->drm,
20052009
"unsupported pixel format %p4cc / modifier 0x%llx\n",
20062010
&mode_cmd->pixel_format, mode_cmd->modifier[0]);
2007-
goto err;
2011+
goto err_frontbuffer_put;
20082012
}
20092013

20102014
max_stride = intel_fb_max_stride(dev_priv, mode_cmd->pixel_format,
@@ -2015,15 +2019,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20152019
mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ?
20162020
"tiled" : "linear",
20172021
mode_cmd->pitches[0], max_stride);
2018-
goto err;
2022+
goto err_frontbuffer_put;
20192023
}
20202024

20212025
/* FIXME need to adjust LINOFF/TILEOFF accordingly. */
20222026
if (mode_cmd->offsets[0] != 0) {
20232027
drm_dbg_kms(&dev_priv->drm,
20242028
"plane 0 offset (0x%08x) must be 0\n",
20252029
mode_cmd->offsets[0]);
2026-
goto err;
2030+
goto err_frontbuffer_put;
20272031
}
20282032

20292033
drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd);
@@ -2034,15 +2038,15 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20342038
if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
20352039
drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n",
20362040
i);
2037-
goto err;
2041+
goto err_frontbuffer_put;
20382042
}
20392043

20402044
stride_alignment = intel_fb_stride_alignment(fb, i);
20412045
if (fb->pitches[i] & (stride_alignment - 1)) {
20422046
drm_dbg_kms(&dev_priv->drm,
20432047
"plane %d pitch (%d) must be at least %u byte aligned\n",
20442048
i, fb->pitches[i], stride_alignment);
2045-
goto err;
2049+
goto err_frontbuffer_put;
20462050
}
20472051

20482052
if (intel_fb_is_gen12_ccs_aux_plane(fb, i)) {
@@ -2053,7 +2057,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20532057
"ccs aux plane %d pitch (%d) must be %d\n",
20542058
i,
20552059
fb->pitches[i], ccs_aux_stride);
2056-
goto err;
2060+
goto err_frontbuffer_put;
20572061
}
20582062
}
20592063

@@ -2062,7 +2066,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20622066

20632067
ret = intel_fill_fb_info(dev_priv, intel_fb);
20642068
if (ret)
2065-
goto err;
2069+
goto err_frontbuffer_put;
20662070

20672071
if (intel_fb_uses_dpt(fb)) {
20682072
struct i915_address_space *vm;
@@ -2071,7 +2075,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20712075
if (IS_ERR(vm)) {
20722076
drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n");
20732077
ret = PTR_ERR(vm);
2074-
goto err;
2078+
goto err_frontbuffer_put;
20752079
}
20762080

20772081
intel_fb->dpt_vm = vm;
@@ -2088,8 +2092,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
20882092
err_free_dpt:
20892093
if (intel_fb_uses_dpt(fb))
20902094
intel_dpt_destroy(intel_fb->dpt_vm);
2091-
err:
2095+
err_frontbuffer_put:
20922096
intel_frontbuffer_put(intel_fb->frontbuffer);
2097+
err:
2098+
intel_fb_bo_framebuffer_fini(obj);
20932099
return ret;
20942100
}
20952101

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#include "intel_fb.h"
1212
#include "intel_fb_bo.h"
1313

14+
void intel_fb_bo_framebuffer_fini(struct drm_i915_gem_object *obj)
15+
{
16+
/* Nothing to do for i915 */
17+
}
18+
1419
int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
1520
struct drm_i915_gem_object *obj,
1621
struct drm_mode_fb_cmd2 *mode_cmd)

drivers/gpu/drm/i915/display/intel_fb_bo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ struct drm_i915_gem_object;
1212
struct drm_i915_private;
1313
struct intel_framebuffer;
1414

15+
void intel_fb_bo_framebuffer_fini(struct drm_i915_gem_object *obj);
16+
1517
int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
1618
struct drm_i915_gem_object *obj,
1719
struct drm_mode_fb_cmd2 *mode_cmd);

0 commit comments

Comments
 (0)