Skip to content

Commit 973c096

Browse files
committed
vgacon: remove software scrollback support
Yunhai Zhang recently fixed a VGA software scrollback bug in commit ebfdfee ("vgacon: Fix for missing check in scrollback handling"), but that then made people look more closely at some of this code, and there were more problems on the vgacon side, but also the fbcon software scrollback. We don't really have anybody who maintains this code - probably because nobody actually _uses_ it any more. Sure, people still use both VGA and the framebuffer consoles, but they are no longer the main user interfaces to the kernel, and haven't been for decades, so these kinds of extra features end up bitrotting and not really being used. So rather than try to maintain a likely unused set of code, I'll just aggressively remove it, and see if anybody even notices. Maybe there are people who haven't jumped on the whole GUI badnwagon yet, and think it's just a fad. And maybe those people use the scrollback code. If that turns out to be the case, we can resurrect this again, once we've found the sucker^Wmaintainer for it who actually uses it. Reported-by: NopNop Nop <[email protected]> Tested-by: Willy Tarreau <[email protected]> Cc: 张云海 <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Acked-by: Willy Tarreau <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 06a0df4 commit 973c096

File tree

6 files changed

+1
-270
lines changed

6 files changed

+1
-270
lines changed

arch/powerpc/configs/pasemi_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ CONFIG_FB_NVIDIA=y
108108
CONFIG_FB_NVIDIA_I2C=y
109109
CONFIG_FB_RADEON=y
110110
# CONFIG_LCD_CLASS_DEVICE is not set
111-
CONFIG_VGACON_SOFT_SCROLLBACK=y
112111
CONFIG_LOGO=y
113112
CONFIG_SOUND=y
114113
CONFIG_SND=y

arch/powerpc/configs/ppc6xx_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ CONFIG_FB_TRIDENT=m
743743
CONFIG_FB_SM501=m
744744
CONFIG_FB_IBM_GXT4500=y
745745
CONFIG_LCD_PLATFORM=m
746-
CONFIG_VGACON_SOFT_SCROLLBACK=y
747746
CONFIG_FRAMEBUFFER_CONSOLE=y
748747
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
749748
CONFIG_LOGO=y

arch/x86/configs/i386_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ CONFIG_DRM_I915=y
186186
CONFIG_FB_MODE_HELPERS=y
187187
CONFIG_FB_TILEBLITTING=y
188188
CONFIG_FB_EFI=y
189-
CONFIG_VGACON_SOFT_SCROLLBACK=y
190189
CONFIG_LOGO=y
191190
# CONFIG_LOGO_LINUX_MONO is not set
192191
# CONFIG_LOGO_LINUX_VGA16 is not set

arch/x86/configs/x86_64_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ CONFIG_DRM_I915=y
181181
CONFIG_FB_MODE_HELPERS=y
182182
CONFIG_FB_TILEBLITTING=y
183183
CONFIG_FB_EFI=y
184-
CONFIG_VGACON_SOFT_SCROLLBACK=y
185184
CONFIG_LOGO=y
186185
# CONFIG_LOGO_LINUX_MONO is not set
187186
# CONFIG_LOGO_LINUX_VGA16 is not set

drivers/video/console/Kconfig

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,6 @@ config VGA_CONSOLE
2222

2323
Say Y.
2424

25-
config VGACON_SOFT_SCROLLBACK
26-
bool "Enable Scrollback Buffer in System RAM"
27-
depends on VGA_CONSOLE
28-
default n
29-
help
30-
The scrollback buffer of the standard VGA console is located in
31-
the VGA RAM. The size of this RAM is fixed and is quite small.
32-
If you require a larger scrollback buffer, this can be placed in
33-
System RAM which is dynamically allocated during initialization.
34-
Placing the scrollback buffer in System RAM will slightly slow
35-
down the console.
36-
37-
If you want this feature, say 'Y' here and enter the amount of
38-
RAM to allocate for this buffer. If unsure, say 'N'.
39-
40-
config VGACON_SOFT_SCROLLBACK_SIZE
41-
int "Scrollback Buffer Size (in KB)"
42-
depends on VGACON_SOFT_SCROLLBACK
43-
range 1 1024
44-
default "64"
45-
help
46-
Enter the amount of System RAM to allocate for scrollback
47-
buffers of VGA consoles. Each 64KB will give you approximately
48-
16 80x25 screenfuls of scrollback buffer.
49-
50-
config VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT
51-
bool "Persistent Scrollback History for each console by default"
52-
depends on VGACON_SOFT_SCROLLBACK
53-
default n
54-
help
55-
Say Y here if the scrollback history should persist by default when
56-
switching between consoles. Otherwise, the scrollback history will be
57-
flushed each time the console is switched. This feature can also be
58-
enabled using the boot command line parameter
59-
'vgacon.scrollback_persistent=1'.
60-
61-
This feature might break your tool of choice to flush the scrollback
62-
buffer, e.g. clear(1) will work fine but Debian's clear_console(1)
63-
will be broken, which might cause security issues.
64-
You can use the escape sequence \e[3J instead if this feature is
65-
activated.
66-
67-
Note that a buffer of VGACON_SOFT_SCROLLBACK_SIZE is taken for each
68-
created tty device.
69-
So if you use a RAM-constrained system, say N here.
70-
7125
config MDA_CONSOLE
7226
depends on !M68K && !PARISC && ISA
7327
tristate "MDA text console (dual-headed)"

drivers/video/console/vgacon.c

Lines changed: 1 addition & 220 deletions
Original file line numberDiff line numberDiff line change
@@ -165,214 +165,6 @@ static inline void vga_set_mem_top(struct vc_data *c)
165165
write_vga(12, (c->vc_visible_origin - vga_vram_base) / 2);
166166
}
167167

168-
#ifdef CONFIG_VGACON_SOFT_SCROLLBACK
169-
/* software scrollback */
170-
struct vgacon_scrollback_info {
171-
void *data;
172-
int tail;
173-
int size;
174-
int rows;
175-
int cnt;
176-
int cur;
177-
int save;
178-
int restore;
179-
};
180-
181-
static struct vgacon_scrollback_info *vgacon_scrollback_cur;
182-
static struct vgacon_scrollback_info vgacon_scrollbacks[MAX_NR_CONSOLES];
183-
static bool scrollback_persistent = \
184-
IS_ENABLED(CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT);
185-
module_param_named(scrollback_persistent, scrollback_persistent, bool, 0000);
186-
MODULE_PARM_DESC(scrollback_persistent, "Enable persistent scrollback for all vga consoles");
187-
188-
static void vgacon_scrollback_reset(int vc_num, size_t reset_size)
189-
{
190-
struct vgacon_scrollback_info *scrollback = &vgacon_scrollbacks[vc_num];
191-
192-
if (scrollback->data && reset_size > 0)
193-
memset(scrollback->data, 0, reset_size);
194-
195-
scrollback->cnt = 0;
196-
scrollback->tail = 0;
197-
scrollback->cur = 0;
198-
}
199-
200-
static void vgacon_scrollback_init(int vc_num)
201-
{
202-
int pitch = vga_video_num_columns * 2;
203-
size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
204-
int rows = size / pitch;
205-
void *data;
206-
207-
data = kmalloc_array(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024,
208-
GFP_NOWAIT);
209-
210-
vgacon_scrollbacks[vc_num].data = data;
211-
vgacon_scrollback_cur = &vgacon_scrollbacks[vc_num];
212-
213-
vgacon_scrollback_cur->rows = rows - 1;
214-
vgacon_scrollback_cur->size = rows * pitch;
215-
216-
vgacon_scrollback_reset(vc_num, size);
217-
}
218-
219-
static void vgacon_scrollback_switch(int vc_num)
220-
{
221-
if (!scrollback_persistent)
222-
vc_num = 0;
223-
224-
if (!vgacon_scrollbacks[vc_num].data) {
225-
vgacon_scrollback_init(vc_num);
226-
} else {
227-
if (scrollback_persistent) {
228-
vgacon_scrollback_cur = &vgacon_scrollbacks[vc_num];
229-
} else {
230-
size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
231-
232-
vgacon_scrollback_reset(vc_num, size);
233-
}
234-
}
235-
}
236-
237-
static void vgacon_scrollback_startup(void)
238-
{
239-
vgacon_scrollback_cur = &vgacon_scrollbacks[0];
240-
vgacon_scrollback_init(0);
241-
}
242-
243-
static void vgacon_scrollback_update(struct vc_data *c, int t, int count)
244-
{
245-
void *p;
246-
247-
if (!vgacon_scrollback_cur->data || !vgacon_scrollback_cur->size ||
248-
c->vc_num != fg_console)
249-
return;
250-
251-
p = (void *) (c->vc_origin + t * c->vc_size_row);
252-
253-
while (count--) {
254-
if ((vgacon_scrollback_cur->tail + c->vc_size_row) >
255-
vgacon_scrollback_cur->size)
256-
vgacon_scrollback_cur->tail = 0;
257-
258-
scr_memcpyw(vgacon_scrollback_cur->data +
259-
vgacon_scrollback_cur->tail,
260-
p, c->vc_size_row);
261-
262-
vgacon_scrollback_cur->cnt++;
263-
p += c->vc_size_row;
264-
vgacon_scrollback_cur->tail += c->vc_size_row;
265-
266-
if (vgacon_scrollback_cur->tail >= vgacon_scrollback_cur->size)
267-
vgacon_scrollback_cur->tail = 0;
268-
269-
if (vgacon_scrollback_cur->cnt > vgacon_scrollback_cur->rows)
270-
vgacon_scrollback_cur->cnt = vgacon_scrollback_cur->rows;
271-
272-
vgacon_scrollback_cur->cur = vgacon_scrollback_cur->cnt;
273-
}
274-
}
275-
276-
static void vgacon_restore_screen(struct vc_data *c)
277-
{
278-
c->vc_origin = c->vc_visible_origin;
279-
vgacon_scrollback_cur->save = 0;
280-
281-
if (!vga_is_gfx && !vgacon_scrollback_cur->restore) {
282-
scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf,
283-
c->vc_screenbuf_size > vga_vram_size ?
284-
vga_vram_size : c->vc_screenbuf_size);
285-
vgacon_scrollback_cur->restore = 1;
286-
vgacon_scrollback_cur->cur = vgacon_scrollback_cur->cnt;
287-
}
288-
}
289-
290-
static void vgacon_scrolldelta(struct vc_data *c, int lines)
291-
{
292-
int start, end, count, soff;
293-
294-
if (!lines) {
295-
vgacon_restore_screen(c);
296-
return;
297-
}
298-
299-
if (!vgacon_scrollback_cur->data)
300-
return;
301-
302-
if (!vgacon_scrollback_cur->save) {
303-
vgacon_cursor(c, CM_ERASE);
304-
vgacon_save_screen(c);
305-
c->vc_origin = (unsigned long)c->vc_screenbuf;
306-
vgacon_scrollback_cur->save = 1;
307-
}
308-
309-
vgacon_scrollback_cur->restore = 0;
310-
start = vgacon_scrollback_cur->cur + lines;
311-
end = start + abs(lines);
312-
313-
if (start < 0)
314-
start = 0;
315-
316-
if (start > vgacon_scrollback_cur->cnt)
317-
start = vgacon_scrollback_cur->cnt;
318-
319-
if (end < 0)
320-
end = 0;
321-
322-
if (end > vgacon_scrollback_cur->cnt)
323-
end = vgacon_scrollback_cur->cnt;
324-
325-
vgacon_scrollback_cur->cur = start;
326-
count = end - start;
327-
soff = vgacon_scrollback_cur->tail -
328-
((vgacon_scrollback_cur->cnt - end) * c->vc_size_row);
329-
soff -= count * c->vc_size_row;
330-
331-
if (soff < 0)
332-
soff += vgacon_scrollback_cur->size;
333-
334-
count = vgacon_scrollback_cur->cnt - start;
335-
336-
if (count > c->vc_rows)
337-
count = c->vc_rows;
338-
339-
if (count) {
340-
int copysize;
341-
342-
int diff = c->vc_rows - count;
343-
void *d = (void *) c->vc_visible_origin;
344-
void *s = (void *) c->vc_screenbuf;
345-
346-
count *= c->vc_size_row;
347-
/* how much memory to end of buffer left? */
348-
copysize = min(count, vgacon_scrollback_cur->size - soff);
349-
scr_memcpyw(d, vgacon_scrollback_cur->data + soff, copysize);
350-
d += copysize;
351-
count -= copysize;
352-
353-
if (count) {
354-
scr_memcpyw(d, vgacon_scrollback_cur->data, count);
355-
d += count;
356-
}
357-
358-
if (diff)
359-
scr_memcpyw(d, s, diff * c->vc_size_row);
360-
} else
361-
vgacon_cursor(c, CM_MOVE);
362-
}
363-
364-
static void vgacon_flush_scrollback(struct vc_data *c)
365-
{
366-
size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
367-
368-
vgacon_scrollback_reset(c->vc_num, size);
369-
}
370-
#else
371-
#define vgacon_scrollback_startup(...) do { } while (0)
372-
#define vgacon_scrollback_init(...) do { } while (0)
373-
#define vgacon_scrollback_update(...) do { } while (0)
374-
#define vgacon_scrollback_switch(...) do { } while (0)
375-
376168
static void vgacon_restore_screen(struct vc_data *c)
377169
{
378170
if (c->vc_origin != c->vc_visible_origin)
@@ -386,11 +178,6 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
386178
vga_set_mem_top(c);
387179
}
388180

389-
static void vgacon_flush_scrollback(struct vc_data *c)
390-
{
391-
}
392-
#endif /* CONFIG_VGACON_SOFT_SCROLLBACK */
393-
394181
static const char *vgacon_startup(void)
395182
{
396183
const char *display_desc = NULL;
@@ -573,10 +360,7 @@ static const char *vgacon_startup(void)
573360
vgacon_xres = screen_info.orig_video_cols * VGA_FONTWIDTH;
574361
vgacon_yres = vga_scan_lines;
575362

576-
if (!vga_init_done) {
577-
vgacon_scrollback_startup();
578-
vga_init_done = true;
579-
}
363+
vga_init_done = true;
580364

581365
return display_desc;
582366
}
@@ -869,7 +653,6 @@ static int vgacon_switch(struct vc_data *c)
869653
vgacon_doresize(c, c->vc_cols, c->vc_rows);
870654
}
871655

872-
vgacon_scrollback_switch(c->vc_num);
873656
return 0; /* Redrawing not needed */
874657
}
875658

@@ -1386,7 +1169,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
13861169
oldo = c->vc_origin;
13871170
delta = lines * c->vc_size_row;
13881171
if (dir == SM_UP) {
1389-
vgacon_scrollback_update(c, t, lines);
13901172
if (c->vc_scr_end + delta >= vga_vram_end) {
13911173
scr_memcpyw((u16 *) vga_vram_base,
13921174
(u16 *) (oldo + delta),
@@ -1450,7 +1232,6 @@ const struct consw vga_con = {
14501232
.con_save_screen = vgacon_save_screen,
14511233
.con_build_attr = vgacon_build_attr,
14521234
.con_invert_region = vgacon_invert_region,
1453-
.con_flush_scrollback = vgacon_flush_scrollback,
14541235
};
14551236
EXPORT_SYMBOL(vga_con);
14561237

0 commit comments

Comments
 (0)