diff mbox series

[REGRESSION] fbdev: fbmem: behave better with small rotated displays and many CPUs

Message ID 20181108095347.19326-1-peda@axentia.se (mailing list archive)
State New, archived
Headers show
Series [REGRESSION] fbdev: fbmem: behave better with small rotated displays and many CPUs | expand

Commit Message

Peter Rosin Nov. 8, 2018, 9:54 a.m. UTC
Blitting an image with "negative" offsets is not working since there
is no clipping. It hopefully just crashes. For the bootup logo, there
is protection so that blitting does not happen as the image is drawn
further and further to the right (ROTATE_UR) or further and further
down (ROTATE_CW). There is however no protection when drawing in the
opposite directions (ROTATE_UD and ROTATE_CCW).

Add back this protection.

The regression is 20-odd years old but the mindless warning-killing
mentality displayed in commit 34bdb666f4b2 ("fbdev: fbmem: remove
positive test on unsigned values") is also to blame, methinks.

Fixes: 448d479747b8 ("fbdev: fb_do_show_logo() updates")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/video/fbdev/core/fbmem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Peter Rosin Nov. 26, 2018, 2:16 p.m. UTC | #1
Ping?!

Cheers,
Peter

On 2018-11-08 10:54, Peter Rosin wrote:
> Blitting an image with "negative" offsets is not working since there
> is no clipping. It hopefully just crashes. For the bootup logo, there
> is protection so that blitting does not happen as the image is drawn
> further and further to the right (ROTATE_UR) or further and further
> down (ROTATE_CW). There is however no protection when drawing in the
> opposite directions (ROTATE_UD and ROTATE_CCW).
> 
> Add back this protection.
> 
> The regression is 20-odd years old but the mindless warning-killing
> mentality displayed in commit 34bdb666f4b2 ("fbdev: fbmem: remove
> positive test on unsigned values") is also to blame, methinks.
> 
> Fixes: 448d479747b8 ("fbdev: fb_do_show_logo() updates")
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/video/fbdev/core/fbmem.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index bb7f5f23e347..1abeb0b72455 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -435,7 +435,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
>  			image->dx += image->width + 8;
>  		}
>  	} else if (rotate == FB_ROTATE_UD) {
> -		for (x = 0; x < num; x++) {
> +		u32 dx = image->dx;
> +
> +		for (x = 0; x < num && image->dx <= dx; x++) {
>  			info->fbops->fb_imageblit(info, image);
>  			image->dx -= image->width + 8;
>  		}
> @@ -447,7 +449,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
>  			image->dy += image->height + 8;
>  		}
>  	} else if (rotate == FB_ROTATE_CCW) {
> -		for (x = 0; x < num; x++) {
> +		u32 dy = image->dy;
> +
> +		for (x = 0; x < num && image->dy <= dy; x++) {
>  			info->fbops->fb_imageblit(info, image);
>  			image->dy -= image->height + 8;
>  		}
>
Bartlomiej Zolnierkiewicz Nov. 26, 2018, 2:33 p.m. UTC | #2
On 11/26/2018 03:16 PM, Peter Rosin wrote:
> Ping?!

Hi,

Thank you for your patch, it will be considered for 4.21 (as it is not
a recent regression + I'm busy with other things currently).

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> Cheers,
> Peter
> 
> On 2018-11-08 10:54, Peter Rosin wrote:
>> Blitting an image with "negative" offsets is not working since there
>> is no clipping. It hopefully just crashes. For the bootup logo, there
>> is protection so that blitting does not happen as the image is drawn
>> further and further to the right (ROTATE_UR) or further and further
>> down (ROTATE_CW). There is however no protection when drawing in the
>> opposite directions (ROTATE_UD and ROTATE_CCW).
>>
>> Add back this protection.
>>
>> The regression is 20-odd years old but the mindless warning-killing
>> mentality displayed in commit 34bdb666f4b2 ("fbdev: fbmem: remove
>> positive test on unsigned values") is also to blame, methinks.
>>
>> Fixes: 448d479747b8 ("fbdev: fb_do_show_logo() updates")
>> Signed-off-by: Peter Rosin <peda@axentia.se>
>> ---
>>  drivers/video/fbdev/core/fbmem.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
>> index bb7f5f23e347..1abeb0b72455 100644
>> --- a/drivers/video/fbdev/core/fbmem.c
>> +++ b/drivers/video/fbdev/core/fbmem.c
>> @@ -435,7 +435,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
>>  			image->dx += image->width + 8;
>>  		}
>>  	} else if (rotate == FB_ROTATE_UD) {
>> -		for (x = 0; x < num; x++) {
>> +		u32 dx = image->dx;
>> +
>> +		for (x = 0; x < num && image->dx <= dx; x++) {
>>  			info->fbops->fb_imageblit(info, image);
>>  			image->dx -= image->width + 8;
>>  		}
>> @@ -447,7 +449,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
>>  			image->dy += image->height + 8;
>>  		}
>>  	} else if (rotate == FB_ROTATE_CCW) {
>> -		for (x = 0; x < num; x++) {
>> +		u32 dy = image->dy;
>> +
>> +		for (x = 0; x < num && image->dy <= dy; x++) {
>>  			info->fbops->fb_imageblit(info, image);
>>  			image->dy -= image->height + 8;
>>  		}
Peter Rosin Nov. 26, 2018, 9:19 p.m. UTC | #3
On 2018-11-26 15:33, Bartlomiej Zolnierkiewicz wrote:
> On 11/26/2018 03:16 PM, Peter Rosin wrote:
>> Ping?!
> 
> Hi,
> 
> Thank you for your patch, it will be considered for 4.21 (as it is not
> a recent regression + I'm busy with other things currently).

Right, thanks for letting me know!

Cheers,
Peter
Bartlomiej Zolnierkiewicz Dec. 20, 2018, 4:49 p.m. UTC | #4
On 11/26/2018 10:19 PM, Peter Rosin wrote:
> On 2018-11-26 15:33, Bartlomiej Zolnierkiewicz wrote:
>> On 11/26/2018 03:16 PM, Peter Rosin wrote:
>>> Ping?!
>>
>> Hi,
>>
>> Thank you for your patch, it will be considered for 4.21 (as it is not
>> a recent regression + I'm busy with other things currently).
> 
> Right, thanks for letting me know!

Patch queued for 4.21, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
diff mbox series

Patch

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index bb7f5f23e347..1abeb0b72455 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -435,7 +435,9 @@  static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
 			image->dx += image->width + 8;
 		}
 	} else if (rotate == FB_ROTATE_UD) {
-		for (x = 0; x < num; x++) {
+		u32 dx = image->dx;
+
+		for (x = 0; x < num && image->dx <= dx; x++) {
 			info->fbops->fb_imageblit(info, image);
 			image->dx -= image->width + 8;
 		}
@@ -447,7 +449,9 @@  static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
 			image->dy += image->height + 8;
 		}
 	} else if (rotate == FB_ROTATE_CCW) {
-		for (x = 0; x < num; x++) {
+		u32 dy = image->dy;
+
+		for (x = 0; x < num && image->dy <= dy; x++) {
 			info->fbops->fb_imageblit(info, image);
 			image->dy -= image->height + 8;
 		}