# \[PATCH\] fbcon: Avoid deleting a timer in IRQ context

- Subsystems: FRAMEBUFFER LAYER, CONSOLE SUBSYSTEM, THE REST
- Maintainers: Helge Deller, Greg Kroah-Hartman, Linus Torvalds
- Status: REVIEWED · 2 reviews, 0 by maintainers (Kevin Hilman Scot Doyle)
- Reviewed.
- 2 review trailers.
- List: linux-fbdev
- 4 messages, 3 authors
- Page: https://ratatoskr.run/linux-fbdev/2015/05/4499082/t

## \[PATCH\] fbcon: Avoid deleting a timer in IRQ context

- From: Thierry Reding \<hidden\>
- Date: 2015-05-21 07:58:09 
- Message: https://ratatoskr.run/linux-fbdev/2015/05/4499082.md

```text
From: Thierry Reding <redacted>

Commit 27a4c827c34a ("fbcon: use the cursor blink interval provided by
vt") unconditionally removes the cursor blink timer. Unfortunately that
wreaks havoc under some circumstances. An easily reproducible way is to
use both the framebuffer console and a debug serial port as the console
output for kernel messages (e.g. "console=ttyS0 console=tty1" on the
kernel command-line. Upon boot this triggers a warning from within the
del_timer_sync() function because it is called from IRQ context:

	[    5.070096] ------------[ cut here ]------------
	[    5.070110] WARNING: CPU: 0 PID: 0 at ../kernel/time/timer.c:1098 del_timer_sync+0x4c/0x54()
	[    5.070115] Modules linked in:
	[    5.070120] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.0-rc4-next-20150519 #1
	[    5.070123] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
	[    5.070142] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
	[    5.070156] [] (show_stack) from [] (dump_stack+0x70/0xbc)
	[    5.070164] [] (dump_stack) from [] (warn_slowpath_common+0x74/0xb0)
	[    5.070169] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
	[    5.070174] [] (warn_slowpath_null) from [] (del_timer_sync+0x4c/0x54)
	[    5.070183] [] (del_timer_sync) from [] (fbcon_del_cursor_timer+0x2c/0x40)
	[    5.070190] [] (fbcon_del_cursor_timer) from [] (fbcon_cursor+0x9c/0x180)
	[    5.070198] [] (fbcon_cursor) from [] (hide_cursor+0x30/0x98)
	[    5.070204] [] (hide_cursor) from [] (vt_console_print+0x2a8/0x340)
	[    5.070212] [] (vt_console_print) from [] (call_console_drivers.constprop.23+0xc8/0xec)
	[    5.070218] [] (call_console_drivers.constprop.23) from [] (console_unlock+0x498/0x4f0)
	[    5.070223] [] (console_unlock) from [] (vprintk_emit+0x1f0/0x508)
	[    5.070228] [] (vprintk_emit) from [] (vprintk_default+0x24/0x2c)
	[    5.070234] [] (vprintk_default) from [] (printk+0x70/0x88)

After which the system starts spewing all kinds of weird and seemingly
unrelated error messages.

This commit fixes this by restoring the condition under which the call
to fbcon_del_cursor_timer() happens.

Reported-by: Daniel Stone <redacted>
Reported-by: Kevin Hilman <khilman@kernel.org>
Tested-by: Kevin Hilman <redacted>
Tested-by: Scot Doyle <redacted>
Signed-off-by: Thierry Reding <redacted>
---
 drivers/video/console/fbcon.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 05b1d1a71ef9..658c34bb9076 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1310,8 +1310,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode)
 		return;
 
 	ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
-	fbcon_del_cursor_timer(info);
-	if (!(vc->vc_cursor_type & 0x10))
+	if (vc->vc_cursor_type & 0x10)
+		fbcon_del_cursor_timer(info);
+	else
 		fbcon_add_cursor_timer(info);
 
 	ops->cursor_flash = (mode = CM_ERASE) ? 0 : 1;
-- 
2.4.1

```

