Skip to content

Commit 39aead8

Browse files
committed
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. 5014547 ("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 <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Bartlomiej Zolnierkiewicz <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Ben Skeggs <[email protected]> Cc: [email protected] Cc: Tomi Valkeinen <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Peilin Ye <[email protected]> Cc: George Kennedy <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Peter Rosin <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent ba23645 commit 39aead8

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

Documentation/gpu/todo.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,24 @@ Contact: Daniel Vetter, Noralf Tronnes
292292

293293
Level: Advanced
294294

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+
295313
idr_init_base()
296314
---------------
297315

drivers/video/fbdev/core/fbcon.c

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ static void fbcon_init(struct vc_data *vc, int init)
10331033
struct vc_data *svc = *default_mode;
10341034
struct fbcon_display *t, *p = &fb_display[vc->vc_num];
10351035
int logo = 1, new_rows, new_cols, rows, cols;
1036-
int cap, ret;
1036+
int ret;
10371037

10381038
if (WARN_ON(info_idx == -1))
10391039
return;
@@ -1042,7 +1042,6 @@ static void fbcon_init(struct vc_data *vc, int init)
10421042
con2fb_map[vc->vc_num] = info_idx;
10431043

10441044
info = registered_fb[con2fb_map[vc->vc_num]];
1045-
cap = info->flags;
10461045

10471046
if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)
10481047
logo_shown = FBCON_LOGO_DONTSHOW;
@@ -1144,11 +1143,13 @@ static void fbcon_init(struct vc_data *vc, int init)
11441143

11451144
ops->graphics = 0;
11461145

1147-
if ((cap & FBINFO_HWACCEL_COPYAREA) &&
1148-
!(cap & FBINFO_HWACCEL_DISABLED))
1149-
p->scrollmode = SCROLL_MOVE;
1150-
else /* default to something safe */
1151-
p->scrollmode = SCROLL_REDRAW;
1146+
/*
1147+
* No more hw acceleration for fbcon.
1148+
*
1149+
* FIXME: Garbage collect all the now dead code after sufficient time
1150+
* has passed.
1151+
*/
1152+
p->scrollmode = SCROLL_REDRAW;
11521153

11531154
/*
11541155
* ++guenther: console.c:vc_allocate() relies on initializing
@@ -1957,45 +1958,15 @@ static void updatescrollmode(struct fbcon_display *p,
19571958
{
19581959
struct fbcon_ops *ops = info->fbcon_par;
19591960
int fh = vc->vc_font.height;
1960-
int cap = info->flags;
1961-
u16 t = 0;
1962-
int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
1963-
info->fix.xpanstep);
1964-
int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
19651961
int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
19661962
int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
19671963
info->var.xres_virtual);
1968-
int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
1969-
divides(ypan, vc->vc_font.height) && vyres > yres;
1970-
int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
1971-
divides(ywrap, vc->vc_font.height) &&
1972-
divides(vc->vc_font.height, vyres) &&
1973-
divides(vc->vc_font.height, yres);
1974-
int reading_fast = cap & FBINFO_READS_FAST;
1975-
int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
1976-
!(cap & FBINFO_HWACCEL_DISABLED);
1977-
int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
1978-
!(cap & FBINFO_HWACCEL_DISABLED);
19791964

19801965
p->vrows = vyres/fh;
19811966
if (yres > (fh * (vc->vc_rows + 1)))
19821967
p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
19831968
if ((yres % fh) && (vyres % fh < yres % fh))
19841969
p->vrows--;
1985-
1986-
if (good_wrap || good_pan) {
1987-
if (reading_fast || fast_copyarea)
1988-
p->scrollmode = good_wrap ?
1989-
SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
1990-
else
1991-
p->scrollmode = good_wrap ? SCROLL_REDRAW :
1992-
SCROLL_PAN_REDRAW;
1993-
} else {
1994-
if (reading_fast || (fast_copyarea && !fast_imageblit))
1995-
p->scrollmode = SCROLL_MOVE;
1996-
else
1997-
p->scrollmode = SCROLL_REDRAW;
1998-
}
19991970
}
20001971

20011972
#define PITCH(w) (((w) + 7) >> 3)

0 commit comments

Comments
 (0)