Skip to content

Commit

Permalink
drm/msm/sde: Don't allocate memory dynamically for CRTC atomic check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kerneltoast authored and Ristovski committed Nov 18, 2023
1 parent 7cc1020 commit 06a0669
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions techpack/display/msm/sde/sde_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -5099,8 +5087,6 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc,
goto end;
}
end:
kfree(pstates);
kfree(multirect_plane);
return rc;
}

Expand Down

0 comments on commit 06a0669

Please sign in to comment.