drm/blend: size zpos array to active planes instead of total
Subsystems (2)
cover drm/blend: size zpos array to active planes instead of total
drm_atomic_helper_crtc_normalize_zpos() allocates a temporary array sized by dev->mode_config.num_total_plane, which counts all planes registered on the device. The function only operates on planes active on the given CRTC, as described by crtc_state->plane_mask.
Replace num_total_plane with hweight32(crtc_state->plane_mask) to size the allocation to exactly the planes being processed.
Gustavo Piaz Da Silva (1):
drm/blend: size zpos array to active planes instead of total
drivers/gpu/drm/drm_blend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH 1/1 drm/blend: size zpos array to active planes instead of total
drm_atomic_helper_crtc_normalize_zpos() allocates a temporary array with num_total_plane entries, which is the total number of planes registered across the entire DRM device. However, the function only processes planes active on the given CRTC, as described by crtc_state->plane_mask.
Replace num_total_plane with hweight32(crtc_state->plane_mask), which counts exactly the planes that drm_for_each_plane_mask will visit. This ensures the allocation is sized precisely for the work being done, reducing memory pressure on devices where num_total_plane is significantly larger than the number of active planes per CRTC.
--- drivers/gpu/drm/drm_blend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_blend.c +1 -1
@@ -465,7 +465,7 @@ static int drm_atomic_helper_crtc_normalize_zpos(struct drm_crtc *crtc, {struct drm_atomic_state *state = crtc_state->state;struct drm_device *dev = crtc->dev; -int total_planes = dev->mode_config.num_total_plane; +int total_planes =hweight32 (crtc_state->plane_mask);struct drm_plane_state **states;struct drm_plane *plane;int i, n =0 ;
Signature · 1 line
2.43.0