[Intel-gfx] [PATCH 27/39] drm/i915: Explicitly cleanup initial_plane_config
Chris Wilson
chris at chris-wilson.co.uk
Fri Jun 14 07:10:11 UTC 2019
I am about to stuff more objects into the plane_config and would like to
have it clean up after itself. Move the current framebuffer release into
a common function so it can be extended with the new object with
relative ease.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
drivers/gpu/drm/i915/intel_display.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 72e2c04b6e11..039536625bbf 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3200,8 +3200,6 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
goto valid_fb;
}
- kfree(plane_config->fb);
-
/*
* Failed to alloc the obj, check to see if we should share
* an fb with another CRTC instead
@@ -3221,7 +3219,6 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
if (intel_plane_ggtt_offset(state) == plane_config->base) {
fb = state->base.fb;
- drm_framebuffer_get(fb);
goto valid_fb;
}
}
@@ -3256,7 +3253,6 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
intel_crtc->pipe, PTR_ERR(intel_state->vma));
intel_state->vma = NULL;
- drm_framebuffer_put(fb);
return;
}
@@ -3278,8 +3274,9 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
if (plane_config->tiling)
dev_priv->preserve_bios_swizzle = true;
- plane_state->fb = fb;
plane_state->crtc = &intel_crtc->base;
+ plane_state->fb = fb;
+ drm_framebuffer_get(fb);
atomic_or(to_intel_plane(primary)->frontbuffer_bit,
&to_intel_frontbuffer(fb)->bits);
@@ -15910,6 +15907,19 @@ static int intel_initial_commit(struct drm_device *dev)
return ret;
}
+static void plane_config_fini(struct intel_initial_plane_config *plane_config)
+{
+ if (plane_config->fb) {
+ struct drm_framebuffer *fb = &plane_config->fb->base;
+
+ /* We may only have the stub and not a full framebuffer */
+ if (drm_framebuffer_read_refcount(fb))
+ drm_framebuffer_put(fb);
+ else
+ kfree(fb);
+ }
+}
+
int intel_modeset_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = to_i915(dev);
@@ -16047,6 +16057,8 @@ int intel_modeset_init(struct drm_device *dev)
* just get the first one.
*/
intel_find_initial_plane_obj(crtc, &plane_config);
+
+ plane_config_fini(&plane_config);
}
/*
--
2.20.1
More information about the Intel-gfx
mailing list