From a99b1a4503579d2e1d34f36ce41a3a60bf440fbe Mon Sep 17 00:00:00 2001 From: hrdl <31923882+hrdl-github@users.noreply.github.com> Date: Sat, 3 May 2025 18:48:35 +0200 Subject: [PATCH] rockchip_ebc: clamp y to [0, height] This shouldn't happen under normal circumstances, but this shouldn't hurt. --- drivers/gpu/drm/rockchip/rockchip_ebc.c | 3 +++ drivers/gpu/drm/rockchip/rockchip_ebc_blit_neon.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_ebc.c b/drivers/gpu/drm/rockchip/rockchip_ebc.c index dcdda1ef6806..a993866ee5db 100644 --- a/drivers/gpu/drm/rockchip/rockchip_ebc.c +++ b/drivers/gpu/drm/rockchip/rockchip_ebc.c @@ -1517,6 +1517,9 @@ static void rockchip_ebc_plane_atomic_update(struct drm_plane *plane, max(0, min(src_clip.x1 & ~15, (int)ebc->pixel_pitch - 16)); src_clip.x2 = min((src_clip.x2 + 15) & ~15, (int)ebc->pixel_pitch); + src_clip.y1 = max(0, src_clip.y1); + src_clip.y2 = min((int) ebc->height, src_clip.y2); + // This is the buffer we are allowed to modify, as it's not being read by the refresh thread int idx_update = ctx->update_index; diff --git a/drivers/gpu/drm/rockchip/rockchip_ebc_blit_neon.c b/drivers/gpu/drm/rockchip/rockchip_ebc_blit_neon.c index eddecdeb6f01..a59e8c2a02a9 100644 --- a/drivers/gpu/drm/rockchip/rockchip_ebc_blit_neon.c +++ b/drivers/gpu/drm/rockchip/rockchip_ebc_blit_neon.c @@ -67,8 +67,8 @@ void rockchip_ebc_schedule_advance_fast_neon( uint16x4_t q16s_maxs = vdup_n_u16(0); uint64x1_t q64s_0x00 = vdup_n_u64(0); - for (unsigned int y = clip_ongoing_or_waiting->y1; - y < clip_ongoing_or_waiting->y2; ++y) { + for (unsigned int y = max(0, clip_ongoing_or_waiting->y1); + y < min((int) ebc->height, clip_ongoing_or_waiting->y2); ++y) { int offset = y * pixel_pitch + x_start; u8 *packed_inner_outer_nextprev_line = ebc->packed_inner_outer_nextprev + offset * 3; u8 *phases_line = @@ -313,8 +313,8 @@ void rockchip_ebc_schedule_advance_neon( uint16x4_t q16s_maxs = vdup_n_u16(0); uint64x1_t q64s_0x00 = vdup_n_u64(0); - for (unsigned int y = clip_ongoing_or_waiting->y1; - y < clip_ongoing_or_waiting->y2; ++y) { + for (unsigned int y = max(0, clip_ongoing_or_waiting->y1); + y < min((int) ebc->height, clip_ongoing_or_waiting->y2); ++y) { int offset = y * pixel_pitch + x_start; u8 *packed_inner_outer_nextprev_line = ebc->packed_inner_outer_nextprev + offset * 3; u8 *phases_line = phase_buffer + y * phase_pitch +