From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221037; b=POZWlnLZCB3amHISMQWR+9ruNAwNZkJNMMgIhbPQueUhpWI2BpS44kf4ul8SiXBbyE9q aawnWz9aBoKE/NOTdIpjesy9JdrxiOHzBWyr5dHDaG4tl1zIqWKLEpaMX7HjQ6H1nW0ch kcuV/XBaUMm9YCj1uEJy4U8OwlAVftxMYURffi3Tce/sIzmIXUGvDCpI21z8JIf/rZy9/ zvNmkOAoVGsgWl/5NLm8KHZYYdUOI9/3RXRNGOIOx+08bD3ZY+rZ8xnQ5x7oBjhTKz4hN D/CewIW/dOKReoXT/pZito848LrXB9u2UzuPbWqmMy5SATQwu6P7S9dGle4FFxkMueQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221037; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=E0HhVJL+K8o92ainopsf35fOhWpvN75aPj34v6IvpS8=; b=f+8gRS3YABXVy2h0sXA/4FwssTp3iKncscB+8ejws9WfvMSE/GXzqg/L2kjXji2kr2ew xYmnjuuicsOCKUyfM5hFoGqfCwzIQl4OdmgFmK99ICj267+3LlsOR68oCRGEekGAHFL1v faORKT8/DXu6fC17nFBm7+vOhfIxTSkrLJ6m+ZBi95Nkg/PUWRkvvAwN4UyZG5okyQ1Gp jOKok8jjt6yc5DVtY3CvCeQlOzMOAZMWTltw1sSS4SzrTQ6qDwZn/JWE9YqEEUxMHOemh r9xpZM5Vy7VTS0THpAtg8jqY2bROKbbahRoAjIgwP8hIeLAYLjhsgSlgf7GvqUPuyTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fgh1z6AL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53469606A69B for ; Wed, 2 Dec 2026 14:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fgh1z6AL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CAAC1F00927; Wed, 2 Dec 2026 14:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221037; bh=E0HhVJL+K8o92ainopsf35fOhWpvN75aPj34v6IvpS8=; h=Subject:To:Cc:From:Date; b=fgh1z6ALp99YMZBk7F7AxMLqcVFoZQhqdh0n/T0QLhs3xfW7qdFfDU9v5cgYnfk8c 3bEuKY5mldv03W6JHUqjQYlkSYk6ZyDYVJNadkL4KVTi0yFYM2QxQmXYRtuP+OnhMc xsFyFM53JqhDQ7/BQ+t2JvFOzMMtNMeaS2ZSCIw8= Subject: FAILED: patch "[PATCH] fbcon: Avoid cancel_delayed_work_sync() in atomic context" failed to apply to 6.12-stable tree To: yaoyiqi3@huawei.com,deller@gmx.de Cc: From: Date: Wed, 02 Dec 2026 14:00:58 +0100 Message-ID: <2026120258-dropbox-wasabi-d35b@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x b3a3f241dace3d4a775e1401b53a3f6d304534f0 # git commit -s git send-email --to '' --in-reply-to '2026120258-dropbox-wasabi-d35b@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From b3a3f241dace3d4a775e1401b53a3f6d304534f0 Mon Sep 17 00:00:00 2001 From: Yao Yiqi Date: Tue, 10 Nov 2026 21:59:59 +0800 Subject: [PATCH] fbcon: Avoid cancel_delayed_work_sync() in atomic context fbcon_cursor() can be reached from the console printing path, which runs in atomic context. When the VT software cursor is enabled (vc_cursor_type & CUR_SW), it calls fbcon_del_cursor_work(), which uses cancel_delayed_work_sync() and therefore may sleep. With CONFIG_DEBUG_ATOMIC_SLEEP enabled, the following is reported: BUG: sleeping function called from invalid context at kernel/workqueue.c:4722 in_atomic(): 1, irqs_disabled(): 1, non_block: 0 ... __cancel_work_sync fbcon_del_cursor_work fbcon_cursor hide_cursor vt_console_print console_unlock ... Make the default helper safe: fbcon_del_cursor_work() only stops blinking, using cancel_delayed_work(), which is allowed in any context. Every "stop blinking" call site keeps using it, including fbcon_cursor(). Only fbcon_release(), which is about to free @par and must ensure that no callback is still using it, calls the separate fbcon_del_cursor_work_sync(). New call sites therefore get the safe variant by default. cancel_delayed_work() does not wait for a callback that is already running. Since fb_flashcursor() re-arms itself, a callback that has already been dequeued by process_one_work() can queue the work again after fbcon_del_cursor_work() returns. Add a cursor_blink_on flag to struct fbcon_par: fbcon_add_cursor_work() sets it, fbcon_del_cursor_work() clears it, and fb_flashcursor() checks it after taking console_lock and returns without drawing or re-arming once blinking has been stopped. Keep the requeue inside the console_lock section so that the flag check and the requeue are not split by a concurrent stop. Fixes: 3b0fb6ab25dd ("fbcon: Use delayed work for cursor") Cc: stable@vger.kernel.org Assisted-by: Opencode:deepseek-v4.1-flash Signed-off-by: Yao Yiqi Signed-off-by: Helge Deller diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 7720dfc80c16..d7890e119dc7 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -410,7 +410,8 @@ static void fb_flashcursor(struct work_struct *work) if (par->currcon != -1) vc = vc_cons[par->currcon].d; - if (!vc || !con_is_visible(vc) || + if (!par->cursor_blink_on || + !vc || !con_is_visible(vc) || fbcon_info_from_console(vc->vc_num) != info || vc->vc_deccm != 1) { console_unlock(); @@ -422,25 +423,53 @@ static void fb_flashcursor(struct work_struct *work) par->bitops->cursor(vc, info, enable, get_fg_color(vc, info, c), get_bg_color(vc, info, c)); - console_unlock(); + /* + * Re-arm under console_lock so that a concurrent + * fbcon_del_cursor_work() cannot race with this requeue. + */ queue_delayed_work(system_power_efficient_wq, &par->cursor_work, par->cur_blink_jiffies); + console_unlock(); } static void fbcon_add_cursor_work(struct fb_info *info) { struct fbcon_par *par = info->fbcon_par; - if (fbcon_cursor_blink) - queue_delayed_work(system_power_efficient_wq, &par->cursor_work, - par->cur_blink_jiffies); + if (!fbcon_cursor_blink) + return; + + par->cursor_blink_on = true; + queue_delayed_work(system_power_efficient_wq, &par->cursor_work, + par->cur_blink_jiffies); } +/* + * Stop the cursor blink. + * + * Does not wait for a callback that is already running, so it is safe to + * call from any context. + * + * console_lock serializes this with the requeue in fb_flashcursor(); + * otherwise a running callback could re-arm the work. + */ static void fbcon_del_cursor_work(struct fb_info *info) { struct fbcon_par *par = info->fbcon_par; + par->cursor_blink_on = false; + cancel_delayed_work(&par->cursor_work); +} + +/* + * Stop the cursor blink and wait for a running callback to finish before + * @par is freed. May sleep, only for teardown paths. + */ +static void fbcon_del_cursor_work_sync(struct fb_info *info) +{ + struct fbcon_par *par = info->fbcon_par; + cancel_delayed_work_sync(&par->cursor_work); } @@ -765,7 +794,7 @@ static void fbcon_release(struct fb_info *info) if (info->fbcon_par) { struct fbcon_par *par = info->fbcon_par; - fbcon_del_cursor_work(info); + fbcon_del_cursor_work_sync(info); kfree(par->cursor_state.mask); kfree(par->cursor_data); kfree(par->cursor_src); diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h index d93a89877d04..6a2f7f6e5a8c 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -97,6 +97,7 @@ struct fbcon_par { int blank_state; int graphics; bool initialized; + bool cursor_blink_on; int rotate; char *cursor_data; #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION