From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> Let's name our planes in a way that makes sense wrt. the spec: - skl+ -> "plane 1A", "plane 2A", "plane 1C", "cursor A" etc. - g4x+ -> "primary A", "primary B", "sprite A", "cursor C" etc. - pre-g4x -> "plane A", "cursor B" etc. v2: Rebase on top of the fixed/cleaned error paths Use a local 'name' variable to make things easier Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/intel_display.c | 30 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_sprite.c | 14 ++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index bb49d7d..15b133e 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -13787,10 +13787,18 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc, */ void intel_plane_destroy(struct drm_plane *plane) { + char *name; + if (!plane) return; + /* + * drm_plane_cleanup() zeroes the structure, so + * need an extra dance to avoid leaking the name. + */ + name = plane->name; drm_plane_cleanup(plane); + kfree(name); kfree(to_intel_plane(plane)); } @@ -13811,6 +13819,7 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, { struct intel_plane *primary = NULL; struct intel_plane_state *state = NULL; + char *name = NULL; const uint32_t *intel_primary_formats; unsigned int num_formats; int ret; @@ -13839,6 +13848,19 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) primary->plane = !pipe; + if (INTEL_INFO(dev)->gen >= 9) + name = kasprintf(GFP_KERNEL, "plane 1%c", + pipe_name(pipe)); + else if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) + name = kasprintf(GFP_KERNEL, "primary %c", + pipe_name(pipe)); + else + name = kasprintf(GFP_KERNEL, "plane %c", + plane_name(primary->plane)); + if (!name) + goto fail; + primary->base.name = name; + if (INTEL_INFO(dev)->gen >= 9) { intel_primary_formats = skl_primary_formats; num_formats = ARRAY_SIZE(skl_primary_formats); @@ -13865,6 +13887,7 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, return &primary->base; fail: + kfree(name); kfree(state); kfree(primary); @@ -13975,6 +13998,7 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, { struct intel_plane *cursor = NULL; struct intel_plane_state *state = NULL; + char *name = NULL; int ret; cursor = kzalloc(sizeof(*cursor), GFP_KERNEL); @@ -13995,6 +14019,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; + name = kasprintf(GFP_KERNEL, "cursor %c", pipe_name(pipe)); + if (!name) + goto fail; + cursor->base.name = name; + ret = drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats, @@ -14023,6 +14052,7 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, return &cursor->base; fail: + kfree(name); kfree(state); kfree(cursor); diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 44e1e39..50e53ee 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1040,6 +1040,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) { struct intel_plane *intel_plane = NULL; struct intel_plane_state *state = NULL; + char *name = NULL; unsigned long possible_crtcs; const uint32_t *plane_formats; int num_plane_formats; @@ -1123,6 +1124,18 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->check_plane = intel_check_sprite_plane; intel_plane->commit_plane = intel_commit_sprite_plane; + if (INTEL_INFO(dev)->gen >= 9) + name = kasprintf(GFP_KERNEL, "plane %d%c", + plane + 2, pipe_name(pipe)); + else + name = kasprintf(GFP_KERNEL, "sprite %c", + sprite_name(pipe, plane)); + if (!name) { + ret = -ENOMEM; + goto fail; + } + intel_plane->base.name = name; + possible_crtcs = (1 << pipe); ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs, @@ -1139,6 +1152,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) return 0; fail: + kfree(name); kfree(state); kfree(intel_plane); -- 2.4.10 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx