| From 210a1ce8ed4391b64a888b3fb4b5611a13f5ccc7 Mon Sep 17 00:00:00 2001 |
| From: Finn Thain <fthain@linux-m68k.org> |
| Date: Fri, 28 Mar 2025 09:39:55 +1100 |
| Subject: m68k: Fix lost column on framebuffer debug console |
| |
| From: Finn Thain <fthain@linux-m68k.org> |
| |
| commit 210a1ce8ed4391b64a888b3fb4b5611a13f5ccc7 upstream. |
| |
| Move the cursor position rightward after rendering the character, |
| not before. This avoids complications that arise when the recursive |
| console_putc call has to wrap the line and/or scroll the display. |
| This also fixes the linewrap bug that crops off the rightmost column. |
| |
| When the cursor is at the bottom of the display, a linefeed will not |
| move the cursor position further downward. Instead, the display scrolls |
| upward. Avoid the repeated add/subtract sequence by way of a single |
| subtraction at the initialization of console_struct_num_rows. |
| |
| Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") |
| Cc: stable@vger.kernel.org |
| Signed-off-by: Finn Thain <fthain@linux-m68k.org> |
| Tested-by: Stan Johnson <userm57@yahoo.com> |
| Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> |
| Link: https://lore.kernel.org/9d4e8c68a456d5f2bc254ac6f87a472d066ebd5e.1743115195.git.fthain@linux-m68k.org |
| Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| arch/m68k/kernel/head.S | 31 +++++++++++++++++++++---------- |
| 1 file changed, 21 insertions(+), 10 deletions(-) |
| |
| --- a/arch/m68k/kernel/head.S |
| +++ b/arch/m68k/kernel/head.S |
| @@ -3404,6 +3404,7 @@ L(console_clear_loop): |
| |
| movel %d4,%d1 /* screen height in pixels */ |
| divul %a0@(FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */ |
| + subql #1,%d1 /* row range is 0 to num - 1 */ |
| |
| movel %d0,%a2@(Lconsole_struct_num_columns) |
| movel %d1,%a2@(Lconsole_struct_num_rows) |
| @@ -3550,15 +3551,14 @@ func_start console_putc,%a0/%a1/%d0-%d7 |
| cmpib #10,%d7 |
| jne L(console_not_lf) |
| movel %a0@(Lconsole_struct_cur_row),%d0 |
| - addil #1,%d0 |
| - movel %d0,%a0@(Lconsole_struct_cur_row) |
| movel %a0@(Lconsole_struct_num_rows),%d1 |
| cmpl %d1,%d0 |
| jcs 1f |
| - subil #1,%d0 |
| - movel %d0,%a0@(Lconsole_struct_cur_row) |
| console_scroll |
| + jra L(console_exit) |
| 1: |
| + addql #1,%d0 |
| + movel %d0,%a0@(Lconsole_struct_cur_row) |
| jra L(console_exit) |
| |
| L(console_not_lf): |
| @@ -3585,12 +3585,6 @@ L(console_not_cr): |
| */ |
| L(console_not_home): |
| movel %a0@(Lconsole_struct_cur_column),%d0 |
| - addql #1,%a0@(Lconsole_struct_cur_column) |
| - movel %a0@(Lconsole_struct_num_columns),%d1 |
| - cmpl %d1,%d0 |
| - jcs 1f |
| - console_putc #'\n' /* recursion is OK! */ |
| -1: |
| movel %a0@(Lconsole_struct_cur_row),%d1 |
| |
| /* |
| @@ -3637,6 +3631,23 @@ L(console_do_font_scanline): |
| addq #1,%d1 |
| dbra %d7,L(console_read_char_scanline) |
| |
| + /* |
| + * Register usage in the code below: |
| + * a0 = pointer to console globals |
| + * d0 = cursor column |
| + * d1 = cursor column limit |
| + */ |
| + |
| + lea %pc@(L(console_globals)),%a0 |
| + |
| + movel %a0@(Lconsole_struct_cur_column),%d0 |
| + addql #1,%d0 |
| + movel %d0,%a0@(Lconsole_struct_cur_column) /* Update cursor pos */ |
| + movel %a0@(Lconsole_struct_num_columns),%d1 |
| + cmpl %d1,%d0 |
| + jcs L(console_exit) |
| + console_putc #'\n' /* Line wrap using tail recursion */ |
| + |
| L(console_exit): |
| func_return console_putc |
| |