Skip to content

Commit 397971e

Browse files
danvetgregkh
authored andcommitted
fbcon: Disable accelerated scrolling
commit 39aead8 upstream. 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 <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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent df83b9b commit 397971e

2 files changed

Lines changed: 26 additions & 37 deletions

File tree

‎Documentation/gpu/todo.rst‎

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

274274
Level: Advanced
275275

276+
Garbage collect fbdev scrolling acceleration
277+
--------------------------------------------
278+
279+
Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =
280+
SCROLL_REDRAW. There's a ton of code this will allow us to remove:
281+
- lots of code in fbcon.c
282+
- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be called
283+
directly instead of the function table (with a switch on p->rotate)
284+
- fb_copyarea is unused after this, and can be deleted from all drivers
285+
286+
Note that not all acceleration code can be deleted, since clearing and cursor
287+
support is still accelerated, which might be good candidates for further
288+
deletion projects.
289+
290+
Contact: Daniel Vetter
291+
292+
Level: Intermediate
293+
276294
idr_init_base()
277295
---------------
278296

‎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, charcnt = 256;
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;
@@ -1147,11 +1146,13 @@ static void fbcon_init(struct vc_data *vc, int init)
11471146

11481147
ops->graphics = 0;
11491148

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

11561157
/*
11571158
* ++guenther: console.c:vc_allocate() relies on initializing
@@ -1961,45 +1962,15 @@ static void updatescrollmode(struct fbcon_display *p,
19611962
{
19621963
struct fbcon_ops *ops = info->fbcon_par;
19631964
int fh = vc->vc_font.height;
1964-
int cap = info->flags;
1965-
u16 t = 0;
1966-
int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
1967-
info->fix.xpanstep);
1968-
int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
19691965
int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
19701966
int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
19711967
info->var.xres_virtual);
1972-
int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
1973-
divides(ypan, vc->vc_font.height) && vyres > yres;
1974-
int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
1975-
divides(ywrap, vc->vc_font.height) &&
1976-
divides(vc->vc_font.height, vyres) &&
1977-
divides(vc->vc_font.height, yres);
1978-
int reading_fast = cap & FBINFO_READS_FAST;
1979-
int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
1980-
!(cap & FBINFO_HWACCEL_DISABLED);
1981-
int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
1982-
!(cap & FBINFO_HWACCEL_DISABLED);
19831968

19841969
p->vrows = vyres/fh;
19851970
if (yres > (fh * (vc->vc_rows + 1)))
19861971
p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
19871972
if ((yres % fh) && (vyres % fh < yres % fh))
19881973
p->vrows--;
1989-
1990-
if (good_wrap || good_pan) {
1991-
if (reading_fast || fast_copyarea)
1992-
p->scrollmode = good_wrap ?
1993-
SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
1994-
else
1995-
p->scrollmode = good_wrap ? SCROLL_REDRAW :
1996-
SCROLL_PAN_REDRAW;
1997-
} else {
1998-
if (reading_fast || (fast_copyarea && !fast_imageblit))
1999-
p->scrollmode = SCROLL_MOVE;
2000-
else
2001-
p->scrollmode = SCROLL_REDRAW;
2002-
}
20031974
}
20041975

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

0 commit comments

Comments
 (0)