From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB6D9C433F5 for ; Mon, 31 Jan 2022 21:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379646AbiAaVGm (ORCPT ); Mon, 31 Jan 2022 16:06:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356610AbiAaVGh (ORCPT ); Mon, 31 Jan 2022 16:06:37 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3554EC06173B for ; Mon, 31 Jan 2022 13:06:37 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id k18so27930838wrg.11 for ; Mon, 31 Jan 2022 13:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5jm2tqChG+6Cl2msdB52h1xzbJ+oW9+NC/C42g3ib0k=; b=V36rEEp+ouYAUNQ82bxdkn5P3ZwQiqH7dskiUsOLGI+nChuOAiU1LKuyDpurK3LEf0 e5/Y8vrIorBlvVcS6pRAaIymj3OXuaa5pr3tcxbawteVa54wRbCrtFTofJ/mCLnXSLJY 8YIDLEgovB750ZktGu8IC9tQWaJXDtpdUOZFA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5jm2tqChG+6Cl2msdB52h1xzbJ+oW9+NC/C42g3ib0k=; b=4rYi8uXOMpH3Sf7ImpwwDMATE3z2DJvGW3hOMhFGi1AHxV8iR6dfXh46eXqubAaHZT JCqFXLMuvILthh51quNZMrNWncV1lN318JDoQXrdJar23vPrXX6UMg16MtrV802T8W5d GUAnykA+dDGLiZr4+Fl/T81gCuncpoDzzAOmEuw6qm6gENb0cdFwHp0mQzentitLx3zx HIXhUlGdhpUVhYMmmDlYXmR7lbYmjhPpX2Mbelq98bgRzc/tLTRyp+eiJkw7D9vRHksW 6Vdq/xOh7WMGKv5ik4OwKmFwntk089PA3fX9U7Y1pR6ck7/iq0WbFfkeP+21BI7iFiZS wPHQ== X-Gm-Message-State: AOAM532qTn9NNjGIkrIS/1ugKc/e0B4jVSZ/Pr7S3kE1bgyTmkXHNnk5 0INdfETbqOrMlmFmGfJtdwtygQ== X-Google-Smtp-Source: ABdhPJzE6MxfkQjvT5nGD4ugcetBmrXO6zOc6yI6XQCT4PSLXqTsNaSQryY0J+V6FA5cpi73SBd1Dg== X-Received: by 2002:a5d:64ad:: with SMTP id m13mr19468526wrp.671.1643663195774; Mon, 31 Jan 2022 13:06:35 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:35 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Dave Airlie , Jani Nikula , Linus Torvalds , Pavel Machek , Sam Ravnborg , Greg Kroah-Hartman , Javier Martinez Canillas , Claudio Suarez , Tomi Valkeinen , Geert Uytterhoeven , Thomas Zimmermann , Daniel Vetter , Sven Schnelle , Gerd Hoffmann Subject: [PATCH 01/21] MAINTAINERS: Add entry for fbdev core Date: Mon, 31 Jan 2022 22:05:32 +0100 Message-Id: <20220131210552.482606-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Ever since Tomi extracted the core code in 2014 it's been defacto me maintaining this, with help from others from dri-devel and sometimes Linus (but those are mostly merge conflicts): $ git shortlog -ns drivers/video/fbdev/core/ | head -n5 35 Daniel Vetter 23 Linus Torvalds 10 Hans de Goede 9 Dave Airlie 6 Peter Rosin I think ideally we'd also record that the various firmware fb drivers (efifb, vesafb, ...) are also maintained in drm-misc because for the past few years the patches have either been to fix handover issues with drm drivers, or caused handover issues with drm drivers. So any other tree just doesn't make sense. But also, there's plenty of outdated MAINTAINER entries for these with people and git trees that haven't been active in years, so maybe let's just leave them alone. And furthermore distros are now adopting simpledrm as the firmware fb driver, so hopefully the need to care about the fbdev firmware drivers will go down going forward. Note that drm-misc is group maintained, I expect that to continue like we've done before, so no new expectations that patches all go through my hands. That would be silly. This also means I'm happy to put any other volunteer's name in the M: line, but otherwise git log says I'm the one who's stuck with this. Cc: Dave Airlie Cc: Jani Nikula Cc: Linus Torvalds Cc: Linux Fbdev development list Cc: Pavel Machek Cc: Sam Ravnborg Cc: Greg Kroah-Hartman Cc: Javier Martinez Canillas Cc: DRI Development Cc: Linux Kernel Mailing List Cc: Claudio Suarez Cc: Tomi Valkeinen Cc: Geert Uytterhoeven Cc: Thomas Zimmermann Cc: Daniel Vetter Cc: Sven Schnelle Cc: Gerd Hoffmann Signed-off-by: Daniel Vetter Acked-by: Alex Deucher Acked-by: Daniel Stone Acked-by: Dave Airlie Acked-by: Geert Uytterhoeven Acked-by: Helge Deller Acked-by: Jani Nikula Acked-by: Maxime Ripard Acked-by: Sam Ravnborg Acked-by: Thomas Zimmermann Acked-by: Tomi Valkeinen Reviewed-by: Javier Martinez Canillas --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ea3e6c914384..49809eaa3096 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7573,6 +7573,12 @@ S: Maintained W: http://floatingpoint.sourceforge.net/emulator/index.html F: arch/x86/math-emu/ =20 +FRAMEBUFFER CORE +M: Daniel Vetter +F: drivers/video/fbdev/core/ +S: Odd Fixes +T: git git://anongit.freedesktop.org/drm/drm-misc + FRAMEBUFFER LAYER M: Helge Deller L: linux-fbdev@vger.kernel.org --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25C19C433FE for ; Mon, 31 Jan 2022 21:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379615AbiAaVGt (ORCPT ); Mon, 31 Jan 2022 16:06:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379564AbiAaVGj (ORCPT ); Mon, 31 Jan 2022 16:06:39 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D25C06173D for ; Mon, 31 Jan 2022 13:06:38 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id c23so27902925wrb.5 for ; Mon, 31 Jan 2022 13:06:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9fqlEl5FrV6kXAQC/GZqlLwA2XdAQw5mGx02dUfQyG8=; b=VVhyGNyp2pNzByagiAchpIT0TdYXQJYBqI6Tj+98mGiUnBiYlrikTw1HMgQurEBYgJ k7OFmH40lEG4+klF8jn739hTAlJJuI02RekLiRa4mJzUuWA4nG+TJ1CDh7NoB2CDbrFl lZ3Dfl5UkvYNoa0R8IdO/bpfKd+FzZ8+pTmvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9fqlEl5FrV6kXAQC/GZqlLwA2XdAQw5mGx02dUfQyG8=; b=GfD1OsgxQbqfjK2Cm+EZu/qSoxiBk+VXbvwmz8Gjjx8mF0EFfmybGv7mJTd6djEK1O l5i5IMCIVpld2x6OWFRTxlOsoJI4ExMid5nzyCSMQDDSicLJ1DJrC03st6dvYKHSWiLY YqhhAU6InO78H0RMhbY7MqJJoKuSIw8OXscSB77TCO6UC7aRVtObBsygqpMKwbQ5nqev Zvt3C1j55GYBk338SjcETF/Vvr/oVhyuDH/bbxPvqViwi5N7g8YL7mRQr8j6aOBtONLc HlDbZXmX8FVsy3cZENeKCkuwScHMZRkADSTgolb6RFFAVAMm0cNhjAUL9N0kLJK8t8yp zLBg== X-Gm-Message-State: AOAM533HsGmviOhwCaC1/qza8cqMV4MMJVrWlJnh3eLIhN5savW0UPeN Lv2aDCwBxKu3IWNmUVNvB6XoBA== X-Google-Smtp-Source: ABdhPJwhhRMCDydJRHK91UdopQ+RbUoVBpBpykMV1ybTBNYtKvX6zza63AUoOvl1/pJlEVkeQlw0Jg== X-Received: by 2002:a05:6000:1ac8:: with SMTP id i8mr19547319wry.542.1643663196898; Mon, 31 Jan 2022 13:06:36 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:36 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Claudio Suarez , stable@vger.kernel.org, Dave Airlie , Jani Nikula , Linus Torvalds , Pavel Machek , Sam Ravnborg , Greg Kroah-Hartman , Javier Martinez Canillas , Tomi Valkeinen , Geert Uytterhoeven , Thomas Zimmermann , Daniel Vetter , Sven Schnelle , Gerd Hoffmann Subject: [PATCH 02/21] fbcon: Resurrect fbcon accelerated scrolling code Date: Mon, 31 Jan 2022 22:05:33 +0100 Message-Id: <20220131210552.482606-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This reverts commit b3ec8cdf457e ("fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)"), but with a twist: Because distros like fedora&suse (probably more) really want to move away from fbcon as much as possible, and don't have a need for fancy accelerated fbcon even less, hide the code behind an option. There's also been noises about resurrecting the scrollback code and other pieces, so there's plenty of need for such an option it seems. Compared to direct revert I did move functions around a bit so they're all in one block, to minimize the number of #ifdef. I also tried to stuff this all into a separate file, but that didn't really look much better. I also considered duplicating fbcon_scroll() since that's a bit meh now, but again didn't seem worth the trouble. Maybe when we resurect more code. And finally to shut up unused parameter warnings warnings the macros became static inline. References: https://lore.kernel.org/dri-devel/feea8303-2b83-fc36-972c-4fc8a= d723bde@gmx.de/ Fixes: b3ec8cdf457e ("fbdev: Garbage collect fbdev scrolling acceleration, = part 1 (from TODO list)") Cc: Claudio Suarez Cc: # v5.16+ Cc: Dave Airlie Cc: Jani Nikula Cc: Linus Torvalds Cc: Linux Fbdev development list Cc: Pavel Machek Cc: Sam Ravnborg Cc: Greg Kroah-Hartman Cc: Javier Martinez Canillas Cc: DRI Development Cc: Linux Kernel Mailing List Cc: Claudio Suarez Cc: Tomi Valkeinen Cc: Geert Uytterhoeven Cc: Thomas Zimmermann Cc: Daniel Vetter Cc: Sven Schnelle Cc: Gerd Hoffmann Signed-off-by: Daniel Vetter --- Documentation/gpu/todo.rst | 13 +- drivers/video/console/Kconfig | 11 + drivers/video/fbdev/core/bitblit.c | 16 + drivers/video/fbdev/core/fbcon.c | 491 +++++++++++++++++++++++- drivers/video/fbdev/core/fbcon.h | 59 +++ drivers/video/fbdev/core/fbcon_ccw.c | 28 +- drivers/video/fbdev/core/fbcon_cw.c | 28 +- drivers/video/fbdev/core/fbcon_rotate.h | 21 + drivers/video/fbdev/core/fbcon_ud.c | 37 +- drivers/video/fbdev/core/tileblit.c | 16 + drivers/video/fbdev/skeletonfb.c | 12 +- include/linux/fb.h | 2 +- 12 files changed, 701 insertions(+), 33 deletions(-) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index da138dd39883..29506815d24a 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -303,19 +303,16 @@ Level: Advanced Garbage collect fbdev scrolling acceleration -------------------------------------------- =20 -Scroll acceleration has been disabled in fbcon. Now it works as the old -SCROLL_REDRAW mode. A ton of code was removed in fbcon.c and the hook bmov= e was -removed from fbcon_ops. -Remaining tasks: +Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =3D +SCROLL_REDRAW. There's a ton of code this will allow us to remove: =20 -- a bunch of the hooks in fbcon_ops could be removed or simplified by call= ing +- lots of code in fbcon.c + +- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be ca= lled directly instead of the function table (with a switch on p->rotate) =20 - fb_copyarea is unused after this, and can be deleted from all drivers =20 -- after that, fb_copyarea can be deleted from fb_ops in include/linux/fb.h= as - well as cfb_copyarea - Note that not all acceleration code can be deleted, since clearing and cur= sor support is still accelerated, which might be good candidates for further deletion projects. diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 840d9813b0bc..f83f5c755084 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -78,6 +78,17 @@ config FRAMEBUFFER_CONSOLE help Low-level framebuffer-based console driver. =20 +config FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + bool "Enable legacy fbcon code for hw acceleration" + depends on FRAMEBUFFER_CONSOLE + default n + help + Only enable this options if you are in full control of machine since + the fbcon acceleration code is essentially unmaintained and known + problematic. + + If unsure, select n. + config FRAMEBUFFER_CONSOLE_DETECT_PRIMARY bool "Map the console to the primary display device" depends on FRAMEBUFFER_CONSOLE diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/= bitblit.c index 01fae2c96965..f98e8f298bc1 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -43,6 +43,21 @@ static void update_attr(u8 *dst, u8 *src, int attribute, } } =20 +static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fb_copyarea area; + + area.sx =3D sx * vc->vc_font.width; + area.sy =3D sy * vc->vc_font.height; + area.dx =3D dx * vc->vc_font.width; + area.dy =3D dy * vc->vc_font.height; + area.height =3D height * vc->vc_font.height; + area.width =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { @@ -378,6 +393,7 @@ static int bit_update_start(struct fb_info *info) =20 void fbcon_set_bitops(struct fbcon_ops *ops) { + ops->bmove =3D bit_bmove; ops->clear =3D bit_clear; ops->putcs =3D bit_putcs; ops->clear_margins =3D bit_clear_margins; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 99ecd9a6d844..2ff90061c7f3 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1125,6 +1125,14 @@ static void fbcon_init(struct vc_data *vc, int init) =20 ops->graphics =3D 0; =20 + /* + * No more hw acceleration for fbcon. + * + * FIXME: Garbage collect all the now dead code after sufficient time + * has passed. + */ + p->scrollmode =3D SCROLL_REDRAW; + /* * ++guenther: console.c:vc_allocate() relies on initializing * vc_{cols,rows}, but we must not set those if we are only @@ -1211,13 +1219,14 @@ static void fbcon_deinit(struct vc_data *vc) * This system is now divided into two levels because of complications * caused by hardware scrolling. Top level functions: * - * fbcon_clear(), fbcon_putc(), fbcon_clear_margins() + * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins() * * handles y values in range [0, scr_height-1] that correspond to real * screen positions. y_wrap shift means that first line of bitmap may be * anywhere on this display. These functions convert lineoffsets to * bitmap offsets and deal with the wrap-around case by splitting blits. * + * fbcon_bmove_physical_8() -- These functions fast implementations * fbcon_clear_physical_8() -- of original fbcon_XXX fns. * fbcon_putc_physical_8() -- (font width !=3D 8) may be added later * @@ -1390,6 +1399,291 @@ static void fbcon_set_disp(struct fb_info *info, st= ruct fb_var_screeninfo *var, } } =20 +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION +static void fbcon_redraw_move(struct vc_data *vc, struct fbcon_display *p, + int line, int count, int dy) +{ + unsigned short *s =3D (unsigned short *) + (vc->vc_origin + vc->vc_size_row * line); + + while (count--) { + unsigned short *start =3D s; + unsigned short *le =3D advance_row(s, 1); + unsigned short c; + int x =3D 0; + unsigned short attr =3D 1; + + do { + c =3D scr_readw(s); + if (attr !=3D (c & 0xff00)) { + attr =3D c & 0xff00; + if (s > start) { + fbcon_putcs(vc, start, s - start, + dy, x); + x +=3D s - start; + start =3D s; + } + } + console_conditional_schedule(); + s++; + } while (s < le); + if (s > start) + fbcon_putcs(vc, start, s - start, dy, x); + console_conditional_schedule(); + dy++; + } +} + +static __inline__ void ywrap_up(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll +=3D count; + if (p->yscroll >=3D p->vrows) /* Deal with wrap */ + p->yscroll -=3D p->vrows; + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode |=3D FB_VMODE_YWRAP; + ops->update_start(info); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ywrap_down(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll -=3D count; + if (p->yscroll < 0) /* Deal with wrap */ + p->yscroll +=3D p->vrows; + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode |=3D FB_VMODE_YWRAP; + ops->update_start(info); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static __inline__ void ypan_up(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + struct fbcon_ops *ops =3D info->fbcon_par; + + p->yscroll +=3D count; + if (p->yscroll > p->vrows - vc->vc_rows) { + ops->bmove(vc, info, p->vrows - vc->vc_rows, + 0, 0, 0, vc->vc_rows, vc->vc_cols); + p->yscroll -=3D p->vrows - vc->vc_rows; + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll +=3D count; + + if (p->yscroll > p->vrows - vc->vc_rows) { + p->yscroll -=3D p->vrows - vc->vc_rows; + fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t); + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max +=3D count; + if (scrollback_max > scrollback_phys_max) + scrollback_max =3D scrollback_phys_max; + scrollback_current =3D 0; +} + +static __inline__ void ypan_down(struct vc_data *vc, int count) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + struct fbcon_ops *ops =3D info->fbcon_par; + + p->yscroll -=3D count; + if (p->yscroll < 0) { + ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows, + 0, vc->vc_rows, vc->vc_cols); + p->yscroll +=3D p->vrows - vc->vc_rows; + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int cou= nt) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + p->yscroll -=3D count; + + if (p->yscroll < 0) { + p->yscroll +=3D p->vrows - vc->vc_rows; + fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count); + } + + ops->var.xoffset =3D 0; + ops->var.yoffset =3D p->yscroll * vc->vc_font.height; + ops->var.vmode &=3D ~FB_VMODE_YWRAP; + ops->update_start(info); + fbcon_clear_margins(vc, 1); + scrollback_max -=3D count; + if (scrollback_max < 0) + scrollback_max =3D 0; + scrollback_current =3D 0; +} + +static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, i= nt sy, int sx, + int dy, int dx, int height, int width, u_int y_break) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops =3D info->fbcon_par; + u_int b; + + if (sy < y_break && sy + height > y_break) { + b =3D y_break - sy; + if (dy < sy) { /* Avoid trashing self */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + } else { + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + } + return; + } + + if (dy < y_break && dy + height > y_break) { + b =3D y_break - dy; + if (dy < sy) { /* Avoid trashing self */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + } else { + fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, + height - b, width, y_break); + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, + y_break); + } + return; + } + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx, + height, width); +} + +static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, + int height, int width) +{ + struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + + if (fbcon_is_inactive(vc, info)) + return; + + if (!width || !height) + return; + + /* Split blits that cross physical y_wrap case. + * Pathological case involves 4 blits, better to use recursive + * code rather than unrolled case + * + * Recursive invocations don't need to erase the cursor over and + * over again, so we use fbcon_bmove_rec() + */ + fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width, + p->vrows - p->yscroll); +} + +static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info, + struct fbcon_display *p, int line, int count, int ycount) +{ + int offset =3D ycount * vc->vc_cols; + unsigned short *d =3D (unsigned short *) + (vc->vc_origin + vc->vc_size_row * line); + unsigned short *s =3D d + offset; + struct fbcon_ops *ops =3D info->fbcon_par; + + while (count--) { + unsigned short *start =3D s; + unsigned short *le =3D advance_row(s, 1); + unsigned short c; + int x =3D 0; + + do { + c =3D scr_readw(s); + + if (c =3D=3D scr_readw(d)) { + if (s > start) { + ops->bmove(vc, info, line + ycount, x, + line, x, 1, s-start); + x +=3D s - start + 1; + start =3D s + 1; + } else { + x++; + start++; + } + } + + scr_writew(c, d); + console_conditional_schedule(); + s++; + d++; + } while (s < le); + if (s > start) + ops->bmove(vc, info, line + ycount, x, line, x, 1, + s-start); + console_conditional_schedule(); + if (ycount > 0) + line++; + else { + line--; + /* NOTE: We subtract two lines from these pointers */ + s -=3D vc->vc_size_row; + d -=3D vc->vc_size_row; + } + } +} +#endif + static void fbcon_redraw(struct vc_data *vc, struct fbcon_display *p, int line, int count, int offset) { @@ -1450,6 +1744,9 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned= int t, unsigned int b, { struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; struct fbcon_display *p =3D &fb_display[vc->vc_num]; +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION + int scroll_partial =3D info->flags & FBINFO_PARTIAL_PAN_OK; +#endif =20 if (fbcon_is_inactive(vc, info)) return true; @@ -1466,6 +1763,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned= int t, unsigned int b, case SM_UP: if (count > vc->vc_rows) /* Maximum realistic size */ count =3D vc->vc_rows; +#ifndef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION fbcon_redraw(vc, p, t, b - t - count, count * vc->vc_cols); fbcon_clear(vc, b - count, 0, count, vc->vc_cols); @@ -1475,10 +1773,99 @@ static bool fbcon_scroll(struct vc_data *vc, unsign= ed int t, unsigned int b, vc->vc_video_erase_char, vc->vc_size_row * count); return true; +#else + if (logo_shown >=3D 0) + goto redraw_up; + switch (p->scrollmode) { + case SCROLL_MOVE: + fbcon_redraw_blit(vc, info, p, t, b - t - count, + count); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + (b - count)), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + + case SCROLL_WRAP_MOVE: + if (b - t - count > 3 * vc->vc_rows >> 2) { + if (t > 0) + fbcon_bmove(vc, 0, 0, count, 0, t, + vc->vc_cols); + ywrap_up(vc, count); + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b - count, 0, b, 0, + vc->vc_rows - b, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t + count, 0, t, 0, + b - t - count, vc->vc_cols); + else + goto redraw_up; + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_REDRAW: + if ((p->yscroll + count <=3D + 2 * (p->vrows - vc->vc_rows)) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (t > 0) + fbcon_redraw_move(vc, p, 0, t, count); + ypan_up_redraw(vc, t, count); + if (vc->vc_rows - b > 0) + fbcon_redraw_move(vc, p, b, + vc->vc_rows - b, b); + } else + fbcon_redraw_move(vc, p, t + count, b - t - count, t); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_MOVE: + if ((p->yscroll + count <=3D + 2 * (p->vrows - vc->vc_rows)) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (t > 0) + fbcon_bmove(vc, 0, 0, count, 0, t, + vc->vc_cols); + ypan_up(vc, count); + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b - count, 0, b, 0, + vc->vc_rows - b, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t + count, 0, t, 0, + b - t - count, vc->vc_cols); + else + goto redraw_up; + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + break; + + case SCROLL_REDRAW: + redraw_up: + fbcon_redraw(vc, p, t, b - t - count, + count * vc->vc_cols); + fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + (b - count)), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + } + break; +#endif =20 case SM_DOWN: if (count > vc->vc_rows) /* Maximum realistic size */ count =3D vc->vc_rows; +#ifndef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION fbcon_redraw(vc, p, b - 1, b - t - count, -count * vc->vc_cols); fbcon_clear(vc, t, 0, count, vc->vc_cols); @@ -1488,10 +1875,96 @@ static bool fbcon_scroll(struct vc_data *vc, unsign= ed int t, unsigned int b, vc->vc_video_erase_char, vc->vc_size_row * count); return true; +#else + if (logo_shown >=3D 0) + goto redraw_down; + switch (p->scrollmode) { + case SCROLL_MOVE: + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, + -count); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + t), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + + case SCROLL_WRAP_MOVE: + if (b - t - count > 3 * vc->vc_rows >> 2) { + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b, 0, b - count, 0, + vc->vc_rows - b, + vc->vc_cols); + ywrap_down(vc, count); + if (t > 0) + fbcon_bmove(vc, count, 0, 0, 0, t, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t, 0, t + count, 0, + b - t - count, vc->vc_cols); + else + goto redraw_down; + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_MOVE: + if ((count - p->yscroll <=3D p->vrows - vc->vc_rows) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (vc->vc_rows - b > 0) + fbcon_bmove(vc, b, 0, b - count, 0, + vc->vc_rows - b, + vc->vc_cols); + ypan_down(vc, count); + if (t > 0) + fbcon_bmove(vc, count, 0, 0, 0, t, + vc->vc_cols); + } else if (info->flags & FBINFO_READS_FAST) + fbcon_bmove(vc, t, 0, t + count, 0, + b - t - count, vc->vc_cols); + else + goto redraw_down; + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_PAN_REDRAW: + if ((count - p->yscroll <=3D p->vrows - vc->vc_rows) + && ((!scroll_partial && (b - t =3D=3D vc->vc_rows)) + || (scroll_partial + && (b - t - count > + 3 * vc->vc_rows >> 2)))) { + if (vc->vc_rows - b > 0) + fbcon_redraw_move(vc, p, b, vc->vc_rows - b, + b - count); + ypan_down_redraw(vc, t, count); + if (t > 0) + fbcon_redraw_move(vc, p, count, t, 0); + } else + fbcon_redraw_move(vc, p, t, b - t - count, t + count); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + break; + + case SCROLL_REDRAW: + redraw_down: + fbcon_redraw(vc, p, b - 1, b - t - count, + -count * vc->vc_cols); + fbcon_clear(vc, t, 0, count, vc->vc_cols); + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + t), + vc->vc_video_erase_char, + vc->vc_size_row * count); + return true; + } +#endif } return false; } =20 + static void updatescrollmode(struct fbcon_display *p, struct fb_info *info, struct vc_data *vc) @@ -1664,7 +2137,21 @@ static int fbcon_switch(struct vc_data *vc) =20 updatescrollmode(p, info, vc); =20 - scrollback_phys_max =3D 0; + switch (p->scrollmode) { + case SCROLL_WRAP_MOVE: + scrollback_phys_max =3D p->vrows - vc->vc_rows; + break; + case SCROLL_PAN_MOVE: + case SCROLL_PAN_REDRAW: + scrollback_phys_max =3D p->vrows - 2 * vc->vc_rows; + if (scrollback_phys_max < 0) + scrollback_phys_max =3D 0; + break; + default: + scrollback_phys_max =3D 0; + break; + } + scrollback_max =3D 0; scrollback_current =3D 0; =20 diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index a00603b4451a..5246d0f2574b 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -29,6 +29,7 @@ struct fbcon_display { /* Filled in by the low-level console driver */ const u_char *fontdata; int userfont; /* !=3D 0 if fontdata kmalloc()ed */ + u_short scrollmode; /* Scroll Method */ u_short inverse; /* !=3D 0 text black on white as defau= lt */ short yscroll; /* Hardware scrolling */ int vrows; /* number of virtual rows */ @@ -51,6 +52,8 @@ struct fbcon_display { }; =20 struct fbcon_ops { + void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width); void (*clear)(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width); void (*putcs)(struct vc_data *vc, struct fb_info *info, @@ -149,6 +152,62 @@ static inline int attr_col_ec(int shift, struct vc_dat= a *vc, #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) =20 + /* + * Scroll Method + */ + +/* There are several methods fbcon can use to move text around the screen: + * + * Operation Pan Wrap + *--------------------------------------------- + * SCROLL_MOVE copyarea No No + * SCROLL_PAN_MOVE copyarea Yes No + * SCROLL_WRAP_MOVE copyarea No Yes + * SCROLL_REDRAW imageblit No No + * SCROLL_PAN_REDRAW imageblit Yes No + * SCROLL_WRAP_REDRAW imageblit No Yes + * + * (SCROLL_WRAP_REDRAW is not implemented yet) + * + * In general, fbcon will choose the best scrolling + * method based on the rule below: + * + * Pan/Wrap > accel imageblit > accel copyarea > + * soft imageblit > (soft copyarea) + * + * Exception to the rule: Pan + accel copyarea is + * preferred over Pan + accel imageblit. + * + * The above is typical for PCI/AGP cards. Unless + * overridden, fbcon will never use soft copyarea. + * + * If you need to override the above rule, set the + * appropriate flags in fb_info->flags. For example, + * to prefer copyarea over imageblit, set + * FBINFO_READS_FAST. + * + * Other notes: + * + use the hardware engine to move the text + * (hw-accelerated copyarea() and fillrect()) + * + use hardware-supported panning on a large virtual screen + * + amifb can not only pan, but also wrap the display by N lines + * (i.e. visible line i =3D physical line (i+N) % yres). + * + read what's already rendered on the screen and + * write it in a different place (this is cfb_copyarea()) + * + re-render the text to the screen + * + * Whether to use wrapping or panning can only be figured out at + * runtime (when we know whether our font height is a multiple + * of the pan/wrap step) + * + */ + +#define SCROLL_MOVE 0x001 +#define SCROLL_PAN_MOVE 0x002 +#define SCROLL_WRAP_MOVE 0x003 +#define SCROLL_REDRAW 0x004 +#define SCROLL_PAN_REDRAW 0x005 + #ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); #endif diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/cor= e/fbcon_ccw.c index ffa78936eaab..9cd2c4b05c32 100644 --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -59,12 +59,31 @@ static void ccw_update_attr(u8 *dst, u8 *src, int attri= bute, } } =20 + +static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + + area.sx =3D sy * vc->vc_font.height; + area.sy =3D vyres - ((sx + width) * vc->vc_font.width); + area.dx =3D dy * vc->vc_font.height; + area.dy =3D vyres - ((dx + width) * vc->vc_font.width); + area.width =3D height * vc->vc_font.height; + area.height =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D sy * vc->vc_font.height; @@ -121,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_inf= o *info, u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -210,7 +229,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_in= fo *info, int mode, int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -368,7 +387,7 @@ static int ccw_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; u32 yoffset; - u32 vyres =3D info->var.yres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); int err; =20 yoffset =3D (vyres - info->var.yres) - ops->var.xoffset; @@ -383,6 +402,7 @@ static int ccw_update_start(struct fb_info *info) =20 void fbcon_rotate_ccw(struct fbcon_ops *ops) { + ops->bmove =3D ccw_bmove; ops->clear =3D ccw_clear; ops->putcs =3D ccw_putcs; ops->clear_margins =3D ccw_clear_margins; diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core= /fbcon_cw.c index 92e5b7fb51ee..88d89fad3f05 100644 --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -44,12 +44,31 @@ static void cw_update_attr(u8 *dst, u8 *src, int attrib= ute, } } =20 + +static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + + area.sx =3D vxres - ((sy + height) * vc->vc_font.height); + area.sy =3D sx * vc->vc_font.width; + area.dx =3D vxres - ((dy + height) * vc->vc_font.height); + area.dy =3D dx * vc->vc_font.width; + area.width =3D height * vc->vc_font.height; + area.height =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dx =3D vxres - ((sy + height) * vc->vc_font.height); @@ -106,7 +125,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info= *info, u32 cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -193,7 +212,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_inf= o *info, int mode, int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -350,7 +369,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_inf= o *info, int mode, static int cw_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; - u32 vxres =3D info->var.xres; + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); u32 xoffset; int err; =20 @@ -366,6 +385,7 @@ static int cw_update_start(struct fb_info *info) =20 void fbcon_rotate_cw(struct fbcon_ops *ops) { + ops->bmove =3D cw_bmove; ops->clear =3D cw_clear; ops->putcs =3D cw_putcs; ops->clear_margins =3D cw_clear_margins; diff --git a/drivers/video/fbdev/core/fbcon_rotate.h b/drivers/video/fbdev/= core/fbcon_rotate.h index b528b2e54283..21cb81615883 100644 --- a/drivers/video/fbdev/core/fbcon_rotate.h +++ b/drivers/video/fbdev/core/fbcon_rotate.h @@ -11,6 +11,27 @@ #ifndef _FBCON_ROTATE_H #define _FBCON_ROTATE_H =20 +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION +#define GETVYRES(s,i) ({ \ + (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE) ? \ + (i)->var.yres : (i)->var.yres_virtual; }) + +#define GETVXRES(s,i) ({ \ + (s =3D=3D SCROLL_REDRAW || s =3D=3D SCROLL_MOVE || !(i)->fix.xpans= tep) ? \ + (i)->var.xres : (i)->var.xres_virtual; }) +#else +static inline u32 GETVYRES(int s, struct fb_info *i) +{ + return i->var.yres; +} + +static inline u32 GETVXRES(int s, struct fb_info *i) +{ + return i->var.xres; +} +#endif + + static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pa= t) { u32 tmp =3D (y * pitch) + x, index =3D tmp / 8, bit =3D tmp % 8; diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core= /fbcon_ud.c index 09619bd8e021..8d5e66b1bdfb 100644 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -44,13 +44,33 @@ static void ud_update_attr(u8 *dst, u8 *src, int attrib= ute, } } =20 + +static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fbcon_ops *ops =3D info->fbcon_par; + struct fb_copyarea area; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); + + area.sy =3D vyres - ((sy + height) * vc->vc_font.height); + area.sx =3D vxres - ((sx + width) * vc->vc_font.width); + area.dy =3D vyres - ((dy + height) * vc->vc_font.height); + area.dx =3D vxres - ((dx + width) * vc->vc_font.width); + area.height =3D height * vc->vc_font.height; + area.width =3D width * vc->vc_font.width; + + info->fbops->fb_copyarea(info, &area); +} + static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { + struct fbcon_ops *ops =3D info->fbcon_par; struct fb_fillrect region; int bgshift =3D (vc->vc_hi_font_mask) ? 13 : 12; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 region.color =3D attr_bgcol_ec(bgshift,vc,info); region.dy =3D vyres - ((sy + height) * vc->vc_font.height); @@ -142,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, struct fb_info= *info, u32 mod =3D vc->vc_font.width % 8, cnt, pitch, size; u32 attribute =3D get_attribute(info, scr_readw(s)); u8 *dst, *buf =3D NULL; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -239,8 +259,8 @@ static void ud_cursor(struct vc_data *vc, struct fb_inf= o *info, int mode, int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1, dx, dy; char *src; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); =20 if (!ops->fontbuffer) return; @@ -390,8 +410,8 @@ static int ud_update_start(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; int xoffset, yoffset; - u32 vyres =3D info->var.yres; - u32 vxres =3D info->var.xres; + u32 vyres =3D GETVYRES(ops->p->scrollmode, info); + u32 vxres =3D GETVXRES(ops->p->scrollmode, info); int err; =20 xoffset =3D vxres - info->var.xres - ops->var.xoffset; @@ -409,6 +429,7 @@ static int ud_update_start(struct fb_info *info) =20 void fbcon_rotate_ud(struct fbcon_ops *ops) { + ops->bmove =3D ud_bmove; ops->clear =3D ud_clear; ops->putcs =3D ud_putcs; ops->clear_margins =3D ud_clear_margins; diff --git a/drivers/video/fbdev/core/tileblit.c b/drivers/video/fbdev/core= /tileblit.c index 72af95053bcb..2768eff247ba 100644 --- a/drivers/video/fbdev/core/tileblit.c +++ b/drivers/video/fbdev/core/tileblit.c @@ -16,6 +16,21 @@ #include #include "fbcon.h" =20 +static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy, + int sx, int dy, int dx, int height, int width) +{ + struct fb_tilearea area; + + area.sx =3D sx; + area.sy =3D sy; + area.dx =3D dx; + area.dy =3D dy; + area.height =3D height; + area.width =3D width; + + info->tileops->fb_tilecopy(info, &area); +} + static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) { @@ -118,6 +133,7 @@ void fbcon_set_tileops(struct vc_data *vc, struct fb_in= fo *info) struct fb_tilemap map; struct fbcon_ops *ops =3D info->fbcon_par; =20 + ops->bmove =3D tile_bmove; ops->clear =3D tile_clear; ops->putcs =3D tile_putcs; ops->clear_margins =3D tile_clear_margins; diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeleto= nfb.c index 0fe922f726e9..bcacfb6934fa 100644 --- a/drivers/video/fbdev/skeletonfb.c +++ b/drivers/video/fbdev/skeletonfb.c @@ -505,15 +505,15 @@ void xxxfb_fillrect(struct fb_info *p, const struct f= b_fillrect *region) } =20 /** - * xxxfb_copyarea - OBSOLETE function. + * xxxfb_copyarea - REQUIRED function. Can use generic routines if + * non acclerated hardware and packed pixel based. * Copies one area of the screen to another area. - * Will be deleted in a future version * * @info: frame buffer structure that represents a single frame buffer * @area: Structure providing the data to copy the framebuffer conten= ts * from one region to another. * - * This drawing operation copied a rectangular area from one area of = the + * This drawing operation copies a rectangular area from one area of = the * screen to another area. */ void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)=20 @@ -645,9 +645,9 @@ static const struct fb_ops xxxfb_ops =3D { .fb_setcolreg =3D xxxfb_setcolreg, .fb_blank =3D xxxfb_blank, .fb_pan_display =3D xxxfb_pan_display, - .fb_fillrect =3D xxxfb_fillrect, /* Needed !!! */ - .fb_copyarea =3D xxxfb_copyarea, /* Obsolete */ - .fb_imageblit =3D xxxfb_imageblit, /* Needed !!! */ + .fb_fillrect =3D xxxfb_fillrect, /* Needed !!! */ + .fb_copyarea =3D xxxfb_copyarea, /* Needed !!! */ + .fb_imageblit =3D xxxfb_imageblit, /* Needed !!! */ .fb_cursor =3D xxxfb_cursor, /* Optional !!! */ .fb_sync =3D xxxfb_sync, .fb_ioctl =3D xxxfb_ioctl, diff --git a/include/linux/fb.h b/include/linux/fb.h index 3da95842b207..02f362c661c8 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -262,7 +262,7 @@ struct fb_ops { =20 /* Draws a rectangle */ void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect= ); - /* Copy data from area to another. Obsolete. */ + /* Copy data from area to another */ void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *regi= on); /* Draws a image to the display */ void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4208C433EF for ; Mon, 31 Jan 2022 21:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379979AbiAaVGw (ORCPT ); Mon, 31 Jan 2022 16:06:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379625AbiAaVGl (ORCPT ); Mon, 31 Jan 2022 16:06:41 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B75C061741 for ; Mon, 31 Jan 2022 13:06:39 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id i187-20020a1c3bc4000000b0034d2ed1be2aso300838wma.1 for ; Mon, 31 Jan 2022 13:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9elcEF+FUVtrFo+P664bpKhWxlWsFcRwRHhOMNgwzW0=; b=XHfO/wn8IkfHT202i85gyvWrkloyUnQE6uoga9lWrzNazjOOPB/rjjTQiTJ02imTWA 54VOxqV1+ChwVtmjS9FUQkPhKTM2bbY7b8fBwefpQdOiYS10EBKZRaaoaHE+LsfiEOsv p7W/lx2r1iXlJDKVVMadBVoM3d+pe9DFQ63FU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9elcEF+FUVtrFo+P664bpKhWxlWsFcRwRHhOMNgwzW0=; b=7meq/D8YF5T16sJC8tmLsQDXgFkuHhGzw8r0JlmKNE5dhCZAPgW7OxKJdIn1k/8lSi zR/W6fwR0+68CHtYBI//4hXcgXbd9J+O0HnZ6En/fzJ4YT7cu52tpbKKy/whIwwO17bV OgRwZny+kjvz7yeU7X+SMMt025NBwlg7qhPhLWeDdJPpq59yTYlYhv+o+5y24MJa+ffg BW+D5G3xT01+aumS00EQJg9FrQq5WjBajmrIc0BuJPWlDIXyO12dmc4RQ0F4moTfxmFa YvhcIBEwF4hkHirte8D+eWyX2LvGguZ9wLKRHKgbR3UUoHlQUE4KPcCPUXJ7ob9w3wM9 2a6Q== X-Gm-Message-State: AOAM533eAH2Hwjxz/nRnEbDLSv5VPtOqzRriNo4Ce52wAZfLWWAOLdjp cEhkHO94rRG3mDgTfOLyUnwLJA== X-Google-Smtp-Source: ABdhPJzFYJxnbuwjv7BgWbSbiYaq6SzlYYSYRiulgLOPdfd4aJ33/Z0Erh9dIHL4H0VhctMf+XoN4Q== X-Received: by 2002:a05:600c:3593:: with SMTP id p19mr19647246wmq.172.1643663197952; Mon, 31 Jan 2022 13:06:37 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:37 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Helge Deller , stable@vger.kernel.org, Claudio Suarez , Dave Airlie , Jani Nikula , Linus Torvalds , Pavel Machek , Sam Ravnborg , Greg Kroah-Hartman , Javier Martinez Canillas , Tomi Valkeinen , Geert Uytterhoeven , Thomas Zimmermann , Daniel Vetter , Sven Schnelle , Gerd Hoffmann Subject: [PATCH 03/21] fbcon: Restore fbcon scrolling acceleration Date: Mon, 31 Jan 2022 22:05:34 +0100 Message-Id: <20220131210552.482606-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This functionally undoes 39aead8373b3 ("fbcon: Disable accelerated scrolling"), but behind the FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION option. References: https://lore.kernel.org/dri-devel/feea8303-2b83-fc36-972c-4fc8a= d723bde@gmx.de/ Fixes: 39aead8373b3 ("fbcon: Disable accelerated scrolling") Cc: Helge Deller Cc: # v5.11+ Cc: Claudio Suarez Cc: Dave Airlie Cc: Jani Nikula Cc: Linus Torvalds Cc: Linux Fbdev development list Cc: Pavel Machek Cc: Sam Ravnborg Cc: Greg Kroah-Hartman Cc: Javier Martinez Canillas Cc: DRI Development Cc: Linux Kernel Mailing List Cc: Claudio Suarez Cc: Tomi Valkeinen Cc: Geert Uytterhoeven Cc: Thomas Zimmermann Cc: Daniel Vetter Cc: Sven Schnelle Cc: Gerd Hoffmann Signed-off-by: Daniel Vetter --- drivers/video/fbdev/core/fbcon.c | 48 ++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 2ff90061c7f3..39dc18a5de86 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1125,13 +1125,15 @@ static void fbcon_init(struct vc_data *vc, int init) =20 ops->graphics =3D 0; =20 - /* - * No more hw acceleration for fbcon. - * - * FIXME: Garbage collect all the now dead code after sufficient time - * has passed. - */ +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION + if ((info->flags & FBINFO_HWACCEL_COPYAREA) && + !(info->flags & FBINFO_HWACCEL_DISABLED)) + p->scrollmode =3D SCROLL_MOVE; + else /* default to something safe */ + p->scrollmode =3D SCROLL_REDRAW; +#else p->scrollmode =3D SCROLL_REDRAW; +#endif =20 /* * ++guenther: console.c:vc_allocate() relies on initializing @@ -1971,15 +1973,49 @@ static void updatescrollmode(struct fbcon_display *= p, { struct fbcon_ops *ops =3D info->fbcon_par; int fh =3D vc->vc_font.height; + int cap =3D info->flags; + u16 t =3D 0; + int ypan =3D FBCON_SWAP(ops->rotate, info->fix.ypanstep, + info->fix.xpanstep); + int ywrap =3D FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); int yres =3D FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); int vyres =3D FBCON_SWAP(ops->rotate, info->var.yres_virtual, info->var.xres_virtual); + int good_pan =3D (cap & FBINFO_HWACCEL_YPAN) && + divides(ypan, vc->vc_font.height) && vyres > yres; + int good_wrap =3D (cap & FBINFO_HWACCEL_YWRAP) && + divides(ywrap, vc->vc_font.height) && + divides(vc->vc_font.height, vyres) && + divides(vc->vc_font.height, yres); + int reading_fast =3D cap & FBINFO_READS_FAST; + int fast_copyarea =3D (cap & FBINFO_HWACCEL_COPYAREA) && + !(cap & FBINFO_HWACCEL_DISABLED); + int fast_imageblit =3D (cap & FBINFO_HWACCEL_IMAGEBLIT) && + !(cap & FBINFO_HWACCEL_DISABLED); =20 p->vrows =3D vyres/fh; if (yres > (fh * (vc->vc_rows + 1))) p->vrows -=3D (yres - (fh * vc->vc_rows)) / fh; if ((yres % fh) && (vyres % fh < yres % fh)) p->vrows--; + + if (good_wrap || good_pan) { + if (reading_fast || fast_copyarea) + p->scrollmode =3D good_wrap ? + SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; + else + p->scrollmode =3D good_wrap ? SCROLL_REDRAW : + SCROLL_PAN_REDRAW; + } else { + if (reading_fast || (fast_copyarea && !fast_imageblit)) + p->scrollmode =3D SCROLL_MOVE; + else + p->scrollmode =3D SCROLL_REDRAW; + } + +#ifndef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION + p->scrollmode =3D SCROLL_REDRAW; +#endif } =20 #define PITCH(w) (((w) + 7) >> 3) --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92E4DC433EF for ; Mon, 31 Jan 2022 21:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381013AbiAaVH2 (ORCPT ); Mon, 31 Jan 2022 16:07:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379502AbiAaVGo (ORCPT ); Mon, 31 Jan 2022 16:06:44 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C341C06174A for ; Mon, 31 Jan 2022 13:06:40 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id m14so27679671wrg.12 for ; Mon, 31 Jan 2022 13:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=maVDh36g+mbMxDQqKVsClyM2EENbHZLdIj/dxYmw5do=; b=Qcsxhy2o/dS11RJsdCfS9Bxk3l2q8JaeoimOSXKdnQQwY7aFMOzBCGs3z75BZLUfjP G5PY5jJU5KSJ23gLrVGnPRmbSww2IYvxZ0Ieehv+Gk524P056aEZJfV+u7yvV1LmpBj6 v0MRUtj2qEfuN8Rj2tN9HSteIZLF/+MTHdjd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=maVDh36g+mbMxDQqKVsClyM2EENbHZLdIj/dxYmw5do=; b=EP91hICLb0dfBZ/RdCBCoC/sgeN5feOsHjLPyhvEDQfMccxHpfm5RJUUNjorKKo8PL ljs9CgTJ/teliGQczUI9hfJQtm1CqNKfWays7cXr4LRxHcSyvUcVSMeB/6CEVnQKzTZA GddzL6JKF7ZzH7i3x07j0aWOTL96HqmqNWrEF7+XfUpXHyNHw+fBAnJ0jlTrPumg/g4C zO/6iM7o6DfBvSbXc+KJw+n2IQZpQ2bqtZMEDiRz3pFrqwEO32zpD0I7jyyWvzfFIIl+ pINyl9cWYPB08aZdEVH21XybdW3stTK6jDICOHWrT+2VN3VitrT4/KZwladdcoA/+PJU OK7w== X-Gm-Message-State: AOAM533U8UDTqa39kRDrtgNFsM8Jacx2cYy0rUpO6oNNghern4Qe79ps /vxI8V9p6hniITQWa6DDo7QNBA== X-Google-Smtp-Source: ABdhPJwUiYtIFsmkn1+ZKECUjh4jElDblVWqzeBW7WDzEcxIsGU9rssDBdn9pVrrCKK6rcDF8iLQ3w== X-Received: by 2002:a05:6000:104e:: with SMTP id c14mr19310924wrx.252.1643663198814; Mon, 31 Jan 2022 13:06:38 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:38 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Helge Deller , Daniel Vetter , Thomas Zimmermann , Du Cheng , Tetsuo Handa , Claudio Suarez , Greg Kroah-Hartman Subject: [PATCH 04/21] fbcon: delete a few unneeded forward decl Date: Mon, 31 Jan 2022 22:05:35 +0100 Message-Id: <20220131210552.482606-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" I didn't bother with any code movement to fix the others, these just got a bit in the way. Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Thomas Zimmermann Cc: Du Cheng Cc: Tetsuo Handa Cc: Claudio Suarez Cc: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbcon.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 39dc18a5de86..2a575620ef59 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -163,18 +163,7 @@ static int fbcon_cursor_noblink; * Interface used by the world */ =20 -static const char *fbcon_startup(void); -static void fbcon_init(struct vc_data *vc, int init); -static void fbcon_deinit(struct vc_data *vc); -static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, - int width); -static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos); -static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos); static void fbcon_clear_margins(struct vc_data *vc, int bottom_only); -static void fbcon_cursor(struct vc_data *vc, int mode); -static int fbcon_switch(struct vc_data *vc); -static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch); static void fbcon_set_palette(struct vc_data *vc, const unsigned char *tab= le); =20 /* @@ -184,8 +173,8 @@ static void fbcon_set_disp(struct fb_info *info, struct= fb_var_screeninfo *var, int unit); static void fbcon_modechanged(struct fb_info *info); static void fbcon_set_all_vcs(struct fb_info *info); -static void fbcon_start(void); static void fbcon_exit(void); + static struct device *fbcon_device; =20 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7DDFC433FE for ; Mon, 31 Jan 2022 21:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379872AbiAaVHA (ORCPT ); Mon, 31 Jan 2022 16:07:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379726AbiAaVGp (ORCPT ); Mon, 31 Jan 2022 16:06:45 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3052FC061751 for ; Mon, 31 Jan 2022 13:06:41 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id n40-20020a05600c3ba800b00353958feb16so21385wms.1 for ; Mon, 31 Jan 2022 13:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y9cn8imFuUzvwepZlKJ58OBUUul6Q5sMSH10T7m8dj8=; b=TA4yPVpB6b5IanWkNA17w/YtvzecZn463AtS5N5iweUFl9YOdws7reKOb0rBfewDpP Um4mw4eT/j7AvGuu8hcKHynpUAF/ypwISn0CGKj2nhF3s/zzFG6H6+BSPzHwdZ3qS+mp 3lePVux6FtNZFZpEXHajvD0qtMU1lw3JKRzI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y9cn8imFuUzvwepZlKJ58OBUUul6Q5sMSH10T7m8dj8=; b=2tejr54XrvUX40jyUE4rUqB1THhxFyTyH+j1embVpoy6kE9PPA4OtZ4lCmsGxG6yBt hgcmu1kYr1tvRZYhJfdLUCqeS93rQa62FQz95me1PY1jBeRuczAd3sz/viEdBF65O95o ZZsJ+m9+Rx6mwk44xf5GSGb3+306DXWDub0HCclki/GNC2jhLaaTYTRdOx8GVXkiS//E FNgEXS4LC5l5MZd13r+59CLTdX9EIi+0XJeUrHD2vtOXqiHvCkAoMZBjg4sQFVzub34w Ok1PhefAHTwpeRvSpk68MgaTHZbQUJd/NfhpNMW5fBGFbmQYKYxT7XTCXsmGyzZZwEaD rmjQ== X-Gm-Message-State: AOAM5333QhZI/CPphYMCHbNID3W1cIUXJHy8ROc8hRr6JdaWSDaVH4Rj ACGJKIFzdh1/L97wHfaGuER671MpKiCXyQ== X-Google-Smtp-Source: ABdhPJxCbKEz0wktfxliLLRUrRMsL2X2hfkjdle8Xa4xgE4OB1zLnz+w0aW/cDTzNAAmInfO0kOPNQ== X-Received: by 2002:a1c:f210:: with SMTP id s16mr28569704wmc.121.1643663199779; Mon, 31 Jan 2022 13:06:39 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:39 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Helge Deller , Daniel Vetter , Greg Kroah-Hartman , Tetsuo Handa , Du Cheng , Claudio Suarez , Thomas Zimmermann Subject: [PATCH 05/21] fbcon: Introduce wrapper for console->fb_info lookup Date: Mon, 31 Jan 2022 22:05:36 +0100 Message-Id: <20220131210552.482606-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Half of it is protected by console_lock, but the other half is a lot more awkward: Registration/deregistration of fbdev are serialized, but we don't really clear out anything in con2fb_map and so there's potential for use-after free mixups. First step is to encapsulate the lookup. Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Tetsuo Handa Cc: Du Cheng Cc: Claudio Suarez Cc: Thomas Zimmermann --- drivers/video/fbdev/core/fbcon.c | 76 ++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 2a575620ef59..8f971de35885 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -110,6 +110,18 @@ static struct fbcon_display fb_display[MAX_NR_CONSOLES= ]; static signed char con2fb_map[MAX_NR_CONSOLES]; static signed char con2fb_map_boot[MAX_NR_CONSOLES]; =20 +static struct fb_info *fbcon_info_from_console(int console) +{ + WARN_CONSOLE_UNLOCKED(); + + /* + * Note that only con2fb_map is protected by the console lock, + * registered_fb is protected by a separate mutex. This lookup can + * therefore race. + */ + return registered_fb[con2fb_map[console]]; +} + static int logo_lines; /* logo_shown is an index to vc_cons when >=3D 0; otherwise follows FBCON_= LOGO enums. */ @@ -197,7 +209,7 @@ static void fbcon_rotate(struct fb_info *info, u32 rota= te) if (!ops || ops->currcon =3D=3D -1) return; =20 - fb_info =3D registered_fb[con2fb_map[ops->currcon]]; + fb_info =3D fbcon_info_from_console(ops->currcon); =20 if (info =3D=3D fb_info) { struct fbcon_display *p =3D &fb_display[ops->currcon]; @@ -224,7 +236,7 @@ static void fbcon_rotate_all(struct fb_info *info, u32 = rotate) for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { vc =3D vc_cons[i].d; if (!vc || vc->vc_mode !=3D KD_TEXT || - registered_fb[con2fb_map[i]] !=3D info) + fbcon_info_from_console(i) !=3D info) continue; =20 p =3D &fb_display[vc->vc_num]; @@ -354,7 +366,7 @@ static void fb_flashcursor(struct work_struct *work) vc =3D vc_cons[ops->currcon].d; =20 if (!vc || !con_is_visible(vc) || - registered_fb[con2fb_map[vc->vc_num]] !=3D info || + fbcon_info_from_console(vc->vc_num) !=3D info || vc->vc_deccm !=3D 1) { console_unlock(); return; @@ -789,7 +801,7 @@ static void con2fb_init_display(struct vc_data *vc, str= uct fb_info *info, if (show_logo) { struct vc_data *fg_vc =3D vc_cons[fg_console].d; struct fb_info *fg_info =3D - registered_fb[con2fb_map[fg_console]]; + fbcon_info_from_console(fg_console); =20 fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols, fg_vc->vc_rows, fg_vc->vc_cols, @@ -1012,7 +1024,7 @@ static void fbcon_init(struct vc_data *vc, int init) if (con2fb_map[vc->vc_num] =3D=3D -1) con2fb_map[vc->vc_num] =3D info_idx; =20 - info =3D registered_fb[con2fb_map[vc->vc_num]]; + info =3D fbcon_info_from_console(vc->vc_num); =20 if (logo_shown < 0 && console_loglevel <=3D CONSOLE_LOGLEVEL_QUIET) logo_shown =3D FBCON_LOGO_DONTSHOW; @@ -1231,7 +1243,7 @@ static void fbcon_deinit(struct vc_data *vc) static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, int width) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; =20 struct fbcon_display *p =3D &fb_display[vc->vc_num]; @@ -1269,7 +1281,7 @@ static void fbcon_clear(struct vc_data *vc, int sy, i= nt sx, int height, static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_display *p =3D &fb_display[vc->vc_num]; struct fbcon_ops *ops =3D info->fbcon_par; =20 @@ -1289,7 +1301,7 @@ static void fbcon_putc(struct vc_data *vc, int c, int= ypos, int xpos) =20 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; =20 if (!fbcon_is_inactive(vc, info)) @@ -1298,7 +1310,7 @@ static void fbcon_clear_margins(struct vc_data *vc, i= nt bottom_only) =20 static void fbcon_cursor(struct vc_data *vc, int mode) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; int c =3D scr_readw((u16 *) vc->vc_pos); =20 @@ -1427,7 +1439,7 @@ static void fbcon_redraw_move(struct vc_data *vc, str= uct fbcon_display *p, =20 static __inline__ void ywrap_up(struct vc_data *vc, int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 @@ -1446,7 +1458,7 @@ static __inline__ void ywrap_up(struct vc_data *vc, i= nt count) =20 static __inline__ void ywrap_down(struct vc_data *vc, int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 @@ -1465,7 +1477,7 @@ static __inline__ void ywrap_down(struct vc_data *vc,= int count) =20 static __inline__ void ypan_up(struct vc_data *vc, int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_display *p =3D &fb_display[vc->vc_num]; struct fbcon_ops *ops =3D info->fbcon_par; =20 @@ -1489,7 +1501,7 @@ static __inline__ void ypan_up(struct vc_data *vc, in= t count) =20 static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 @@ -1513,7 +1525,7 @@ static __inline__ void ypan_up_redraw(struct vc_data = *vc, int t, int count) =20 static __inline__ void ypan_down(struct vc_data *vc, int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_display *p =3D &fb_display[vc->vc_num]; struct fbcon_ops *ops =3D info->fbcon_par; =20 @@ -1537,7 +1549,7 @@ static __inline__ void ypan_down(struct vc_data *vc, = int count) =20 static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int cou= nt) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 @@ -1562,7 +1574,7 @@ static __inline__ void ypan_down_redraw(struct vc_dat= a *vc, int t, int count) static void fbcon_bmove_rec(struct vc_data *vc, struct fbcon_display *p, i= nt sy, int sx, int dy, int dx, int height, int width, u_int y_break) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; u_int b; =20 @@ -1604,7 +1616,7 @@ static void fbcon_bmove_rec(struct vc_data *vc, struc= t fbcon_display *p, int sy, static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, int height, int width) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 if (fbcon_is_inactive(vc, info)) @@ -1733,7 +1745,7 @@ static void fbcon_redraw(struct vc_data *vc, struct f= bcon_display *p, static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int = b, enum con_scroll dir, unsigned int count) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_display *p =3D &fb_display[vc->vc_num]; #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION int scroll_partial =3D info->flags & FBINFO_PARTIAL_PAN_OK; @@ -2013,7 +2025,7 @@ static void updatescrollmode(struct fbcon_display *p, static int fbcon_resize(struct vc_data *vc, unsigned int width,=20 unsigned int height, unsigned int user) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; struct fb_var_screeninfo var =3D info->var; @@ -2082,7 +2094,7 @@ static int fbcon_switch(struct vc_data *vc) struct fb_var_screeninfo var; int i, ret, prev_console; =20 - info =3D registered_fb[con2fb_map[vc->vc_num]]; + info =3D fbcon_info_from_console(vc->vc_num); ops =3D info->fbcon_par; =20 if (logo_shown >=3D 0) { @@ -2096,7 +2108,7 @@ static int fbcon_switch(struct vc_data *vc) =20 prev_console =3D ops->currcon; if (prev_console !=3D -1) - old_info =3D registered_fb[con2fb_map[prev_console]]; + old_info =3D fbcon_info_from_console(prev_console); /* * FIXME: If we have multiple fbdev's loaded, we need to * update all info->currcon. Perhaps, we can place this @@ -2219,7 +2231,7 @@ static void fbcon_generic_blank(struct vc_data *vc, s= truct fb_info *info, =20 static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; =20 if (mode_switch) { @@ -2261,7 +2273,7 @@ static int fbcon_blank(struct vc_data *vc, int blank,= int mode_switch) =20 static int fbcon_debug_enter(struct vc_data *vc) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; =20 ops->save_graphics =3D ops->graphics; @@ -2274,7 +2286,7 @@ static int fbcon_debug_enter(struct vc_data *vc) =20 static int fbcon_debug_leave(struct vc_data *vc) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; =20 ops->graphics =3D ops->save_graphics; @@ -2410,7 +2422,7 @@ static void set_vc_hi_font(struct vc_data *vc, bool s= et) static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcou= nt, const u8 * data, int userfont) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; int resize; @@ -2464,7 +2476,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int = w, int h, int charcount, static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned int flags) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); unsigned charcount =3D font->charcount; int w =3D font->width; int h =3D font->height; @@ -2528,7 +2540,7 @@ static int fbcon_set_font(struct vc_data *vc, struct = console_font *font, =20 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *fon= t, char *name) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); const struct font_desc *f; =20 if (!name) @@ -2552,7 +2564,7 @@ static struct fb_cmap palette_cmap =3D { =20 static void fbcon_set_palette(struct vc_data *vc, const unsigned char *tab= le) { - struct fb_info *info =3D registered_fb[con2fb_map[vc->vc_num]]; + struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); int i, j, k, depth; u8 val; =20 @@ -2668,7 +2680,7 @@ static void fbcon_modechanged(struct fb_info *info) return; vc =3D vc_cons[ops->currcon].d; if (vc->vc_mode !=3D KD_TEXT || - registered_fb[con2fb_map[ops->currcon]] !=3D info) + fbcon_info_from_console(ops->currcon) !=3D info) return; =20 p =3D &fb_display[vc->vc_num]; @@ -2708,7 +2720,7 @@ static void fbcon_set_all_vcs(struct fb_info *info) for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { vc =3D vc_cons[i].d; if (!vc || vc->vc_mode !=3D KD_TEXT || - registered_fb[con2fb_map[i]] !=3D info) + fbcon_info_from_console(i) !=3D info) continue; =20 if (con_is_visible(vc)) { @@ -2971,7 +2983,7 @@ void fbcon_fb_blanked(struct fb_info *info, int blank) =20 vc =3D vc_cons[ops->currcon].d; if (vc->vc_mode !=3D KD_TEXT || - registered_fb[con2fb_map[ops->currcon]] !=3D info) + fbcon_info_from_console(ops->currcon) !=3D info) return; =20 if (con_is_visible(vc)) { @@ -2991,7 +3003,7 @@ void fbcon_new_modelist(struct fb_info *info) const struct fb_videomode *mode; =20 for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { - if (registered_fb[con2fb_map[i]] !=3D info) + if (fbcon_info_from_console(i) !=3D info) continue; if (!fb_display[i].mode) continue; --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08C58C4332F for ; Mon, 31 Jan 2022 21:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380544AbiAaVHI (ORCPT ); Mon, 31 Jan 2022 16:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379821AbiAaVGt (ORCPT ); Mon, 31 Jan 2022 16:06:49 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5D8C061757 for ; Mon, 31 Jan 2022 13:06:42 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id o30-20020a05600c511e00b0034f4c3186f4so286707wms.3 for ; Mon, 31 Jan 2022 13:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SwGrwfETCM+M9+P3a4Nrp7y6QdxVSyzi92rKf4e0uVo=; b=J6qMgc5fOJUK3XPhn1qGhcwH2ALMYUIfKhMWansn7faeg7GJBdjaxgar/VwywGvql4 93rIl4vZzDgIr6h21wtvZK2gzoTF2HpHw5kK2rnmsRT15RHohQ2exKndfEkXHIEFSvJi RDIJiadd0mNQP9LnViwYbhh+P80BASVMK1SKs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SwGrwfETCM+M9+P3a4Nrp7y6QdxVSyzi92rKf4e0uVo=; b=klL3y9YNtR4XaQc6PT51GJF5qaLAnWw0KwGST3xc4NfkjCELYmpJLM5AU7mvaENzjZ X68Ho5g9zF1DTLM129UWZhsp8nGMOQMA9nquygORqbntDscyHWernT6zoOH3qQcsoPZX 313r7dFSEBk5ThuuK1MYEixJj4ZqYFlKuMRkn4WCspnsp1HSjBZeyqPC8m90x7S627yP s3GONrEQYsP0QyZ8sC72nmg48KV/U7rhmtnbWgDJP66f744JPWmWn+C3Dbmb6Rig0nW2 JfXDLBMAYge0TUvNNq+bCAwmWvWeRvX5GqETOwX5AXgxjsP7fjo+upXgiBlpcRh5C0K5 q7iw== X-Gm-Message-State: AOAM532V5sToBdFTfuk8gNoTUoONovU7QQITiUHDyLbDM9nxPBzkiEc3 xUKXvo8nLfYb+yWrs4yrPK80Zw== X-Google-Smtp-Source: ABdhPJxlmDJLYtqZduMCaW0cxX2UeObaGw0dY/yqKl+E3ubVsocJ1ZEGqF+GaPai8YvkFp0Tm9EM5w== X-Received: by 2002:a7b:c84f:: with SMTP id c15mr28407018wml.181.1643663200650; Mon, 31 Jan 2022 13:06:40 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:40 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Helge Deller , Daniel Vetter , Claudio Suarez , Greg Kroah-Hartman , Tetsuo Handa , Du Cheng Subject: [PATCH 06/21] fbcon: delete delayed loading code Date: Mon, 31 Jan 2022 22:05:37 +0100 Message-Id: <20220131210552.482606-7-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Before commit 6104c37094e729f3d4ce65797002112735d49cd1 Author: Daniel Vetter Date: Tue Aug 1 17:32:07 2017 +0200 fbcon: Make fbcon a built-time depency for fbdev it was possible to load fbcon and fbdev drivers in any order, which means that fbcon init had to handle the case where fbdev drivers where already registered. This is no longer possible, hence delete that code. Note that the exit case is a bit more complex and will be done in a separate patch. Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Claudio Suarez Cc: Greg Kroah-Hartman Cc: Tetsuo Handa Cc: Du Cheng --- drivers/video/fbdev/core/fbcon.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 8f971de35885..814b648e8f09 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -942,7 +942,7 @@ static const char *fbcon_startup(void) return display_desc; /* * Instead of blindly using registered_fb[0], we use info_idx, set by - * fb_console_init(); + * fbcon_fb_registered(); */ info =3D registered_fb[info_idx]; if (!info) @@ -3316,17 +3316,6 @@ static void fbcon_start(void) return; } #endif - - if (num_registered_fb) { - int i; - - for_each_registered_fb(i) { - info_idx =3D i; - break; - } - - do_fbcon_takeover(0); - } } =20 static void fbcon_exit(void) --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1C07C43217 for ; Mon, 31 Jan 2022 21:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350833AbiAaVHU (ORCPT ); Mon, 31 Jan 2022 16:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379839AbiAaVGt (ORCPT ); Mon, 31 Jan 2022 16:06:49 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB303C061758 for ; Mon, 31 Jan 2022 13:06:42 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id e8so27971157wrc.0 for ; Mon, 31 Jan 2022 13:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gNEcCsAHbmO8BObbR0rzHcF3KU0XqbiUyO0AgqiLr9Q=; b=XB0If8d+oNzt5EGFOz/pJSfVqwossHreq5Z3/8sGNGT1tWVb8HeX+PuSX4HzuKCtxL 85Ce3vd3TA/uayqURoZ6LVnYYD+zcPj1L3cM6aaDGzt5LCXHqB2YeYKof0DAcvGHjWoE WAj/NXLBP9zyNJqrR3yjJ4zw+CAjDKmq/tKN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gNEcCsAHbmO8BObbR0rzHcF3KU0XqbiUyO0AgqiLr9Q=; b=wBfIWViVjVtpl4Ozd6xD3UXxXnKDo3sZO1qfgic4Ae9IF7z23R7G8/5z8LMIJib/4r ToX8S2JnSxjRunzKOSxjfVtjtxmULjL0sUAAqNC2p13qRfX6rWBoe6Q2SNoB9fYdijyS 6NtdErApq6FK6JCrdZ2CgTe1yWl1no+DnEC01Yt1s0POjdDmEilKB+4TZSx2nwgVn9fc P8OEsYFojxtJTdjNPz2stZuSFMIdRaIeXPDG6w4Brad/SUCy5g/yKOxfRCacyrj3Pkvh tMBk4YERFtfJNYvm6ziq+XFROmHAgf6JRSErvE6kX+LKHOliAJdoCf40xyXQkNL8BJgf x8uA== X-Gm-Message-State: AOAM531f/cYqwtFPXf0vrLvaK4Hg8uwHUmmzMey/H9yuB/rp4/FBm3VR h2RJvhtX7Lttit+McuaiEflVag== X-Google-Smtp-Source: ABdhPJyCY4pMX5KDnbLHXSX+AzjieeB1bfyqYC6ZVcKQr80N8d2mwo0uPWz2LhfKAg4dG48zDem7wQ== X-Received: by 2002:a05:6000:1d90:: with SMTP id bk16mr9737566wrb.217.1643663201557; Mon, 31 Jan 2022 13:06:41 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:41 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Helge Deller , Daniel Vetter , Qing Wang , Sam Ravnborg Subject: [PATCH 07/21] fbdev/sysfs: Fix locking Date: Mon, 31 Jan 2022 22:05:38 +0100 Message-Id: <20220131210552.482606-8-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" fb_set_var requires we hold the fb_info lock. Or at least this now matches what the ioctl does ... Note that ps3fb and sh_mobile_lcdcfb are busted in different ways here, but I will not fix them up. Also in practice this isn't a big deal, because really variable fbdev state is actually protected by console_lock (because fbcon just doesn't bother with lock_fb_info() at all), and lock_fb_info protecting anything is really just a neat lie. But that's a much bigger fish to fry. Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: Daniel Vetter Cc: Qing Wang Cc: Sam Ravnborg --- drivers/video/fbdev/core/fbsysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/= fbsysfs.c index 26892940c213..8c1ee9ecec3d 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -91,9 +91,11 @@ static int activate(struct fb_info *fb_info, struct fb_v= ar_screeninfo *var) =20 var->activate |=3D FB_ACTIVATE_FORCE; console_lock(); + lock_fb_info(fb_info); err =3D fb_set_var(fb_info, var); if (!err) fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL); + unlock_fb_info(fb_info); console_unlock(); if (err) return err; --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0072C433EF for ; Mon, 31 Jan 2022 21:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379972AbiAaVHi (ORCPT ); Mon, 31 Jan 2022 16:07:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379873AbiAaVGt (ORCPT ); Mon, 31 Jan 2022 16:06:49 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEA79C06175A for ; Mon, 31 Jan 2022 13:06:43 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id e2so27977400wra.2 for ; Mon, 31 Jan 2022 13:06:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AGFhDGryxjuBc9pLIOSfx0xFgTrTTX1sIqhqyt/kJz8=; b=k4RCrbw2SzASAe0fFcoeoFRDLS+QUlQzEZQGK+mgi5w94n2tRyrosagvguSOBMTayW cix/RUsFZwPt185f+02AQeMrThDpNBY6n/t2Jzf8mROm3DdJ0y8rtDN5jBvFCtMr2M3X olDb26S4XtUepgHpZ2zYxleHGUBVNLrRM3ibg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AGFhDGryxjuBc9pLIOSfx0xFgTrTTX1sIqhqyt/kJz8=; b=uu2DbWgSNZZYO7kPB6T14newbojc0fOCznG3hyIGsmxHxoIYY2CWgV6DTbh0xAb5Yl Mnn+kuBCb41Sm5NNEo8N+pZ9KAYE1V4DHE16rA/f1Bc4U6+kjTW8G+VOqxU6VGIi62qK 4weXg6qUP+okbOlvgL+PJU4g0uS8cR5VBFMxlA1FIoihwU3Ss4V56j4jokwTMzxWnf0W ltvz6k9plQntG6UmxA2fschS7IWBIJiQAfj3DisJtsV6mrficr2XppZUJjxwmyoln15t lyZ3PJDdqxrs4NVNdBJ/Pgt1rvR2XgMX480KjBRtIU6IlrgSG/uZg/hSnx0kG4LhvUs8 YfRQ== X-Gm-Message-State: AOAM533uHFSWIGUHWravrwNTyA0aMdZDKNNsnzhZZmHB+3MSvwA7muNt r9dEUmFD9+288JQNTwnjJoSM3g== X-Google-Smtp-Source: ABdhPJxZZ1xhuWVtSzpEobDrhChDtXcf2nVaPsVwPmajZXySVFdry9xQXezcJiObqHaPqFMFr0Y7Mg== X-Received: by 2002:a5d:6f10:: with SMTP id ay16mr19478357wrb.205.1643663202537; Mon, 31 Jan 2022 13:06:42 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:42 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Claudio Suarez , Du Cheng , Thomas Zimmermann , Greg Kroah-Hartman , Tetsuo Handa Subject: [PATCH 08/21] fbcon: Use delayed work for cursor Date: Mon, 31 Jan 2022 22:05:39 +0100 Message-Id: <20220131210552.482606-9-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Allows us to delete a bunch of hand-rolled stuff. Also to simplify the code we initialize the cursor_work completely when we allocate the fbcon_ops structure, instead of trying to cope with console re-initialization. The motiviation here is that fbcon code stops using the fb_info.queue, which helps with locking issues around cleanup and all that in a later patch. Also note that this allows us to ditch the hand-rolled work cleanup in fbcon_exit - we already call fbcon_del_cursor_timer, which takes care of everything. Plus this was racy anyway. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Claudio Suarez Cc: Du Cheng Cc: Thomas Zimmermann Cc: Greg Kroah-Hartman Cc: Tetsuo Handa --- drivers/video/fbdev/core/fbcon.c | 85 +++++++++++++------------------- drivers/video/fbdev/core/fbcon.h | 4 +- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 814b648e8f09..affb40658fee 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -348,8 +348,8 @@ static int get_color(struct vc_data *vc, struct fb_info= *info, =20 static void fb_flashcursor(struct work_struct *work) { - struct fb_info *info =3D container_of(work, struct fb_info, queue); - struct fbcon_ops *ops =3D info->fbcon_par; + struct fbcon_ops *ops =3D container_of(work, struct fbcon_ops, cursor_wor= k.work); + struct fb_info *info; struct vc_data *vc =3D NULL; int c; int mode; @@ -362,7 +362,10 @@ static void fb_flashcursor(struct work_struct *work) if (ret =3D=3D 0) return; =20 - if (ops && ops->currcon !=3D -1) + /* protected by console_lock */ + info =3D ops->info; + + if (ops->currcon !=3D -1) vc =3D vc_cons[ops->currcon].d; =20 if (!vc || !con_is_visible(vc) || @@ -378,42 +381,25 @@ static void fb_flashcursor(struct work_struct *work) ops->cursor(vc, info, mode, get_color(vc, info, c, 1), get_color(vc, info, c, 0)); console_unlock(); -} =20 -static void cursor_timer_handler(struct timer_list *t) -{ - struct fbcon_ops *ops =3D from_timer(ops, t, cursor_timer); - struct fb_info *info =3D ops->info; - - queue_work(system_power_efficient_wq, &info->queue); - mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies); + queue_delayed_work(system_power_efficient_wq, &ops->cursor_work, + ops->cur_blink_jiffies); } =20 -static void fbcon_add_cursor_timer(struct fb_info *info) +static void fbcon_add_cursor_work(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; =20 - if ((!info->queue.func || info->queue.func =3D=3D fb_flashcursor) && - !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) && - !fbcon_cursor_noblink) { - if (!info->queue.func) - INIT_WORK(&info->queue, fb_flashcursor); - - timer_setup(&ops->cursor_timer, cursor_timer_handler, 0); - mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies); - ops->flags |=3D FBCON_FLAGS_CURSOR_TIMER; - } + if (!fbcon_cursor_noblink) + queue_delayed_work(system_power_efficient_wq, &ops->cursor_work, + ops->cur_blink_jiffies); } =20 -static void fbcon_del_cursor_timer(struct fb_info *info) +static void fbcon_del_cursor_work(struct fb_info *info) { struct fbcon_ops *ops =3D info->fbcon_par; =20 - if (info->queue.func =3D=3D fb_flashcursor && - ops->flags & FBCON_FLAGS_CURSOR_TIMER) { - del_timer_sync(&ops->cursor_timer); - ops->flags &=3D ~FBCON_FLAGS_CURSOR_TIMER; - } + cancel_delayed_work_sync(&ops->cursor_work); } =20 #ifndef MODULE @@ -712,6 +698,8 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, s= truct fb_info *info, ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); if (!ops) err =3D -ENOMEM; + + INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); } =20 if (!err) { @@ -749,7 +737,7 @@ static int con2fb_release_oldinfo(struct vc_data *vc, s= truct fb_info *oldinfo, } =20 if (!err) { - fbcon_del_cursor_timer(oldinfo); + fbcon_del_cursor_work(oldinfo); kfree(ops->cursor_state.mask); kfree(ops->cursor_data); kfree(ops->cursor_src); @@ -865,7 +853,7 @@ static int set_con2fb_map(int unit, int newidx, int use= r) logo_shown !=3D FBCON_LOGO_DONTSHOW); =20 if (!found) - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); con2fb_map_boot[unit] =3D newidx; con2fb_init_display(vc, info, unit, show_logo); } @@ -962,6 +950,8 @@ static const char *fbcon_startup(void) return NULL; } =20 + INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); + ops->currcon =3D -1; ops->graphics =3D 1; ops->cur_rotate =3D -1; @@ -1004,7 +994,7 @@ static const char *fbcon_startup(void) info->var.yres, info->var.bits_per_pixel); =20 - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); return display_desc; } =20 @@ -1194,7 +1184,7 @@ static void fbcon_deinit(struct vc_data *vc) goto finished; =20 if (con_is_visible(vc)) - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); =20 ops->flags &=3D ~FBCON_FLAGS_INIT; finished: @@ -1320,9 +1310,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode) return; =20 if (vc->vc_cursor_type & CUR_SW) - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); else - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); =20 ops->cursor_flash =3D (mode =3D=3D CM_ERASE) ? 0 : 1; =20 @@ -2149,14 +2139,14 @@ static int fbcon_switch(struct vc_data *vc) } =20 if (old_info !=3D info) - fbcon_del_cursor_timer(old_info); + fbcon_del_cursor_work(old_info); } =20 if (fbcon_is_inactive(vc, info) || ops->blank_state !=3D FB_BLANK_UNBLANK) - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); else - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); =20 set_blitting_type(vc, info); ops->cursor_reset =3D 1; @@ -2264,9 +2254,9 @@ static int fbcon_blank(struct vc_data *vc, int blank,= int mode_switch) =20 if (mode_switch || fbcon_is_inactive(vc, info) || ops->blank_state !=3D FB_BLANK_UNBLANK) - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); else - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); =20 return 0; } @@ -3198,7 +3188,7 @@ static ssize_t show_cursor_blink(struct device *devic= e, if (!ops) goto err; =20 - blink =3D (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; + blink =3D delayed_work_pending(&ops->cursor_work); err: console_unlock(); return snprintf(buf, PAGE_SIZE, "%d\n", blink); @@ -3227,10 +3217,10 @@ static ssize_t store_cursor_blink(struct device *de= vice, =20 if (blink) { fbcon_cursor_noblink =3D 0; - fbcon_add_cursor_timer(info); + fbcon_add_cursor_work(info); } else { fbcon_cursor_noblink =3D 1; - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); } =20 err: @@ -3331,15 +3321,9 @@ static void fbcon_exit(void) #endif =20 for_each_registered_fb(i) { - int pending =3D 0; - mapped =3D 0; info =3D registered_fb[i]; =20 - if (info->queue.func) - pending =3D cancel_work_sync(&info->queue); - pr_debug("fbcon: %s pending work\n", (pending ? "canceled" : "no")); - for (j =3D first_fb_vc; j <=3D last_fb_vc; j++) { if (con2fb_map[j] =3D=3D i) { mapped =3D 1; @@ -3355,15 +3339,12 @@ static void fbcon_exit(void) if (info->fbcon_par) { struct fbcon_ops *ops =3D info->fbcon_par; =20 - fbcon_del_cursor_timer(info); + fbcon_del_cursor_work(info); kfree(ops->cursor_src); kfree(ops->cursor_state.mask); kfree(info->fbcon_par); info->fbcon_par =3D NULL; } - - if (info->queue.func =3D=3D fb_flashcursor) - info->queue.func =3D NULL; } } } diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index 5246d0f2574b..dce5ce41093e 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -14,11 +14,11 @@ #include #include #include +#include =20 #include =20 #define FBCON_FLAGS_INIT 1 -#define FBCON_FLAGS_CURSOR_TIMER 2 =20 /* * This is the interface between the low-level console driver and the @@ -66,7 +66,7 @@ struct fbcon_ops { int (*update_start)(struct fb_info *info); int (*rotate_font)(struct fb_info *info, struct vc_data *vc); struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ - struct timer_list cursor_timer; /* Cursor timer */ + struct delayed_work cursor_work; /* Cursor timer */ struct fb_cursor cursor_state; struct fbcon_display *p; struct fb_info *info; --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F7CBC4332F for ; Mon, 31 Jan 2022 21:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381198AbiAaVII (ORCPT ); Mon, 31 Jan 2022 16:08:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379642AbiAaVGu (ORCPT ); Mon, 31 Jan 2022 16:06:50 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3213C06175D for ; Mon, 31 Jan 2022 13:06:44 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id m14so27680065wrg.12 for ; Mon, 31 Jan 2022 13:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ktnbB1ojORyX7qViEKPREZJfUmPXv1LwX1hQ8oWjiis=; b=cdsZgRoYD88FU7+3gh6EQWI/SqTtDKrJZlCWkb+J41Gzoleb6NhfahNF9ou5PBoXp3 UgdC/e3Vg3a93mPGk/8HyGNbb9IBbszmGJlf/DakHr8Qojd6/p70yisKMAs/P5Hbj3iz NL6+D3vPRuPvSQ3OxtoyOPOdL3xKjZZZXlKZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ktnbB1ojORyX7qViEKPREZJfUmPXv1LwX1hQ8oWjiis=; b=LM60qsoGXKc/nnzIDoWfCoOwqyDOsjwWo/c47iKPGe8BNXEzutSvR3emi75OklumGe PMLyDh2hnqGbDsuUSq2QnZ2wOGJnv/Ebx1GoMcCUEIGfiRdjPT7BdWabPumYHQ3CJmbP raFQZJhM0XUTLbPBC2X2BR9fEmK6AGQgWEzOUOKpSKtY8qXpKSApcb/HqhupkrQA2x+H kCfThMM286MJzDDJPtMKfl6IGqvwXrrFcCrPAVSAqF0/ZYzLv4ZojH2+ZxDsh3uT9XiV VfEZpmIymcjAg2n4oXc2/8NyIs315r67e2QOrQa4U0IeUN6rAfXDjyGmfn8uJLl7srLC hXxg== X-Gm-Message-State: AOAM532jG8qDLjor7JPklYosMgJvf8pOv3A0ksVxoEDjSmoLerpLOyFl URcmrSn7uBUH58u+cGZL7g8kEA== X-Google-Smtp-Source: ABdhPJyt52ljZXEkTAhCLoV1KTfkV9714hjj7Pee2NOp7IUyUzjNGEEiV+/NRnESSYx4YNVGxnxa2Q== X-Received: by 2002:a5d:6686:: with SMTP id l6mr19103345wru.314.1643663203444; Mon, 31 Jan 2022 13:06:43 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:43 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Tetsuo Handa , Greg Kroah-Hartman , Du Cheng , Thomas Zimmermann , Claudio Suarez Subject: [PATCH 09/21] fbcon: Replace FBCON_FLAGS_INIT with a boolean Date: Mon, 31 Jan 2022 22:05:40 +0100 Message-Id: <20220131210552.482606-10-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's only one flag and slightly tidier code. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Tetsuo Handa Cc: Greg Kroah-Hartman Cc: Du Cheng Cc: Thomas Zimmermann Cc: Claudio Suarez --- drivers/video/fbdev/core/fbcon.c | 11 +++++------ drivers/video/fbdev/core/fbcon.h | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index affb40658fee..fa30e1909164 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -773,7 +773,7 @@ static void con2fb_init_display(struct vc_data *vc, str= uct fb_info *info, =20 ops->currcon =3D fg_console; =20 - if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { + if (info->fbops->fb_set_par && !ops->initialized) { ret =3D info->fbops->fb_set_par(info); =20 if (ret) @@ -782,7 +782,7 @@ static void con2fb_init_display(struct vc_data *vc, str= uct fb_info *info, "error code %d\n", ret); } =20 - ops->flags |=3D FBCON_FLAGS_INIT; + ops->initialized =3D true; ops->graphics =3D 0; fbcon_set_disp(info, &info->var, unit); =20 @@ -1101,8 +1101,7 @@ static void fbcon_init(struct vc_data *vc, int init) * We need to do it in fbcon_init() to prevent screen corruption. */ if (con_is_visible(vc) && vc->vc_mode =3D=3D KD_TEXT) { - if (info->fbops->fb_set_par && - !(ops->flags & FBCON_FLAGS_INIT)) { + if (info->fbops->fb_set_par && !ops->initialized) { ret =3D info->fbops->fb_set_par(info); =20 if (ret) @@ -1111,7 +1110,7 @@ static void fbcon_init(struct vc_data *vc, int init) "error code %d\n", ret); } =20 - ops->flags |=3D FBCON_FLAGS_INIT; + ops->initialized =3D true; } =20 ops->graphics =3D 0; @@ -1186,7 +1185,7 @@ static void fbcon_deinit(struct vc_data *vc) if (con_is_visible(vc)) fbcon_del_cursor_work(info); =20 - ops->flags &=3D ~FBCON_FLAGS_INIT; + ops->initialized =3D false; finished: =20 fbcon_free_font(p, free_font); diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index dce5ce41093e..b18d0cbf73b6 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -18,8 +18,6 @@ =20 #include =20 -#define FBCON_FLAGS_INIT 1 - /* * This is the interface between the low-level console driver and the * low-level frame buffer device @@ -77,7 +75,7 @@ struct fbcon_ops { int blank_state; int graphics; int save_graphics; /* for debug enter/leave */ - int flags; + bool initialized; int rotate; int cur_rotate; char *cursor_data; --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21921C433FE for ; Mon, 31 Jan 2022 21:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381165AbiAaVHw (ORCPT ); Mon, 31 Jan 2022 16:07:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379703AbiAaVGu (ORCPT ); Mon, 31 Jan 2022 16:06:50 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF4AC061714 for ; Mon, 31 Jan 2022 13:06:45 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id n12-20020a05600c3b8c00b0034eb13edb8eso497871wms.0 for ; Mon, 31 Jan 2022 13:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fEFT7RaLl3MIWyBeJu8+YbW4+Kc4zGdBG2ByELA82FY=; b=GUAHnoGJ2g60XQIxA1S0UBTEjmAhGsZ5SnXwaSbMm4WguOGFJ080okWbKoG6WuelXb voQq0GCXWqeAxlMSnqXUzcMTJe09M5cg5JRDYNy2F4304We++p19+m+1PzPGP4OK3sng CMHb0eixfCd0LaM62LMEll+iAEqIn9PA0TosA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fEFT7RaLl3MIWyBeJu8+YbW4+Kc4zGdBG2ByELA82FY=; b=DHzjtmJnVTPkRkcsFXZxrtZJ9+heYsK/boPdYfuBkoMHZ1RuUi1TW5jymdTw/CT+lN d1v04YRtuHFPyFs64UC7qzwfJECf5FDjNsTLxTzRYld27/dv+VCiqr4k+4JYbY1setxV an7J5g7/rF4nP8noTKnQ83vrJ1gxeuPfXbzzqygLRH+3SYjtT+fJcWCoe1vq1xBDVqzJ XrNGKYzw7U7Tij6RNLPtdtmiq6MOle1Xw0r/qWsrgRM+aHVeeBrWgAq/sjfLTLCXGjP/ s0X+SnguinGPJJVg6aulc1/BKdR0kW0+tj32cOsnYw0qtkrycgo7tVXNQLEr7Reeedfk FFSA== X-Gm-Message-State: AOAM532Nle6fMD3fPld/YqwrT4ysF3OGy2JbiwMetZeil8xFjtXn5FY1 j2xkdf1JSTE4+fW/lQ96Dhb4Nw== X-Google-Smtp-Source: ABdhPJwadVtgHupBXYfEY4Bh9lTcVc2T1fYq6ymL+YzCfw4JZaBt+O2KULSz2DRwEILgsDakrL0ghg== X-Received: by 2002:a05:600c:1f15:: with SMTP id bd21mr28339002wmb.145.1643663204166; Mon, 31 Jan 2022 13:06:44 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:43 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Helge Deller Subject: [PATCH 10/21] fb: Delete fb_info->queue Date: Mon, 31 Jan 2022 22:05:41 +0100 Message-Id: <20220131210552.482606-11-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It was only used by fbcon, and that now switched to its own, private work. Signed-off-by: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org --- include/linux/fb.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/fb.h b/include/linux/fb.h index 02f362c661c8..a8a00d2ba1f3 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -449,7 +449,6 @@ struct fb_info { struct fb_var_screeninfo var; /* Current var */ struct fb_fix_screeninfo fix; /* Current fix */ struct fb_monspecs monspecs; /* Current Monitor specs */ - struct work_struct queue; /* Framebuffer event queue */ struct fb_pixmap pixmap; /* Image hardware mapper */ struct fb_pixmap sprite; /* Cursor hardware mapper */ struct fb_cmap cmap; /* Current cmap */ --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 306D6C433F5 for ; Mon, 31 Jan 2022 21:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381184AbiAaVIA (ORCPT ); Mon, 31 Jan 2022 16:08:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379640AbiAaVGu (ORCPT ); Mon, 31 Jan 2022 16:06:50 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A700C06175F for ; Mon, 31 Jan 2022 13:06:46 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id e8so27971375wrc.0 for ; Mon, 31 Jan 2022 13:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6wfZA3tFd16Wtm8S/Dh1qu27uVxdzEk758J89g6umwA=; b=IJD+m3Kxr+r+xmupJ1J+uzZNue3hzbe3JLMQ24+wok5XgdzjDqsg0K1ZUktgzTW/bq CR93sjoSXr9ksqso1GkmJtRyHkXp6dXn87C7hQQaM1WEB68XrwrR2Ii5qNDTMGv8Ani1 3cM3S7Y23qfL4LABSgltvAprTFhSHdc2w1+B8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6wfZA3tFd16Wtm8S/Dh1qu27uVxdzEk758J89g6umwA=; b=raXhfw8LIRT8RnqQRDj1iJo5zLyo03cre3UApohMYwqkcma1XRa/2XTkhsd0lKv35I BWdwEiBwOgW4OjrlOrcmq66qWb/2AufDRbB2/+7zWM9QmNw3cbcm7+vXV6c7mS3dYxT9 8syTnekr/yrcGqjHMfMmEJICs3ZcJ+TNiV99LsGsSW2XJttu0Dp3oIgTeYCGaOyd3vwD cV8xvX6wYAMS6yGtFwxuIirzVY9z/UGyyQIvNqrZ7inwWMRPUkfRXyk9578QYmUaK+QB a/ffP5GUNfxYaoi6OPWisT+3siUxVJeKz1jxM+7BT6tf/cpSWkZvymlnfD4wauuSeKex n1Ww== X-Gm-Message-State: AOAM530x3/NF/jnK8G+1aSrRSBo+tCPpJ1wEOGeQth+VrixpmNmj41Nt h1kM6HgZkNtuhx3Mt43F6H/kZw== X-Google-Smtp-Source: ABdhPJwOtD4ta20T1lJZOY42qm42b9pZtXBcPDQBEXfwqq5jZUkp0DdIWb26xD0pncVtAPxrGP15iw== X-Received: by 2002:a5d:6090:: with SMTP id w16mr18830782wrt.476.1643663205056; Mon, 31 Jan 2022 13:06:45 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:44 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Claudio Suarez , Greg Kroah-Hartman , Tetsuo Handa , Du Cheng Subject: [PATCH 11/21] fbcon: Extract fbcon_open/release helpers Date: Mon, 31 Jan 2022 22:05:42 +0100 Message-Id: <20220131210552.482606-12-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There's two minor behaviour changes in here: - in error paths we now consistently call fb_ops->fb_release - fb_release really can't fail (fbmem.c ignores it too) and there's no reasonable cleanup we can do anyway. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Claudio Suarez Cc: Greg Kroah-Hartman Cc: Tetsuo Handa Cc: Du Cheng --- drivers/video/fbdev/core/fbcon.c | 107 +++++++++++++++---------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index fa30e1909164..eea2ee14b64c 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -680,19 +680,37 @@ static int fbcon_invalid_charcount(struct fb_info *in= fo, unsigned charcount) =20 #endif /* CONFIG_MISC_TILEBLITTING */ =20 +static int fbcon_open(struct fb_info *info) +{ + if (!try_module_get(info->fbops->owner)) + return -ENODEV; + + if (info->fbops->fb_open && + info->fbops->fb_open(info, 0)) { + module_put(info->fbops->owner); + return -ENODEV; + } + + return 0; +} + +static void fbcon_release(struct fb_info *info) +{ + if (info->fbops->fb_release) + info->fbops->fb_release(info, 0); + + module_put(info->fbops->owner); +} =20 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, int unit, int oldidx) { struct fbcon_ops *ops =3D NULL; - int err =3D 0; - - if (!try_module_get(info->fbops->owner)) - err =3D -ENODEV; + int err; =20 - if (!err && info->fbops->fb_open && - info->fbops->fb_open(info, 0)) - err =3D -ENODEV; + err =3D fbcon_open(info); + if (err) + return err; =20 if (!err) { ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); @@ -713,7 +731,7 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, s= truct fb_info *info, =20 if (err) { con2fb_map[unit] =3D oldidx; - module_put(info->fbops->owner); + fbcon_release(info); } =20 return err; @@ -724,45 +742,34 @@ static int con2fb_release_oldinfo(struct vc_data *vc,= struct fb_info *oldinfo, int oldidx, int found) { struct fbcon_ops *ops =3D oldinfo->fbcon_par; - int err =3D 0, ret; + int ret; =20 - if (oldinfo->fbops->fb_release && - oldinfo->fbops->fb_release(oldinfo, 0)) { - con2fb_map[unit] =3D oldidx; - if (!found && newinfo->fbops->fb_release) - newinfo->fbops->fb_release(newinfo, 0); - if (!found) - module_put(newinfo->fbops->owner); - err =3D -ENODEV; - } + fbcon_release(oldinfo); =20 - if (!err) { - fbcon_del_cursor_work(oldinfo); - kfree(ops->cursor_state.mask); - kfree(ops->cursor_data); - kfree(ops->cursor_src); - kfree(ops->fontbuffer); - kfree(oldinfo->fbcon_par); - oldinfo->fbcon_par =3D NULL; - module_put(oldinfo->fbops->owner); - /* - If oldinfo and newinfo are driving the same hardware, - the fb_release() method of oldinfo may attempt to - restore the hardware state. This will leave the - newinfo in an undefined state. Thus, a call to - fb_set_par() may be needed for the newinfo. - */ - if (newinfo && newinfo->fbops->fb_set_par) { - ret =3D newinfo->fbops->fb_set_par(newinfo); + fbcon_del_cursor_work(oldinfo); + kfree(ops->cursor_state.mask); + kfree(ops->cursor_data); + kfree(ops->cursor_src); + kfree(ops->fontbuffer); + kfree(oldinfo->fbcon_par); + oldinfo->fbcon_par =3D NULL; + /* + If oldinfo and newinfo are driving the same hardware, + the fb_release() method of oldinfo may attempt to + restore the hardware state. This will leave the + newinfo in an undefined state. Thus, a call to + fb_set_par() may be needed for the newinfo. + */ + if (newinfo && newinfo->fbops->fb_set_par) { + ret =3D newinfo->fbops->fb_set_par(newinfo); =20 - if (ret) - printk(KERN_ERR "con2fb_release_oldinfo: " - "detected unhandled fb_set_par error, " - "error code %d\n", ret); - } + if (ret) + printk(KERN_ERR "con2fb_release_oldinfo: " + "detected unhandled fb_set_par error, " + "error code %d\n", ret); } =20 - return err; + return 0; } =20 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, @@ -917,7 +924,6 @@ static const char *fbcon_startup(void) struct fbcon_display *p =3D &fb_display[fg_console]; struct vc_data *vc =3D vc_cons[fg_console].d; const struct font_desc *font =3D NULL; - struct module *owner; struct fb_info *info =3D NULL; struct fbcon_ops *ops; int rows, cols; @@ -936,17 +942,12 @@ static const char *fbcon_startup(void) if (!info) return NULL; =09 - owner =3D info->fbops->owner; - if (!try_module_get(owner)) + if (fbcon_open(info)) return NULL; - if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { - module_put(owner); - return NULL; - } =20 ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); if (!ops) { - module_put(owner); + fbcon_release(info); return NULL; } =20 @@ -3331,10 +3332,6 @@ static void fbcon_exit(void) } =20 if (mapped) { - if (info->fbops->fb_release) - info->fbops->fb_release(info, 0); - module_put(info->fbops->owner); - if (info->fbcon_par) { struct fbcon_ops *ops =3D info->fbcon_par; =20 @@ -3344,6 +3341,8 @@ static void fbcon_exit(void) kfree(info->fbcon_par); info->fbcon_par =3D NULL; } + + fbcon_release(info); } } } --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E769C43217 for ; Mon, 31 Jan 2022 21:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381221AbiAaVIP (ORCPT ); Mon, 31 Jan 2022 16:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379922AbiAaVGu (ORCPT ); Mon, 31 Jan 2022 16:06:50 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5AAC061762 for ; Mon, 31 Jan 2022 13:06:47 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id s18so27876615wrv.7 for ; Mon, 31 Jan 2022 13:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AUTw8V7HxKRdtSwZCGcGzWOP5vCv7juYPfGf+0JDGh8=; b=hBV4RcKOE2SCL7MS+ukEqNHtEjxW2tHq5evpclBGbPiMqwnLYbPCte7oygeO4v0Sef u/qZlYiw6W5BbTfxyFYzHB5lY1Kiyzg+KXHPHlBlJh/atUWkOMB48ijEa8gfrnz3jalr WWgMhmyq10rjrF9MPc/QRAsQaSVeIG46o3N9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AUTw8V7HxKRdtSwZCGcGzWOP5vCv7juYPfGf+0JDGh8=; b=Maz/5t4oU/Q4SNXxR+WYKHNXgxJ8IXOanMHdXl8RZfQLqPcuSMi6+FecxRRBr3YdU5 bkCoOSzkq5wfVrzv1ZVQL+Tm8WLSQf4Yx2UTyRek8DKqycGAWLw/BI875m5b8veO1MXj i+yz3eiFU+7jWI5koI3gRwxTUqfGpZm0UJez/lE3j2rNNAv2Igr+GoJwtc0am/55qBo1 DH/3VA9AFzgi/vsPdrNry4QeBbMsYHI1FuhsghH9I6WNfYkWEOkccjeR+HxCcnW+wViW e/i++TXz38tlxlodfhni8MwWy1RimGQ6TpBXHYo8+4Rk9/vvDGGPvjIYSqNUgSmGCg7u HDmA== X-Gm-Message-State: AOAM532D41T2nZirWmbuHAqq4gVeUHGgkSdNIByLa17XJNx57Y1LYBFm pcU/t16LgdhB58tIEnQI7mzk+w== X-Google-Smtp-Source: ABdhPJwFf0hltBLXnhPQNqmgPHTzrw+ymImbnDYnaTA7+jqQxU3KwwG7Ys6uUsKlWnGpdjnXw4/V4Q== X-Received: by 2002:adf:ff83:: with SMTP id j3mr19458575wrr.618.1643663205951; Mon, 31 Jan 2022 13:06:45 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:45 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Thomas Zimmermann , Greg Kroah-Hartman , Claudio Suarez , Du Cheng , Tetsuo Handa Subject: [PATCH 12/21] fbcon: Ditch error handling for con2fb_release_oldinfo Date: Mon, 31 Jan 2022 22:05:43 +0100 Message-Id: <20220131210552.482606-13-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It doesn't ever fail anymore. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Thomas Zimmermann Cc: Greg Kroah-Hartman Cc: Claudio Suarez Cc: Du Cheng Cc: Tetsuo Handa --- drivers/video/fbdev/core/fbcon.c | 37 +++++++++++--------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index eea2ee14b64c..b83a5a77d8a8 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -737,9 +737,8 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, s= truct fb_info *info, return err; } =20 -static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldi= nfo, - struct fb_info *newinfo, int unit, - int oldidx, int found) +static void con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *old= info, + struct fb_info *newinfo) { struct fbcon_ops *ops =3D oldinfo->fbcon_par; int ret; @@ -768,8 +767,6 @@ static int con2fb_release_oldinfo(struct vc_data *vc, s= truct fb_info *oldinfo, "detected unhandled fb_set_par error, " "error code %d\n", ret); } - - return 0; } =20 static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, @@ -823,7 +820,7 @@ static int set_con2fb_map(int unit, int newidx, int use= r) int oldidx =3D con2fb_map[unit]; struct fb_info *info =3D registered_fb[newidx]; struct fb_info *oldinfo =3D NULL; - int found, err =3D 0; + int found, err =3D 0, show_logo; =20 WARN_CONSOLE_UNLOCKED(); =20 @@ -852,18 +849,15 @@ static int set_con2fb_map(int unit, int newidx, int u= ser) * fbcon should release it. */ if (!err && oldinfo && !search_fb_in_map(oldidx)) - err =3D con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx, - found); + con2fb_release_oldinfo(vc, oldinfo, info); =20 - if (!err) { - int show_logo =3D (fg_console =3D=3D 0 && !user && - logo_shown !=3D FBCON_LOGO_DONTSHOW); + show_logo =3D (fg_console =3D=3D 0 && !user && + logo_shown !=3D FBCON_LOGO_DONTSHOW); =20 - if (!found) - fbcon_add_cursor_work(info); - con2fb_map_boot[unit] =3D newidx; - con2fb_init_display(vc, info, unit, show_logo); - } + if (!found) + fbcon_add_cursor_work(info); + con2fb_map_boot[unit] =3D newidx; + con2fb_init_display(vc, info, unit, show_logo); =20 if (!search_fb_in_map(info_idx)) info_idx =3D newidx; @@ -2786,7 +2780,7 @@ static inline void fbcon_unbind(void) {} /* called with console_lock held */ void fbcon_fb_unbind(struct fb_info *info) { - int i, new_idx =3D -1, ret =3D 0; + int i, new_idx =3D -1; int idx =3D info->node; =20 WARN_CONSOLE_UNLOCKED(); @@ -2820,13 +2814,8 @@ void fbcon_fb_unbind(struct fb_info *info) if (con2fb_map[i] =3D=3D idx) { con2fb_map[i] =3D -1; if (!search_fb_in_map(idx)) { - ret =3D con2fb_release_oldinfo(vc_cons[i].d, - info, NULL, i, - idx, 0); - if (ret) { - con2fb_map[i] =3D idx; - return; - } + con2fb_release_oldinfo(vc_cons[i].d, + info, NULL); } } } --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF6FEC433F5 for ; Mon, 31 Jan 2022 21:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351177AbiAaVI1 (ORCPT ); Mon, 31 Jan 2022 16:08:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379939AbiAaVGv (ORCPT ); Mon, 31 Jan 2022 16:06:51 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA76C061768 for ; Mon, 31 Jan 2022 13:06:48 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id m14so27680319wrg.12 for ; Mon, 31 Jan 2022 13:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NgnSdd2AvfoeNcByN2bDHp+PhpIRGYatmO8U9PanFuc=; b=S+8VBUNNneiGc1+bGPSnrLBcbuVFkgKSU1F9WHEKGEhoPtQNo9kYEWH32/VdEJ10IN +9JFlSujzOM4Bw11VzRyD+o6Ay/zYtaJDCVsEreNhW23/UsII4y11JSGXkMSZ5oO87vf awGxIE+pHd6B7RDP848NhmOIATd3HdslcGwVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NgnSdd2AvfoeNcByN2bDHp+PhpIRGYatmO8U9PanFuc=; b=KfpmYCXKVEVAndJDWu269kM4yvq8fCERijkRz/7F5wtSGf211Mfhm+cwc/Ob69F0rf kg1RvofCZdlWMQJxOXVgTL0hrtj8ohKnf5N17KLUPL25L3bA15nGwNMLbQOCeOd5yh7S S/hXALEk4HqmGX7Yb3mOHZSJjsk5jpgLAqExmyrERTwIuNQbXaW/yaRVpemPbUEVqwxD 8subAJYzVv0a1HE/0WxJiaDgF6hNivUMfQHcjzDQW9Pr4U3Bgdw81WQ7YKaMNpCiH7CS h48pC740qKsWSUo8f0qRCbXgFupw8Q5/nc7wt2CZlmm8Em/a1PZaw4YymCqN457R+t85 BU8Q== X-Gm-Message-State: AOAM530WUumfE/g1ElZBcWwM9RCokBaxblqNIZcxMIX63UT6sr5DoIu6 39EXahxkSFtp6N7Vwrd3bLFraA== X-Google-Smtp-Source: ABdhPJzMRGhgP+Wd468RY30pZW2pKS4gWFtsBggDBPv5aBnxBsUkCxh6leO3bSHMlVVRxYvL1JzDCg== X-Received: by 2002:a5d:4b4d:: with SMTP id w13mr19360147wrs.640.1643663206862; Mon, 31 Jan 2022 13:06:46 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:46 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Greg Kroah-Hartman , Tetsuo Handa , Thomas Zimmermann , Claudio Suarez , Du Cheng Subject: [PATCH 13/21] fbcon: move more common code into fb_open() Date: Mon, 31 Jan 2022 22:05:44 +0100 Message-Id: <20220131210552.482606-14-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" No idea why con2fb_acquire_newinfo() initializes much less than fbcon_startup(), but so be it. From a quick look most of the un-initialized stuff should be fairly harmless, but who knows. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Tetsuo Handa Cc: Thomas Zimmermann Cc: Claudio Suarez Cc: Du Cheng --- drivers/video/fbdev/core/fbcon.c | 74 +++++++++++++------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index b83a5a77d8a8..5a3391ff038d 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -680,8 +680,18 @@ static int fbcon_invalid_charcount(struct fb_info *inf= o, unsigned charcount) =20 #endif /* CONFIG_MISC_TILEBLITTING */ =20 +static void fbcon_release(struct fb_info *info) +{ + if (info->fbops->fb_release) + info->fbops->fb_release(info, 0); + + module_put(info->fbops->owner); +} + static int fbcon_open(struct fb_info *info) { + struct fbcon_ops *ops; + if (!try_module_get(info->fbops->owner)) return -ENODEV; =20 @@ -691,19 +701,22 @@ static int fbcon_open(struct fb_info *info) return -ENODEV; } =20 - return 0; -} + ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); + if (!ops) { + fbcon_release(info); + return -ENOMEM; + } =20 -static void fbcon_release(struct fb_info *info) -{ - if (info->fbops->fb_release) - info->fbops->fb_release(info, 0); + INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); + ops->info =3D info; + info->fbcon_par =3D ops; + ops->cur_blink_jiffies =3D HZ / 5; =20 - module_put(info->fbops->owner); + return 0; } =20 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, - int unit, int oldidx) + int unit) { struct fbcon_ops *ops =3D NULL; int err; @@ -712,27 +725,10 @@ static int con2fb_acquire_newinfo(struct vc_data *vc,= struct fb_info *info, if (err) return err; =20 - if (!err) { - ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); - if (!ops) - err =3D -ENOMEM; - - INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); - } - - if (!err) { - ops->cur_blink_jiffies =3D HZ / 5; - ops->info =3D info; - info->fbcon_par =3D ops; - - if (vc) - set_blitting_type(vc, info); - } + ops =3D info->fbcon_par; =20 - if (err) { - con2fb_map[unit] =3D oldidx; - fbcon_release(info); - } + if (vc) + set_blitting_type(vc, info); =20 return err; } @@ -840,9 +836,11 @@ static int set_con2fb_map(int unit, int newidx, int us= er) =20 found =3D search_fb_in_map(newidx); =20 - con2fb_map[unit] =3D newidx; - if (!err && !found) - err =3D con2fb_acquire_newinfo(vc, info, unit, oldidx); + if (!err && !found) { + err =3D con2fb_acquire_newinfo(vc, info, unit); + if (!err) + con2fb_map[unit] =3D newidx; + } =20 /* * If old fb is not mapped to any of the consoles, @@ -939,20 +937,10 @@ static const char *fbcon_startup(void) if (fbcon_open(info)) return NULL; =20 - ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); - if (!ops) { - fbcon_release(info); - return NULL; - } - - INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); - + ops =3D info->fbcon_par; ops->currcon =3D -1; ops->graphics =3D 1; ops->cur_rotate =3D -1; - ops->cur_blink_jiffies =3D HZ / 5; - ops->info =3D info; - info->fbcon_par =3D ops; =20 p->con_rotate =3D initial_rotation; if (p->con_rotate =3D=3D -1) @@ -1022,7 +1010,7 @@ static void fbcon_init(struct vc_data *vc, int init) return; =20 if (!info->fbcon_par) - con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); + con2fb_acquire_newinfo(vc, info, vc->vc_num); =20 /* If we are not the first console on this fb, copy the font from that console */ --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1518C433EF for ; Mon, 31 Jan 2022 21:08:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350999AbiAaVIj (ORCPT ); Mon, 31 Jan 2022 16:08:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379757AbiAaVGv (ORCPT ); Mon, 31 Jan 2022 16:06:51 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5A6C06176C for ; Mon, 31 Jan 2022 13:06:49 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id o30-20020a05600c511e00b0034f4c3186f4so286916wms.3 for ; Mon, 31 Jan 2022 13:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3hWiJw8I0v/FhKndgqc2O30e2FmZYwhYniGtWb90tWY=; b=HHQSy572JqEYwMH+XAImxbYANsnDK/FocLe1VGb5+1HoyTQOlf6pkJdzMLp+bQVtjl 6nGB7Yu3HDEDy7AAoG4b1oLVSDRpa9s5ddsKnU8r6m1P82LiOt+SAZcWqZYeQWPQARgU WXr3wNTQE3KehfvQbrgyI6k9xn3+ZGRP2IBiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3hWiJw8I0v/FhKndgqc2O30e2FmZYwhYniGtWb90tWY=; b=SToWB4mgAseyyjkytVihtCq9SmD8Ns9OLNl3ZcxfVsNkYUji6/tg1YAO3EIxbc2yUC IpmgQ1Rvdxc7t1m0oC2uw9dwopQI13aP+XCP+qbGHk64H8+umfMRocVTnlswHqmMXI+7 v3JghQxi5yIVs5hZCKNg2C+N1iDYQ1naaUpN711Ke8l0NoG/eIsQb8ewN4Ki7v9WtB0h 45XEGPV9SbpMYhyzgVOetwkpAHFOeWL0CoH69fbypo+Pm8gPyv1J9J/q0t4mMpdMGjBM bK2yKJrGN7VPHzmySWvOLtPMaR97WVzRvMrirX5X4cyffK8K0Tbh6pwSNO37WIVDn7b/ XPzg== X-Gm-Message-State: AOAM531xy3ATRJlDOSpD4SzAKiiHRABqEPGSlHl+gwNewIUl3Qc4ZcEc aOGHkBE7C+7J5MsrBOEAM1njuQ== X-Google-Smtp-Source: ABdhPJxUkcP7tvQC/1g/mrtlDB25tdXfgU7PSiuLoapLSdk12hfg/ro1vp1kr0Y7TNymzUpLM79pKg== X-Received: by 2002:a7b:c4c5:: with SMTP id g5mr19646400wmk.139.1643663207885; Mon, 31 Jan 2022 13:06:47 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:47 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Claudio Suarez , Tetsuo Handa , Thomas Zimmermann , Greg Kroah-Hartman , Du Cheng , Sam Ravnborg , Matthew Wilcox , William Kucharski , Alex Deucher , Zheyu Ma , Zhen Lei , Xiyu Yang Subject: [PATCH 14/21] fbcon: use lock_fb_info in fbcon_open/release Date: Mon, 31 Jan 2022 22:05:45 +0100 Message-Id: <20220131210552.482606-15-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now we get to the real motiviation, because fbmem.c insists that that's the right lock for these. Ofc fbcon.c has a lot more places where it probably should call lock_fb_info(). But looking at fbmem.c at least most of these seem to be protected by console_lock() too, which is probably what papers over any issues. Note that this means we're shuffling around a bit the locking sections for some of the console takeover and unbind paths, but not all: - console binding/unbinding from the console layer never with lock_fb_info - unbind (as opposed to unlink) never bother with lock_fb_info Also the real serialization against set_par and set_pan are still doing by wrapping the entire ioctl code in console_lock(). So this shuffling shouldn't be worse than what we had from a "can you trigger races?" pov, but it's at least clearer. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Claudio Suarez Cc: Tetsuo Handa Cc: Thomas Zimmermann Cc: Greg Kroah-Hartman Cc: Du Cheng Cc: Sam Ravnborg Cc: Matthew Wilcox Cc: William Kucharski Cc: Alex Deucher Cc: Zheyu Ma Cc: Zhen Lei Cc: Xiyu Yang --- drivers/video/fbdev/core/fbcon.c | 5 +++++ drivers/video/fbdev/core/fbmem.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 5a3391ff038d..496bc5f2133e 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -682,8 +682,10 @@ static int fbcon_invalid_charcount(struct fb_info *inf= o, unsigned charcount) =20 static void fbcon_release(struct fb_info *info) { + lock_fb_info(info); if (info->fbops->fb_release) info->fbops->fb_release(info, 0); + unlock_fb_info(info); =20 module_put(info->fbops->owner); } @@ -695,11 +697,14 @@ static int fbcon_open(struct fb_info *info) if (!try_module_get(info->fbops->owner)) return -ENODEV; =20 + lock_fb_info(info); if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { + unlock_fb_info(info); module_put(info->fbops->owner); return -ENODEV; } + unlock_fb_info(info); =20 ops =3D kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); if (!ops) { diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fb= mem.c index 0fa7ede94fa6..fd51d12f2702 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1653,9 +1653,7 @@ static int do_register_framebuffer(struct fb_info *fb= _info) console_lock(); else atomic_inc(&ignore_console_lock_warning); - lock_fb_info(fb_info); ret =3D fbcon_fb_registered(fb_info); - unlock_fb_info(fb_info); =20 if (!lockless_register_fb) console_unlock(); @@ -1672,9 +1670,7 @@ static void unbind_console(struct fb_info *fb_info) return; =20 console_lock(); - lock_fb_info(fb_info); fbcon_fb_unbind(fb_info); - unlock_fb_info(fb_info); console_unlock(); } =20 --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28AF1C433F5 for ; Mon, 31 Jan 2022 21:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381213AbiAaVIp (ORCPT ); Mon, 31 Jan 2022 16:08:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380109AbiAaVG5 (ORCPT ); Mon, 31 Jan 2022 16:06:57 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 204C2C061744 for ; Mon, 31 Jan 2022 13:06:50 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id n8so11190448wmk.3 for ; Mon, 31 Jan 2022 13:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zvAncPlENd1mkArHeBkA576DDmIGdQX94f0ukCjnIXQ=; b=U2t8kjkQ/Vt2HJQRdamapjasWFD4c3zJbcxURpYTYrPL2cbDmMJxvxEJJMlW99DO/4 HUhOQG+NtbaKJIqcJQ1bk77wmHdiXo6RDrFZUBjDjoYa1m3+m13Io4vvAUPU/RdXN4pI fBNkESnc3jQO0p8GldNWuLNg+S4Y098h1Fh7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zvAncPlENd1mkArHeBkA576DDmIGdQX94f0ukCjnIXQ=; b=uqy3QlX1HINhNi4R6yBoRBIfbgPUWh4//iMbtKo1/NjiYW/27j6JVYbHyzq55m+8V6 mw0XZ8EyX7JEyehmctU6u+UXPXdFOMCZVjxAG2irFIBcfvTz2SuGZFfgii97NmGRIBgk 4JPnIMBEhjbAy1NnGebrZIZn8bX+LnkinsXGmoENI27A3JuVBb7oGcWHtMdNWmRhaibh cqzvLPGo45beC3hfxvq3o0ht9Z37fu9339e6LvawnCP7bRs3Wj9VcAciDHl4ZRUobRBV LwPlVENfXSSw4E1akvRx25QOctk2w15zA0L8R5021Lj447ipd6DZOKGjV799dtIPZG3t rfaQ== X-Gm-Message-State: AOAM530CDtwYXpR2VTP216znTZ98TVB6Rs6IxjYuDGhx2nxgdUml8fZy 5muKl/0gLY+wHpMjd/qnbMvcpw== X-Google-Smtp-Source: ABdhPJw4OlP2ZiGsyZ53C2rKU+S/VlUSh/yp+iwZxn0Bz//sDKkThBEktGnYMjV7P/SFzkmcbMEHWA== X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr28683628wmq.35.1643663208709; Mon, 31 Jan 2022 13:06:48 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:48 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Du Cheng , Tetsuo Handa , Claudio Suarez , Thomas Zimmermann Subject: [PATCH 15/21] fbcon: Consistently protect deferred_takeover with console_lock() Date: Mon, 31 Jan 2022 22:05:46 +0100 Message-Id: <20220131210552.482606-16-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This shouldn't be a problem in practice since until we've actually taken over the console there's nothing we've registered with the console/vt subsystem, so the exit/unbind path that check this can't do the wrong thing. But it's confusing, so fix it by moving it a tad later. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Du Cheng Cc: Tetsuo Handa Cc: Claudio Suarez Cc: Thomas Zimmermann --- drivers/video/fbdev/core/fbcon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 496bc5f2133e..11b9f962af6f 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -3247,6 +3247,9 @@ static void fbcon_register_existing_fbs(struct work_s= truct *work) =20 console_lock(); =20 + deferred_takeover =3D false; + logo_shown =3D FBCON_LOGO_DONTSHOW; + for_each_registered_fb(i) fbcon_fb_registered(registered_fb[i]); =20 @@ -3264,8 +3267,6 @@ static int fbcon_output_notifier(struct notifier_bloc= k *nb, pr_info("fbcon: Taking over console\n"); =20 dummycon_unregister_output_notifier(&fbcon_output_nb); - deferred_takeover =3D false; - logo_shown =3D FBCON_LOGO_DONTSHOW; =20 /* We may get called in atomic context */ schedule_work(&fbcon_deferred_takeover_work); --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB7EBC433F5 for ; Mon, 31 Jan 2022 21:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380227AbiAaVIs (ORCPT ); Mon, 31 Jan 2022 16:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379865AbiAaVG5 (ORCPT ); Mon, 31 Jan 2022 16:06:57 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD21C06173E for ; Mon, 31 Jan 2022 13:06:51 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id m26so4920918wms.0 for ; Mon, 31 Jan 2022 13:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=70C1nUGW1Odwr3K26s4abeBZbxMd/ekX/TwRBXQgU6I=; b=Cktd6LG20ahzPI4oj3t4KT9MFDkIjKZcnN4iE+WrSr6LnFr8k7E/f/zMHzEosSr2Ow V1HO2plPctry6v8vF5kL/X6lOJUj2xn269gw+kQqt/GEhdetUhCgfrbU+SNnT9V9zUht Ra6Zf969RefcZ8k+CXKYoHtO5GO1Lfo7OnFfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=70C1nUGW1Odwr3K26s4abeBZbxMd/ekX/TwRBXQgU6I=; b=iO3pvVMe5KL0EqFTw7HoM0L45c+zsO7WfbKB1smAvtEa9nUXsaL/ihTNoOYqjdRbgn o9Fs86G7IfVGWhPadlZ49bxqdDKbNbw3CSfIcyIuMaGEuWsigsKMZ/sduNiiT/ntFDRS kRthy8PC3KaaTTyVSfAbVi6TB7c8WgilKuePBzgAuEtC+A2eGHAmIxKK78b/LQLgj9Gj snO65NUmp5+QM24q8OrEF89zpWrLeBXkkNO9VwkieYa3Ts3rDQzIHjG7T+a8bN7Js1OR t5tQvzOBsB87UqzahsoRqQtgsHf6ovsCzTBmNH7Xvvfe6FnuxDjX+llknqPHKB6ozvBq z50Q== X-Gm-Message-State: AOAM530GKk0JGkXZpCtwTknxvP/GwdmE1Wn0md8iwZu1BfqbBU85Z2Du qSMucynT8erkbmb1PUlHv4+R/Q== X-Google-Smtp-Source: ABdhPJxrzmAxjflibmy9TG+Tz9akgKGj2BNfeHpJ8d17fTQTFbXHnAsoNzZUYtYG9tFfmy514BI1MA== X-Received: by 2002:a05:600c:3386:: with SMTP id o6mr20080048wmp.79.1643663209778; Mon, 31 Jan 2022 13:06:49 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:49 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Thomas Zimmermann , Du Cheng , Claudio Suarez , Greg Kroah-Hartman , Tetsuo Handa , Matthew Wilcox , Sam Ravnborg , Zheyu Ma , Guenter Roeck , Alex Deucher , Zhen Lei , Xiyu Yang Subject: [PATCH 16/21] fbcon: Move console_lock for register/unlink/unregister Date: Mon, 31 Jan 2022 22:05:47 +0100 Message-Id: <20220131210552.482606-17-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Ideally console_lock becomes an implementation detail of fbcon.c and doesn't show up anywhere in fbmem.c. We're still pretty far from that, but at least the register/unregister code is there now. With this the do_fb_ioctl() handler is the only code in fbmem.c still calling console_lock(). Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Thomas Zimmermann Cc: Du Cheng Cc: Claudio Suarez Cc: Greg Kroah-Hartman Cc: Tetsuo Handa Cc: Matthew Wilcox Cc: Sam Ravnborg Cc: Zheyu Ma Cc: Guenter Roeck Cc: Alex Deucher Cc: Zhen Lei Cc: Xiyu Yang --- drivers/video/fbdev/core/fbcon.c | 33 ++++++++++++++++++++++++++------ drivers/video/fbdev/core/fbmem.c | 23 ++-------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 11b9f962af6f..e5e8aaf6f60d 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2776,10 +2776,12 @@ void fbcon_fb_unbind(struct fb_info *info) int i, new_idx =3D -1; int idx =3D info->node; =20 - WARN_CONSOLE_UNLOCKED(); + console_lock(); =20 - if (!fbcon_has_console_bind) + if (!fbcon_has_console_bind) { + console_unlock(); return; + } =20 for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { if (con2fb_map[i] !=3D idx && @@ -2814,6 +2816,8 @@ void fbcon_fb_unbind(struct fb_info *info) } fbcon_unbind(); } + + console_unlock(); } =20 /* called with console_lock held */ @@ -2821,10 +2825,12 @@ void fbcon_fb_unregistered(struct fb_info *info) { int i, idx; =20 - WARN_CONSOLE_UNLOCKED(); + console_lock(); =20 - if (deferred_takeover) + if (deferred_takeover) { + console_unlock(); return; + } =20 idx =3D info->node; for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { @@ -2853,6 +2859,7 @@ void fbcon_fb_unregistered(struct fb_info *info) =20 if (!num_registered_fb) do_unregister_con_driver(&fb_con); + console_unlock(); } =20 void fbcon_remap_all(struct fb_info *info) @@ -2910,19 +2917,27 @@ static inline void fbcon_select_primary(struct fb_i= nfo *info) } #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */ =20 +static bool lockless_register_fb; +module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool= , 0400); +MODULE_PARM_DESC(lockless_register_fb, + "Lockless framebuffer registration for debugging [default=3Doff]"); + /* called with console_lock held */ int fbcon_fb_registered(struct fb_info *info) { int ret =3D 0, i, idx; =20 - WARN_CONSOLE_UNLOCKED(); + if (!lockless_register_fb) + console_lock(); + else + atomic_inc(&ignore_console_lock_warning); =20 idx =3D info->node; fbcon_select_primary(info); =20 if (deferred_takeover) { pr_info("fbcon: Deferring console take-over\n"); - return 0; + goto out; } =20 if (info_idx =3D=3D -1) { @@ -2942,6 +2957,12 @@ int fbcon_fb_registered(struct fb_info *info) } } =20 +out: + if (!lockless_register_fb) + console_unlock(); + else + atomic_dec(&ignore_console_lock_warning); + return ret; } =20 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fb= mem.c index fd51d12f2702..904ef1250677 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1573,14 +1573,9 @@ static void do_remove_conflicting_framebuffers(struc= t apertures_struct *a, } } =20 -static bool lockless_register_fb; -module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool= , 0400); -MODULE_PARM_DESC(lockless_register_fb, - "Lockless framebuffer registration for debugging [default=3Doff]"); - static int do_register_framebuffer(struct fb_info *fb_info) { - int i, ret; + int i; struct fb_videomode mode; =20 if (fb_check_foreignness(fb_info)) @@ -1649,17 +1644,7 @@ static int do_register_framebuffer(struct fb_info *f= b_info) } #endif =20 - if (!lockless_register_fb) - console_lock(); - else - atomic_inc(&ignore_console_lock_warning); - ret =3D fbcon_fb_registered(fb_info); - - if (!lockless_register_fb) - console_unlock(); - else - atomic_dec(&ignore_console_lock_warning); - return ret; + return fbcon_fb_registered(fb_info); } =20 static void unbind_console(struct fb_info *fb_info) @@ -1669,9 +1654,7 @@ static void unbind_console(struct fb_info *fb_info) if (WARN_ON(i < 0 || i >=3D FB_MAX || registered_fb[i] !=3D fb_info)) return; =20 - console_lock(); fbcon_fb_unbind(fb_info); - console_unlock(); } =20 static void unlink_framebuffer(struct fb_info *fb_info) @@ -1714,9 +1697,7 @@ static void do_unregister_framebuffer(struct fb_info = *fb_info) fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); } #endif - console_lock(); fbcon_fb_unregistered(fb_info); - console_unlock(); =20 /* this may free fb info */ put_fb_info(fb_info); --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37CFAC433FE for ; Mon, 31 Jan 2022 21:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380351AbiAaVIy (ORCPT ); Mon, 31 Jan 2022 16:08:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380237AbiAaVG7 (ORCPT ); Mon, 31 Jan 2022 16:06:59 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E66C061753 for ; Mon, 31 Jan 2022 13:06:51 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso230560wms.4 for ; Mon, 31 Jan 2022 13:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DLCFktF5bXfVELdSs1sFnaEEXohencjsFb8X+BTPOv4=; b=IHzC2SevZm5+o9SbqNmhgWdJDul0iEkmYGyVGe/SmayW6tHVYAPf+A5/26FIZeTE+D 0VOw3ADfS5vBpiQTuUGs2n8y+G19uSujvFy7DZ7THok1dM7BC3LIlrb046oFUnkEtglA ktiGzuVyyG84pbn82uIEzbyH2elqAexWphQIk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DLCFktF5bXfVELdSs1sFnaEEXohencjsFb8X+BTPOv4=; b=GTG5CwIM5MJnN2j1i4BrxSUA0xGlNOWQGoxNM4L8GIYdDIofWXQx6pA3FBISbyegze D3xi50Czm2pbjIV8apYvU3XdjjqJjTUT0LCG6H4ZVTHwWTG6SP+u1LjRsfIkuaYQu7X2 EdifWZ3k1FVYbxeydSwSpaouVs8xxHNUtZ5O43n3UVdzXPVwP1AXHA6pQETfJXGvHbY0 0dy4OZfI6wnCmTrSX6JOjqBMUgKGO7P9ZaR2ibcB7SZ5b2geb7uUy7jYXX5wdCDnKHP0 9G7U4cMfLYYaKUKGdWGB3GfKc5S3KCuwi2ckxQ52eyUod/4QZLVblr9NqgF7FZ7+lxY1 ERvQ== X-Gm-Message-State: AOAM532NjHyxXeTGQnqx9GKMY3PRz2L/r0ntUJqndV8lAOGK2AEOkowh C+PFFazKlcLGo5ysRpvirEP3zw== X-Google-Smtp-Source: ABdhPJwL5EQol13tK1r2sH3cLNG0kbIqqGvoNKhVRDedFDmv74vH5tVE+s2M6mlbGpn9cwEZu83+7w== X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr28651132wmq.44.1643663210600; Mon, 31 Jan 2022 13:06:50 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:50 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Tetsuo Handa , Greg Kroah-Hartman , Du Cheng , Claudio Suarez Subject: [PATCH 17/21] fbcon: Move more code into fbcon_release Date: Mon, 31 Jan 2022 22:05:48 +0100 Message-Id: <20220131210552.482606-18-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" con2fb_release_oldinfo() has a bunch more kfree() calls than fbcon_exit(), but since kfree() on NULL is harmless doing that in both places should be ok. This is also a bit more symmetric now again with fbcon_open also allocating the fbcon_ops structure. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Tetsuo Handa Cc: Greg Kroah-Hartman Cc: Du Cheng Cc: Claudio Suarez --- drivers/video/fbdev/core/fbcon.c | 33 +++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index e5e8aaf6f60d..5c14e24d14a1 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -688,6 +688,18 @@ static void fbcon_release(struct fb_info *info) unlock_fb_info(info); =20 module_put(info->fbops->owner); + + if (info->fbcon_par) { + struct fbcon_ops *ops =3D info->fbcon_par; + + fbcon_del_cursor_work(info); + kfree(ops->cursor_state.mask); + kfree(ops->cursor_data); + kfree(ops->cursor_src); + kfree(ops->fontbuffer); + kfree(info->fbcon_par); + info->fbcon_par =3D NULL; + } } =20 static int fbcon_open(struct fb_info *info) @@ -741,18 +753,10 @@ static int con2fb_acquire_newinfo(struct vc_data *vc,= struct fb_info *info, static void con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *old= info, struct fb_info *newinfo) { - struct fbcon_ops *ops =3D oldinfo->fbcon_par; int ret; =20 fbcon_release(oldinfo); =20 - fbcon_del_cursor_work(oldinfo); - kfree(ops->cursor_state.mask); - kfree(ops->cursor_data); - kfree(ops->cursor_src); - kfree(ops->fontbuffer); - kfree(oldinfo->fbcon_par); - oldinfo->fbcon_par =3D NULL; /* If oldinfo and newinfo are driving the same hardware, the fb_release() method of oldinfo may attempt to @@ -3335,19 +3339,8 @@ static void fbcon_exit(void) } } =20 - if (mapped) { - if (info->fbcon_par) { - struct fbcon_ops *ops =3D info->fbcon_par; - - fbcon_del_cursor_work(info); - kfree(ops->cursor_src); - kfree(ops->cursor_state.mask); - kfree(info->fbcon_par); - info->fbcon_par =3D NULL; - } - + if (mapped) fbcon_release(info); - } } } =20 --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A33BC433EF for ; Mon, 31 Jan 2022 21:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381280AbiAaVI5 (ORCPT ); Mon, 31 Jan 2022 16:08:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380436AbiAaVHE (ORCPT ); Mon, 31 Jan 2022 16:07:04 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCC0C061757 for ; Mon, 31 Jan 2022 13:06:52 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id n8so11190524wmk.3 for ; Mon, 31 Jan 2022 13:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xR2Cpj9NPzd3PMXMumK8tGjLNRzMjrUh58YqCebhDEo=; b=ZXAAWHU3cxYjQqaynKuzlDitJZki2ld78sfGg5BvoOXCxWUICbZVwllmG72oQjrJqV MFAF6FjmGHluZ4RcYolzuSjzNn2P05ro9f3pwcZjHwx7b9I20PuWxiFZLgb3boxLRRsu DLoJLArEnqol2fPTAyDdyu3SOHyLveDYE6buc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xR2Cpj9NPzd3PMXMumK8tGjLNRzMjrUh58YqCebhDEo=; b=fWdd6N79fVKtuVFktCx/mOqR//BMEAOCd1d9+crvieCc2mMOOlBgBLDAwaoKEko/sb yxFW7IzOYDeMeEahKBjwLkwtOHX7Z5FhDGLan5+hqIjyL0rBqljQ651pufaRguFMoBs3 F8BvFUye5fheLoPDtpYvD8o88/cwRuQgin6g8ZNniJTz0ZMm/5+shurgzUvkuBHEccTx nMO8LtSyQoiWNG5dKn0jQSidVIdNFVOPIpHDEMTt+l2eScrraH3r/F6/Btw0+yvcCNen HHODZdrw+2L+FTJKyeBAE1jnUblmw0QGJ/VRHWV/dMANCStm1dmPuX3QJcoUvYdnpUwq 5m/w== X-Gm-Message-State: AOAM5309pvucUUrpVIVRDZDq3xYk6l75DXI0eTK58xY1WPXJPWTInWmi KnWPImrKwoZN9uGWZvD55RRHgQ== X-Google-Smtp-Source: ABdhPJwsHKFlXJjctslIwLzw0eq71bo0GChWx/OaKsX1kI+rSPX9G1EgnGiUQOnkpJ2lxJyTJPvEfw== X-Received: by 2002:a05:600c:38a:: with SMTP id w10mr23340953wmd.12.1643663211423; Mon, 31 Jan 2022 13:06:51 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:51 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Greg Kroah-Hartman , Claudio Suarez , Du Cheng , Tetsuo Handa Subject: [PATCH 18/21] fbcon: untangle fbcon_exit Date: Mon, 31 Jan 2022 22:05:49 +0100 Message-Id: <20220131210552.482606-19-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There's a bunch of confusions going on here: - The deferred fbcon setup notifier should only be cleaned up from fb_console_exit(), to be symmetric with fb_console_init() - We also need to make sure we don't race with the work, which means temporarily dropping the console lock (or we can deadlock) - That also means no point in clearing deferred_takeover, we are unloading everything anyway. - Finally rename fbcon_exit to fbcon_release_all and move it, since that's what's it doing when being called from consw->con_deinit through fbcon_deinit. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Claudio Suarez Cc: Du Cheng Cc: Tetsuo Handa --- drivers/video/fbdev/core/fbcon.c | 63 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 5c14e24d14a1..22581952b4fd 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -185,7 +185,6 @@ static void fbcon_set_disp(struct fb_info *info, struct= fb_var_screeninfo *var, int unit); static void fbcon_modechanged(struct fb_info *info); static void fbcon_set_all_vcs(struct fb_info *info); -static void fbcon_exit(void); =20 static struct device *fbcon_device; =20 @@ -1149,6 +1148,27 @@ static void fbcon_free_font(struct fbcon_display *p,= bool freefont) =20 static void set_vc_hi_font(struct vc_data *vc, bool set); =20 +static void fbcon_release_all(void) +{ + struct fb_info *info; + int i, j, mapped; + + for_each_registered_fb(i) { + mapped =3D 0; + info =3D registered_fb[i]; + + for (j =3D first_fb_vc; j <=3D last_fb_vc; j++) { + if (con2fb_map[j] =3D=3D i) { + mapped =3D 1; + con2fb_map[j] =3D -1; + } + } + + if (mapped) + fbcon_release(info); + } +} + static void fbcon_deinit(struct vc_data *vc) { struct fbcon_display *p =3D &fb_display[vc->vc_num]; @@ -1188,7 +1208,7 @@ static void fbcon_deinit(struct vc_data *vc) set_vc_hi_font(vc, false); =20 if (!con_is_bound(&fb_con)) - fbcon_exit(); + fbcon_release_all(); =20 if (vc->vc_num =3D=3D logo_shown) logo_shown =3D FBCON_LOGO_CANSHOW; @@ -3316,34 +3336,6 @@ static void fbcon_start(void) #endif } =20 -static void fbcon_exit(void) -{ - struct fb_info *info; - int i, j, mapped; - -#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER - if (deferred_takeover) { - dummycon_unregister_output_notifier(&fbcon_output_nb); - deferred_takeover =3D false; - } -#endif - - for_each_registered_fb(i) { - mapped =3D 0; - info =3D registered_fb[i]; - - for (j =3D first_fb_vc; j <=3D last_fb_vc; j++) { - if (con2fb_map[j] =3D=3D i) { - mapped =3D 1; - con2fb_map[j] =3D -1; - } - } - - if (mapped) - fbcon_release(info); - } -} - void __init fb_console_init(void) { int i; @@ -3383,10 +3375,19 @@ static void __exit fbcon_deinit_device(void) =20 void __exit fb_console_exit(void) { +#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER + console_lock(); + if (deferred_takeover) + dummycon_unregister_output_notifier(&fbcon_output_nb); + console_unlock(); + + cancel_work_sync(&fbcon_deferred_takeover_work); +#endif + console_lock(); fbcon_deinit_device(); device_destroy(fb_class, MKDEV(0, 0)); - fbcon_exit(); + do_unregister_con_driver(&fb_con); console_unlock(); }=09 --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EED5C433F5 for ; Mon, 31 Jan 2022 21:09:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381300AbiAaVJB (ORCPT ); Mon, 31 Jan 2022 16:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380560AbiAaVHJ (ORCPT ); Mon, 31 Jan 2022 16:07:09 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A41D6C06176F for ; Mon, 31 Jan 2022 13:06:53 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id o1-20020a1c4d01000000b0034d95625e1fso284229wmh.4 for ; Mon, 31 Jan 2022 13:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BL4fo+2WOVTby6QLKLV1nVWtvQ3JNOhu+8wB2s/+LIQ=; b=lLAk+I5V89CC9MFc55MMdOMjGF/tYWATRKVaKN+mU+U/Zp9rNdtcHwwA4O9ivim8U4 uhebJSd0VSHz4+CYgUEh4M7+LU+xaEJZG+163OfCeS7yOE+ftK3RBaICg7lCK+O10tNI 7MA38sqKnpewyjNRhdRuH71H/gnUy0kn0+j0I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BL4fo+2WOVTby6QLKLV1nVWtvQ3JNOhu+8wB2s/+LIQ=; b=McrvnLCfa4M2Vh/d1kNkoXMiG/rQh9yp02f9oDWefhderwHyV6dd+MTX0GC1y70O73 CnKuUb0zm9CrfBCv9T4bGUw9s3JX7PSoy36+iqvRXHpxrZwN0HKitDfF2t/migPLJgrT O2Urg1emVHEcQmjMlck0+W7+kwHIsV4+WrwJl72F1e8L6ShEVgVpT9sqqgmBZzWbM8qt 6OomahpBLarAyjVs2SQ48O/ZAcia9goJPTgMLecmlQ1KQAawxCYqFrwWvKPPgksvX8wF T5i6EUKP8DucyFXlVs8iZUOt1VI9OWh+OcRLxvu1XeDA60cVw4S+xXAmtY2ApFruISgS 62ag== X-Gm-Message-State: AOAM5302GoOCTMKRXXRh9Ly+hfOKcd8MLF0HMLw/Vz6FSDHmuPAzdOmA f5cNhmhv7753I9UfcUoDHoQ1qMffbgULXQ== X-Google-Smtp-Source: ABdhPJym9NA44EvixyMQWymA9HgMTQo3UEXCCeTnD39yMkLuzcB/0jUZ9xIYu3slC/yauz5ZL1NXmg== X-Received: by 2002:a1c:f210:: with SMTP id s16mr20179198wmc.99.1643663212301; Mon, 31 Jan 2022 13:06:52 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:51 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Daniel Vetter , Daniel Vetter , Tetsuo Handa , Claudio Suarez , Du Cheng , Greg Kroah-Hartman Subject: [PATCH 19/21] fbcon: Maintain a private array of fb_info Date: Mon, 31 Jan 2022 22:05:50 +0100 Message-Id: <20220131210552.482606-20-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Accessing the one in fbmem.c without taking the right locks is a bad idea. Instead maintain our own private copy, which is fully protected by console_lock() (like everything else in fbcon.c). That copy is serialized through fbcon_fb_registered/unregistered() calls. Also this means we do not need to hold a full fb_info reference, which is nice because doing so would mean a refcount loop between the console and the fb_info. But it's also not nice since it means console_lock() must be held absolutely everywhere. Well strictly speaking we could still try to do some refcounting games again by calling get_fb_info before we drop the console_lock. But things will get tricky. Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Tetsuo Handa Cc: Claudio Suarez Cc: Du Cheng Cc: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbcon.c | 82 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 22581952b4fd..a0ca34b29615 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -86,10 +86,6 @@ * - fbcon state itself is protected by the console_lock, and the code doe= s a * pretty good job at making sure that lock is held everywhere it's need= ed. * - * - access to the registered_fb array is entirely unprotected. This shoul= d use - * proper object lifetime handling, i.e. get/put_fb_info. This also means - * switching from indices to proper pointers for fb_info everywhere. - * * - fbcon doesn't bother with fb_lock/unlock at all. This is buggy, since= it * means concurrent access to the same fbdev from both fbcon and userspa= ce * will blow up. To fix this all fbcon calls from fbmem.c need to be mov= ed out @@ -107,6 +103,13 @@ enum { =20 static struct fbcon_display fb_display[MAX_NR_CONSOLES]; =20 +struct fb_info *fbcon_registered_fb[FB_MAX]; +int fbcon_num_registered_fb; + +#define fbcon_for_each_registered_fb(i) \ + for (i =3D 0; WARN_CONSOLE_UNLOCKED(), i < FB_MAX; i++) \ + if (!fbcon_registered_fb[i]) {} else + static signed char con2fb_map[MAX_NR_CONSOLES]; static signed char con2fb_map_boot[MAX_NR_CONSOLES]; =20 @@ -114,12 +117,7 @@ static struct fb_info *fbcon_info_from_console(int con= sole) { WARN_CONSOLE_UNLOCKED(); =20 - /* - * Note that only con2fb_map is protected by the console lock, - * registered_fb is protected by a separate mutex. This lookup can - * therefore race. - */ - return registered_fb[con2fb_map[console]]; + return fbcon_registered_fb[con2fb_map[console]]; } =20 static int logo_lines; @@ -516,7 +514,7 @@ static int do_fbcon_takeover(int show_logo) { int err, i; =20 - if (!num_registered_fb) + if (!fbcon_num_registered_fb) return -ENODEV; =20 if (!show_logo) @@ -822,7 +820,7 @@ static int set_con2fb_map(int unit, int newidx, int use= r) { struct vc_data *vc =3D vc_cons[unit].d; int oldidx =3D con2fb_map[unit]; - struct fb_info *info =3D registered_fb[newidx]; + struct fb_info *info =3D fbcon_registered_fb[newidx]; struct fb_info *oldinfo =3D NULL; int found, err =3D 0, show_logo; =20 @@ -840,7 +838,7 @@ static int set_con2fb_map(int unit, int newidx, int use= r) } =20 if (oldidx !=3D -1) - oldinfo =3D registered_fb[oldidx]; + oldinfo =3D fbcon_registered_fb[oldidx]; =20 found =3D search_fb_in_map(newidx); =20 @@ -932,13 +930,13 @@ static const char *fbcon_startup(void) * If num_registered_fb is zero, this is a call for the dummy part. * The frame buffer devices weren't initialized yet. */ - if (!num_registered_fb || info_idx =3D=3D -1) + if (!fbcon_num_registered_fb || info_idx =3D=3D -1) return display_desc; /* * Instead of blindly using registered_fb[0], we use info_idx, set by * fbcon_fb_registered(); */ - info =3D registered_fb[info_idx]; + info =3D fbcon_registered_fb[info_idx]; if (!info) return NULL; =09 @@ -1153,9 +1151,9 @@ static void fbcon_release_all(void) struct fb_info *info; int i, j, mapped; =20 - for_each_registered_fb(i) { + fbcon_for_each_registered_fb(i) { mapped =3D 0; - info =3D registered_fb[i]; + info =3D fbcon_registered_fb[i]; =20 for (j =3D first_fb_vc; j <=3D last_fb_vc; j++) { if (con2fb_map[j] =3D=3D i) { @@ -1182,7 +1180,7 @@ static void fbcon_deinit(struct vc_data *vc) if (idx =3D=3D -1) goto finished; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; =20 if (!info) goto finished; @@ -2118,9 +2116,9 @@ static int fbcon_switch(struct vc_data *vc) * * info->currcon =3D vc->vc_num; */ - for_each_registered_fb(i) { - if (registered_fb[i]->fbcon_par) { - struct fbcon_ops *o =3D registered_fb[i]->fbcon_par; + fbcon_for_each_registered_fb(i) { + if (fbcon_registered_fb[i]->fbcon_par) { + struct fbcon_ops *o =3D fbcon_registered_fb[i]->fbcon_par; =20 o->currcon =3D vc->vc_num; } @@ -2765,7 +2763,7 @@ int fbcon_mode_deleted(struct fb_info *info, j =3D con2fb_map[i]; if (j =3D=3D -1) continue; - fb_info =3D registered_fb[j]; + fb_info =3D fbcon_registered_fb[j]; if (fb_info !=3D info) continue; p =3D &fb_display[i]; @@ -2821,7 +2819,7 @@ void fbcon_fb_unbind(struct fb_info *info) set_con2fb_map(i, new_idx, 0); } } else { - struct fb_info *info =3D registered_fb[idx]; + struct fb_info *info =3D fbcon_registered_fb[idx]; =20 /* This is sort of like set_con2fb_map, except it maps * the consoles to no device and then releases the @@ -2851,6 +2849,9 @@ void fbcon_fb_unregistered(struct fb_info *info) =20 console_lock(); =20 + fbcon_registered_fb[info->node] =3D NULL; + fbcon_num_registered_fb--; + if (deferred_takeover) { console_unlock(); return; @@ -2865,7 +2866,7 @@ void fbcon_fb_unregistered(struct fb_info *info) if (idx =3D=3D info_idx) { info_idx =3D -1; =20 - for_each_registered_fb(i) { + fbcon_for_each_registered_fb(i) { info_idx =3D i; break; } @@ -2881,7 +2882,7 @@ void fbcon_fb_unregistered(struct fb_info *info) if (primary_device =3D=3D idx) primary_device =3D -1; =20 - if (!num_registered_fb) + if (!fbcon_num_registered_fb) do_unregister_con_driver(&fb_con); console_unlock(); } @@ -2956,6 +2957,9 @@ int fbcon_fb_registered(struct fb_info *info) else atomic_inc(&ignore_console_lock_warning); =20 + fbcon_registered_fb[info->node] =3D info; + fbcon_num_registered_fb++; + idx =3D info->node; fbcon_select_primary(info); =20 @@ -3075,9 +3079,9 @@ int fbcon_set_con2fb_map_ioctl(void __user *argp) return -EINVAL; if (con2fb.framebuffer >=3D FB_MAX) return -EINVAL; - if (!registered_fb[con2fb.framebuffer]) + if (!fbcon_registered_fb[con2fb.framebuffer]) request_module("fb%d", con2fb.framebuffer); - if (!registered_fb[con2fb.framebuffer]) { + if (!fbcon_registered_fb[con2fb.framebuffer]) { return -EINVAL; } =20 @@ -3144,10 +3148,10 @@ static ssize_t store_rotate(struct device *device, console_lock(); idx =3D con2fb_map[fg_console]; =20 - if (idx =3D=3D -1 || registered_fb[idx] =3D=3D NULL) + if (idx =3D=3D -1 || fbcon_registered_fb[idx] =3D=3D NULL) goto err; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; rotate =3D simple_strtoul(buf, last, 0); fbcon_rotate(info, rotate); err: @@ -3166,10 +3170,10 @@ static ssize_t store_rotate_all(struct device *devi= ce, console_lock(); idx =3D con2fb_map[fg_console]; =20 - if (idx =3D=3D -1 || registered_fb[idx] =3D=3D NULL) + if (idx =3D=3D -1 || fbcon_registered_fb[idx] =3D=3D NULL) goto err; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; rotate =3D simple_strtoul(buf, last, 0); fbcon_rotate_all(info, rotate); err: @@ -3186,10 +3190,10 @@ static ssize_t show_rotate(struct device *device, console_lock(); idx =3D con2fb_map[fg_console]; =20 - if (idx =3D=3D -1 || registered_fb[idx] =3D=3D NULL) + if (idx =3D=3D -1 || fbcon_registered_fb[idx] =3D=3D NULL) goto err; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; rotate =3D fbcon_get_rotate(info); err: console_unlock(); @@ -3206,10 +3210,10 @@ static ssize_t show_cursor_blink(struct device *dev= ice, console_lock(); idx =3D con2fb_map[fg_console]; =20 - if (idx =3D=3D -1 || registered_fb[idx] =3D=3D NULL) + if (idx =3D=3D -1 || fbcon_registered_fb[idx] =3D=3D NULL) goto err; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; ops =3D info->fbcon_par; =20 if (!ops) @@ -3232,10 +3236,10 @@ static ssize_t store_cursor_blink(struct device *de= vice, console_lock(); idx =3D con2fb_map[fg_console]; =20 - if (idx =3D=3D -1 || registered_fb[idx] =3D=3D NULL) + if (idx =3D=3D -1 || fbcon_registered_fb[idx] =3D=3D NULL) goto err; =20 - info =3D registered_fb[idx]; + info =3D fbcon_registered_fb[idx]; =20 if (!info->fbcon_par) goto err; @@ -3295,8 +3299,8 @@ static void fbcon_register_existing_fbs(struct work_s= truct *work) deferred_takeover =3D false; logo_shown =3D FBCON_LOGO_DONTSHOW; =20 - for_each_registered_fb(i) - fbcon_fb_registered(registered_fb[i]); + fbcon_for_each_registered_fb(i) + fbcon_fb_registered(fbcon_registered_fb[i]); =20 console_unlock(); } --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2797BC433F5 for ; Mon, 31 Jan 2022 21:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381315AbiAaVJF (ORCPT ); Mon, 31 Jan 2022 16:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380576AbiAaVHJ (ORCPT ); Mon, 31 Jan 2022 16:07:09 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987EEC061771 for ; Mon, 31 Jan 2022 13:06:54 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id m14so27680858wrg.12 for ; Mon, 31 Jan 2022 13:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aGreVoBv5lFrGAhkKBR22I8AcuYmyzl1ND80HuTCbWw=; b=Ce2EXiZ6NeWaMQg7vuTxuhe84d+UnW4ndFL8GON+RIrMFrKsXLBgnAYvw3YX7WHoob 8iy9fYppGJA1n5RdF5uOmTbl35qes7UPTXp58TH4VzJ/2T4MaY6yf24bJlKJAdBErdgu qHKH9P+j50ghgEGyY1xMaZSVgQklR+WgfJEBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aGreVoBv5lFrGAhkKBR22I8AcuYmyzl1ND80HuTCbWw=; b=UFehHlFwQKzH++54q3HR6TNPlLgAPIMDLp3OOgAz/VXQNcloJRcv/mVhnzYpRt6ZZ2 T9fglFJgZm5Qeg0dXHYo5kEpcRjgmNy1k+59v3se0aaXnpFI89T2/daHOIH7XYExwZaL N8+zvJ0+lgmCWQwn0mE/2m8kJHzkknT0n72vLw+31ceR10M0M1NCvbsFyYHNnMfTTOF5 2oe9i/aDSgWyELV0Py9+TqNJe6OJv2voudcZ35rE6ZByLq8DEILBev0q8HU+ko8V2cd3 G8l3Dlvu1ZziPMx/aoIKFrvd9Wwf1vjw2uegushjkD/sebi6UHRVKNdsyXgh/KIdYGnN D5GA== X-Gm-Message-State: AOAM532qah2hRdRYzWThaRkr+wbMn5ny+dcAvodr9D1eZ6tTV+WOuKzO 89JZKKUMUYXqL1YMUwu16BTcEA== X-Google-Smtp-Source: ABdhPJx/nOHwEr/5eFZj9enrGYAxDjjY1aE3BvBG5xK+gsRkdtoyvkoY3tqiyHdzYyxTwphjn5fXwQ== X-Received: by 2002:a5d:6341:: with SMTP id b1mr18173217wrw.719.1643663213206; Mon, 31 Jan 2022 13:06:53 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:52 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Thomas Zimmermann , Zack Rusin , Javier Martinez Canillas , Hans de Goede , Ilya Trukhanov , Daniel Vetter , Peter Jones Subject: [PATCH 20/21] Revert "fbdev: Prevent probing generic drivers if a FB is already registered" Date: Mon, 31 Jan 2022 22:05:51 +0100 Message-Id: <20220131210552.482606-21-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This reverts commit fb561bf9abde49f7e00fdbf9ed2ccf2d86cac8ee. With commit 27599aacbaefcbf2af7b06b0029459bbf682000d Author: Thomas Zimmermann Date: Tue Jan 25 10:12:18 2022 +0100 fbdev: Hot-unplug firmware fb devices on forced removal this should be fixed properly and we can remove this somewhat hackish check here (e.g. this won't catch drm drivers if fbdev emulation isn't enabled). Cc: Thomas Zimmermann Cc: Zack Rusin Cc: Javier Martinez Canillas Cc: Zack Rusin Cc: Hans de Goede Cc: Ilya Trukhanov Signed-off-by: Daniel Vetter Cc: Peter Jones Cc: linux-fbdev@vger.kernel.org --- drivers/video/fbdev/efifb.c | 11 ----------- drivers/video/fbdev/simplefb.c | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index ea42ba6445b2..edca3703b964 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -351,17 +351,6 @@ static int efifb_probe(struct platform_device *dev) char *option =3D NULL; efi_memory_desc_t md; =20 - /* - * Generic drivers must not be registered if a framebuffer exists. - * If a native driver was probed, the display hardware was already - * taken and attempting to use the system framebuffer is dangerous. - */ - if (num_registered_fb > 0) { - dev_err(&dev->dev, - "efifb: a framebuffer is already registered\n"); - return -EINVAL; - } - if (screen_info.orig_video_isVGA !=3D VIDEO_TYPE_EFI || pci_dev_disabled) return -ENODEV; =20 diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 57541887188b..ee8b4412f7e4 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -407,17 +407,6 @@ static int simplefb_probe(struct platform_device *pdev) struct simplefb_par *par; struct resource *mem; =20 - /* - * Generic drivers must not be registered if a framebuffer exists. - * If a native driver was probed, the display hardware was already - * taken and attempting to use the system framebuffer is dangerous. - */ - if (num_registered_fb > 0) { - dev_err(&pdev->dev, - "simplefb: a framebuffer is already registered\n"); - return -EINVAL; - } - if (fb_get_options("simplefb", NULL)) return -ENODEV; =20 --=20 2.33.0 From nobody Mon Jun 29 23:25:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5FC8C433EF for ; Mon, 31 Jan 2022 21:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381336AbiAaVJJ (ORCPT ); Mon, 31 Jan 2022 16:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380665AbiAaVHN (ORCPT ); Mon, 31 Jan 2022 16:07:13 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B928C061773 for ; Mon, 31 Jan 2022 13:06:55 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id e2so27978316wra.2 for ; Mon, 31 Jan 2022 13:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FxNR4P5lDXdqDoRY6o7wMDtTBWXikuXUtP+0kdBf7FQ=; b=Lo4AW9guvOF81u6WGQBXjsTZUvFuBcQIdzBj2fKuxIY0ijvWI/WKVVcAEew+wpAmNv T9o5T51UXeGAC8PY0e/dJSsEAeJCL79CCkRMNfyQnjXBUsH8+RxF6XddMCurXVkMGdfT UwQJSGBW+iiRzyYdMPsOrpy+yu64udBa1ILAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FxNR4P5lDXdqDoRY6o7wMDtTBWXikuXUtP+0kdBf7FQ=; b=Zs7k2cumxjGybbH+asvNzk93p4ontH2a3ehSRi59G7vqgy3skKMMS3FbqH5AXnwHCk eK+GujLipdSXXCSxYVXtW5CTKkVETGQlVjXYDz36cVKf7TTdTdr8bmoPV13yinw5XbW5 ELjvCGqgJH7RASTWOK/WTxL/hm+QG2ecNF+h1OaHEbJIDA17txNPUDHEZxuaXHChEOa8 urQJdNQgG0p2UMH0kJXLqIktal8S3c4WzpVTsEqTOtyxlESJa4NL9tb+/kP/HGR1mZqN 1TGla51iGq64aozPEHd25rbAQsODmlgEsMYvtpNFJcn10xpAeTRYYiPVQFn2Uy9b3+B8 OL6g== X-Gm-Message-State: AOAM530vxmv3XnXOs4/0sktNrvEdYWOiLDHR/thKtlAW79PaLN9mG6RX LCgayFwKOmKBYNffOKhCIPUv9g== X-Google-Smtp-Source: ABdhPJwF2QvK4hmf/7QGpz8EsMBpbsf23W007iTEYAPXtLNPFXTESQvIlo2rylKpGsmivnZGCNYQaQ== X-Received: by 2002:adf:e8ce:: with SMTP id k14mr10214483wrn.284.1643663214293; Mon, 31 Jan 2022 13:06:54 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id b11sm314961wmq.46.2022.01.31.13.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:06:53 -0800 (PST) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , linux-fbdev@vger.kernel.org, LKML , Daniel Vetter , Jens Frederich , Jon Nettleton , Greg Kroah-Hartman , linux-staging@lists.linux.dev, Daniel Vetter , Daniel Vetter , Helge Deller , Matthew Wilcox , Sam Ravnborg , Tetsuo Handa , Zhen Lei , Alex Deucher , Xiyu Yang , Zheyu Ma , Guenter Roeck Subject: [PATCH 21/21] fbdev: Make registered_fb[] private to fbmem.c Date: Mon, 31 Jan 2022 22:05:52 +0100 Message-Id: <20220131210552.482606-22-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220131210552.482606-1-daniel.vetter@ffwll.ch> References: <20220131210552.482606-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Well except when the olpc dcon fbdev driver is enabled, that thing digs around in there in rather unfixable ways. Cc oldc_dcon maintainers as fyi. Cc: Jens Frederich Cc: Jon Nettleton Cc: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev Signed-off-by: Daniel Vetter Cc: Daniel Vetter Cc: Helge Deller Cc: Matthew Wilcox Cc: Sam Ravnborg Cc: Tetsuo Handa Cc: Zhen Lei Cc: Alex Deucher Cc: Xiyu Yang Cc: linux-fbdev@vger.kernel.org Cc: Zheyu Ma Cc: Guenter Roeck --- drivers/video/fbdev/core/fbmem.c | 8 ++++++-- include/linux/fb.h | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fb= mem.c index 904ef1250677..dad6572942fa 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -48,10 +48,14 @@ static DEFINE_MUTEX(registration_lock); =20 struct fb_info *registered_fb[FB_MAX] __read_mostly; -EXPORT_SYMBOL(registered_fb); - int num_registered_fb __read_mostly; +#if IS_ENABLED(CONFIG_OLPC_DCON) +EXPORT_SYMBOL(registered_fb); EXPORT_SYMBOL(num_registered_fb); +#endif +#define for_each_registered_fb(i) \ + for (i =3D 0; i < FB_MAX; i++) \ + if (!registered_fb[i]) {} else =20 bool fb_center_logo __read_mostly; =20 diff --git a/include/linux/fb.h b/include/linux/fb.h index a8a00d2ba1f3..e236817502c2 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -622,16 +622,15 @@ extern int fb_get_color_depth(struct fb_var_screeninf= o *var, extern int fb_get_options(const char *name, char **option); extern int fb_new_modelist(struct fb_info *info); =20 +#if IS_ENABLED(CONFIG_OLPC_DCON) extern struct fb_info *registered_fb[FB_MAX]; + extern int num_registered_fb; +#endif extern bool fb_center_logo; extern int fb_logo_count; extern struct class *fb_class; =20 -#define for_each_registered_fb(i) \ - for (i =3D 0; i < FB_MAX; i++) \ - if (!registered_fb[i]) {} else - static inline void lock_fb_info(struct fb_info *info) { mutex_lock(&info->lock); --=20 2.33.0