Skip to content

Commit 460f6b1

Browse files
hdellergregkh
authored andcommitted
Revert "fbcon: Disable accelerated scrolling"
commit 87ab9f6 upstream. This reverts commit 39aead8. Revert the first (of 2) commits which disabled scrolling acceleration in fbcon/fbdev. It introduced a regression for fbdev-supported graphic cards because of the performance penalty by doing screen scrolling by software instead of using the existing graphic card 2D hardware acceleration. Console scrolling acceleration was disabled by dropping code which checked at runtime the driver hardware capabilities for the BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move screen contents. After dropping those checks scrollmode was hard-wired to SCROLL_REDRAW instead, which forces all graphic cards to redraw every character at the new screen position when scrolling. This change effectively disabled all hardware-based scrolling acceleration for ALL drivers, because now all kind of 2D hardware acceleration (bitblt, fillrect) in the drivers isn't used any longer. The original commit message mentions that only 3 DRM drivers (nouveau, omapdrm and gma500) used hardware acceleration in the past and thus code for checking and using scrolling acceleration is obsolete. This statement is NOT TRUE, because beside the DRM drivers there are around 35 other fbdev drivers which depend on fbdev/fbcon and still provide hardware acceleration for fbdev/fbcon. The original commit message also states that syzbot found lots of bugs in fbcon and thus it's "often the solution to just delete code and remove features". This is true, and the bugs - which actually affected all users of fbcon, including DRM - were fixed, or code was dropped like e.g. the support for software scrollback in vgacon (commit 973c096). So to further analyze which bugs were found by syzbot, I've looked through all patches in drivers/video which were tagged with syzbot or syzkaller back to year 2005. The vast majority fixed the reported issues on a higher level, e.g. when screen is to be resized, or when font size is to be changed. The few ones which touched driver code fixed a real driver bug, e.g. by adding a check. But NONE of those patches touched code of either the SCROLL_MOVE or the SCROLL_REDRAW case. That means, there was no real reason why SCROLL_MOVE had to be ripped-out and just SCROLL_REDRAW had to be used instead. The only reason I can imagine so far was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it could go away. That argument completely missed the fact that SCROLL_MOVE is still heavily used by fbdev (non-DRM) drivers. Some people mention that using memcpy() instead of the hardware acceleration is pretty much the same speed. But that's not true, at least not for older graphic cards and machines where we see speed decreases by factor 10 and more and thus this change leads to console responsiveness way worse than before. That's why the original commit is to be reverted. By reverting we reintroduce hardware-based scrolling acceleration and fix the performance regression for fbdev drivers. There isn't any impact on DRM when reverting those patches. Signed-off-by: Helge Deller <deller@gmx.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Sven Schnelle <svens@stackframe.org> Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-deller@gmx.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 460aa9d commit 460f6b1

2 files changed

Lines changed: 37 additions & 26 deletions

File tree

Documentation/gpu/todo.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,6 @@ 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-
294276
idr_init_base()
295277
---------------
296278

drivers/video/fbdev/core/fbcon.c

Lines changed: 37 additions & 8 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 ret;
1036+
int cap, ret;
10371037

10381038
if (WARN_ON(info_idx == -1))
10391039
return;
@@ -1042,6 +1042,7 @@ 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;
10451046

10461047
if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)
10471048
logo_shown = FBCON_LOGO_DONTSHOW;
@@ -1146,13 +1147,11 @@ static void fbcon_init(struct vc_data *vc, int init)
11461147

11471148
ops->graphics = 0;
11481149

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;
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;
11561155

11571156
/*
11581157
* ++guenther: console.c:vc_allocate() relies on initializing
@@ -1965,15 +1964,45 @@ static void updatescrollmode(struct fbcon_display *p,
19651964
{
19661965
struct fbcon_ops *ops = info->fbcon_par;
19671966
int fh = vc->vc_font.height;
1967+
int cap = info->flags;
1968+
u16 t = 0;
1969+
int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
1970+
info->fix.xpanstep);
1971+
int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
19681972
int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
19691973
int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
19701974
info->var.xres_virtual);
1975+
int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
1976+
divides(ypan, vc->vc_font.height) && vyres > yres;
1977+
int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
1978+
divides(ywrap, vc->vc_font.height) &&
1979+
divides(vc->vc_font.height, vyres) &&
1980+
divides(vc->vc_font.height, yres);
1981+
int reading_fast = cap & FBINFO_READS_FAST;
1982+
int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
1983+
!(cap & FBINFO_HWACCEL_DISABLED);
1984+
int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
1985+
!(cap & FBINFO_HWACCEL_DISABLED);
19711986

19721987
p->vrows = vyres/fh;
19731988
if (yres > (fh * (vc->vc_rows + 1)))
19741989
p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
19751990
if ((yres % fh) && (vyres % fh < yres % fh))
19761991
p->vrows--;
1992+
1993+
if (good_wrap || good_pan) {
1994+
if (reading_fast || fast_copyarea)
1995+
p->scrollmode = good_wrap ?
1996+
SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
1997+
else
1998+
p->scrollmode = good_wrap ? SCROLL_REDRAW :
1999+
SCROLL_PAN_REDRAW;
2000+
} else {
2001+
if (reading_fast || (fast_copyarea && !fast_imageblit))
2002+
p->scrollmode = SCROLL_MOVE;
2003+
else
2004+
p->scrollmode = SCROLL_REDRAW;
2005+
}
19772006
}
19782007

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

0 commit comments

Comments
 (0)