Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbcon: Disable accelerated scrolling

So ever since syzbot discovered fbcon, we have solid proof that it's
full of bugs. And often the solution is to just delete code and remove
features, e.g. 50145474f6ef ("fbcon: remove soft scrollback code").

Now the problem is that most modern-ish drivers really only treat
fbcon as an dumb kernel console until userspace takes over, and Oops
printer for some emergencies. Looking at drm drivers and the basic
vesa/efi fbdev drivers shows that only 3 drivers support any kind of
acceleration:

- nouveau, seems to be enabled by default
- omapdrm, when a DMM remapper exists using remapper rewriting for
y/xpanning
- gma500, but that is getting deleted now for the GTT remapper trick,
and the accelerated copyarea never set the FBINFO_HWACCEL_COPYAREA
flag, so unused (and could be deleted already I think).

No other driver supportes accelerated fbcon. And fbcon is the only
user of this accel code (it's not exposed as uapi through ioctls),
which means we could garbage collect fairly enormous amounts of code
if we kill this.

Plus because syzbot only runs on virtual hardware, and none of the
drivers for that have acceleration, we'd remove a huge gap in testing.
And there's no other even remotely comprehensive testing aside from
syzbot.

This patch here just disables the acceleration code by always
redrawing when scrolling. The plan is that once this has been merged
for well over a year in released kernels, we can start to go around
and delete a lot of code.

v2:
- Drop a few more unused local variables, somehow I missed the
compiler warnings (Sam)
- Fix typo in comment (Jiri)
- add a todo entry for the cleanup (Thomas)

v3: Remove more unused variables (0day)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: nouveau@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Peilin Ye <yepeilin.cs@gmail.com>
Cc: George Kennedy <george.kennedy@oracle.com>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201029132229.4068359-1-daniel.vetter@ffwll.ch

+26 -37
+18
Documentation/gpu/todo.rst
··· 292 292 293 293 Level: Advanced 294 294 295 + Garbage collect fbdev scrolling acceleration 296 + -------------------------------------------- 297 + 298 + Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode = 299 + SCROLL_REDRAW. There's a ton of code this will allow us to remove: 300 + - lots of code in fbcon.c 301 + - a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be called 302 + directly instead of the function table (with a switch on p->rotate) 303 + - fb_copyarea is unused after this, and can be deleted from all drivers 304 + 305 + Note that not all acceleration code can be deleted, since clearing and cursor 306 + support is still accelerated, which might be good candidates for further 307 + deletion projects. 308 + 309 + Contact: Daniel Vetter 310 + 311 + Level: Intermediate 312 + 295 313 idr_init_base() 296 314 --------------- 297 315
+8 -37
drivers/video/fbdev/core/fbcon.c
··· 1033 1033 struct vc_data *svc = *default_mode; 1034 1034 struct fbcon_display *t, *p = &fb_display[vc->vc_num]; 1035 1035 int logo = 1, new_rows, new_cols, rows, cols; 1036 - int cap, ret; 1036 + int ret; 1037 1037 1038 1038 if (WARN_ON(info_idx == -1)) 1039 1039 return; ··· 1042 1042 con2fb_map[vc->vc_num] = info_idx; 1043 1043 1044 1044 info = registered_fb[con2fb_map[vc->vc_num]]; 1045 - cap = info->flags; 1046 1045 1047 1046 if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET) 1048 1047 logo_shown = FBCON_LOGO_DONTSHOW; ··· 1143 1144 1144 1145 ops->graphics = 0; 1145 1146 1146 - if ((cap & FBINFO_HWACCEL_COPYAREA) && 1147 - !(cap & FBINFO_HWACCEL_DISABLED)) 1148 - p->scrollmode = SCROLL_MOVE; 1149 - else /* default to something safe */ 1150 - p->scrollmode = SCROLL_REDRAW; 1147 + /* 1148 + * No more hw acceleration for fbcon. 1149 + * 1150 + * FIXME: Garbage collect all the now dead code after sufficient time 1151 + * has passed. 1152 + */ 1153 + p->scrollmode = SCROLL_REDRAW; 1151 1154 1152 1155 /* 1153 1156 * ++guenther: console.c:vc_allocate() relies on initializing ··· 1958 1957 { 1959 1958 struct fbcon_ops *ops = info->fbcon_par; 1960 1959 int fh = vc->vc_font.height; 1961 - int cap = info->flags; 1962 - u16 t = 0; 1963 - int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep, 1964 - info->fix.xpanstep); 1965 - int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); 1966 1960 int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); 1967 1961 int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual, 1968 1962 info->var.xres_virtual); 1969 - int good_pan = (cap & FBINFO_HWACCEL_YPAN) && 1970 - divides(ypan, vc->vc_font.height) && vyres > yres; 1971 - int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) && 1972 - divides(ywrap, vc->vc_font.height) && 1973 - divides(vc->vc_font.height, vyres) && 1974 - divides(vc->vc_font.height, yres); 1975 - int reading_fast = cap & FBINFO_READS_FAST; 1976 - int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) && 1977 - !(cap & FBINFO_HWACCEL_DISABLED); 1978 - int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) && 1979 - !(cap & FBINFO_HWACCEL_DISABLED); 1980 1963 1981 1964 p->vrows = vyres/fh; 1982 1965 if (yres > (fh * (vc->vc_rows + 1))) 1983 1966 p->vrows -= (yres - (fh * vc->vc_rows)) / fh; 1984 1967 if ((yres % fh) && (vyres % fh < yres % fh)) 1985 1968 p->vrows--; 1986 - 1987 - if (good_wrap || good_pan) { 1988 - if (reading_fast || fast_copyarea) 1989 - p->scrollmode = good_wrap ? 1990 - SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; 1991 - else 1992 - p->scrollmode = good_wrap ? SCROLL_REDRAW : 1993 - SCROLL_PAN_REDRAW; 1994 - } else { 1995 - if (reading_fast || (fast_copyarea && !fast_imageblit)) 1996 - p->scrollmode = SCROLL_MOVE; 1997 - else 1998 - p->scrollmode = SCROLL_REDRAW; 1999 - } 2000 1969 } 2001 1970 2002 1971 #define PITCH(w) (((w) + 7) >> 3)