drm/fb-helper: Fix height, width, and accel_flags in fb_var
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 23 May 2023 15:06:20 +0000 (17:06 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 24 May 2023 11:35:40 +0000 (13:35 +0200)
commite79d85c6c217221ea32354a5ac0587a7ccea02b9
tree829ac871880c4c393d87e94b86a1d26d31397659
parente997c218ad736fd6f524d73a987bad9d94128d3d
drm/fb-helper: Fix height, width, and accel_flags in fb_var

Fbtest contains some very simple validation of the fbdev userspace API
contract.  When used with shmob-drm, it reports the following warnings
and errors:

    height changed from 68 to 0
    height was rounded down
    width changed from 111 to 0
    width was rounded down
    accel_flags changed from 0 to 1

The first part happens because __fill_var() resets the physical
dimensions of the first connector, as filled in by drm_setup_crtcs_fb().
Fix this by retaining the original values.

The last part happens because __fill_var() forces the FB_ACCELF_TEXT
flag on, while fbtest disables all acceleration on purpose, so it can
draw safely to the frame buffer.  Fix this by setting accel_flags to
zero, as DRM does not implement any text console acceleration.
Note that this issue can also be seen in the output of fbset, which
reports "accel true".

Fixes: ee4cce0a8f03a333 ("drm/fb-helper: fix input validation gaps in check_var")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/57e6b334dae8148b1b8ae6ef308ce9a83810a850.1684854344.git.geert+renesas@glider.be
drivers/gpu/drm/drm_fb_helper.c