## Re: \[PATCH\] fbcon: Avoid deleting a timer in IRQ context

- From: Andrey Wagin \<hidden\>
- Date: 2015-05-27 11:19:07 
- Message: https://ratatoskr.run/linux-fbdev/2015/05/4503039.md

```text
2015-05-21 10:58 GMT+03:00 Thierry Reding [ref]:
> From: Thierry Reding <redacted>
>
> Commit 27a4c827c34a ("fbcon: use the cursor blink interval provided by
> vt") unconditionally removes the cursor blink timer. Unfortunately that
> wreaks havoc under some circumstances. An easily reproducible way is to
> use both the framebuffer console and a debug serial port as the console
> output for kernel messages (e.g. "console=ttyS0 console=tty1" on the
> kernel command-line. Upon boot this triggers a warning from within the
> del_timer_sync() function because it is called from IRQ context:
>
>         [    5.070096] ------------[ cut here ]------------
>         [    5.070110] WARNING: CPU: 0 PID: 0 at ../kernel/time/timer.c:1098 del_timer_sync+0x4c/0x54()
>         [    5.070115] Modules linked in:
>         [    5.070120] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.0-rc4-next-20150519 #1
>         [    5.070123] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
>         [    5.070142] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
>         [    5.070156] [] (show_stack) from [] (dump_stack+0x70/0xbc)
>         [    5.070164] [] (dump_stack) from [] (warn_slowpath_common+0x74/0xb0)
>         [    5.070169] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
>         [    5.070174] [] (warn_slowpath_null) from [] (del_timer_sync+0x4c/0x54)
>         [    5.070183] [] (del_timer_sync) from [] (fbcon_del_cursor_timer+0x2c/0x40)
>         [    5.070190] [] (fbcon_del_cursor_timer) from [] (fbcon_cursor+0x9c/0x180)
>         [    5.070198] [] (fbcon_cursor) from [] (hide_cursor+0x30/0x98)
>         [    5.070204] [] (hide_cursor) from [] (vt_console_print+0x2a8/0x340)
>         [    5.070212] [] (vt_console_print) from [] (call_console_drivers.constprop.23+0xc8/0xec)
>         [    5.070218] [] (call_console_drivers.constprop.23) from [] (console_unlock+0x498/0x4f0)
>         [    5.070223] [] (console_unlock) from [] (vprintk_emit+0x1f0/0x508)
>         [    5.070228] [] (vprintk_emit) from [] (vprintk_default+0x24/0x2c)
>         [    5.070234] [] (vprintk_default) from [] (printk+0x70/0x88)
>
> After which the system starts spewing all kinds of weird and seemingly
> unrelated error messages.
>
> This commit fixes this by restoring the condition under which the call
> to fbcon_del_cursor_timer() happens.

Tested-by: Andrew Vagin <redacted>

It would be good to push this patch into linux-next asap. Without this
patch I can't execute tests on linux-next. Thanks.

>
> Reported-by: Daniel Stone <redacted>
> Reported-by: Kevin Hilman <khilman@kernel.org>
> Tested-by: Kevin Hilman <redacted>
> Tested-by: Scot Doyle <redacted>
> Signed-off-by: Thierry Reding <redacted>
> ---
>  drivers/video/console/fbcon.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index 05b1d1a71ef9..658c34bb9076 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -1310,8 +1310,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode)
>                 return;
>
>         ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
> -       fbcon_del_cursor_timer(info);
> -       if (!(vc->vc_cursor_type & 0x10))
> +       if (vc->vc_cursor_type & 0x10)
> +               fbcon_del_cursor_timer(info);
> +       else
>                 fbcon_add_cursor_timer(info);
>
>         ops->cursor_flash = (mode = CM_ERASE) ? 0 : 1;
> --
> 2.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
```

## Re: \[PATCH\] fbcon: Avoid deleting a timer in IRQ context

