From nobody Wed Nov 25 17:40:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=93.77.172.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795626230; b=3bQXLl+AE30Jybze2oDNyJSPd7ziW43ehd4ChRlFSY3I1LMyWqKOD4rU+oxZlZmVye5U CQADVnlj+pHoC2f77i+lSLHpOcoz3G4du8zJwuqEZfH9t4x/KctnQ1xCj2bLeUARCKQNV UXRUyIRinbGOgYclLr74XB0wxojbxDzto0LktAFS6pn0AeXsmSbT6M30qiNfTf0ETMYhk K8K95aaph9nDAj8t62Auzzyzp51B+smi9DkmRy7vM51SvT6EIAMX3IWiSOEmj4SRNTfP5 CJ7STXde3xeSc7MEeyjvo1FpFpjcPLenLpxVjM9Uh9K6w4tUC+CUbg5RAatyM1TRZtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795626230; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=hQzOlpIe7Macc6jkr29wJlXF7KJ+0xfNYtPVrAFrPjI=; b=kdrksESH55L+S1qcdzUSL3yi+ESip0/A2RIOPKCnXuEJwJhGbdoRR1ccZYQCnQe87Iqk BMUHEFehO/lS2qMBVaoX/JGOyJirX3xB44I1FgY+uSd8QYSXtSdPK0bPjl18mNl8WYRXu D3WTjja44XAkABFrFaSEP0eMkbFA5artjouweNdnA0TgCmyKsuqR6l38lkAwdQRdg0iTw M2dKUyAmaWg+Olc/MyxAkYVJbOOasqAg0kJrP8RKrSXvDYYhM061mUDLyJsqsWcE3f8ln br0MmcM4ktiRZ4fxadysYdLcjfmMAfFV9j+/HxN+DdpWVyiL7pvxK+16eHLdMOAcWHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yandex-team.ru; spf=pass smtp.mailfrom=yandex-team.ru; dkim=pass header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=sp3XbSIG; arc=none smtp.remote-ip=93.77.172.4 Received: from forwardcorp1e.mail.yandex.net (forwardcorp1e.mail.yandex.net [93.77.172.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAAF7606A327; Wed, 25 Nov 2026 17:03:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DAAF7606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=sp3XbSIG Received: from mail-nwsmtp-smtp-corp-main-80 (mail-nwsmtp-smtp-corp-main-80.yp-c.yandex.net) by forwardcorp1e.mail.yandex.net (postfix) with ESMTPS id E617B10031F; Wed, 25 Nov 2026 20:03:40 +0300 (MSK) Received: from [127.0.1.1] by mail-nwsmtp-smtp-corp-main-80 with ESMTPSA id a3lrP22Zo8c0-skm5dOxa; Wed, 25 Nov 2026 20:03:40 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1795626220; bh=hQzOlpIe7Macc6jkr29wJlXF7KJ+0xfNYtPVrAFrPjI=; h=Cc:In-Reply-To:Message-Id:To:Date:References:From:Subject; b=sp3XbSIGnCe95K7Azy4+apRXQGPldONKo8EZZtcR4MkhxVqr3LriDbkYR32FY7j4Y +71vB4RUEowKwoKeP4+Zk5h1OaiOwBbgn0E8m8xHsRRINjGS2gGpI168gP5Fvcdgsg MSGOLn/dML7TTkDQFYBiV2qytGraDEhHl3GY7BaE= Authentication-Results: mail-nwsmtp-smtp-corp-main-80; dkim=pass header.i=@yandex-team.ru From: Mikhail Rudenko Date: Wed, 25 Nov 2026 20:03:25 +0300 Subject: [PATCH 1/3] efi: earlycon: unmap framebuffer when the console is unregistered X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261125-efi-earlycon-v1-1-49ac2c0a430b@yandex-team.ru> References: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> In-Reply-To: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> To: Ard Biesheuvel , Ilias Apalodimas , Thomas Zimmermann , Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter , Peter Jones , Helge Deller , Hans de Goede , Jonathan Corbet , Shuah Khan , Randy Dunlap Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-doc@vger.kernel.org, Mikhail Rudenko X-Mailer: b4 0.15.2 EFI earlycon currently unmaps its framebuffer at a late initcall only if the boot console has already been unregistered. With keep_bootcon, the console is still registered at that point, so the mapping is retained. Move the unmap to the console exit callback. This ties the mapping's lifetime to the console's lifetime and releases it after console writers have stopped. Clear the saved console pointer on exit. Signed-off-by: Mikhail Rudenko --- drivers/firmware/efi/earlycon.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlyco= n.c index 3d060d59968cf..3a6eaf5481f40 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -14,7 +14,7 @@ =20 #include =20 -static const struct console *earlycon_console __initdata; +static struct console *earlycon_console; static const struct font_desc *font; static u16 cur_line_y, max_line_y; static u32 efi_x_array[1024]; @@ -44,14 +44,15 @@ static int __init efi_earlycon_remap_fb(void) } early_initcall(efi_earlycon_remap_fb); =20 -static int __init efi_earlycon_unmap_fb(void) +static int efi_earlycon_exit(struct console *con) { - /* unmap the bootconsole fb unless keep_bootcon left it registered */ - if (efi_fb && !console_is_registered(earlycon_console)) + if (efi_fb) { memunmap(efi_fb); + efi_fb =3D NULL; + } + WRITE_ONCE(earlycon_console, NULL); return 0; } -late_initcall(efi_earlycon_unmap_fb); =20 static __ref void *efi_earlycon_map(unsigned long start, unsigned long len) { @@ -269,6 +270,7 @@ static int __init efi_earlycon_setup(struct earlycon_de= vice *device, efi_earlycon_scroll_up(si); =20 device->con->write =3D efi_earlycon_write; + device->con->exit =3D efi_earlycon_exit; earlycon_console =3D device->con; return 0; } --=20 2.56.1 From nobody Wed Nov 25 17:40:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=178.154.239.207 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795626231; b=f0wJ+ot+GoSMa5FrlsGn5uW5VBqHn+XFHcRk6fF4WAmcHF7WSjbbu+kfXaPnmmKx/nto WGvdUPpaqSCqdBjtwnqF9KVg4Wk8ZQWLcVHnf3XJWqOWWPplcc6DpsDPfOZSoiTVD1B0h x1Dzg55YuqHrTVxwjV/somRJ7fPwB6M7t4B01UZyD5NN1bmHFnGml2mb3qNK4iJhynZAU 0mfkQhckYeN8Gz5gkLLHc9DmizS1ycLD0Bg+xT9KHGnhTu6+yBVYWFvCcuwTWyghVa5y6 q8gVQnlSHI5AKJRMFS7qyZRNDumToKSt+NYE0K6P0qRS39zrWMJGX6V++rkQ5R2EHbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795626231; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=4GN2NjoUctxblUXPoG785/QR7v7He6l/la/VsAFii1g=; b=3s0p9/Cmpd3WQaCbNYy8btgSKM6GFTMvIzJCvpwLr6a+2nJFhw5yPxAQkOe7VtVE9cf5 Q4OHBh9igzpdqyB1sk4Tk7d0Cs2uJzx0/uf0Ooyq/0fFzD4XhZgK9lQZqdMRSl2wMb9Z4 s5xQs0bCmiL/LBaz/A0nVsNxHy7/79SgaApqbg0VA0TF8NoVByaYcfGO50ZB8GOczbi/n N5ujI+HrMO31sVhllB9UFKakMubrOSySQDHTna/WjB9Xo059cAQ1Q15qmmJU2i77zYEPP Cv7jxVs3i0HB5oq8X2gqU9QxH8kt+mz/2Qc/K1vM/Bj/GA5ru8HbDTiJ/HNuvzJAEXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yandex-team.ru; spf=pass smtp.mailfrom=yandex-team.ru; dkim=pass header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b="tr+/S78R"; arc=none smtp.remote-ip=178.154.239.207 Received: from forwardcorp2d.mail.yandex.net (forwardcorp2d.mail.yandex.net [178.154.239.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0EBE606A323; Wed, 25 Nov 2026 17:03:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C0EBE606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=tr+/S78R Received: from mail-nwsmtp-smtp-corp-main-80 (mail-nwsmtp-smtp-corp-main-80.yp-c.yandex.net) by forwardcorp2d.mail.yandex.net (postfix) with ESMTPS id 7884F80CDF; Wed, 25 Nov 2026 20:03:42 +0300 (MSK) Received: from [127.0.1.1] by mail-nwsmtp-smtp-corp-main-80 with ESMTPSA id a3lrP22Zo8c0-dbNcXmfJ; Wed, 25 Nov 2026 20:03:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1795626221; bh=4GN2NjoUctxblUXPoG785/QR7v7He6l/la/VsAFii1g=; h=Cc:In-Reply-To:Message-Id:To:Date:References:From:Subject; b=tr+/S78R89GjelvqFKXJtvE39HfzS258I7qbcE+SIz9fkWHuD6ChISJm4o+nh/it1 7fIP7xpIoaVM1U7VNt3l/UsvhSFH+VnjnMYnkKY0mo0FWLf3QXXPSZ/N9LcJYkwDp1 Wz2bkhoF/3mRjabxVywEThlQ0M7/2jsaqyRX/5vM= Authentication-Results: mail-nwsmtp-smtp-corp-main-80; dkim=pass header.i=@yandex-team.ru From: Mikhail Rudenko Date: Wed, 25 Nov 2026 20:03:26 +0300 Subject: [PATCH 2/3] video: acquire firmware framebuffer apertures before mapping X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261125-efi-earlycon-v1-2-49ac2c0a430b@yandex-team.ru> References: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> In-Reply-To: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> To: Ard Biesheuvel , Ilias Apalodimas , Thomas Zimmermann , Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter , Peter Jones , Helge Deller , Hans de Goede , Jonathan Corbet , Shuah Khan , Randy Dunlap Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-doc@vger.kernel.org, Mikhail Rudenko X-Mailer: b4 0.15.2 efifb and simplefb acquire their framebuffer apertures after mapping the framebuffer. Move acquisition ahead of mapping, so each driver claims the range before accessing it. Also check the framebuffer size against the memory resource before simpledrm acquires the aperture. Signed-off-by: Mikhail Rudenko --- drivers/gpu/drm/sysfb/simpledrm.c | 28 ++++++++++++++-------------- drivers/video/fbdev/efifb.c | 12 +++++++----- drivers/video/fbdev/simplefb.c | 11 ++++++----- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simp= ledrm.c index 21ddf4502ecc8..af4ce286fd6c8 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -747,6 +747,13 @@ static struct simpledrm_device *simpledrm_device_creat= e(struct drm_driver *drv, if (mem) { void *screen_base; =20 + if (size > resource_size(mem)) { + drm_err(dev, + "framebuffer size of %llu exceeds memory range %pr\n", + size, mem); + return ERR_PTR(-EINVAL); + } + ret =3D devm_aperture_acquire_for_platform_device(pdev, mem->start, resource_size(mem)); if (ret) { @@ -756,13 +763,6 @@ static struct simpledrm_device *simpledrm_device_creat= e(struct drm_driver *drv, =20 drm_dbg(dev, "using system memory framebuffer at %pr\n", mem); =20 - if (size > resource_size(mem)) { - drm_err(dev, - "framebuffer size of %llu exceeds memory range %pr\n", - size, mem); - return ERR_PTR(-EINVAL); - } - screen_base =3D devm_memremap(dev->dev, mem->start, resource_size(mem), = MEMREMAP_WC); if (IS_ERR(screen_base)) return screen_base; @@ -775,6 +775,13 @@ static struct simpledrm_device *simpledrm_device_creat= e(struct drm_driver *drv, if (!res) return ERR_PTR(-EINVAL); =20 + if (size > resource_size(res)) { + drm_err(dev, + "framebuffer size of %llu exceeds memory range %pr\n", + size, res); + return ERR_PTR(-EINVAL); + } + ret =3D devm_aperture_acquire_for_platform_device(pdev, res->start, resource_size(res)); if (ret) { @@ -796,13 +803,6 @@ static struct simpledrm_device *simpledrm_device_creat= e(struct drm_driver *drv, mem =3D res; } =20 - if (size > resource_size(mem)) { - drm_err(dev, - "framebuffer size of %llu exceeds memory range %pr\n", - size, mem); - return ERR_PTR(-EINVAL); - } - screen_base =3D devm_ioremap_wc(&pdev->dev, mem->start, resource_size(me= m)); if (!screen_base) return ERR_PTR(-ENOMEM); diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 6361861b3ccf3..28295829932b1 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -478,6 +478,13 @@ static int efifb_probe(struct platform_device *dev) mem_flags &=3D md.attribute; } } + + err =3D devm_aperture_acquire_for_platform_device(dev, par->base, par->si= ze); + if (err) { + pr_err("efifb: cannot acquire aperture\n"); + goto err_release_fb; + } + if (mem_flags & EFI_MEMORY_WC) info->screen_base =3D ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len); @@ -569,11 +576,6 @@ static int efifb_probe(struct platform_device *dev) goto err_unmap; } =20 - err =3D devm_aperture_acquire_for_platform_device(dev, par->base, par->si= ze); - if (err) { - pr_err("efifb: cannot acquire aperture\n"); - goto err_fb_dealloc_cmap; - } err =3D devm_register_framebuffer(&dev->dev, info); if (err < 0) { pr_err("efifb: cannot register framebuffer\n"); diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 60e5dcec201ff..f682ead384bf6 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -599,6 +599,12 @@ static int simplefb_probe(struct platform_device *pdev) par->size =3D info->fix.smem_len; =20 info->fbops =3D &simplefb_ops; + ret =3D devm_aperture_acquire_for_platform_device(pdev, par->base, par->s= ize); + if (ret) { + dev_err(&pdev->dev, "Unable to acquire aperture: %d\n", ret); + goto error_fb_release; + } + info->screen_base =3D ioremap_wc(info->fix.smem_start, info->fix.smem_len); if (!info->screen_base) { @@ -632,11 +638,6 @@ static int simplefb_probe(struct platform_device *pdev) if (mem !=3D res) par->mem =3D mem; /* release in clean-up handler */ =20 - ret =3D devm_aperture_acquire_for_platform_device(pdev, par->base, par->s= ize); - if (ret) { - dev_err(&pdev->dev, "Unable to acquire aperture: %d\n", ret); - goto error_genpds; - } ret =3D register_framebuffer(info); if (ret < 0) { dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret); --=20 2.56.1 From nobody Wed Nov 25 17:40:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=93.77.172.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795626232; b=12j3GWgeFEVAA6wiSFToUuO4XobTyEju+BgqcENzWfSO4zRJPGdigRA+Ry6Nc3vZKdom g3/NjYgc67mj1BZmorFGPdwIDpDayxJMtvOZyrorDfYWWheWSipRy9qt9sMcQGx1ljYoW E3Q9dNEuxdvHrv10WAaRgUM/HdWKyyQ7rkJf/Ftbyq/VeB+mSSsLitnQw8MJwGm94jhPw 4b1qKBG3ZteZu+Ito+701RReuq3hvQblsaiNYWJpNxfUlblLE4atoy401eO4yRHdhiFYw gzAen42oDLZGhbD8UMq2hMgGZXTqR1xAuHxt8Maspt99AhrqRsg/F3Kk6R832OnF+tQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795626232; h=DMARC-Filter:Received:Received:X-Yandex-Fwd:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=D6e784RAfl1zWvIKf8VvIP9R0Xn4wVs0JRUhlpHhbJQ=; b=Rh+n5F3Gmn4QhwPCOhQHGLoEMuVdIZ4Rc2X2mfLgVayPslGMk4YJ19sNiHlGqvREA652 Td0kW1vys5F92pbXR+8kYATpwXC9bUw0SuOufNNl/T5uOugIQRKTP8GROISJrfTrL+icF lT4rcqKgkBdLQvHh+JWPijuZXQG8J8lF8RzYtSTPAvh7puaX4R6qi1v7mU8WaDK2TYeNz qODPIbyQXJ5+8DbhxsWdSdcjJCswyHnxh6lbI2JO+2ODwW5Ri2fV5bnwpsITL0iIGhy0E P/iGFK7EdpG/2l1Mh2JBxFVolB/BnHCY/gSKe91LkUobnox1hy51raatF1KwDFfGUUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yandex-team.ru; spf=pass smtp.mailfrom=yandex-team.ru; dkim=pass header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=ifVmvqKT; arc=none smtp.remote-ip=93.77.172.4 Received: from forwardcorp1e.mail.yandex.net (forwardcorp1e.mail.yandex.net [93.77.172.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CD5606A33D; Wed, 25 Nov 2026 17:03:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7CD5606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex-team.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=ifVmvqKT Received: from mail-nwsmtp-smtp-corp-main-80 (mail-nwsmtp-smtp-corp-main-80.yp-c.yandex.net) by forwardcorp1e.mail.yandex.net (postfix) with ESMTPS id A80E8100336; Wed, 25 Nov 2026 20:03:43 +0300 (MSK) Received: from [127.0.1.1] by mail-nwsmtp-smtp-corp-main-80 with ESMTPSA id a3lrP22Zo8c0-sRAf1WTV; Wed, 25 Nov 2026 20:03:42 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1795626222; bh=D6e784RAfl1zWvIKf8VvIP9R0Xn4wVs0JRUhlpHhbJQ=; h=Cc:In-Reply-To:Message-Id:To:Date:References:From:Subject; b=ifVmvqKT+7d8cLgAMMnVyYRRibQhivvzVTfOsbHcwGY6thKnU6SohPfAebPCA5IEc 7PK52KMI7IMwADqJ25ILkCbacC70sVC0GIW8AVFA0sPa65dm8lYp9FjEZZjdDy2bTR PIQplQ8qdAO1AkGxZBGrZbFrYhZZ500fP9Tz8cl4= Authentication-Results: mail-nwsmtp-smtp-corp-main-80; dkim=pass header.i=@yandex-team.ru From: Mikhail Rudenko Date: Wed, 25 Nov 2026 20:03:27 +0300 Subject: [PATCH 3/3] video: aperture: hand off EFI earlycon on aperture ackquisition X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261125-efi-earlycon-v1-3-49ac2c0a430b@yandex-team.ru> References: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> In-Reply-To: <20261125-efi-earlycon-v1-0-49ac2c0a430b@yandex-team.ru> To: Ard Biesheuvel , Ilias Apalodimas , Thomas Zimmermann , Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter , Peter Jones , Helge Deller , Hans de Goede , Jonathan Corbet , Shuah Khan , Randy Dunlap Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-doc@vger.kernel.org, Mikhail Rudenko X-Mailer: b4 0.15.2 With keep_bootcon, EFI earlycon can keep writing to the firmware framebuffer while a graphics driver takes over. Add a handoff option that unregisters it after framebuffer/drm device successfully acquires its aperture or when a conflicting-device removal helper is called. The option opt-in, default behavior is preserved. When handoff option is effective, unregister the EFI earlycon when a graphics device driver ackquires aperture (unless it was unregistered earlier). Signed-off-by: Mikhail Rudenko --- Documentation/admin-guide/kernel-parameters.txt | 5 +++- drivers/firmware/efi/earlycon.c | 37 +++++++++++++++++++++= +++- drivers/video/aperture.c | 13 ++++++++- include/linux/efi.h | 7 +++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 0b3c140babd94..829bb01cc10d0 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1532,7 +1532,10 @@ Kernel parameters memory mapped framebuffer (if available). On cache coherent non-x86 systems that use system memory for the framebuffer, pass the 'ram' option so that it is - mapped with the correct attributes. + mapped with the correct attributes. Pass 'handoff' with + keep_bootcon to retain EFI earlycon until a graphics + driver acquires a firmware framebuffer aperture. Options + may be combined, e.g. earlycon=3Defifb,ram,handoff. =20 linflex, Use early console provided by Freescale LINFlexD UART diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlyco= n.c index 3a6eaf5481f40..9d65777d225e1 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -21,8 +21,20 @@ static u32 efi_x_array[1024]; static u32 efi_x, efi_y; static u64 fb_base; static bool fb_wb; +static bool fb_handoff; static void *efi_fb; =20 +void efi_earlycon_unregister(void) +{ + struct console *con =3D READ_ONCE(earlycon_console); + + if (!con || !fb_handoff) + return; + + if (console_is_registered(con)) + unregister_console(con); +} + /* * EFI earlycon needs to use early_memremap() to map the framebuffer. * But early_memremap() is not usable for 'earlycon=3Defifb keep_bootcon', @@ -219,6 +231,29 @@ efi_earlycon_write(struct console *con, const char *st= r, unsigned int num) =20 static bool __initdata fb_probed; =20 +static void __init efi_earlycon_parse_options(const char *opt) +{ + /* Reprobe has no options; retain those parsed on the first attempt. */ + if (!opt) + return; + + fb_wb =3D false; + fb_handoff =3D false; + + while (*opt) { + size_t len =3D strcspn(opt, ","); + + if (len =3D=3D 3 && !strncmp(opt, "ram", len)) + fb_wb =3D true; + else if (len =3D=3D 7 && !strncmp(opt, "handoff", len)) + fb_handoff =3D true; + + opt +=3D len; + if (*opt) + opt++; + } +} + void __init efi_earlycon_reprobe(void) { if (fb_probed) @@ -232,7 +267,7 @@ static int __init efi_earlycon_setup(struct earlycon_de= vice *device, u16 xres, yres; u32 i; =20 - fb_wb =3D opt && !strcmp(opt, "ram"); + efi_earlycon_parse_options(opt); =20 if (si->orig_video_isVGA !=3D VIDEO_TYPE_EFI) { fb_probed =3D true; diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c index 2b5a1e666e9b2..249b037562103 100644 --- a/drivers/video/aperture.c +++ b/drivers/video/aperture.c @@ -2,6 +2,7 @@ =20 #include #include +#include #include #include #include @@ -240,7 +241,13 @@ int devm_aperture_acquire_for_platform_device(struct p= latform_device *pdev, resource_size_t base, resource_size_t size) { - return devm_aperture_acquire(&pdev->dev, base, size, aperture_detach_plat= form_device); + int ret; + + ret =3D devm_aperture_acquire(&pdev->dev, base, size, aperture_detach_pla= tform_device); + if (!ret) + efi_earlycon_unregister(); + + return ret; } EXPORT_SYMBOL(devm_aperture_acquire_for_platform_device); =20 @@ -284,6 +291,8 @@ static void aperture_detach_devices(resource_size_t bas= e, resource_size_t size) int aperture_remove_conflicting_devices(resource_size_t base, resource_siz= e_t size, const char *name) { + efi_earlycon_unregister(); + /* * If a driver asked to unregister a platform device registered by * sysfb, then can be assumed that this is a driver for a display @@ -349,6 +358,8 @@ int aperture_remove_conflicting_pci_devices(struct pci_= dev *pdev, const char *na resource_size_t base, size; int bar, ret =3D 0; =20 + efi_earlycon_unregister(); + sysfb_disable(&pdev->dev); =20 for (bar =3D 0; bar < PCI_STD_NUM_BARS; ++bar) { diff --git a/include/linux/efi.h b/include/linux/efi.h index cc1df1577d5fb..44cff6fe53f90 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -720,6 +720,13 @@ efi_guid_to_str(const efi_guid_t *guid, char *out) =20 extern void efi_init (void); extern void efi_earlycon_reprobe(void); +#ifdef CONFIG_EFI_EARLYCON +void efi_earlycon_unregister(void); +#else +static inline void efi_earlycon_unregister(void) +{ +} +#endif #ifdef CONFIG_EFI extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, = if possible */ #else --=20 2.56.1