drm/solomon: remove unneeded variables in blit functions
Subsystems (3)
PATCH 1/1 drm/solomon: remove unneeded variables in blit functions
Remove unneeded 'ret' variables in ssd130x_fb_blit_rect(), ssd132x_fb_blit_rect(), and ssd133x_fb_blit_rect() functions. These functions initialize ret to 0 and return it unchanged, so return 0 directly instead.
---
Fix unneeded variable warnings reported by kernel test robot in the Solomon SSD130x driver. Three blit functions were initializing 'ret' variables to 0, never modifying them, and then returning the unchanged value.
The fix simplifies the code by returning 0 directly, addressing the static analysis warnings while maintaining the same functionality.
--- drivers/gpu/drm/solomon/ssd130x.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +3 -6
@@ -897,7 +897,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb,struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev);struct iosys_map dst;unsigned int dst_pitch; -int ret =0 ;/* Align y to display page boundaries */ rect->y1 =round_down (rect->y1,SSD130X_PAGE_HEIGHT );
@@ -910,7 +909,7 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb,ssd130x_update_rect (ssd130x, rect, buf, data_array); -return ret; +return 0 ; } static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,
@@ -922,7 +921,6 @@ static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,struct ssd130x_device *ssd130x =drm_to_ssd130x (fb->dev);unsigned int dst_pitch;struct iosys_map dst; -int ret =0 ;/* Align x to display segment boundaries */ rect->x1 =round_down (rect->x1,SSD132X_SEGMENT_WIDTH );
@@ -936,7 +934,7 @@ static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,ssd132x_update_rect (ssd130x, rect, buf, data_array); -return ret; +return 0 ; } static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,
@@ -948,7 +946,6 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,const struct drm_format_info *fi =drm_format_info (DRM_FORMAT_RGB332 );unsigned int dst_pitch;struct iosys_map dst; -int ret =0 ;if (!fi)return -EINVAL ;
@@ -960,7 +957,7 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,ssd133x_update_rect (ssd130x, rect, data_array, dst_pitch); -return ret; +return 0 ; } static int ssd130x_primary_plane_atomic_check(struct drm_plane *plane,
---
base-commit: 671b7825dbfe9ea6e3ad3001003aeee0df48d1b5
change-id: 20260709-fix-ssd130x-d7dc491af074
Best regards,
Signature · 1 line
Iker Pedrosa <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The format conversion state buffer is drastically under-allocated (or not allocated at all) in atomic_check, forcing GFP_KERNEL reallocation during the atomic_update phase. --
--- Patch [1]: [PATCH] drm/solomon: remove unneeded variables in blit functions --- commit 8b406f12f83f8bdc420f079608108a65e9772103
Author: Iker Pedrosa <[email protected]>
drm/solomon: remove unneeded variables in blit functions
Remove unneeded 'ret' variables in ssd130x_fb_blit_rect(), ssd132x_fb_blit_rect(), and ssd133x_fb_blit_rect() functions. These functions initialize ret to 0 and return it unchanged, so return 0 directly instead.
Quoted 4 lines
drivers/gpu/drm/solomon/ssd130x.c +0
-0
[ ... ]
drivers/gpu/drm/solomon/ssd130x.c static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb, · line 963
Quoted 9 lines
drivers/gpu/drm/solomon/ssd130x.c +1
-1@@ -960,7 +957,7 @@ static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,ssd133x_update_rect (ssd130x, rect, data_array, dst_pitch); -return ret; +return 0 ; } static int ssd130x_primary_plane_atomic_check(struct drm_plane *plane,
[Severity: High]
This isn't a bug introduced by this patch, but does the format conversion state buffer get drastically under-allocated (or not allocated at all) in the atomic_check functions, forcing a GFP_KERNEL reallocation during the atomic_update phase?
Looking at ssd130x_primary_plane_atomic_check(), it reserves memory based on the much smaller destination format pitch instead of the XRGB8888 source format requirement:
if (plane_state->fb->format != fi) {
void *buf;
/* format conversion necessary; reserve buffer */
buf = drm_format_conv_state_reserve(&shadow_plane_state->fmtcnv_state,
pitch, GFP_KERNEL);
if (!buf)
return -ENOMEM;
}Later, during the non-blocking atomic_update phase, conversion helpers like drm_fb_xrgb8888_to_mono() request a much larger buffer:
src32 = drm_format_conv_state_reserve(state, len_src32 + linepixels, GFP_KERNEL);
Since the newly requested size exceeds the previously reserved size, won't this force drm_format_conv_state_reserve() to execute a sleeping krealloc with GFP_KERNEL in atomic context?
This same pattern appears in ssd132x_primary_plane_atomic_check(), and ssd133x_primary_plane_atomic_check() completely omits calling drm_format_conv_state_reserve() which guarantees a 0 size reserve.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Iker Pedrosa <[email protected]> writes:
Hello Iker,
Thanks for the patch.
Quoted 14 lines
Remove unneeded 'ret' variables in
ssd130x_fb_blit_rect(),ssd132x_fb_blit_rect(), andssd133x_fb_blit_rect()functions. These functions initialize ret to 0 and return it unchanged, so return 0 directly instead.Fixes 2258f03989af ("drm/solomon: Move calls to drm_gem_fb_end_cpu*()")Reported-by kernel test robot <[email protected]>Signed-off-by Iker Pedrosa <[email protected]>---
Fix unneeded variable warnings reported by kernel test robot in the Solomon SSD130x driver. Three blit functions were initializing 'ret' variables to 0, never modifying them, and then returning the unchanged value.
Quoted 6 lines
The fix simplifies the code by returning 0 directly, addressing the static analysis warnings while maintaining the same functionality.
---drivers/gpu/drm/solomon/ssd130x.c | 9 +++------
I'll push it to drm-misc (drm-misc-next). Thanks!
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat