vt: regression caused by "Fix line garbage in virtual.."
Hi,
commit 81732c3b2fede049a692e58a7ceabb6d18ffb18c
(tty vt: Fix line garbage in virtual console on command line edition) introduced some regression in deleting characters/clearing line during selecting previous command in bash by using "up" arrow.
The problem can be reproduced by two following commands:
echo -n "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
echo -e "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x1b\x5b\x33\x50\x64\x72\x69\x76\x65\x72\x73\x2f\x69\x6e\x70\x75\x74\x2f\x6d\x6f\x75\x73\x65\x64\x65\x76\x2e\x63"
(the first command generates just some garbage, the second command generates string captured by strace when the issue occured).
On Linux v3.6 the resulting line is:
...AAAdrivers/input/mousedev.c
with fbcon on inteldrmfb and v3.7-rc6...AAAdrivers/input/mousedev.c A
with fbcon on radeondrmfb and v3.7-rc6
...AAAdrivers/input/mousedev.cAAA
There are some garbage after mousedev.c not present on older kernels.
Reverting commit 81732c in v3.7-rc6 fixes the issue.
Krzysiek
Quoted 4 lines
There are some garbage after
mousedev.cnot present on older kernels.Reverting commit 81732c in v3.7-rc6 fixes the issue.
Then we should drop this for 3.7 until a fixed one is provided IMHO. Its not relevant to most platforms.
Quoted 6 lines · On Mon, 19 Nov 2012 11:38:28 +0000 Alan Cox <[email protected]> wrote:
Quoted 3 lines
There are some garbage after
mousedev.cnot present on older kernels.Reverting commit 81732c in v3.7-rc6 fixes the issue.
Then we should drop this for 3.7 until a fixed one is provided IMHO. Its not relevant to most platforms.
Sorry, juggling with the byte offsets and the character indexes was not so obvious.
Here is a patch towards the kernel 3.7.
Krzysztof, may you check it?
Thanks.
drivers/tty/vt/vt.c +4 -4
@@ -539,25 +539,25 @@ {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memmovew (p + nr, p, vc->vc_cols - vc->vc_x); +scr_memmovew (p + nr, p, (vc->vc_cols - vc->vc_x) *2 );scr_memsetw (p, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 +1 ); + vc->vc_cols - vc->vc_x +1 ); }static void delete_char (struct vc_data *vc,unsigned int nr) {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memcpyw (p, p + nr, vc->vc_cols - vc->vc_x - nr); +scr_memcpyw (p, p + nr, (vc->vc_cols - vc->vc_x - nr) *2 );scr_memsetw (p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 ); + vc->vc_cols - vc->vc_x); }static int softcursor_original;
Signature · 2 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/
Quoted 5 lines · Jean-Francois Moine
Quoted 2 lines · On Mon, 19 Nov 2012 11:38:28 +0000 Alan Cox <[email protected]> wrote:
Quoted 2 lines
There are some garbage after
mousedev.cnot present on older kernels.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Reverting commit 81732c in v3.7-rc6 fixes the issue.
Then we should drop this for 3.7 until a fixed one is provided IMHO. Its not relevant to most platforms.
Sorry, juggling with the byte offsets and the character indexes was not so obvious.
That's why I even did not try to fix it.
Quoted 5 lines
Here is a patch towards the kernel 3.7.
Krzysztof, may you check it?
That patch fixed the original issue, but I noticed another artifact (I tested only v3.7-rc6 after your fix, I didn't check if the same problems exists in v3.7).
After:
for ((i = 0; i < 40; i++)); do
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
done
echo -e -n "\x0d\x1b[2@"
(also generated by bash during command line editing, this time by CTRL-r
+ something)
the first character on screen (first column and first row) is cleared.
I think it's too late for fixing it in 3.7 and it's better, like Alan proposed, to just revert it for now.
Thanks,
Krzysiek
-- >8 --
Subject: [PATCH] Revert "tty vt: Fix line garbage in virtual console on
command line edition"
This reverts commit 81732c3b2fede049a692e58a7ceabb6d18ffb18c.
This commit introduced frequent display artifacts during simple command line editing in bash, at least with framebuffer console on top inteldrmfb and radeondrmfb framebuffers.
--- drivers/tty/vt/vt.c | 78 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 17 deletions(-)
drivers/tty/vt/vt.c +61 -17
@@ -537,27 +537,45 @@ void complement_pos(struct vc_data *vc, int offset)static void insert_char (struct vc_data *vc,unsigned int nr) { -unsigned short *p = (unsigned short *) vc->vc_pos; +unsigned short *p, *q = (unsigned short *)vc->vc_pos; -scr_memmovew (p + nr, p, vc->vc_cols - vc->vc_x); -scr_memsetw (p, vc->vc_video_erase_char, nr *2 ); + p = q + vc->vc_cols - nr - vc->vc_x; +while (--p >= q) +scr_writew (scr_readw (p), p + nr); +scr_memsetw (q, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ; -if (DO_UPDATE (vc)) -do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 +1 ); +if (DO_UPDATE (vc)) { +unsigned short oldattr = vc->vc_attr; + vc->vc_sw->con_bmove (vc, vc->vc_y, vc->vc_x, vc->vc_y, vc->vc_x + nr,1 , + vc->vc_cols - vc->vc_x - nr); + vc->vc_attr = vc->vc_video_erase_char >>8 ; +while (nr--) + vc->vc_sw->con_putc (vc, vc->vc_video_erase_char, vc->vc_y, vc->vc_x + nr); + vc->vc_attr = oldattr; + } }static void delete_char (struct vc_data *vc,unsigned int nr) { -unsigned short *p = (unsigned short *) vc->vc_pos; +unsigned int i = vc->vc_x; +unsigned short *p = (unsigned short *)vc->vc_pos; -scr_memcpyw (p, p + nr, vc->vc_cols - vc->vc_x - nr); -scr_memsetw (p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, - nr *2 ); +while (++i <= vc->vc_cols - nr) { +scr_writew (scr_readw (p+nr), p); + p++; + } +scr_memsetw (p, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ; -if (DO_UPDATE (vc)) -do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 ); +if (DO_UPDATE (vc)) { +unsigned short oldattr = vc->vc_attr; + vc->vc_sw->con_bmove (vc, vc->vc_y, vc->vc_x + nr, vc->vc_y, vc->vc_x,1 , + vc->vc_cols - vc->vc_x - nr); + vc->vc_attr = vc->vc_video_erase_char >>8 ; +while (nr--) + vc->vc_sw->con_putc (vc, vc->vc_video_erase_char, vc->vc_y, + vc->vc_cols -1 - nr); + vc->vc_attr = oldattr; + } }static int softcursor_original;
@@ -1154,26 +1172,45 @@ static void csi_J(struct vc_data *vc, int vpar)case 0 :/* erase from cursor to end of display */ count = (vc->vc_scr_end - vc->vc_pos) >>1 ; start = (unsigned short *)vc->vc_pos; +if (DO_UPDATE (vc)) { +/* do in two stages */ + vc->vc_sw->con_clear (vc, vc->vc_y, vc->vc_x,1 , + vc->vc_cols - vc->vc_x); + vc->vc_sw->con_clear (vc, vc->vc_y +1 ,0 , + vc->vc_rows - vc->vc_y -1 , + vc->vc_cols); + }break ;case 1 :/* erase from start to cursor */ count = ((vc->vc_pos - vc->vc_origin) >>1 ) +1 ; start = (unsigned short *)vc->vc_origin; +if (DO_UPDATE (vc)) { +/* do in two stages */ + vc->vc_sw->con_clear (vc,0 ,0 , vc->vc_y, + vc->vc_cols); + vc->vc_sw->con_clear (vc, vc->vc_y,0 ,1 , + vc->vc_x +1 ); + }break ;case 3 :/* erase scroll-back buffer (and whole display) */ scr_memsetw (vc->vc_screenbuf, vc->vc_video_erase_char, vc->vc_screenbuf_size >>1 );set_origin (vc); +if (CON_IS_VISIBLE (vc)) +update_screen (vc);/* fall through */ case 2 :/* erase whole display */ count = vc->vc_cols * vc->vc_rows; start = (unsigned short *)vc->vc_origin; +if (DO_UPDATE (vc)) + vc->vc_sw->con_clear (vc,0 ,0 , + vc->vc_rows, + vc->vc_cols);break ;default :return ; }scr_memsetw (start, vc->vc_video_erase_char,2 * count); -if (DO_UPDATE (vc)) -do_update_region (vc, (unsigned long ) start, count); vc->vc_need_wrap =0 ; }
@@ -1186,22 +1223,29 @@ static void csi_K(struct vc_data *vc, int vpar)case 0 :/* erase from cursor to end of line */ count = vc->vc_cols - vc->vc_x; start = (unsigned short *)vc->vc_pos; +if (DO_UPDATE (vc)) + vc->vc_sw->con_clear (vc, vc->vc_y, vc->vc_x,1 , + vc->vc_cols - vc->vc_x);break ;case 1 :/* erase from start of line to cursor */ start = (unsigned short *)(vc->vc_pos - (vc->vc_x <<1 )); count = vc->vc_x +1 ; +if (DO_UPDATE (vc)) + vc->vc_sw->con_clear (vc, vc->vc_y,0 ,1 , + vc->vc_x +1 );break ;case 2 :/* erase whole line */ start = (unsigned short *)(vc->vc_pos - (vc->vc_x <<1 )); count = vc->vc_cols; +if (DO_UPDATE (vc)) + vc->vc_sw->con_clear (vc, vc->vc_y,0 ,1 , + vc->vc_cols);break ;default :return ; }scr_memsetw (start, vc->vc_video_erase_char,2 * count); vc->vc_need_wrap =0 ; -if (DO_UPDATE (vc)) -do_update_region (vc, (unsigned long ) start, count); }static void csi_X (struct vc_data *vc,int vpar)/* erase the following vpar positions */
Signature · 1 line
1.8.0.283.gc57d856
Quoted 11 lines · On Mon, 19 Nov 2012 22:15:53 +0100 Krzysztof Mazur <[email protected]>…
That patch fixed the original issue, but I noticed another artifact (I tested only v3.7-rc6 after your fix, I didn't check if the same problems exists in v3.7).
After:
for ((i = 0; i < 40; i++)); do
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
done
echo -e -n "\x0d\x1b[2@"
Quoted 8 lines
(also generated by bash during command line editing, this time by CTRL-r
+ something)the first character on screen (first column and first row) is cleared.
I think it's too late for fixing it in 3.7 and it's better, like Alan proposed, to just revert it for now.
Thanks for testing. This time, the fix was easy.
But anyway, as it seems that my patch fixes only the Cubox machine and as we are still using a kernel 3.5 with specific patches, the fix may be delayed.
--->8 ---
drivers/tty/vt/vt.c +4 -4
@@ -539,25 +539,25 @@ {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memmovew (p + nr, p, vc->vc_cols - vc->vc_x); +scr_memmovew (p + nr, p, (vc->vc_cols - vc->vc_x) *2 );scr_memsetw (p, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 +1 ); + vc->vc_cols - vc->vc_x); }static void delete_char (struct vc_data *vc,unsigned int nr) {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memcpyw (p, p + nr, vc->vc_cols - vc->vc_x - nr); +scr_memcpyw (p, p + nr, (vc->vc_cols - vc->vc_x - nr) *2 );scr_memsetw (p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 ); + vc->vc_cols - vc->vc_x); }static int softcursor_original;
Signature · 2 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/
Krzysztof Mazur
Tested-byQuoted 29 lines · Jean-Francois Moine
Thanks for testing. This time, the fix was easy.
But anyway, as it seems that my patch fixes only the Cubox machine and as we are still using a kernel 3.5 with specific patches, the fix may be delayed.
--->8 ---
drivers/tty/vt/vt.c +3
-3@@ -539,25 +539,25 @@ {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memmovew (p + nr, p, vc->vc_cols - vc->vc_x); +scr_memmovew (p + nr, p, (vc->vc_cols - vc->vc_x) *2 );scr_memsetw (p, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 +1 ); + vc->vc_cols - vc->vc_x); }static void delete_char (struct vc_data *vc,unsigned int nr) {unsigned short *p = (unsigned short *) vc->vc_pos; -scr_memcpyw (p, p + nr, vc->vc_cols - vc->vc_x - nr); +scr_memcpyw (p, p + nr, (vc->vc_cols - vc->vc_x - nr) *2 );
drivers/tty/vt/vt.c line 563
Quoted 10 lines
drivers/tty/vt/vt.c +1
-1scr_memsetw (p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, nr *2 ); vc->vc_need_wrap =0 ;if (DO_UPDATE (vc))do_update_region (vc, (unsigned long ) p, - (vc->vc_cols - vc->vc_x) /2 ); + vc->vc_cols - vc->vc_x); }static int softcursor_original;
Thanks,
Krzysiek