From 06a06699bddeacfb647067a867c28d0ec1fa9e17 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 18 Nov 2023 19:36:44 +0100 Subject: [PATCH] drm/msm/sde: Don't allocate memory dynamically for CRTC atomic check Every atomic frame commit allocates memory dynamically to check the states of the CRTCs, when those allocations can just be stored on the stack instead. Eliminate these dynamic memory allocations in the frame commit path to improve performance. They don't need need to be zeroed out either. --- techpack/display/msm/sde/sde_crtc.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/techpack/display/msm/sde/sde_crtc.c b/techpack/display/msm/sde/sde_crtc.c index 9caa41328..e0b518a64 100644 --- a/techpack/display/msm/sde/sde_crtc.c +++ b/techpack/display/msm/sde/sde_crtc.c @@ -1415,7 +1415,7 @@ static void _sde_crtc_blend_setup_mixer(struct drm_crtc *crtc, struct drm_plane_state *state; struct sde_crtc_state *cstate; struct sde_plane_state *pstate = NULL; - struct plane_state *pstates = NULL; + struct plane_state pstates[SDE_PSTATES_MAX]; struct sde_format *format; struct sde_hw_ctl *ctl; struct sde_hw_mixer *lm; @@ -5006,7 +5006,7 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc, struct sde_crtc_state *cstate; struct drm_display_mode *mode; int rc = 0; - struct sde_multirect_plane_states *multirect_plane = NULL; + struct sde_multirect_plane_states multirect_plane[SDE_MULTIRECT_PLANE_MAX]; struct drm_connector *conn; struct drm_connector_list_iter conn_iter; @@ -5025,18 +5025,6 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc, goto end; } - pstates = kcalloc(SDE_PSTATES_MAX, - sizeof(struct plane_state), GFP_KERNEL); - - multirect_plane = kcalloc(SDE_MULTIRECT_PLANE_MAX, - sizeof(struct sde_multirect_plane_states), - GFP_KERNEL); - - if (!pstates || !multirect_plane) { - rc = -ENOMEM; - goto end; - } - mode = &state->adjusted_mode; SDE_DEBUG("%s: check", sde_crtc->name); @@ -5099,8 +5087,6 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc, goto end; } end: - kfree(pstates); - kfree(multirect_plane); return rc; }