- From: Tomeu Vizoso \<hidden\>
- Date: 2015-05-27 12:10:28 
- Message: https://ratatoskr.run/linux-fbdev/2015/05/4503072.md

```text
On 27 May 2015 at 13:19, Andrey Wagin [ref] wrote:
> 2015-05-21 10:58 GMT+03:00 Thierry Reding [ref]:
>> From: Thierry Reding <redacted>
>>
>> Commit 27a4c827c34a ("fbcon: use the cursor blink interval provided by
>> vt") unconditionally removes the cursor blink timer. Unfortunately that
>> wreaks havoc under some circumstances. An easily reproducible way is to
>> use both the framebuffer console and a debug serial port as the console
>> output for kernel messages (e.g. "console=ttyS0 console=tty1" on the
>> kernel command-line. Upon boot this triggers a warning from within the
>> del_timer_sync() function because it is called from IRQ context:
>>
>>         [    5.070096] ------------[ cut here ]------------
>>         [    5.070110] WARNING: CPU: 0 PID: 0 at ../kernel/time/timer.c:1098 del_timer_sync+0x4c/0x54()
>>         [    5.070115] Modules linked in:
>>         [    5.070120] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.0-rc4-next-20150519 #1
>>         [    5.070123] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
>>         [    5.070142] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
>>         [    5.070156] [] (show_stack) from [] (dump_stack+0x70/0xbc)
>>         [    5.070164] [] (dump_stack) from [] (warn_slowpath_common+0x74/0xb0)
>>         [    5.070169] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
>>         [    5.070174] [] (warn_slowpath_null) from [] (del_timer_sync+0x4c/0x54)
>>         [    5.070183] [] (del_timer_sync) from [] (fbcon_del_cursor_timer+0x2c/0x40)
>>         [    5.070190] [] (fbcon_del_cursor_timer) from [] (fbcon_cursor+0x9c/0x180)
>>         [    5.070198] [] (fbcon_cursor) from [] (hide_cursor+0x30/0x98)
>>         [    5.070204] [] (hide_cursor) from [] (vt_console_print+0x2a8/0x340)
>>         [    5.070212] [] (vt_console_print) from [] (call_console_drivers.constprop.23+0xc8/0xec)
>>         [    5.070218] [] (call_console_drivers.constprop.23) from [] (console_unlock+0x498/0x4f0)
>>         [    5.070223] [] (console_unlock) from [] (vprintk_emit+0x1f0/0x508)
>>         [    5.070228] [] (vprintk_emit) from [] (vprintk_default+0x24/0x2c)
>>         [    5.070234] [] (vprintk_default) from [] (printk+0x70/0x88)
>>
>> After which the system starts spewing all kinds of weird and seemingly
>> unrelated error messages.
>>
>> This commit fixes this by restoring the condition under which the call
>> to fbcon_del_cursor_timer() happens.
>
> Tested-by: Andrew Vagin <redacted>
>
> It would be good to push this patch into linux-next asap. Without this
> patch I can't execute tests on linux-next. Thanks.

Tested-by: Tomeu Vizoso <redacted>

Same here, please apply.

Thanks,

Tomeu

>>
>> Reported-by: Daniel Stone <redacted>
>> Reported-by: Kevin Hilman <khilman@kernel.org>
>> Tested-by: Kevin Hilman <redacted>
>> Tested-by: Scot Doyle <redacted>
>> Signed-off-by: Thierry Reding <redacted>
>> ---
>>  drivers/video/console/fbcon.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
>> index 05b1d1a71ef9..658c34bb9076 100644
>> --- a/drivers/video/console/fbcon.c
>> +++ b/drivers/video/console/fbcon.c
>> @@ -1310,8 +1310,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode)
>>                 return;
>>
>>         ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
>> -       fbcon_del_cursor_timer(info);
>> -       if (!(vc->vc_cursor_type & 0x10))
>> +       if (vc->vc_cursor_type & 0x10)
>> +               fbcon_del_cursor_timer(info);
>> +       else
>>                 fbcon_add_cursor_timer(info);
>>
>>         ops->cursor_flash = (mode = CM_ERASE) ? 0 : 1;
>> --
>> 2.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
```

## Re: \[PATCH\] fbcon: Avoid deleting a timer in IRQ context

- From: Thierry Reding \<hidden\>
- Date: 2015-05-27 12:39:49 
- Message: https://ratatoskr.run/linux-fbdev/2015/05/4503093.md

```text
On Thu, May 21, 2015 at 09:58:03AM +0200, Thierry Reding wrote:
> From: Thierry Reding <redacted>
> 
> Commit 27a4c827c34a ("fbcon: use the cursor blink interval provided by
> vt") unconditionally removes the cursor blink timer. Unfortunately that
> wreaks havoc under some circumstances. An easily reproducible way is to
> use both the framebuffer console and a debug serial port as the console
> output for kernel messages (e.g. "console=ttyS0 console=tty1" on the
> kernel command-line. Upon boot this triggers a warning from within the
> del_timer_sync() function because it is called from IRQ context:
> 
> 	[    5.070096] ------------[ cut here ]------------
> 	[    5.070110] WARNING: CPU: 0 PID: 0 at ../kernel/time/timer.c:1098 del_timer_sync+0x4c/0x54()
> 	[    5.070115] Modules linked in:
> 	[    5.070120] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.0-rc4-next-20150519 #1
> 	[    5.070123] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
> 	[    5.070142] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
> 	[    5.070156] [] (show_stack) from [] (dump_stack+0x70/0xbc)
> 	[    5.070164] [] (dump_stack) from [] (warn_slowpath_common+0x74/0xb0)
> 	[    5.070169] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
> 	[    5.070174] [] (warn_slowpath_null) from [] (del_timer_sync+0x4c/0x54)
> 	[    5.070183] [] (del_timer_sync) from [] (fbcon_del_cursor_timer+0x2c/0x40)
> 	[    5.070190] [] (fbcon_del_cursor_timer) from [] (fbcon_cursor+0x9c/0x180)
> 	[    5.070198] [] (fbcon_cursor) from [] (hide_cursor+0x30/0x98)
> 	[    5.070204] [] (hide_cursor) from [] (vt_console_print+0x2a8/0x340)
> 	[    5.070212] [] (vt_console_print) from [] (call_console_drivers.constprop.23+0xc8/0xec)
> 	[    5.070218] [] (call_console_drivers.constprop.23) from [] (console_unlock+0x498/0x4f0)
> 	[    5.070223] [] (console_unlock) from [] (vprintk_emit+0x1f0/0x508)
> 	[    5.070228] [] (vprintk_emit) from [] (vprintk_default+0x24/0x2c)
> 	[    5.070234] [] (vprintk_default) from [] (printk+0x70/0x88)
> 
> After which the system starts spewing all kinds of weird and seemingly
> unrelated error messages.
> 
> This commit fixes this by restoring the condition under which the call
> to fbcon_del_cursor_timer() happens.
> 
> Reported-by: Daniel Stone <redacted>
> Reported-by: Kevin Hilman <khilman@kernel.org>
> Tested-by: Kevin Hilman <redacted>
> Tested-by: Scot Doyle <redacted>
> Signed-off-by: Thierry Reding <redacted>
> ---
>  drivers/video/console/fbcon.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Ping? This is an important fix, can we get this into linux-next sometime
soon?

Thierry

> 
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index 05b1d1a71ef9..658c34bb9076 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -1310,8 +1310,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode)
>  		return;
>  
>  	ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
> -	fbcon_del_cursor_timer(info);
> -	if (!(vc->vc_cursor_type & 0x10))
> +	if (vc->vc_cursor_type & 0x10)
> +		fbcon_del_cursor_timer(info);
> +	else
>  		fbcon_add_cursor_timer(info);
>  
>  	ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
> -- 
> 2.4.1
> 
```
