From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9568328635 for ; Wed, 18 Feb 2026 08:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403968; cv=none; b=KcNDhOqKDUSzySFhb362HjRjH1xt3qje5wwmGu6rm3fXwwHLv+E8lF/1Q0M4U1Abpk8sHXrs7sqpxgjo7yqm40UOEYtLi3nK8xvGVbvoRNmuiYSq31miBD4SOkF2C1330jThVZFsqOv/AcSdrT+5PqWKeHwsBrw9TrpU+Ir6NSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403968; c=relaxed/simple; bh=onqtRKcn4mnPmKQl4LZpN2q8etQWd2vibW2PM7CgK+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rHdvSMTANgkIjKqkNZmUBgsSJHpK1YTUZFcA6nbYlAhO/Ymlc7NnX4sP3uivcmkTuZ+UVNU/rs2WCocR0XZiD7ZO6LWmTJgGl0XynAYT0VWfIoBPgHeE41unaHwlSFtOpYJSCrNBnN+wAICp3tgNGNlQ8s+PQ1d61ldQ0vNcNpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=eQ7A0QRM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=n47Hhbhd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=eQ7A0QRM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=n47Hhbhd; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eQ7A0QRM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="n47Hhbhd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eQ7A0QRM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="n47Hhbhd" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D809A3E6F2; Wed, 18 Feb 2026 08:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KcqdIEuyqZbwAcDIbummLGMBVqW6LxpC7bOENZ3olu0=; b=eQ7A0QRMnZAFiliALKu61DLApAE3r/HjP5t4M84hFgWvWtTk737O3THR87TV+bovYoZpGo u7UbN3VZAGp9BGUPS9Yu81IZAj+27/POJ622hdtlf35jkSfzg3jVMuXM2Fxx2yNziT7zNB 4nLVMUduWyM9v8gCP1rDkdhUmw05TXU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KcqdIEuyqZbwAcDIbummLGMBVqW6LxpC7bOENZ3olu0=; b=n47HhbhdIHDHf/HMryBFcl0nh9/EjrWSOPkmRJkcQJZjGYQw9LY9RAl81BSVe9EDme5tpq vL1ryynW0S5bvvCQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eQ7A0QRM; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=n47Hhbhd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KcqdIEuyqZbwAcDIbummLGMBVqW6LxpC7bOENZ3olu0=; b=eQ7A0QRMnZAFiliALKu61DLApAE3r/HjP5t4M84hFgWvWtTk737O3THR87TV+bovYoZpGo u7UbN3VZAGp9BGUPS9Yu81IZAj+27/POJ622hdtlf35jkSfzg3jVMuXM2Fxx2yNziT7zNB 4nLVMUduWyM9v8gCP1rDkdhUmw05TXU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KcqdIEuyqZbwAcDIbummLGMBVqW6LxpC7bOENZ3olu0=; b=n47HhbhdIHDHf/HMryBFcl0nh9/EjrWSOPkmRJkcQJZjGYQw9LY9RAl81BSVe9EDme5tpq vL1ryynW0S5bvvCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 90B9C3EA66; Wed, 18 Feb 2026 08:39:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SPfuIad6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:03 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 01/13] fbdev: Declare src parameter of fb_pad_ helpers as constant Date: Wed, 18 Feb 2026 09:15:52 +0100 Message-ID: <20260218083855.10743-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: D809A3E6F2 Content-Type: text/plain; charset="utf-8" Fbdev's padding helpers do not modify the source buffer. Declare the parameter as 'const'. Fbcon's font-rendering code calls these helpers with the font data. Declaring src as const will allow for making the font data constant as well. While at it, also remove the extern qualifier from the function declarations in the header file. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/core/fbmem.c | 6 +++--- include/linux/fb.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fb= mem.c index eff757ebbed1..9c78fd32e7b3 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -91,14 +91,14 @@ EXPORT_SYMBOL(fb_get_color_depth); /* * Data padding functions. */ -void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32= height) +void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, const u8 *src, u32 s_pitc= h, u32 height) { __fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, height); } EXPORT_SYMBOL(fb_pad_aligned_buffer); =20 -void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 h= eight, - u32 shift_high, u32 shift_low, u32 mod) +void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, const u8 *src, u32 idx,= u32 height, + u32 shift_high, u32 shift_low, u32 mod) { u8 mask =3D (u8) (0xfff << shift_high), tmp; int i, j; diff --git a/include/linux/fb.h b/include/linux/fb.h index b8b6f54f3312..9a8051f258ac 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -606,9 +606,9 @@ extern int register_framebuffer(struct fb_info *fb_info= ); extern void unregister_framebuffer(struct fb_info *fb_info); extern int devm_register_framebuffer(struct device *dev, struct fb_info *f= b_info); extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *= buf, u32 size); -extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, - u32 height, u32 shift_high, u32 shift_low, u32 mod); -extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pit= ch, u32 height); +void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, const u8 *src, u32 idx,= u32 height, + u32 shift_high, u32 shift_low, u32 mod); +void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, const u8 *src, u32 s_pitc= h, u32 height); extern void fb_set_suspend(struct fb_info *info, int state); extern int fb_get_color_depth(struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); @@ -625,8 +625,8 @@ static inline void unlock_fb_info(struct fb_info *info) mutex_unlock(&info->lock); } =20 -static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, - u8 *src, u32 s_pitch, u32 height) +static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, const u8 = *src, u32 s_pitch, + u32 height) { u32 i, j; =20 --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDE6E321F5E for ; Wed, 18 Feb 2026 08:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403957; cv=none; b=GbCU1IxSmE0bJm9o0yln/+sN1Y+oYto/xjNO84FEhrT4rQZKM7fZO7xLjYUt+SZeoWynhPEXfTm6D+XQcdcWS9czhrgjvRkJSufnVaM+7Yz+5ryp68ZPPSebmcf+2Q8Ianutrba92B8ComUrgj41gj6VUsSj8uqD4Ty9RpKaG6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403957; c=relaxed/simple; bh=00id+AxL3uPm1Slbk6uY/CeVnAVCxRcjTBO6uXeNY3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QAzGPsrBOZmgToNwpqvgXNzhli5IU01UhMMjRW0fAktQbQKHA2vHC6Wp5ngSg5bjnm6df9zELFOKqjtQMJJhZy5nmO+9hhQBml9mHmPLNsKW/iHyDLeXSvKeh2ZajaJLhY8Bkuc8dT7+3FxERHzZMMX2zKjFv58p/uqZIqC8ouQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bB1uGvDG; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=mMAEt0q5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bB1uGvDG; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=mMAEt0q5; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bB1uGvDG"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mMAEt0q5"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bB1uGvDG"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mMAEt0q5" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2151B3E6F3; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHTcLFDIDFmcbV8Dnl4TDKco30itr077plX6MeCLa9A=; b=bB1uGvDGOIys4IUzjQaZs3w4t8tl4BjKb+c1VNqxpCps1D6JVtzeUmj90cPQJEgzSrwy0H qQnL+5QWIWI63gMxIrEHGk+EK/lmjKHl8zcU50NSCYlNvLKgRRiAegyP6fcVi4YQfpz4Ys f4gCs1ZQruhs6F8eJuN39CXFtw4a1RI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHTcLFDIDFmcbV8Dnl4TDKco30itr077plX6MeCLa9A=; b=mMAEt0q5THvMQV2uNOQRwiI4VK05HdlXJ7N0Favn1dDa20aYSw2mD3/73USV9X7+KVj+90 bfocoGHu4NAb7SAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bB1uGvDG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mMAEt0q5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHTcLFDIDFmcbV8Dnl4TDKco30itr077plX6MeCLa9A=; b=bB1uGvDGOIys4IUzjQaZs3w4t8tl4BjKb+c1VNqxpCps1D6JVtzeUmj90cPQJEgzSrwy0H qQnL+5QWIWI63gMxIrEHGk+EK/lmjKHl8zcU50NSCYlNvLKgRRiAegyP6fcVi4YQfpz4Ys f4gCs1ZQruhs6F8eJuN39CXFtw4a1RI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHTcLFDIDFmcbV8Dnl4TDKco30itr077plX6MeCLa9A=; b=mMAEt0q5THvMQV2uNOQRwiI4VK05HdlXJ7N0Favn1dDa20aYSw2mD3/73USV9X7+KVj+90 bfocoGHu4NAb7SAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CF44A3EA67; Wed, 18 Feb 2026 08:39:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +PAwMad6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:03 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 02/13] vt: Remove trailing whitespaces Date: Wed, 18 Feb 2026 09:15:53 +0100 Message-ID: <20260218083855.10743-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid,suse.de:email]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 2151B3E6F3 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- include/linux/console_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index 13b35637bd5a..ebdb9750d348 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -120,7 +120,7 @@ struct vc_data { unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */ unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */ unsigned long vc_pos; /* Cursor address */ - /* fonts */=09 + /* fonts */ unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars = of font or 0 if not supported */ struct console_font vc_font; /* Current VC font set */ unsigned short vc_video_erase_char; /* Background erase character */ --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFA24320CB1 for ; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403947; cv=none; b=M86FjGpjUR4dCk5mnNYqRnPRdNSMcz2FQzxmozNdrKHGDrxeHbKhDqdl9LaiGukkH0j5tsKMSxgB8gicg0j0x8unmJipFjPOBhK4M0M/Y5W7cB7K9bHuwY45vQz4VCP9a/uR/691rUumQ0/8gycNholczgF55yk5I+A2tVY6b7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403947; c=relaxed/simple; bh=Tp1RD8v4+hE5Qaubxn3uAFxHLRlk9TfOKckghTUgTGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZmsH7HOP+8ztY+60sb6iBEfAsTNToP1Rne2sFaZRi6TQe/g0pSulBiFJ5EgR6xAyqqJrs+iMshmp7a+QkP1A+ScLDUe/YNtC/m8UaynHkR1OAT7SFCno5wSNZps6p+IQXFNGloPlQpQy5hbBJQRETEu/lfMAMijA6K4478Qu+yk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=dqCOza8z; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=lrp1nol/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=dqCOza8z; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=lrp1nol/; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dqCOza8z"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lrp1nol/"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dqCOza8z"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lrp1nol/" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5EFAF5BCC8; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFDg3azLDhv0Xd3Ttn8111WHot7AbDXzcN7F8ppqaPA=; b=dqCOza8zwqw3UQpLYqQIgaJZDorcICbnk7dNX3ZHgDu37QnlbQXPiSyY39VC2+MuBEvCgH lvCNUgqHRBV6Njr0zFI8nXytbXL1Mvhr8Hvr7bM7eVn5s5m3uoK6AWz2bE7TCxTNOAfMpw vGWrP3jqHMRX2mjGs/ZmVTt8Hy2+AOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFDg3azLDhv0Xd3Ttn8111WHot7AbDXzcN7F8ppqaPA=; b=lrp1nol/2UDh2TqRbhDvG7majAAxJ33AFIEtZ6rPPWojppix3ofNIjsFKcYRzEWYfDvW1w ysaRslRTg3y7mdBA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFDg3azLDhv0Xd3Ttn8111WHot7AbDXzcN7F8ppqaPA=; b=dqCOza8zwqw3UQpLYqQIgaJZDorcICbnk7dNX3ZHgDu37QnlbQXPiSyY39VC2+MuBEvCgH lvCNUgqHRBV6Njr0zFI8nXytbXL1Mvhr8Hvr7bM7eVn5s5m3uoK6AWz2bE7TCxTNOAfMpw vGWrP3jqHMRX2mjGs/ZmVTt8Hy2+AOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFDg3azLDhv0Xd3Ttn8111WHot7AbDXzcN7F8ppqaPA=; b=lrp1nol/2UDh2TqRbhDvG7majAAxJ33AFIEtZ6rPPWojppix3ofNIjsFKcYRzEWYfDvW1w ysaRslRTg3y7mdBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1AA023EA65; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EBxMBah6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:04 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 03/13] vt: Store font in struct vc_font Date: Wed, 18 Feb 2026 09:15:54 +0100 Message-ID: <20260218083855.10743-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Replace struct console_font with struct vc_font for the type of the vc_font field of struct vc_data. Struct console_font is UAPI, which prevents further changes. Hence a new data type is required. Struct console_font has a documented vertical pitch of 32 bytes. This is not the case after the font data has been loaded into the kernel. Changing the type of vc_font addresses this inconsistency. The font data is now declared as constant, as it might come from the kernel's read-only section. There's some fallout throughout the console code where non-const variables refer to it. Fix them. A later update will declare the font data to a dedicated data type. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/core/bitblit.c | 11 +++++------ drivers/video/fbdev/core/fbcon.c | 4 ++-- drivers/video/fbdev/core/fbcon.h | 4 ++-- include/linux/console_struct.h | 29 +++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/= bitblit.c index 085ffb44c51a..7478accea8ec 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -22,8 +22,7 @@ /* * Accelerated handlers. */ -static void update_attr(u8 *dst, u8 *src, int attribute, - struct vc_data *vc) +static void update_attr(u8 *dst, const u8 *src, int attribute, struct vc_d= ata *vc) { int i, offset =3D (vc->vc_font.height < 10) ? 1 : 2; int width =3D DIV_ROUND_UP(vc->vc_font.width, 8); @@ -81,7 +80,7 @@ static inline void bit_putcs_aligned(struct vc_data *vc, = struct fb_info *info, u16 charmask =3D vc->vc_hi_font_mask ? 0x1ff : 0xff; unsigned int charcnt =3D vc->vc_font.charcount; u32 idx =3D vc->vc_font.width >> 3; - u8 *src; + const u8 *src; =20 while (cnt--) { u16 ch =3D scr_readw(s++) & charmask; @@ -120,7 +119,7 @@ static inline void bit_putcs_unaligned(struct vc_data *= vc, u32 shift_low =3D 0, mod =3D vc->vc_font.width % 8; u32 shift_high =3D 8; u32 idx =3D vc->vc_font.width >> 3; - u8 *src; + const u8 *src; =20 while (cnt--) { u16 ch =3D scr_readw(s++) & charmask; @@ -267,7 +266,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_in= fo *info, bool enable, int y =3D real_y(par->p, vc->state.y); int attribute, use_sw =3D vc->vc_cursor_type & CUR_SW; int err =3D 1; - char *src; + const u8 *src; =20 cursor.set =3D 0; =20 @@ -278,7 +277,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_in= fo *info, bool enable, attribute =3D get_attribute(info, c); src =3D vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); =20 - if (par->cursor_state.image.data !=3D src || + if (par->cursor_state.image.data !=3D (const char *)src || par->cursor_reset) { par->cursor_state.image.data =3D src; cursor.set |=3D FB_CUR_SETIMAGE; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 34ea14412ace..5467b37b1441 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2291,7 +2291,7 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa= _blank_mode blank, =20 static int fbcon_get_font(struct vc_data *vc, struct console_font *font, u= nsigned int vpitch) { - u8 *fontdata =3D vc->vc_font.data; + const u8 *fontdata =3D vc->vc_font.data; u8 *data =3D font->data; int i, j; =20 @@ -2422,7 +2422,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int = w, int h, int charcount, struct fbcon_par *par =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; int resize, ret, old_userfont, old_width, old_height, old_charcount; - u8 *old_data =3D vc->vc_font.data; + const u8 *old_data =3D vc->vc_font.data; =20 resize =3D (w !=3D vc->vc_font.width) || (h !=3D vc->vc_font.height); vc->vc_font.data =3D (void *)(p->fontdata =3D data); diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index fca14e9b729b..3f4386a40237 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -82,8 +82,8 @@ struct fbcon_par { int rotate; int cur_rotate; char *cursor_data; - u8 *fontbuffer; - u8 *fontdata; + u8 *fontbuffer; + const u8 *fontdata; u8 *cursor_src; u32 cursor_size; u32 fd_size; diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index ebdb9750d348..7fdcae6ed49c 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -13,8 +13,9 @@ #ifndef _LINUX_CONSOLE_STRUCT_H #define _LINUX_CONSOLE_STRUCT_H =20 -#include +#include #include +#include #include =20 struct uni_pagedict; @@ -58,6 +59,30 @@ struct vc_state { bool reverse; }; =20 +/** + * struct vc_font - Describes a font + * @width: The width of a single glyph in bits + * @height: The height of a single glyph in scanlines + * @charcount: The number of glyphs in the font + * @data: The raw font data + * + * Font data is organized as an array of glyphs. Each glyph is a bitmap wi= th + * set bits indicating the foreground color. Unset bits indicate background + * color. The fields @width and @height store a single glyph's number of + * horizontal bits and vertical scanlines. If width is not a multiple of 8, + * there are trailing bits to fill up the byte. These bits should not be d= rawn. + * + * The field @data points to the first glphy's first byte. The value @char= count + * gives the number of glyphs in the font. There are no empty scanlines be= tween + * two adjacent glyphs. + */ +struct vc_font { + unsigned int width; + unsigned int height; + unsigned int charcount; + const unsigned char *data; +}; + /* * Example: vc_data of a console that was scrolled 3 lines down. * @@ -122,7 +147,7 @@ struct vc_data { unsigned long vc_pos; /* Cursor address */ /* fonts */ unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars = of font or 0 if not supported */ - struct console_font vc_font; /* Current VC font set */ + struct vc_font vc_font; /* Current VC font set */ unsigned short vc_video_erase_char; /* Background erase character */ /* VT terminal data */ unsigned int vc_state; /* Escape sequence parser state */ --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DA02320A02 for ; Wed, 18 Feb 2026 08:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403953; cv=none; b=RqAtnbVtHfnFbspW6vpVq1yRfkcLjtC2tLx4pFhn8bc5U9chcffEfpT/o5u0qwhl8Q5JLVOjC1Quq1j+wv7MP7lHHwHdFZHkDyD0PtryRwrbbov0vLw6tL3AJZ5KdX5doTa+dsECHX7c4moDvwUeQVhPgLpd8UKetbY0oEv0xhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403953; c=relaxed/simple; bh=Es//qKrSyYlU6BHtRMvOluv38Q7GY2tlIWcQd5BP6B8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xgv6vKGBzM8GvnRGfxYsPCCyT1eSbus3xnd0Fkp/z5tT/SeanVSMVQrgYgpPlwkOm04vpgClNa32/ykBRI4GY+V/v/sMtnr4E6+Sq/RJ4/0URAY/V887UiuCvoiTIptutPcDtXBbcuMTitBNIBVW8sLto9qeTSuuTBPhJMzCPVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=QRfrw483; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=01fkvanA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=QRfrw483; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=01fkvanA; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="QRfrw483"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="01fkvanA"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="QRfrw483"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="01fkvanA" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9B3D15BCC9; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xOZEzhfDSpl/+3mnFnqRpcaYFSjgaxuf/m0MT1S4mKY=; b=QRfrw483H+tukew4um6mIuyuUuCcSy2/TaoHFpyz45P/F3WZ/EF+lg/FDzawTxb5kwZh6y XRhkoodxnZmCwVfd3bGuGz8PvAGDw6+IT84Rc+IHDTVCDpy5MJjI6fZAu75aCnr9LYUGlm +Nis5K/t3nMUrcyt+22KNEp01ABVNzA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xOZEzhfDSpl/+3mnFnqRpcaYFSjgaxuf/m0MT1S4mKY=; b=01fkvanAelq8X5W2lNY80lKvuqbodKLdIzQ7psJIgm5s/dG6HgrCITyRjZqymk4kgGB1s+ V8K8ADSXWY1dRQAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=QRfrw483; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=01fkvanA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xOZEzhfDSpl/+3mnFnqRpcaYFSjgaxuf/m0MT1S4mKY=; b=QRfrw483H+tukew4um6mIuyuUuCcSy2/TaoHFpyz45P/F3WZ/EF+lg/FDzawTxb5kwZh6y XRhkoodxnZmCwVfd3bGuGz8PvAGDw6+IT84Rc+IHDTVCDpy5MJjI6fZAu75aCnr9LYUGlm +Nis5K/t3nMUrcyt+22KNEp01ABVNzA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xOZEzhfDSpl/+3mnFnqRpcaYFSjgaxuf/m0MT1S4mKY=; b=01fkvanAelq8X5W2lNY80lKvuqbodKLdIzQ7psJIgm5s/dG6HgrCITyRjZqymk4kgGB1s+ V8K8ADSXWY1dRQAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5A0E63EA67; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ALvLFKh6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:04 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 04/13] vt: Calculate font-buffer size with vc_font_size() Date: Wed, 18 Feb 2026 09:15:55 +0100 Message-ID: <20260218083855.10743-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCPT_COUNT_SEVEN(0.00)[7]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:dkim,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLf7er7x8tqp4b41gsueb7z9k6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 9B3D15BCC9 Content-Type: text/plain; charset="utf-8" In fbcon, fbcon_resize() computes the size of the font buffer from the values stored in vc_font. Move these calculations to the dedicated helpers vc_font_pitch() and vc_font_size(). Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/core/fbcon.c | 9 ++------- include/linux/console_struct.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 5467b37b1441..96cf890aa0c9 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2042,7 +2042,6 @@ static void updatescrollmode(struct fbcon_display *p, } =20 #define PITCH(w) (((w) + 7) >> 3) -#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size =3D height * pitch = * charcount */ =20 static int fbcon_resize(struct vc_data *vc, unsigned int width, unsigned int height, bool from_user) @@ -2054,8 +2053,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; =20 if (p->userfont && FNTSIZE(vc->vc_font.data)) { - int size; - int pitch =3D PITCH(vc->vc_font.width); + unsigned int size =3D vc_font_size(&vc->vc_font); =20 /* * If user font, ensure that a possible change to user font @@ -2064,10 +2062,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned= int width, * charcount can change and cannot be used to determine the * font data allocated size. */ - if (pitch <=3D 0) - return -EINVAL; - size =3D CALC_FONTSZ(vc->vc_font.height, pitch, vc->vc_font.charcount); - if (size > FNTSIZE(vc->vc_font.data)) + if (!size || size > FNTSIZE(vc->vc_font.data)) return -EINVAL; } =20 diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index 7fdcae6ed49c..fbb5dd5f6761 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -83,6 +83,34 @@ struct vc_font { const unsigned char *data; }; =20 +/** + * vc_font_pitch - Calculates the number of bytes between two adjacent sca= nlines + * @font: The VC font + * + * Returns: + * The number of bytes between two adjacent scanlines in the font data + */ +static inline unsigned int vc_font_pitch(const struct vc_font *font) +{ + return DIV_ROUND_UP(font->width, 8); +} + +/** + * vc_font_size - Calculates the size of the font data in bytes + * @font: The VC font + * + * vc_font_size() calculates the number of bytes of font data in the + * font specified by @font. The function calculates the size from the + * font parameters. + * + * Returns: + * The size of the font data in bytes. + */ +static inline unsigned int vc_font_size(const struct vc_font *font) +{ + return font->height * vc_font_pitch(font) * font->charcount; +} + /* * Example: vc_data of a console that was scrolled 3 lines down. * --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2789630AAAF for ; Wed, 18 Feb 2026 08:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403963; cv=none; b=tSaelS54PzZ0HP6sMBtxuvcTf2kEJsjydttkoAF4WzQphaGNRzxjabEaNawHZHVAS6eN/nUlt188yCOS5VUXyWpw2Ri0nc9LceKt6Ltzvr9yORWjrxKgGPr7wR5MPw2KquNULHIDsi579TpheNc7SDareucS3FoIu1YjsVEjOGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403963; c=relaxed/simple; bh=PPLfn2scF9l/xxxH2pNK4Zfoob6YhwQTVb1vABaxb3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VOk8WYctBx1I3UWW+1VVESlMafstvqPWd50zuCDrCQbmt3J+F1V6YlM36qsEj86wwPe55cdsSmIdVeEGs6LTR5+m30N3LB7BhcROgpFYFYcBUy6cnpSrHhHQxrRiatArLnqDPZWvTWR2jU+IkR3mBXTNlKw/T/Di2UW08o2SxhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BNxbSxYZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WlwUiNZC; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BNxbSxYZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WlwUiNZC; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BNxbSxYZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WlwUiNZC"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BNxbSxYZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WlwUiNZC" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D90363E6F6; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3myX3kviNVslUVcrKR9W819kIhzyOtHaBnJvEe8hBw=; b=BNxbSxYZPoGey+Q224KuJi1VcJAh3dSy0P9G8fUTgE5biTQUU+RvUhPFmJZKoQAHMxZwam Ep8480kRC4SGR/rDC+BA/CkCEl9gZRmYbblaCp+4P7DQYHfIT1RcfhXRXUCQ5aRZ8Mo5ax YcD49TPcFdSO14wV3Dvy1Zx9LZj/BaI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3myX3kviNVslUVcrKR9W819kIhzyOtHaBnJvEe8hBw=; b=WlwUiNZC28nsYvcs7f9b+1qVU3miFrYGTFSYk7/KDPqkEPRiw9fl7SSy0qyzx9l6TFzlBb Teh/2uKN/YMgLTDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3myX3kviNVslUVcrKR9W819kIhzyOtHaBnJvEe8hBw=; b=BNxbSxYZPoGey+Q224KuJi1VcJAh3dSy0P9G8fUTgE5biTQUU+RvUhPFmJZKoQAHMxZwam Ep8480kRC4SGR/rDC+BA/CkCEl9gZRmYbblaCp+4P7DQYHfIT1RcfhXRXUCQ5aRZ8Mo5ax YcD49TPcFdSO14wV3Dvy1Zx9LZj/BaI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403944; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3myX3kviNVslUVcrKR9W819kIhzyOtHaBnJvEe8hBw=; b=WlwUiNZC28nsYvcs7f9b+1qVU3miFrYGTFSYk7/KDPqkEPRiw9fl7SSy0qyzx9l6TFzlBb Teh/2uKN/YMgLTDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 989393EA65; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eMzTI6h6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:04 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 05/13] lib/fonts: Remove trailing whitespaces Date: Wed, 18 Feb 2026 09:15:56 +0100 Message-ID: <20260218083855.10743-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Fix coding style. No functional changes. Signed-off-by: Thomas Zimmermann --- lib/fonts/font_acorn_8x8.c | 2 +- lib/fonts/font_mini_4x6.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c index 18755c33d249..af5fa72aa8b7 100644 --- a/lib/fonts/font_acorn_8x8.c +++ b/lib/fonts/font_acorn_8x8.c @@ -68,7 +68,7 @@ static const struct font_data acorndata_8x8 =3D { /* 3A */ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, /* : */ /* 3B */ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30, /* ; */ /* 3C */ 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, /* < */ -/* 3D */ 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, /* =3D */=20 +/* 3D */ 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, /* =3D */ /* 3E */ 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00, /* > */ /* 3F */ 0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00, /* ? */ /* 40 */ 0x3C, 0x66, 0x6E, 0x6A, 0x6E, 0x60, 0x3C, 0x00, /* @ */ diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c index 8d39fd447952..cc21dc70cfd1 100644 --- a/lib/fonts/font_mini_4x6.c +++ b/lib/fonts/font_mini_4x6.c @@ -18,15 +18,15 @@ s{((0x)?[0-9a-fA-F]+)(.*\[([\*\ ]{4})\])}{ =20 ($num,$pat,$bits) =3D ($1,$3,$4); -=09 + $bits =3D~ s/([^\s0])|(.)/ defined($1) + 0 /ge; -=09 + $num =3D ord(pack("B8", $bits)); $num |=3D $num >> 4; $num =3D sprintf("0x%.2x", $num); -=09 + #print "$num,$pat,$bits\n"; -=09 + $num . $pat; }ge; =20 --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9093C321F5E for ; Wed, 18 Feb 2026 08:39:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403974; cv=none; b=ELXZgwlznJlxCZy3rCTuFAcDHzyuRPW/2+byIkcTrHUqlSIVuHPYB1EoKduXbeY3+sysCYDRF1zijw6nCGzhw5T1grEtQlYmLkgKIkbznQekUDZrvKMEMrPnh82k/XZEeCI6YPj/3tezjLpdtcer+Iu5Unw37ew+hc8uwVg2Xx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403974; c=relaxed/simple; bh=/Pswo3sVRK5U6GR/xBDZyJKJHLDw/miTuP5+9/w6DB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQbNICD5V5WSBsU3vlEgRJIQ0UdX93Stl60FzNTODHqzhk3s6Xq4QEX0KymEoCr+aIxRnNnuqj1FImH8szL5GWpdpm2TUfqrmP1JrnGRggIr8SF3VTsKN6iPVRGismdhQz20GuLtVvEUHy8hJYRh9oEHRfXSVt7ce8whSNubdko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MZAlZLLl; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=m0TIHxy4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MZAlZLLl; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=m0TIHxy4; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MZAlZLLl"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="m0TIHxy4"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MZAlZLLl"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="m0TIHxy4" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 244BD3E6FA; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aomxNFQXVshb7d7YZZSQ/RbBFSjsS+YpZCnHEOnjtDU=; b=MZAlZLLlYY4uc4FaSN+zvv3aFWksyIxjTohOihOxegOjHy/2tlBeoDyRZV+ckpQ8Pot63j ozSt+U7XrJ1+jsZxwxe4CW/iRWE7mL9DilaYA1imilotwola9q5ng6XfwNApZA5l5Wz90s tVdkYCfXzYdgvTK0jyFDCRn2DTyb9gA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aomxNFQXVshb7d7YZZSQ/RbBFSjsS+YpZCnHEOnjtDU=; b=m0TIHxy4nA0fjyL5DAnnOLdiWYe1IxUn5VT/wbuPJUFPy3SPwsm8Lqo+eOt8rwA83d6bAy CZ912bmrRBXY91CA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aomxNFQXVshb7d7YZZSQ/RbBFSjsS+YpZCnHEOnjtDU=; b=MZAlZLLlYY4uc4FaSN+zvv3aFWksyIxjTohOihOxegOjHy/2tlBeoDyRZV+ckpQ8Pot63j ozSt+U7XrJ1+jsZxwxe4CW/iRWE7mL9DilaYA1imilotwola9q5ng6XfwNApZA5l5Wz90s tVdkYCfXzYdgvTK0jyFDCRn2DTyb9gA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aomxNFQXVshb7d7YZZSQ/RbBFSjsS+YpZCnHEOnjtDU=; b=m0TIHxy4nA0fjyL5DAnnOLdiWYe1IxUn5VT/wbuPJUFPy3SPwsm8Lqo+eOt8rwA83d6bAy CZ912bmrRBXY91CA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D66483EA67; Wed, 18 Feb 2026 08:39:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CG/YMqh6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:04 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 06/13] lib/fonts: Remove FNTCHARCNT() Date: Wed, 18 Feb 2026 09:15:57 +0100 Message-ID: <20260218083855.10743-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" The character count in the font data is unused. The internal fonts also do not set it. Remove FNTCHARCNT(). Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 1 - include/linux/font.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index a474c5e8e97e..6e9d61791888 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -516,7 +516,6 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, =20 new_data +=3D FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) =3D size; - FNTCHARCNT(new_data) =3D op->charcount; REFCOUNT(new_data) =3D 0; /* usage counter */ FNTSUM(new_data) =3D 0; =20 diff --git a/include/linux/font.h b/include/linux/font.h index fd8625cd76b2..d929c5fa32ca 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -68,7 +68,6 @@ extern const struct font_desc *get_default_font(int xres,= int yres, /* Extra word getters */ #define REFCOUNT(fd) (((int *)(fd))[-1]) #define FNTSIZE(fd) (((int *)(fd))[-2]) -#define FNTCHARCNT(fd) (((int *)(fd))[-3]) #define FNTSUM(fd) (((int *)(fd))[-4]) =20 #define FONT_EXTRA_WORDS 4 --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8296321F5E for ; Wed, 18 Feb 2026 08:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403980; cv=none; b=U34AfensTyEafO46gET7m+KKOIdTH+4K9DPk0BcR9a5ibudP5NN6UMY6ftfgUkS2QJ15agLVfg0cUSW/r+L3lf/gR+58aclI9S7Q3COsViD79fRMjTCYCNAGD+NUFd2w0B6wEl9tg6MPuG3z1lnY0sAedt8xPMeMGmUeZypZvtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403980; c=relaxed/simple; bh=bsIoEKH0PhURcu6JnCqwGPG7MbqyVc27FvR7qLKAWaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yo0+wwdFDuU2VJfno0bGB5GqIbRGb5kaaCkL7ydcxemDgL2P4TOiEVDzmp8m+JTuZFnzto9hiHc37Vn38mIctFgZnPLkq4LW8t5zOdjnNTWz/2T/tZ2WV7/w+mXaT07sqrfQpbnzbatgEtKghD7ut9mDijDDm+IHL/toNi6Kxqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=xeoCsH1i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pA/S95tK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=xeoCsH1i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pA/S95tK; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="xeoCsH1i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pA/S95tK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="xeoCsH1i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pA/S95tK" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 65AE13E6FF; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZ1XWdnMQOF0YFSTaaGMx+byRiwPaovl3du8wyBeyaY=; b=xeoCsH1i7L19sG//ODpBE7ecebyo+5EMJ8Gh4AtWnTpSffVC8S58MmIo95c34iu2fIZt2Y zpE8FJmrItrZPn5MOu58GinhhtdkBd1sLpy7+9Ni9DmU8l5UQQaLCJVXxR+HMTw5S12Ppw bZEQNJ0Lj+TvhZnzOzT2hF0fN6TbvSw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZ1XWdnMQOF0YFSTaaGMx+byRiwPaovl3du8wyBeyaY=; b=pA/S95tK28cPODbE/YBiDuAQ4NibQsOaCSaxudnjXv2DoX/h7XSrfqa/8WWYdmGfFX6zQk nvrD/wGACxCVV6Cw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZ1XWdnMQOF0YFSTaaGMx+byRiwPaovl3du8wyBeyaY=; b=xeoCsH1i7L19sG//ODpBE7ecebyo+5EMJ8Gh4AtWnTpSffVC8S58MmIo95c34iu2fIZt2Y zpE8FJmrItrZPn5MOu58GinhhtdkBd1sLpy7+9Ni9DmU8l5UQQaLCJVXxR+HMTw5S12Ppw bZEQNJ0Lj+TvhZnzOzT2hF0fN6TbvSw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZ1XWdnMQOF0YFSTaaGMx+byRiwPaovl3du8wyBeyaY=; b=pA/S95tK28cPODbE/YBiDuAQ4NibQsOaCSaxudnjXv2DoX/h7XSrfqa/8WWYdmGfFX6zQk nvrD/wGACxCVV6Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 227BD3EA65; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +LH+Bql6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:05 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 07/13] lib/fonts: Store font data as font_data_t; update consoles Date: Wed, 18 Feb 2026 09:15:58 +0100 Message-ID: <20260218083855.10743-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL4936hw7dbgk3hb39jfn1xy19)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Store font data as pointer to font_data_t instead of unsigned char. Update consoles. Pointers to font data refer to the raw data. There is a hidden header before the data that contains additional state. Document the existing layout and semantics of font_data_t. The data field in struct vc_font can be used by any console. Therefore it still points to plain data without the additional header. Fbcon sets its value from struct fbcon_display.fontdata. Hence, update the size test in fbcon_resize() to use struct fbcon_display.fontdata instead of struct vc_font.data. Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 17 ++++++----- drivers/video/fbdev/core/fbcon.c | 44 ++++++++++++++++----------- drivers/video/fbdev/core/fbcon.h | 3 +- include/linux/font.h | 47 ++++++++++++++++++++++++++++- 4 files changed, 84 insertions(+), 27 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index 6e9d61791888..fcf76f65b06e 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -33,9 +33,9 @@ =20 #define NEWPORT_LEN 0x10000 =20 -#define FONT_DATA ((unsigned char *)font_vga_8x16.data) +#define FONT_DATA font_vga_8x16.data =20 -static unsigned char *font_data[MAX_NR_CONSOLES]; +static font_data_t *font_data[MAX_NR_CONSOLES]; =20 static struct newport_regs *npregs; static unsigned long newport_addr; @@ -370,9 +370,9 @@ static void newport_clear(struct vc_data *vc, unsigned = int sy, unsigned int sx, static void newport_putc(struct vc_data *vc, u16 charattr, unsigned int yp= os, unsigned int xpos) { - unsigned char *p; + const unsigned char *p; =20 - p =3D &font_data[vc->vc_num][(charattr & 0xff) << 4]; + p =3D &font_data_buf(font_data[vc->vc_num])[(charattr & 0xff) << 4]; charattr =3D (charattr >> 8) & 0xff; xpos <<=3D 3; ypos <<=3D 4; @@ -400,7 +400,7 @@ static void newport_putcs(struct vc_data *vc, const u16= *s, unsigned int count, unsigned int ypos, unsigned int xpos) { - unsigned char *p; + const unsigned char *p; unsigned int i; u16 charattr; =20 @@ -424,7 +424,7 @@ static void newport_putcs(struct vc_data *vc, const u16= *s, NPORT_DMODE0_L32); =20 for (i =3D 0; i < count; i++, xpos +=3D 8) { - p =3D &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4]; + p =3D &font_data_buf(font_data[vc->vc_num])[(scr_readw(s++) & 0xff) << 4= ]; =20 newport_wait(npregs); =20 @@ -503,7 +503,8 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, int h =3D op->height; int size =3D h * op->charcount; int i; - unsigned char *new_data, *data =3D op->data, *p; + font_data_t *new_data; + unsigned char *data =3D op->data, *p; =20 /* ladis: when I grow up, there will be a day... and more sizes will * be supported ;-) */ @@ -519,7 +520,7 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, REFCOUNT(new_data) =3D 0; /* usage counter */ FNTSUM(new_data) =3D 0; =20 - p =3D new_data; + p =3D (unsigned char *)font_data_buf(new_data); for (i =3D 0; i < op->charcount; i++) { memcpy(p, data, h); data +=3D 32; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 96cf890aa0c9..73f2757155e6 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1019,8 +1019,10 @@ static const char *fbcon_startup(void) info->pixmap.blit_y); vc->vc_font.width =3D font->width; vc->vc_font.height =3D font->height; - vc->vc_font.data =3D (void *)(p->fontdata =3D font->data); + vc->vc_font.data =3D font_data_buf(font->data); vc->vc_font.charcount =3D font->charcount; + + p->fontdata =3D font->data; } =20 cols =3D FBCON_SWAP(par->rotate, info->var.xres, info->var.yres); @@ -1077,11 +1079,12 @@ static void fbcon_init(struct vc_data *vc, bool ini= t) if (t->fontdata) { struct vc_data *fvc =3D vc_cons[fg_console].d; =20 - vc->vc_font.data =3D (void *)(p->fontdata =3D - fvc->vc_font.data); + vc->vc_font.data =3D fvc->vc_font.data; vc->vc_font.width =3D fvc->vc_font.width; vc->vc_font.height =3D fvc->vc_font.height; vc->vc_font.charcount =3D fvc->vc_font.charcount; + + p->fontdata =3D t->fontdata; p->userfont =3D t->userfont; =20 if (p->userfont) @@ -1096,8 +1099,10 @@ static void fbcon_init(struct vc_data *vc, bool init) info->pixmap.blit_y); vc->vc_font.width =3D font->width; vc->vc_font.height =3D font->height; - vc->vc_font.data =3D (void *)(p->fontdata =3D font->data); + vc->vc_font.data =3D font_data_buf(font->data); vc->vc_font.charcount =3D font->charcount; + + p->fontdata =3D font->data; } } =20 @@ -1408,11 +1413,12 @@ static void fbcon_set_disp(struct fb_info *info, st= ruct fb_var_screeninfo *var, svc =3D *default_mode; t =3D &fb_display[svc->vc_num]; =20 - if (!vc->vc_font.data) { - vc->vc_font.data =3D (void *)(p->fontdata =3D t->fontdata); + if (!p->fontdata) { + vc->vc_font.data =3D font_data_buf(t->fontdata); vc->vc_font.width =3D (*default_mode)->vc_font.width; vc->vc_font.height =3D (*default_mode)->vc_font.height; vc->vc_font.charcount =3D (*default_mode)->vc_font.charcount; + p->fontdata =3D t->fontdata; p->userfont =3D t->userfont; if (p->userfont) REFCOUNT(p->fontdata)++; @@ -2052,7 +2058,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, struct fb_var_screeninfo var =3D info->var; int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; =20 - if (p->userfont && FNTSIZE(vc->vc_font.data)) { + if (p->userfont && FNTSIZE(p->fontdata)) { unsigned int size =3D vc_font_size(&vc->vc_font); =20 /* @@ -2062,7 +2068,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, * charcount can change and cannot be used to determine the * font data allocated size. */ - if (!size || size > FNTSIZE(vc->vc_font.data)) + if (!size || size > FNTSIZE(p->fontdata)) return -EINVAL; } =20 @@ -2286,7 +2292,8 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa= _blank_mode blank, =20 static int fbcon_get_font(struct vc_data *vc, struct console_font *font, u= nsigned int vpitch) { - const u8 *fontdata =3D vc->vc_font.data; + struct fbcon_display *p =3D &fb_display[vc->vc_num]; + font_data_t *fontdata =3D p->fontdata; u8 *data =3D font->data; int i, j; =20 @@ -2411,16 +2418,18 @@ static void set_vc_hi_font(struct vc_data *vc, bool= set) } =20 static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcou= nt, - const u8 * data, int userfont) + font_data_t *data, int userfont) { struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_par *par =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; int resize, ret, old_userfont, old_width, old_height, old_charcount; + font_data_t *old_fontdata =3D p->fontdata; const u8 *old_data =3D vc->vc_font.data; =20 resize =3D (w !=3D vc->vc_font.width) || (h !=3D vc->vc_font.height); - vc->vc_font.data =3D (void *)(p->fontdata =3D data); + p->fontdata =3D data; + vc->vc_font.data =3D font_data_buf(p->fontdata); old_userfont =3D p->userfont; if ((p->userfont =3D userfont)) REFCOUNT(data)++; @@ -2453,12 +2462,12 @@ static int fbcon_do_set_font(struct vc_data *vc, in= t w, int h, int charcount, update_screen(vc); } =20 - if (old_userfont && (--REFCOUNT(old_data) =3D=3D 0)) - kfree(old_data - FONT_EXTRA_WORDS * sizeof(int)); + if (old_userfont && (--REFCOUNT(old_fontdata) =3D=3D 0)) + kfree(old_fontdata - FONT_EXTRA_WORDS * sizeof(int)); return 0; =20 err_out: - p->fontdata =3D old_data; + p->fontdata =3D old_fontdata; vc->vc_font.data =3D old_data; =20 if (userfont) { @@ -2488,7 +2497,8 @@ static int fbcon_set_font(struct vc_data *vc, const s= truct console_font *font, int h =3D font->height; int size, alloc_size; int i, csum; - u8 *new_data, *data =3D font->data; + font_data_t *new_data; + u8 *data =3D font->data; int pitch =3D PITCH(font->width); =20 /* Is there a reason why fbconsole couldn't handle any charcount >256? @@ -2527,13 +2537,13 @@ static int fbcon_set_font(struct vc_data *vc, const= struct console_font *font, if (!new_data) return -ENOMEM; =20 - memset(new_data, 0, FONT_EXTRA_WORDS * sizeof(int)); + memset((u8 *)new_data, 0, FONT_EXTRA_WORDS * sizeof(int)); =20 new_data +=3D FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) =3D size; REFCOUNT(new_data) =3D 0; /* usage counter */ for (i=3D0; i< charcount; i++) { - memcpy(new_data + i*h*pitch, data + i*vpitch*pitch, h*pitch); + memcpy((u8 *)new_data + i * h * pitch, data + i * vpitch * pitch, h * pi= tch); } =20 /* Since linux has a nice crc32 function use it for counting font diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index 3f4386a40237..d26ee7860cf5 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -11,6 +11,7 @@ #ifndef _VIDEO_FBCON_H #define _VIDEO_FBCON_H =20 +#include #include #include #include @@ -25,7 +26,7 @@ =20 struct fbcon_display { /* Filled in by the low-level console driver */ - const u_char *fontdata; + font_data_t *fontdata; int userfont; /* !=3D 0 if fontdata kmalloc()ed */ #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION u_short scrollmode; /* Scroll Method, use fb_scrollmode() = */ diff --git a/include/linux/font.h b/include/linux/font.h index d929c5fa32ca..4ff8d52e59c3 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -13,12 +13,57 @@ =20 #include =20 +/* + * font_data_t and helpers + */ + +/** + * font_data_t - Raw font data + * + * Values of type font_data_t store a pointer to raw font data. The format + * is monochrome. Each bit sets a pixel of a stored glyph. Font data does + * not store geometry information for the individual glyphs. Users of the + * font have to store glyph size, pitch and characer count separately. + * + * Font data in font_data_t is not equivalent to raw u8. Each pointer stor= es + * an additional hidden header before the fotn data. The layout is + * + * +------+-----------------------------+ + * | -16 | CRC32 Checksum (optional) | + * | -12 | | + * | -8 | Number of data bytes | + * | -4 | Reference count | + * +------+-----------------------------+ + * | 0 | Data buffer | + * | ... | | + * +------+-----------------------------+ + * + * Use helpers to access font_data_t. Use font_data_buf() to get the store= d data. + */ +typedef const unsigned char font_data_t; + +/** + * font_data_buf() - Returns the font data as raw bytes + * @fd: The font data + * + * Returns: + * The raw font data. The provided buffer is read-only. + */ +static inline const unsigned char *font_data_buf(font_data_t *fd) +{ + return (const unsigned char *)fd; +} + +/* + * Font lookup + */ + struct font_desc { int idx; const char *name; unsigned int width, height; unsigned int charcount; - const void *data; + font_data_t *data; int pref; }; =20 --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4888632470A for ; Wed, 18 Feb 2026 08:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403960; cv=none; b=RawGH7JpuUzHATJF1h4ipmp5SNlNHBymjWtTAPguDc29a0h4mfWBgh4sfR+w2DacCMFfV+vZkJ4yUk+P+u+y/kzOopehhdwkh+M2TCLeHPoG4hAZ/eBlJJlgqYmCNbBd+wb+UCEN4OH3vMaqm7HHpSiCZ7uzUXR5tLByaBMiEAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403960; c=relaxed/simple; bh=WE1wpX68LXlxkEpm6KWSIjw7o4VuBy+NDYyGGHGSNDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mRQ1w4pwv/hA/mQ+1/Cn8Zt+hoSVWB3Jz2zOt/W155gTsofRfbgKbo/H14kftHolAjSQbG917aF5JFKqpZqru7AfFIjLbg+dvjPCvgKlBkDC34QB2OD+HNjbZ+MvMDphGzI1SGTyfRhMvLr2AJPAPI12VORQ1uSoKiIpaQ5OqMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=XQ4Z4tQV; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=XXqCKc/r; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=XQ4Z4tQV; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=XXqCKc/r; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XQ4Z4tQV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="XXqCKc/r"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XQ4Z4tQV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="XXqCKc/r" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A72E95BCD1; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nS/q8UxVLTw4u9oLSBlMg/OWbLCkEyUXBJg1N3jUEzw=; b=XQ4Z4tQVvKT6hVAD3iXCYdM/R/qqfJpzfUIz2SMByFB9+lzYNm1xp/MNgyFdIO9duiBEFC Pm5n+6kw9fVerGb/JHQnmrGIZFYL/tC3TqaIF8nSg8yv0wf88E8ehz6oRssuW6QcromN5k l6txqCOWUk0TD1FLcaCqskL2Tz63klU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nS/q8UxVLTw4u9oLSBlMg/OWbLCkEyUXBJg1N3jUEzw=; b=XXqCKc/rwhvFcG7tCFUyer+iLHGOrqD6eTB5ce6vDW4mQLOk0jUifi6JQL6q1mNHcejaWd rgo97ejzrixyt/Dg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nS/q8UxVLTw4u9oLSBlMg/OWbLCkEyUXBJg1N3jUEzw=; b=XQ4Z4tQVvKT6hVAD3iXCYdM/R/qqfJpzfUIz2SMByFB9+lzYNm1xp/MNgyFdIO9duiBEFC Pm5n+6kw9fVerGb/JHQnmrGIZFYL/tC3TqaIF8nSg8yv0wf88E8ehz6oRssuW6QcromN5k l6txqCOWUk0TD1FLcaCqskL2Tz63klU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nS/q8UxVLTw4u9oLSBlMg/OWbLCkEyUXBJg1N3jUEzw=; b=XXqCKc/rwhvFcG7tCFUyer+iLHGOrqD6eTB5ce6vDW4mQLOk0jUifi6JQL6q1mNHcejaWd rgo97ejzrixyt/Dg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 61F503EA66; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UK64Fql6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:05 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 08/13] lib/fonts: Read font size with font_data_size() Date: Wed, 18 Feb 2026 09:15:59 +0100 Message-ID: <20260218083855.10743-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL4936hw7dbgk3hb39jfn1xy19)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" Add font_data_size() and update consoles to use it. Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 2 +- drivers/video/fbdev/core/fbcon.c | 14 +++++++------- include/linux/font.h | 2 ++ lib/fonts/fonts.c | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index fcf76f65b06e..eee9695c3eb5 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -530,7 +530,7 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, /* check if font is already used by other console */ for (i =3D 0; i < MAX_NR_CONSOLES; i++) { if (font_data[i] !=3D FONT_DATA - && FNTSIZE(font_data[i]) =3D=3D size + && font_data_size(font_data[i]) =3D=3D size && !memcmp(font_data[i], new_data, size)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); /* current font is the same as the new one */ diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 73f2757155e6..ebb9c5c1b247 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2058,7 +2058,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, struct fb_var_screeninfo var =3D info->var; int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; =20 - if (p->userfont && FNTSIZE(p->fontdata)) { + if (p->userfont && font_data_size(p->fontdata)) { unsigned int size =3D vc_font_size(&vc->vc_font); =20 /* @@ -2068,7 +2068,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, * charcount can change and cannot be used to determine the * font data allocated size. */ - if (!size || size > FNTSIZE(p->fontdata)) + if (!size || size > font_data_size(p->fontdata)) return -EINVAL; } =20 @@ -2307,7 +2307,7 @@ static int fbcon_get_font(struct vc_data *vc, struct = console_font *font, unsigne =20 if (font->width <=3D 8) { j =3D vc->vc_font.height; - if (font->charcount * j > FNTSIZE(fontdata)) + if (font->charcount * j > font_data_size(fontdata)) return -EINVAL; =20 for (i =3D 0; i < font->charcount; i++) { @@ -2318,7 +2318,7 @@ static int fbcon_get_font(struct vc_data *vc, struct = console_font *font, unsigne } } else if (font->width <=3D 16) { j =3D vc->vc_font.height * 2; - if (font->charcount * j > FNTSIZE(fontdata)) + if (font->charcount * j > font_data_size(fontdata)) return -EINVAL; =20 for (i =3D 0; i < font->charcount; i++) { @@ -2328,7 +2328,7 @@ static int fbcon_get_font(struct vc_data *vc, struct = console_font *font, unsigne fontdata +=3D j; } } else if (font->width <=3D 24) { - if (font->charcount * (vc->vc_font.height * sizeof(u32)) > FNTSIZE(fontd= ata)) + if (font->charcount * (vc->vc_font.height * sizeof(u32)) > font_data_siz= e(fontdata)) return -EINVAL; =20 for (i =3D 0; i < font->charcount; i++) { @@ -2343,7 +2343,7 @@ static int fbcon_get_font(struct vc_data *vc, struct = console_font *font, unsigne } } else { j =3D vc->vc_font.height * 4; - if (font->charcount * j > FNTSIZE(fontdata)) + if (font->charcount * j > font_data_size(fontdata)) return -EINVAL; =20 for (i =3D 0; i < font->charcount; i++) { @@ -2558,7 +2558,7 @@ static int fbcon_set_font(struct vc_data *vc, const s= truct console_font *font, if (fb_display[i].userfont && fb_display[i].fontdata && FNTSUM(fb_display[i].fontdata) =3D=3D csum && - FNTSIZE(fb_display[i].fontdata) =3D=3D size && + font_data_size(fb_display[i].fontdata) =3D=3D size && tmp->vc_font.width =3D=3D w && !memcmp(fb_display[i].fontdata, new_data, size)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); diff --git a/include/linux/font.h b/include/linux/font.h index 4ff8d52e59c3..3afb32b625d3 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -54,6 +54,8 @@ static inline const unsigned char *font_data_buf(font_dat= a_t *fd) return (const unsigned char *)fd; } =20 +unsigned int font_data_size(font_data_t *fd); + /* * Font lookup */ diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index a7f118b30171..8c9a6762061c 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -20,6 +20,27 @@ #endif #include =20 +/* + * Helpers for font_data_t + */ + +/** + * font_data_size - Return size of the font data in bytes + * @fd: Font data + * + * Returns: + * The number of bytes in the given font data. + */ +unsigned int font_data_size(font_data_t *fd) +{ + return FNTSIZE(fd); +} +EXPORT_SYMBOL_GPL(font_data_size); + +/* + * Font lookup + */ + static const struct font_desc *fonts[] =3D { #ifdef CONFIG_FONT_8x8 &font_vga_8x8, --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4455B328B67 for ; Wed, 18 Feb 2026 08:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403986; cv=none; b=LGZkGI1zu+M+CVmiiWOvYohDQ2Sl/Ra1+fdVhPFfOLDI15g5Tn+ksmunzf+eQTrdd+87BJ5jaPpVT7I1h+Xx9HFJBnrVpr7zosEm5B0pa2Md/80XrWzWh0WQB6WLTsfAJqDLPrShuasBqgZBPL2V/py037EImO4jvo5K32eDRz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403986; c=relaxed/simple; bh=rt++1rOyH24xhyR/UKMz+OyIvVYgk6XvGA4TupzT8pU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I/3H8em0RkSDWYUJ3tfcAHU8+Q0xQggfyIiIMX79+mr1XUfwisLVQpMBDCmolCzaXv3+FOhLilRV3sDYsqpltC5WRtEpF/6HLMqumBZ4Ax9g+SYeQLPwoSpZ+/Rhal0OHUoy+tn5/lCnr0W/9kwj6MGZVMgZJ8jb3nomLIwWxdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MXjAgxcQ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+YcvbbTt; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MXjAgxcQ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+YcvbbTt; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MXjAgxcQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+YcvbbTt"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MXjAgxcQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+YcvbbTt" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E37F43E6FB; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QzqtmJhuJ2RxEAWSLSo7zzX/rZyzWuOAMbwlIRZfewI=; b=MXjAgxcQjy0BkN1IUrnfAvixhtazyANfUuc2XS2PswsX8K1AELcovruU8D39OW2qrEPLup 07swLmZdm4XLtaYQ6TbgBfvGj0iLz2gzlsEocT1g5zDX/sKLEdBX2bVX84iTbQyU6MteCi BG/dEn0+NEGeD3RGuKa7zFh3O2PwxC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QzqtmJhuJ2RxEAWSLSo7zzX/rZyzWuOAMbwlIRZfewI=; b=+YcvbbTtWNEz/pQGc1UD7g/t1+vt5WcXAG8XNYnQiaCm7ADa11sgcQDQyM5xlpJ47tE9wl KkdhDxJpKeEe/VDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QzqtmJhuJ2RxEAWSLSo7zzX/rZyzWuOAMbwlIRZfewI=; b=MXjAgxcQjy0BkN1IUrnfAvixhtazyANfUuc2XS2PswsX8K1AELcovruU8D39OW2qrEPLup 07swLmZdm4XLtaYQ6TbgBfvGj0iLz2gzlsEocT1g5zDX/sKLEdBX2bVX84iTbQyU6MteCi BG/dEn0+NEGeD3RGuKa7zFh3O2PwxC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403945; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QzqtmJhuJ2RxEAWSLSo7zzX/rZyzWuOAMbwlIRZfewI=; b=+YcvbbTtWNEz/pQGc1UD7g/t1+vt5WcXAG8XNYnQiaCm7ADa11sgcQDQyM5xlpJ47tE9wl KkdhDxJpKeEe/VDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A26A93EA65; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MDtzJql6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:05 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 09/13] lib/fonts: Compare font data for equality with font_data_is_equal() Date: Wed, 18 Feb 2026 09:16:00 +0100 Message-ID: <20260218083855.10743-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL4936hw7dbgk3hb39jfn1xy19)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" Add font_data_is_equal() and update consoles to use it. Font data is equal if it has the same size and contains the same values on all bytes. Only fbcon uses a crc32 checksum. If set in both operands the checksums have to be equal. The new helper also guarantees to not compare internal fonts against fonts from user space. Internal fonts cannot be ref-counted, so making them equal to user-space fonts with the same byte sequence results in undefined behavior. The test only compares data buffers. Their interpretation is up each console. Therefore remove a width test in fbcon_set_font(). Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 3 +-- drivers/video/fbdev/core/fbcon.c | 7 +----- include/linux/font.h | 1 + lib/fonts/fonts.c | 37 +++++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index eee9695c3eb5..02bf4df05016 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -530,8 +530,7 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, /* check if font is already used by other console */ for (i =3D 0; i < MAX_NR_CONSOLES; i++) { if (font_data[i] !=3D FONT_DATA - && font_data_size(font_data[i]) =3D=3D size - && !memcmp(font_data[i], new_data, size)) { + && font_data_is_equal(font_data[i], new_data)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); /* current font is the same as the new one */ if (i =3D=3D unit) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index ebb9c5c1b247..6fbecce606fd 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2553,14 +2553,9 @@ static int fbcon_set_font(struct vc_data *vc, const = struct console_font *font, FNTSUM(new_data) =3D csum; /* Check if the same font is on some other console already */ for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { - struct vc_data *tmp =3D vc_cons[i].d; - if (fb_display[i].userfont && fb_display[i].fontdata && - FNTSUM(fb_display[i].fontdata) =3D=3D csum && - font_data_size(fb_display[i].fontdata) =3D=3D size && - tmp->vc_font.width =3D=3D w && - !memcmp(fb_display[i].fontdata, new_data, size)) { + font_data_is_equal(fb_display[i].fontdata, new_data)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); new_data =3D (u8 *)fb_display[i].fontdata; break; diff --git a/include/linux/font.h b/include/linux/font.h index 3afb32b625d3..da9869ca2294 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -55,6 +55,7 @@ static inline const unsigned char *font_data_buf(font_dat= a_t *fd) } =20 unsigned int font_data_size(font_data_t *fd); +bool font_data_is_equal(font_data_t *lhs, font_data_t *rhs); =20 /* * Font lookup diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 8c9a6762061c..c9f6328d5dda 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -12,18 +12,25 @@ * for more details. */ =20 +#include #include -#include #include +#include + +#include #if defined(__mc68000__) #include #endif -#include =20 /* * Helpers for font_data_t */ =20 +static bool font_data_is_internal(font_data_t *fd) +{ + return is_kernel_rodata((unsigned long)fd); +} + /** * font_data_size - Return size of the font data in bytes * @fd: Font data @@ -37,6 +44,32 @@ unsigned int font_data_size(font_data_t *fd) } EXPORT_SYMBOL_GPL(font_data_size); =20 +/** + * font_data_is_equal - Compares font data for equality + * @lhs: Left-hand side font data + * @rhs: Right-hand-size font data + * + * Font data is equal if is constain the same sequence of values. The + * helper also use the checksum, if both arguments contain it. Font data + * coming from different origins, internal or from user space, is never + * equal. Allowing this would break reference counting. + * + * Returns: + * True if the given font data is equal, false otherwise. + */ +bool font_data_is_equal(font_data_t *lhs, font_data_t *rhs) +{ + if (font_data_is_internal(lhs) !=3D font_data_is_internal(rhs)) + return false; + if (font_data_size(lhs) !=3D font_data_size(rhs)) + return false; + if (FNTSUM(lhs) && FNTSUM(rhs) && FNTSUM(lhs) !=3D FNTSUM(rhs)) + return false; + + return !memcmp(lhs, rhs, FNTSIZE(lhs)); +} +EXPORT_SYMBOL_GPL(font_data_is_equal); + /* * Font lookup */ --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D11E32470A for ; Wed, 18 Feb 2026 08:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403992; cv=none; b=bZqSgu3aLgrDdwl2OXKnjLJv26QQTFk+56P8/uSw0AWZ27izcXQ7UABmXZKf61xLao1DAzbUBQxc3q4tmYActvrDEPaaTWeZNNxn+EKEuRW4rzNTgsLR4To7y5eZ1TT+PZn2qA6dAGuRhI6TEsu7edH5jvImXCAqlMvt47E4/l4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403992; c=relaxed/simple; bh=VJQaSz8i4rTkDRwtyJGQsYScEQl7YVMVsiqvwe/3Sdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=atP7q1GkDPEDdbR3S6O3M1iXB/xooVO75cOSNQVFmOVq+vhXvku2frnfeVVoi2rrGquMFzgQvl5G6fKB18BJmMAjdHa8FUltvQt607PykjS9wRMr4hEGtZ0QSmsbF580gcpwPil8Rfc1JuoJ1b1BPZUYNASSjvYcOEHvURk2srQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hhPkqLJO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pXhZwpnS; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hhPkqLJO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pXhZwpnS; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hhPkqLJO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pXhZwpnS"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hhPkqLJO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pXhZwpnS" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2CE713E705; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vrjM6e79Cdgss09ujR62hHqpHlTZihmDPKizIeRd1ZM=; b=hhPkqLJOKIKU72F8D4i4KeQGLRx5y4twTsbJMKLEoy3U+k8fY96z8kcSUezLmLFPFDr0/9 cJ6A05tADMIjxrAadU9iBVo3fl8/86+8S4rHzwN38L5toCgwrfozPIVcCq8Pnh4Dgko8UY rmnSjuYdFxOPYeIkFRP7XymSz5oIpmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vrjM6e79Cdgss09ujR62hHqpHlTZihmDPKizIeRd1ZM=; b=pXhZwpnSOammOZaE16OzoEskCqroWfX/P9VBlJu4AbXw4n5NqulUdAe6QnagMsMNKtZFLF w4GRlm7J5Q49a9CQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hhPkqLJO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pXhZwpnS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vrjM6e79Cdgss09ujR62hHqpHlTZihmDPKizIeRd1ZM=; b=hhPkqLJOKIKU72F8D4i4KeQGLRx5y4twTsbJMKLEoy3U+k8fY96z8kcSUezLmLFPFDr0/9 cJ6A05tADMIjxrAadU9iBVo3fl8/86+8S4rHzwN38L5toCgwrfozPIVcCq8Pnh4Dgko8UY rmnSjuYdFxOPYeIkFRP7XymSz5oIpmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vrjM6e79Cdgss09ujR62hHqpHlTZihmDPKizIeRd1ZM=; b=pXhZwpnSOammOZaE16OzoEskCqroWfX/P9VBlJu4AbXw4n5NqulUdAe6QnagMsMNKtZFLF w4GRlm7J5Q49a9CQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E1D953EA66; Wed, 18 Feb 2026 08:39:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EEuwNal6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:05 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 10/13] lib/fonts: Manage font-data lifetime with font_data_get/_put() Date: Wed, 18 Feb 2026 09:16:01 +0100 Message-ID: <20260218083855.10743-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCPT_COUNT_SEVEN(0.00)[7]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLf7er7x8tqp4b41gsueb7z9k6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 2CE713E705 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Add font_data_get() and font_data_put(). Update consoles to use them over REFCOUNT() and plain kfree(). Newly allocated font data starts with a reference count of 1. Loading the font puts the previously loaded font. If the reference count reaches zero, font_data_put() frees the font data. The kernel stores internal font data in a read-only section. Invoking font_data_get() and font_data_put() tests this internally and returns success without further operation. From the caller's perspective, getting and putting works the same for all font data. Fbcon used the userfont flag distinguish between internal fonts and fonts loaded by user space. Only the latter where refcounted. With the new helper's automatic handling of internal font data, remove the userfont flag from fbcon. Newport_con uses a default font, FONT_DATA, until user space loads custom font data. Remove all special cases for FONT_DATA, as the get and put calls' read-only handlign also covers this case. Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 26 ++++------- drivers/video/fbdev/core/fbcon.c | 65 +++++++++++++-------------- drivers/video/fbdev/core/fbcon.h | 1 - include/linux/font.h | 2 + lib/fonts/fonts.c | 70 +++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 53 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index 02bf4df05016..8870555cf837 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -517,7 +517,7 @@ static int newport_set_font(int unit, const struct cons= ole_font *op, =20 new_data +=3D FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) =3D size; - REFCOUNT(new_data) =3D 0; /* usage counter */ + REFCOUNT(new_data) =3D 1; /* usage counter */ FNTSUM(new_data) =3D 0; =20 p =3D (unsigned char *)font_data_buf(new_data); @@ -529,23 +529,18 @@ static int newport_set_font(int unit, const struct co= nsole_font *op, =20 /* check if font is already used by other console */ for (i =3D 0; i < MAX_NR_CONSOLES; i++) { - if (font_data[i] !=3D FONT_DATA - && font_data_is_equal(font_data[i], new_data)) { - kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); + if (font_data_is_equal(font_data[i], new_data)) { + font_data_put(new_data); /* current font is the same as the new one */ if (i =3D=3D unit) return 0; new_data =3D font_data[i]; + font_data_get(new_data); break; } } - /* old font is user font */ - if (font_data[unit] !=3D FONT_DATA) { - if (--REFCOUNT(font_data[unit]) =3D=3D 0) - kfree(font_data[unit] - - FONT_EXTRA_WORDS * sizeof(int)); - } - REFCOUNT(new_data)++; + + font_data_put(font_data[unit]); font_data[unit] =3D new_data; =20 return 0; @@ -553,12 +548,9 @@ static int newport_set_font(int unit, const struct con= sole_font *op, =20 static int newport_set_def_font(int unit, struct console_font *op) { - if (font_data[unit] !=3D FONT_DATA) { - if (--REFCOUNT(font_data[unit]) =3D=3D 0) - kfree(font_data[unit] - - FONT_EXTRA_WORDS * sizeof(int)); - font_data[unit] =3D FONT_DATA; - } + font_data_put(font_data[unit]); + font_data[unit] =3D FONT_DATA; + font_data_get(font_data[unit]); =20 return 0; } diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 6fbecce606fd..b1123f3911d7 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1023,6 +1023,7 @@ static const char *fbcon_startup(void) vc->vc_font.charcount =3D font->charcount; =20 p->fontdata =3D font->data; + font_data_get(p->fontdata); } =20 cols =3D FBCON_SWAP(par->rotate, info->var.xres, info->var.yres); @@ -1085,10 +1086,7 @@ static void fbcon_init(struct vc_data *vc, bool init) vc->vc_font.charcount =3D fvc->vc_font.charcount; =20 p->fontdata =3D t->fontdata; - p->userfont =3D t->userfont; - - if (p->userfont) - REFCOUNT(p->fontdata)++; + font_data_get(p->fontdata); } else { const struct font_desc *font =3D NULL; =20 @@ -1103,6 +1101,7 @@ static void fbcon_init(struct vc_data *vc, bool init) vc->vc_font.charcount =3D font->charcount; =20 p->fontdata =3D font->data; + font_data_get(p->fontdata); } } =20 @@ -1193,10 +1192,10 @@ static void fbcon_init(struct vc_data *vc, bool ini= t) =20 static void fbcon_free_font(struct fbcon_display *p) { - if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) =3D=3D 0)) - kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int)); - p->fontdata =3D NULL; - p->userfont =3D 0; + if (p->fontdata) { + font_data_put(p->fontdata); + p->fontdata =3D NULL; + } } =20 static void set_vc_hi_font(struct vc_data *vc, bool set); @@ -1419,9 +1418,7 @@ static void fbcon_set_disp(struct fb_info *info, stru= ct fb_var_screeninfo *var, vc->vc_font.height =3D (*default_mode)->vc_font.height; vc->vc_font.charcount =3D (*default_mode)->vc_font.charcount; p->fontdata =3D t->fontdata; - p->userfont =3D t->userfont; - if (p->userfont) - REFCOUNT(p->fontdata)++; + font_data_get(p->fontdata); } =20 var->activate =3D FB_ACTIVATE_NOW; @@ -2058,7 +2055,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned = int width, struct fb_var_screeninfo var =3D info->var; int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; =20 - if (p->userfont && font_data_size(p->fontdata)) { + if (font_data_size(p->fontdata)) { unsigned int size =3D vc_font_size(&vc->vc_font); =20 /* @@ -2418,21 +2415,20 @@ static void set_vc_hi_font(struct vc_data *vc, bool= set) } =20 static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcou= nt, - font_data_t *data, int userfont) + font_data_t *data) { struct fb_info *info =3D fbcon_info_from_console(vc->vc_num); struct fbcon_par *par =3D info->fbcon_par; struct fbcon_display *p =3D &fb_display[vc->vc_num]; - int resize, ret, old_userfont, old_width, old_height, old_charcount; + int resize, ret, old_width, old_height, old_charcount; font_data_t *old_fontdata =3D p->fontdata; const u8 *old_data =3D vc->vc_font.data; =20 + font_data_get(data); + resize =3D (w !=3D vc->vc_font.width) || (h !=3D vc->vc_font.height); p->fontdata =3D data; vc->vc_font.data =3D font_data_buf(p->fontdata); - old_userfont =3D p->userfont; - if ((p->userfont =3D userfont)) - REFCOUNT(data)++; =20 old_width =3D vc->vc_font.width; old_height =3D vc->vc_font.height; @@ -2462,24 +2458,20 @@ static int fbcon_do_set_font(struct vc_data *vc, in= t w, int h, int charcount, update_screen(vc); } =20 - if (old_userfont && (--REFCOUNT(old_fontdata) =3D=3D 0)) - kfree(old_fontdata - FONT_EXTRA_WORDS * sizeof(int)); + if (old_fontdata) + font_data_put(old_fontdata); + return 0; =20 err_out: p->fontdata =3D old_fontdata; vc->vc_font.data =3D old_data; - - if (userfont) { - p->userfont =3D old_userfont; - if (--REFCOUNT(data) =3D=3D 0) - kfree(data - FONT_EXTRA_WORDS * sizeof(int)); - } - vc->vc_font.width =3D old_width; vc->vc_font.height =3D old_height; vc->vc_font.charcount =3D old_charcount; =20 + font_data_put(data); + return ret; } =20 @@ -2496,9 +2488,9 @@ static int fbcon_set_font(struct vc_data *vc, const s= truct console_font *font, int w =3D font->width; int h =3D font->height; int size, alloc_size; - int i, csum; + int i, csum, ret; font_data_t *new_data; - u8 *data =3D font->data; + const u8 *data =3D font->data; int pitch =3D PITCH(font->width); =20 /* Is there a reason why fbconsole couldn't handle any charcount >256? @@ -2541,7 +2533,7 @@ static int fbcon_set_font(struct vc_data *vc, const s= truct console_font *font, =20 new_data +=3D FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) =3D size; - REFCOUNT(new_data) =3D 0; /* usage counter */ + REFCOUNT(new_data) =3D 1; /* usage counter */ for (i=3D0; i< charcount; i++) { memcpy((u8 *)new_data + i * h * pitch, data + i * vpitch * pitch, h * pi= tch); } @@ -2553,15 +2545,18 @@ static int fbcon_set_font(struct vc_data *vc, const= struct console_font *font, FNTSUM(new_data) =3D csum; /* Check if the same font is on some other console already */ for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { - if (fb_display[i].userfont && - fb_display[i].fontdata && + if (fb_display[i].fontdata && font_data_is_equal(fb_display[i].fontdata, new_data)) { - kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); - new_data =3D (u8 *)fb_display[i].fontdata; + font_data_get(fb_display[i].fontdata); + font_data_put(new_data); + new_data =3D fb_display[i].fontdata; break; } } - return fbcon_do_set_font(vc, font->width, font->height, charcount, new_da= ta, 1); + ret =3D fbcon_do_set_font(vc, font->width, font->height, charcount, new_d= ata); + font_data_put(new_data); + + return ret; } =20 static int fbcon_set_def_font(struct vc_data *vc, struct console_font *fon= t, @@ -2578,7 +2573,7 @@ static int fbcon_set_def_font(struct vc_data *vc, str= uct console_font *font, =20 font->width =3D f->width; font->height =3D f->height; - return fbcon_do_set_font(vc, f->width, f->height, f->charcount, f->data, = 0); + return fbcon_do_set_font(vc, f->width, f->height, f->charcount, f->data); } =20 static u16 palette_red[16]; diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fb= con.h index d26ee7860cf5..1e3c1ef84762 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -27,7 +27,6 @@ struct fbcon_display { /* Filled in by the low-level console driver */ font_data_t *fontdata; - int userfont; /* !=3D 0 if fontdata kmalloc()ed */ #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION u_short scrollmode; /* Scroll Method, use fb_scrollmode() = */ #endif diff --git a/include/linux/font.h b/include/linux/font.h index da9869ca2294..d548684e6430 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -54,6 +54,8 @@ static inline const unsigned char *font_data_buf(font_dat= a_t *fd) return (const unsigned char *)fd; } =20 +void font_data_get(font_data_t *fd); +bool font_data_put(font_data_t *fd); unsigned int font_data_size(font_data_t *fd); bool font_data_is_equal(font_data_t *lhs, font_data_t *rhs); =20 diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index c9f6328d5dda..1da0acdebf53 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -12,8 +12,10 @@ * for more details. */ =20 +#include #include #include +#include #include #include =20 @@ -26,11 +28,79 @@ * Helpers for font_data_t */ =20 +static struct font_data *to_font_data_struct(font_data_t *fd) +{ + return container_of(fd, struct font_data, data[0]); +} + static bool font_data_is_internal(font_data_t *fd) { return is_kernel_rodata((unsigned long)fd); } =20 +static void font_data_free(font_data_t *fd) +{ + if (WARN_ON(font_data_is_internal(fd))) + return; + + kfree(to_font_data_struct(fd)); +} + +/** + * font_data_get - Acquires a reference on font data + * @fd: Font data + * + * Font data from user space is reference counted. The helper + * font_data_get() increases the reference counter by one. Invoke + * font_data_put() to release the reference. + * + * Internal font data is located in read-only memory. In this case + * the helper returns success without modifying the counter field. + * It is still required to call font_data_put() on internal font data. + */ +void font_data_get(font_data_t *fd) +{ + if (font_data_is_internal(fd)) + return; /* never ref static data */ + + if (WARN_ON(!REFCOUNT(fd))) + return; /* should never be 0 */ + ++REFCOUNT(fd); +} +EXPORT_SYMBOL_GPL(font_data_get); + +/** + * font_data_put - Release a reference on font data + * @fd: Font data + * + * Font data from user space is reference counted. The helper + * font_data_put() decreases the reference counter by one. If this was + * the final reference, it frees the allocated memory. + * + * Internal font data is located in read-only memory. In this case + * the helper returns success without modifying the counter field. + * + * Returns: + * True if this was the final reference, false otherwise. + */ +bool font_data_put(font_data_t *fd) +{ + unsigned int count; + + if (font_data_is_internal(fd)) + return true; /* never unref static data */ + + if (WARN_ON(!REFCOUNT(fd))) + return true; /* should never be 0 */ + + count =3D --REFCOUNT(fd); + if (!count) + font_data_free(fd); + + return !count; +} +EXPORT_SYMBOL_GPL(font_data_put); + /** * font_data_size - Return size of the font data in bytes * @fd: Font data --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0D4F32548C for ; Wed, 18 Feb 2026 08:39:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403966; cv=none; b=pukohEgebNtQ/D1pMjj4TJJE6Dy1tB38c8H9iphyp0T/Kmbo4SkF4+fcU/WqYQZB/Q8gR4/fO/PTkKrGjJPY7rHul/xu5Sjx/TVGjhqDn5M8f++2QaxqKn7Kb4/kem2wG5R9nt49y1+iQIp3dyw5WbyfyBscB1t7TKBIqLO87jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403966; c=relaxed/simple; bh=0p+B4WgcXzfWE0uxav1zOJtUwKbQlwHOfqrfYuEHveU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ldwgptYpUCXqWLLHVYKW+ieXAe10RtEro1G6zMJprOSabH3GAxGJxmkv/wW4bOoNPt6BhRtSY44ZTrGXBfibIxWOXUI6akRG3YhoHe8NlhDFQ3pQmwn6vBSQa1OopAe6Gu8kg/wtA0il1ALJ6xDTOefjQO6QsqqJ+HhwuWyJU1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NTX9HnQn; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=3JLKVeFI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NTX9HnQn; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=3JLKVeFI; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NTX9HnQn"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="3JLKVeFI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NTX9HnQn"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="3JLKVeFI" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6F4CD5BCD4; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLnmpUnXpt6L2p3Di4r7+x/zDQOjRKhw+YqPsiGwPHU=; b=NTX9HnQnlkK0TUWZ6N4v0Au7otmyAjGdZqMUfoYfKyENxTZDgGYku7j7qNGFUN6/P0HCsD CPUTervAy1zPq9f9cYxE0/Be/D4zrOlox5DLaMel/2bOksORZ2CvMqBvqqg5RmP/4m2cKX j6yAZrvlcUxsZodMMEXW+j5lMRRa2lw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLnmpUnXpt6L2p3Di4r7+x/zDQOjRKhw+YqPsiGwPHU=; b=3JLKVeFIGUToirabuG5sOu4uWrnIDXGbHnwLfqFQ4za2SOlxYm3rgPJwDkJ7LmFHdYHMS1 o8aTlbr/OLZvJLBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=NTX9HnQn; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=3JLKVeFI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLnmpUnXpt6L2p3Di4r7+x/zDQOjRKhw+YqPsiGwPHU=; b=NTX9HnQnlkK0TUWZ6N4v0Au7otmyAjGdZqMUfoYfKyENxTZDgGYku7j7qNGFUN6/P0HCsD CPUTervAy1zPq9f9cYxE0/Be/D4zrOlox5DLaMel/2bOksORZ2CvMqBvqqg5RmP/4m2cKX j6yAZrvlcUxsZodMMEXW+j5lMRRa2lw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLnmpUnXpt6L2p3Di4r7+x/zDQOjRKhw+YqPsiGwPHU=; b=3JLKVeFIGUToirabuG5sOu4uWrnIDXGbHnwLfqFQ4za2SOlxYm3rgPJwDkJ7LmFHdYHMS1 o8aTlbr/OLZvJLBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2C69C3EA65; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wNAfCap6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:06 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 11/13] lib/fonts: Create font_data_t from struct console_font with font_data_import() Date: Wed, 18 Feb 2026 09:16:02 +0100 Message-ID: <20260218083855.10743-12-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCPT_COUNT_SEVEN(0.00)[7]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLf7er7x8tqp4b41gsueb7z9k6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 6F4CD5BCD4 Content-Type: text/plain; charset="utf-8" Add font_data_import() and update consoles to use it. The implementation of font_data_import() is based on code from fbcon, which supports overflow checks and crc32 checksums. Fbcon uses the crc32 checksum. Newport_con now implements the same overflow checks as fbcon. As before, this console does not support checksums, which are optional. Newport_con can now also handle input font data with a vertical pitch other than 32 bytes. (The vertical pitch is the offset between two glyphs in the font data.) As an internal change, remove the const qualifier from the data field if struct font_data. This allows font_data_import() to write the data without type casting. For all users of the font data via font_data_t, the stored data is still read only. Signed-off-by: Thomas Zimmermann --- drivers/video/console/newport_con.c | 22 ++-------- drivers/video/fbdev/core/fbcon.c | 38 ++---------------- include/linux/font.h | 6 ++- lib/fonts/fonts.c | 62 +++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 53 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index 8870555cf837..15451c6512f7 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -501,31 +501,17 @@ static int newport_set_font(int unit, const struct co= nsole_font *op, { int w =3D op->width; int h =3D op->height; - int size =3D h * op->charcount; int i; font_data_t *new_data; - unsigned char *data =3D op->data, *p; =20 /* ladis: when I grow up, there will be a day... and more sizes will * be supported ;-) */ - if ((w !=3D 8) || (h !=3D 16) || (vpitch !=3D 32) - || (op->charcount !=3D 256 && op->charcount !=3D 512)) + if (w !=3D 8 || h !=3D 16 || (op->charcount !=3D 256 && op->charcount != =3D 512)) return -EINVAL; =20 - if (!(new_data =3D kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, - GFP_USER))) return -ENOMEM; - - new_data +=3D FONT_EXTRA_WORDS * sizeof(int); - FNTSIZE(new_data) =3D size; - REFCOUNT(new_data) =3D 1; /* usage counter */ - FNTSUM(new_data) =3D 0; - - p =3D (unsigned char *)font_data_buf(new_data); - for (i =3D 0; i < op->charcount; i++) { - memcpy(p, data, h); - data +=3D 32; - p +=3D h; - } + new_data =3D font_data_import(op, vpitch, NULL); + if (IS_ERR(new_data)) + return PTR_ERR(new_data); =20 /* check if font is already used by other console */ for (i =3D 0; i < MAX_NR_CONSOLES; i++) { diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index b1123f3911d7..30d82290d01f 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2044,8 +2044,6 @@ static void updatescrollmode(struct fbcon_display *p, updatescrollmode_accel(p, info, vc); } =20 -#define PITCH(w) (((w) + 7) >> 3) - static int fbcon_resize(struct vc_data *vc, unsigned int width, unsigned int height, bool from_user) { @@ -2429,7 +2427,6 @@ static int fbcon_do_set_font(struct vc_data *vc, int = w, int h, int charcount, resize =3D (w !=3D vc->vc_font.width) || (h !=3D vc->vc_font.height); p->fontdata =3D data; vc->vc_font.data =3D font_data_buf(p->fontdata); - old_width =3D vc->vc_font.width; old_height =3D vc->vc_font.height; old_charcount =3D vc->vc_font.charcount; @@ -2487,11 +2484,8 @@ static int fbcon_set_font(struct vc_data *vc, const = struct console_font *font, unsigned charcount =3D font->charcount; int w =3D font->width; int h =3D font->height; - int size, alloc_size; - int i, csum, ret; + int i, ret; font_data_t *new_data; - const u8 *data =3D font->data; - int pitch =3D PITCH(font->width); =20 /* Is there a reason why fbconsole couldn't handle any charcount >256? * If not this check should be changed to charcount < 256 */ @@ -2515,34 +2509,10 @@ static int fbcon_set_font(struct vc_data *vc, const= struct console_font *font, if (fbcon_invalid_charcount(info, charcount)) return -EINVAL; =20 - /* Check for integer overflow in font size calculation */ - if (check_mul_overflow(h, pitch, &size) || - check_mul_overflow(size, charcount, &size)) - return -EINVAL; - - /* Check for overflow in allocation size calculation */ - if (check_add_overflow(FONT_EXTRA_WORDS * sizeof(int), size, &alloc_size)) - return -EINVAL; - - new_data =3D kmalloc(alloc_size, GFP_USER); - - if (!new_data) - return -ENOMEM; - - memset((u8 *)new_data, 0, FONT_EXTRA_WORDS * sizeof(int)); - - new_data +=3D FONT_EXTRA_WORDS * sizeof(int); - FNTSIZE(new_data) =3D size; - REFCOUNT(new_data) =3D 1; /* usage counter */ - for (i=3D0; i< charcount; i++) { - memcpy((u8 *)new_data + i * h * pitch, data + i * vpitch * pitch, h * pi= tch); - } - - /* Since linux has a nice crc32 function use it for counting font - * checksums. */ - csum =3D crc32(0, new_data, size); + new_data =3D font_data_import(font, vpitch, crc32); + if (IS_ERR(new_data)) + return PTR_ERR(new_data); =20 - FNTSUM(new_data) =3D csum; /* Check if the same font is on some other console already */ for (i =3D first_fb_vc; i <=3D last_fb_vc; i++) { if (fb_display[i].fontdata && diff --git a/include/linux/font.h b/include/linux/font.h index d548684e6430..5a1bf433b275 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -13,6 +13,8 @@ =20 #include =20 +struct console_font; + /* * font_data_t and helpers */ @@ -54,6 +56,8 @@ static inline const unsigned char *font_data_buf(font_dat= a_t *fd) return (const unsigned char *)fd; } =20 +font_data_t *font_data_import(const struct console_font *font, unsigned in= t vpitch, + u32 (*calc_csum)(u32, const void *, size_t)); void font_data_get(font_data_t *fd); bool font_data_put(font_data_t *fd); unsigned int font_data_size(font_data_t *fd); @@ -124,7 +128,7 @@ extern const struct font_desc *get_default_font(int xre= s, int yres, =20 struct font_data { unsigned int extra[FONT_EXTRA_WORDS]; - const unsigned char data[]; + unsigned char data[]; } __packed; =20 #endif /* _VIDEO_FONT_H */ diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 1da0acdebf53..9b5355f6d2dc 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -14,7 +14,9 @@ =20 #include #include +#include #include +#include #include #include #include @@ -24,6 +26,8 @@ #include #endif =20 +#define console_font_pitch(font) DIV_ROUND_UP((font)->width, 8) + /* * Helpers for font_data_t */ @@ -46,6 +50,64 @@ static void font_data_free(font_data_t *fd) kfree(to_font_data_struct(fd)); } =20 +/** + * font_data_import - Allocates and initializes font data from user space + * @font: A font from user space + * @vpitch: The size of a single glyph in @font in bytes + * @calc_csum: An optional helper to calculate a chechsum + * + * Font data from user space must be translated to the kernel's format. The + * font's glyph geometry and data is provided in @font. The parameter @vpi= tch + * gives the number of bytes per glyph, including trailing bytes. + * + * The parameter @calc_sum is optional. Fbcon passes crc32() to calculate = the + * font data's checksum. + * + * Returns: + * Newly initialized font data on success, or a pointer-encoded errno valu= e otherwise. + */ +font_data_t *font_data_import(const struct console_font *font, unsigned in= t vpitch, + u32 (*calc_csum)(u32, const void *, size_t)) +{ + unsigned int pitch =3D console_font_pitch(font); + unsigned int h =3D font->height; + unsigned int charcount =3D font->charcount; + const unsigned char *data =3D font->data; + u32 csum =3D 0; + struct font_data *font_data; + int size, alloc_size; + unsigned int i; + font_data_t *fd; + + /* Check for integer overflow in font-size calculation */ + if (check_mul_overflow(h, pitch, &size) || + check_mul_overflow(size, charcount, &size)) + return ERR_PTR(-EINVAL); + + /* Check for overflow in allocation size calculation */ + if (check_add_overflow(sizeof(*font_data), size, &alloc_size)) + return ERR_PTR(-EINVAL); + + font_data =3D kmalloc(alloc_size, GFP_USER); + if (!font_data) + return ERR_PTR(-ENOMEM); + memset(font_data->extra, 0, sizeof(font_data->extra)); + + for (i =3D 0; i < charcount; ++i) + memcpy(font_data->data + i * h * pitch, data + i * vpitch * pitch, h * p= itch); + + if (calc_csum) + csum =3D calc_csum(0, font_data->data, size); + + fd =3D font_data->data; + REFCOUNT(fd) =3D 1; /* start with reference acquired */ + FNTSIZE(fd) =3D size; + FNTSUM(fd) =3D csum; + + return fd; +} +EXPORT_SYMBOL_GPL(font_data_import); + /** * font_data_get - Acquires a reference on font data * @fd: Font data --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F2AA32AAA1 for ; Wed, 18 Feb 2026 08:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403997; cv=none; b=hcjEIJ1zMiE3bVOekBcdIElkkJ5bsy+0BBy4WDtKIFfSeEtkP0XGHh/qCBLnSxGWcdW9orN2BbbZnSLjnqZZhcKt4GMRnL1fhH4Bovc1r1/SxFvrBF9v1LDFpHGqzHqfp5eTOYYaVvJOu624JzETjrzYb6VhvX3zg1wxf2QMJBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771403997; c=relaxed/simple; bh=hGcbzcH1/aaOlxivAnqTV18vAS1xonaHcY0mqljRTUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gv0o6ixfn4eYST/22CLWgy2gFKyE23UWlxvLcl1A7+dhxZ+cmSseBYNacMmo0I9XW3bv+UnxgcUSWeghiFf4wKYbvQZKkb4BM0yL+uqGMpl+9AvHT3/3nWccgzS1EpR1vsclYPFbpIztGCQCjkxs3/+kIUbw18p6drPobKdLRfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=j7/Fuv/i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kFsl2OE6; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=j7/Fuv/i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kFsl2OE6; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j7/Fuv/i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kFsl2OE6"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j7/Fuv/i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kFsl2OE6" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AFDAE3E701; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0yMEMTxlC1oZRfGY8ChNRsGXucnS2R9aO9U9nIXoPhk=; b=j7/Fuv/if0cjy5suD0vQ/swSviSVzf+2HWPJJ5CP/3G+P705xk96kMgT/6cskewUZQu5MH JcstL2nUCQFTbxatCKTTJ5MfJLmhCQgzTtvPXenNkkANPGO0csxOVxOK5YYr84KAkSh6aQ UP5SiG5iR9iVphVNM9UjcH+edOB5GWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0yMEMTxlC1oZRfGY8ChNRsGXucnS2R9aO9U9nIXoPhk=; b=kFsl2OE6XFFMhzqMKtduCEEUSwEm11BTAlm3T+22eFvylYMb7tdqEpLETDvElm9EQWYgp3 KDj5jsnLl4ckcUCg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="j7/Fuv/i"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kFsl2OE6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0yMEMTxlC1oZRfGY8ChNRsGXucnS2R9aO9U9nIXoPhk=; b=j7/Fuv/if0cjy5suD0vQ/swSviSVzf+2HWPJJ5CP/3G+P705xk96kMgT/6cskewUZQu5MH JcstL2nUCQFTbxatCKTTJ5MfJLmhCQgzTtvPXenNkkANPGO0csxOVxOK5YYr84KAkSh6aQ UP5SiG5iR9iVphVNM9UjcH+edOB5GWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0yMEMTxlC1oZRfGY8ChNRsGXucnS2R9aO9U9nIXoPhk=; b=kFsl2OE6XFFMhzqMKtduCEEUSwEm11BTAlm3T+22eFvylYMb7tdqEpLETDvElm9EQWYgp3 KDj5jsnLl4ckcUCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6BA673EA66; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aJ8WGap6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:06 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 12/13] lib/fonts: Store font data for user space with font_data_export() Date: Wed, 18 Feb 2026 09:16:03 +0100 Message-ID: <20260218083855.10743-13-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCPT_COUNT_SEVEN(0.00)[7]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLf7er7x8tqp4b41gsueb7z9k6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: AFDAE3E701 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Add font_data_export() and update consoles to use it. The helper font_data_export() is based on code in fbcon_get_font(). It extends the size of a single glyph to match the requested vpitch, which us usually 32 bytes for fonts from user space. Internal fonts have a pitch according to the glyph's height. The implementation of font_data_export() differs in several ways from the original code. The original implementation distinguished between different pitches of the font data. This is not necessary as the pitch is a parameter in the copying. There was also special handling for a font pitch of 3 bytes, which got expanded to 4 bytes (with trailing bits on each scanline). The logic originated from long before git history exists even in the historical tree. So it is not clear why this was implemented. It is not what user space expects. The setfont utitlity loads font with 3-bytes pitches and expects to read such fonts with a 3-byte pitch. For any font width, the font pitch is always the width extended to the next multiple of 8. See [1] for the user-space font-reading code. With the changes ot handling the font pitches, font_data_export() replaces the original code's various special cases with a single copying logic. Signed-off-by: Thomas Zimmermann Link: https://github.com/legionus/kbd/blob/v2.9.0/src/libkfont/kdfontop.c#L= 73 # [1] --- drivers/video/fbdev/core/fbcon.c | 57 ++------------------------------ include/linux/font.h | 1 + lib/fonts/fonts.c | 40 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 30d82290d01f..4d07904f62e9 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2287,68 +2287,15 @@ static bool fbcon_blank(struct vc_data *vc, enum ve= sa_blank_mode blank, =20 static int fbcon_get_font(struct vc_data *vc, struct console_font *font, u= nsigned int vpitch) { - struct fbcon_display *p =3D &fb_display[vc->vc_num]; - font_data_t *fontdata =3D p->fontdata; - u8 *data =3D font->data; - int i, j; + const struct fbcon_display *p =3D &fb_display[vc->vc_num]; =20 font->width =3D vc->vc_font.width; font->height =3D vc->vc_font.height; if (font->height > vpitch) return -ENOSPC; font->charcount =3D vc->vc_hi_font_mask ? 512 : 256; - if (!font->data) - return 0; - - if (font->width <=3D 8) { - j =3D vc->vc_font.height; - if (font->charcount * j > font_data_size(fontdata)) - return -EINVAL; =20 - for (i =3D 0; i < font->charcount; i++) { - memcpy(data, fontdata, j); - memset(data + j, 0, vpitch - j); - data +=3D vpitch; - fontdata +=3D j; - } - } else if (font->width <=3D 16) { - j =3D vc->vc_font.height * 2; - if (font->charcount * j > font_data_size(fontdata)) - return -EINVAL; - - for (i =3D 0; i < font->charcount; i++) { - memcpy(data, fontdata, j); - memset(data + j, 0, 2*vpitch - j); - data +=3D 2*vpitch; - fontdata +=3D j; - } - } else if (font->width <=3D 24) { - if (font->charcount * (vc->vc_font.height * sizeof(u32)) > font_data_siz= e(fontdata)) - return -EINVAL; - - for (i =3D 0; i < font->charcount; i++) { - for (j =3D 0; j < vc->vc_font.height; j++) { - *data++ =3D fontdata[0]; - *data++ =3D fontdata[1]; - *data++ =3D fontdata[2]; - fontdata +=3D sizeof(u32); - } - memset(data, 0, 3 * (vpitch - j)); - data +=3D 3 * (vpitch - j); - } - } else { - j =3D vc->vc_font.height * 4; - if (font->charcount * j > font_data_size(fontdata)) - return -EINVAL; - - for (i =3D 0; i < font->charcount; i++) { - memcpy(data, fontdata, j); - memset(data + j, 0, 4 * vpitch - j); - data +=3D 4 * vpitch; - fontdata +=3D j; - } - } - return 0; + return font_data_export(p->fontdata, font, vpitch); } =20 /* set/clear vc_hi_font_mask and update vc attrs accordingly */ diff --git a/include/linux/font.h b/include/linux/font.h index 5a1bf433b275..4ff956a1cd0a 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -62,6 +62,7 @@ void font_data_get(font_data_t *fd); bool font_data_put(font_data_t *fd); unsigned int font_data_size(font_data_t *fd); bool font_data_is_equal(font_data_t *lhs, font_data_t *rhs); +int font_data_export(font_data_t *fd, struct console_font *font, unsigned = int vpitch); =20 /* * Font lookup diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 9b5355f6d2dc..1830e6ae9c87 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -202,6 +202,46 @@ bool font_data_is_equal(font_data_t *lhs, font_data_t = *rhs) } EXPORT_SYMBOL_GPL(font_data_is_equal); =20 +/** + * font_data_export - Stores font data for user space + * @fd: Font data + * @font: A font for user space + * @vpitch: The size of a single glyph in @font in bytes + * + * Store the font data given in @fd to the font in @font. Values and + * pointers in @font are pre-initialized. This helper mostly checks some + * corner cases and translates glyph sizes according to the value given + * @vpitch. + * + * Returns: + * 0 on success, or a negative errno code otherwise. + */ +int font_data_export(font_data_t *fd, struct console_font *font, unsigned = int vpitch) +{ + const unsigned char *font_data =3D font_data_buf(fd); + unsigned char *data =3D font->data; + unsigned int pitch =3D console_font_pitch(font); + unsigned int glyphsize, i; + + if (!font->width || !font->height || !font->charcount || !font->data) + return 0; + + glyphsize =3D font->height * pitch; + + if (font->charcount * glyphsize > font_data_size(fd)) + return -EINVAL; + + for (i =3D 0; i < font->charcount; i++) { + memcpy(data, font_data, glyphsize); + memset(data + glyphsize, 0, pitch * vpitch - glyphsize); + data +=3D pitch * vpitch; + font_data +=3D glyphsize; + } + + return 0; +} +EXPORT_SYMBOL_GPL(font_data_export); + /* * Font lookup */ --=20 2.52.0 From nobody Fri Apr 17 14:57:03 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1AB332BF3D for ; Wed, 18 Feb 2026 08:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771404004; cv=none; b=eab944yV7/Ix1iTfsVXtergSspbmA9co3KweI9jC8aCMSVTHFCQkiWko36uTCm6jKefdRPpjobeQceFO3rrjAFqPB5KagrtIphnflGxv5Jkt/5jQWdXTqlFe4dvVlS4sczaDSdNNenZYFa6rXF52pE0Dok/hivLBlhPaP2A98xU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771404004; c=relaxed/simple; bh=K9cqzh3t4pfomNP2+voMY7ti5lZrcI1ouF4fKPkDIpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fHk3hI151G8/ih9ytHmNwk0P7yqwarGTJcK0I6Iw+OobsXhX7+4Te+cq7gFWpj6WWh4FqB23wOBlLwtjrylPA/l5vjNNEkxwzp03BuJeZQ3DzkqOx+Zktarq+7VzuASqlrBKZdjaJQKGlXrc0JUhn8iffL5Fc8KugRKAEeWbfCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=h8LC+zyL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6Fnkn6hY; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=tOwEDsWU; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Ep9tnNLM; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="h8LC+zyL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6Fnkn6hY"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tOwEDsWU"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Ep9tnNLM" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EF3733E70A; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UWbN3XkbHkscdP0E7iQp4kH5azPVaqBQxyqSwFkqhuI=; b=h8LC+zyLSNWM3PdGueV2b4PXOiZHbnwr7Km5zUBIpYSblTaxX87W3fNRgoEjdxbDZkxUM7 NfLaZyRAzqHcfkyOlAX/JF8KWv2M+mk3VEZ4OLrf4unCm9hbkwZ0Bjlq4NZ2Jmj5C/aTTr tQRkGZVeVuTD9ZgBAU69y5uM6u5BpEM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UWbN3XkbHkscdP0E7iQp4kH5azPVaqBQxyqSwFkqhuI=; b=6Fnkn6hYPmPK+M4tM0lawp20tpx539I6igeC9NyNU8Wt066QX1OAP96oTWhiw630KKW8Qe QfPrRreeAYu3DzCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UWbN3XkbHkscdP0E7iQp4kH5azPVaqBQxyqSwFkqhuI=; b=tOwEDsWUZgJasXgDPU55cYYmRV2bRosN213Jws4oZbpdwPckRVr3K+0PYSXIAYBKBsEtTt SZrB6O8h1pGPFtYEjcf/EKOlRz/Jx+NkLx+DyxPBpt93Dncx9ApK9uJipSKWXxHOI1EOQd 0rq2/9cTNRQwDORCvmxdH2sGie/qnv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1771403946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UWbN3XkbHkscdP0E7iQp4kH5azPVaqBQxyqSwFkqhuI=; b=Ep9tnNLMZWtinfnPMYAAC1ZsTbSMQEiXqma496OQrbe10ihvCjYzHU2fvX4WT4P7b+LtfF LxPyZyehrvxkoMBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AC2E33EA65; Wed, 18 Feb 2026 08:39:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SI6XKKp6lWn8LwAAD6G6ig (envelope-from ); Wed, 18 Feb 2026 08:39:06 +0000 From: Thomas Zimmermann To: gregkh@linuxfoundation.org, deller@gmx.de, sam@ravnborg.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 13/13] lib/fonts: Remove internal symbols and macros from public header file Date: Wed, 18 Feb 2026 09:16:04 +0100 Message-ID: <20260218083855.10743-14-tzimmermann@suse.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218083855.10743-1-tzimmermann@suse.de> References: <20260218083855.10743-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[linuxfoundation.org,gmx.de,ravnborg.org]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL4936hw7dbgk3hb39jfn1xy19)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmx.de] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" Define access macros for font_data_t in fonts.c. Define struct font_data and declare most of the font symbols in the internal header font.h, where they can only be seen by the font code. Add config guards around font symbols. Signed-off-by: Thomas Zimmermann --- include/linux/font.h | 32 +++++------------------ lib/fonts/font.h | 52 ++++++++++++++++++++++++++++++++++++++ lib/fonts/font_10x18.c | 2 +- lib/fonts/font_6x10.c | 3 ++- lib/fonts/font_6x11.c | 2 +- lib/fonts/font_6x8.c | 3 ++- lib/fonts/font_7x14.c | 2 +- lib/fonts/font_8x16.c | 3 ++- lib/fonts/font_8x8.c | 2 +- lib/fonts/font_acorn_8x8.c | 2 +- lib/fonts/font_mini_4x6.c | 2 +- lib/fonts/font_pearl_8x8.c | 2 +- lib/fonts/font_sun12x22.c | 3 ++- lib/fonts/font_sun8x16.c | 3 ++- lib/fonts/font_ter10x18.c | 4 ++- lib/fonts/font_ter16x32.c | 4 ++- lib/fonts/fonts.c | 8 +++++- 17 files changed, 88 insertions(+), 41 deletions(-) create mode 100644 lib/fonts/font.h diff --git a/include/linux/font.h b/include/linux/font.h index 4ff956a1cd0a..6e9a4c93b47b 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -92,20 +92,12 @@ struct font_desc { #define FONT6x8_IDX 12 #define TER10x18_IDX 13 =20 -extern const struct font_desc font_vga_8x8, - font_vga_8x16, - font_pearl_8x8, - font_vga_6x11, - font_7x14, - font_10x18, - font_sun_8x16, - font_sun_12x22, - font_acorn_8x8, - font_mini_4x6, - font_6x10, - font_ter_16x32, - font_6x8, - font_ter_10x18; +#if defined(CONFIG_FONT_8x8) +extern const struct font_desc font_vga_8x8; +#endif +#if defined(CONFIG_FONT_8x16) +extern const struct font_desc font_vga_8x16; +#endif =20 /* Find a font with a specific name */ =20 @@ -120,16 +112,4 @@ extern const struct font_desc *get_default_font(int xr= es, int yres, /* Max. length for the name of a predefined font */ #define MAX_FONT_NAME 32 =20 -/* Extra word getters */ -#define REFCOUNT(fd) (((int *)(fd))[-1]) -#define FNTSIZE(fd) (((int *)(fd))[-2]) -#define FNTSUM(fd) (((int *)(fd))[-4]) - -#define FONT_EXTRA_WORDS 4 - -struct font_data { - unsigned int extra[FONT_EXTRA_WORDS]; - unsigned char data[]; -} __packed; - #endif /* _VIDEO_FONT_H */ diff --git a/lib/fonts/font.h b/lib/fonts/font.h new file mode 100644 index 000000000000..00f65a3da5c2 --- /dev/null +++ b/lib/fonts/font.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LIB_FONTS_FONT_H +#define _LIB_FONTS_FONT_H + +#include + +#if defined(CONFIG_FONT_PEARL_8x8) +extern const struct font_desc font_pearl_8x8; +#endif +#if defined(CONFIG_FONT_6x11) +extern const struct font_desc font_vga_6x11; +#endif +#if defined(CONFIG_FONT_7x14) +extern const struct font_desc font_7x14; +#endif +#if defined(CONFIG_FONT_10x18) +extern const struct font_desc font_10x18; +#endif +#if defined(CONFIG_FONT_SUN8x16) +extern const struct font_desc font_sun_8x16; +#endif +#if defined(CONFIG_FONT_SUN12x22) +extern const struct font_desc font_sun_12x22; +#endif +#if defined(CONFIG_FONT_ACORN_8x8) +extern const struct font_desc font_acorn_8x8; +#endif +#if defined(CONFIG_FONT_MINI_4x6) +extern const struct font_desc font_mini_4x6; +#endif +#if defined(CONFIG_FONT_6x10) +extern const struct font_desc font_6x10; +#endif +#if defined(CONFIG_FONT_TER16x32) +extern const struct font_desc font_ter_16x32; +#endif +#if defined(CONFIG_FONT_6x8) +extern const struct font_desc font_6x8; +#endif +#if defined(CONFIG_FONT_TER10x18) +extern const struct font_desc font_ter_10x18; +#endif + +#define FONT_EXTRA_WORDS 4 + +struct font_data { + unsigned int extra[FONT_EXTRA_WORDS]; + unsigned char data[]; +} __packed; + +#endif diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c index 5d940db626e7..10edebc4bb74 100644 --- a/lib/fonts/font_10x18.c +++ b/lib/fonts/font_10x18.c @@ -4,7 +4,7 @@ * by Jurriaan Kalkman 06-2005 * ********************************/ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 9216 =20 diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c index e65df019e0d2..660d3a371b30 100644 --- a/lib/fonts/font_6x10.c +++ b/lib/fonts/font_6x10.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -#include + +#include "font.h" =20 #define FONTDATAMAX 2560 =20 diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c index bd76b3f6b635..671487ccc172 100644 --- a/lib/fonts/font_6x11.c +++ b/lib/fonts/font_6x11.c @@ -5,7 +5,7 @@ /* */ /**********************************************/ =20 -#include +#include "font.h" =20 #define FONTDATAMAX (11*256) =20 diff --git a/lib/fonts/font_6x8.c b/lib/fonts/font_6x8.c index 06ace7792521..5811ee07f4d8 100644 --- a/lib/fonts/font_6x8.c +++ b/lib/fonts/font_6x8.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -#include + +#include "font.h" =20 #define FONTDATAMAX 2048 =20 diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c index a2f561c9fa04..0c7475d643c8 100644 --- a/lib/fonts/font_7x14.c +++ b/lib/fonts/font_7x14.c @@ -4,7 +4,7 @@ /* by Jurriaan Kalkman 05-2005 */ /**************************************/ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 3584 =20 diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c index 06ae14088514..523e95c75569 100644 --- a/lib/fonts/font_8x16.c +++ b/lib/fonts/font_8x16.c @@ -5,9 +5,10 @@ /* */ /**********************************************/ =20 -#include #include =20 +#include "font.h" + #define FONTDATAMAX 4096 =20 static const struct font_data fontdata_8x16 =3D { diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c index 69570b8c31af..e5b697fc9675 100644 --- a/lib/fonts/font_8x8.c +++ b/lib/fonts/font_8x8.c @@ -5,7 +5,7 @@ /* */ /**********************************************/ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 2048 =20 diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c index af5fa72aa8b7..36c51016769d 100644 --- a/lib/fonts/font_acorn_8x8.c +++ b/lib/fonts/font_acorn_8x8.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Acorn-like font definition, with PC graphics characters */ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 2048 =20 diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c index cc21dc70cfd1..dc919c160dde 100644 --- a/lib/fonts/font_mini_4x6.c +++ b/lib/fonts/font_mini_4x6.c @@ -39,7 +39,7 @@ __END__; MSBit to LSBit =3D left to right. */ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 1536 =20 diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c index ae98ca17982e..2438b374acea 100644 --- a/lib/fonts/font_pearl_8x8.c +++ b/lib/fonts/font_pearl_8x8.c @@ -10,7 +10,7 @@ /* */ /**********************************************/ =20 -#include +#include "font.h" =20 #define FONTDATAMAX 2048 =20 diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c index 91daf5ab8b6b..2afbc144bea8 100644 --- a/lib/fonts/font_sun12x22.c +++ b/lib/fonts/font_sun12x22.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -#include + +#include "font.h" =20 #define FONTDATAMAX 11264 =20 diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c index 81bb4eeae04e..2b7b2d8e548a 100644 --- a/lib/fonts/font_sun8x16.c +++ b/lib/fonts/font_sun8x16.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -#include + +#include "font.h" =20 #define FONTDATAMAX 4096 =20 diff --git a/lib/fonts/font_ter10x18.c b/lib/fonts/font_ter10x18.c index 80356e9d56c7..3f30b4a211ab 100644 --- a/lib/fonts/font_ter10x18.c +++ b/lib/fonts/font_ter10x18.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -#include + #include =20 +#include "font.h" + #define FONTDATAMAX 9216 =20 static const struct font_data fontdata_ter10x18 =3D { diff --git a/lib/fonts/font_ter16x32.c b/lib/fonts/font_ter16x32.c index 5baedc573dd6..93616cffe642 100644 --- a/lib/fonts/font_ter16x32.c +++ b/lib/fonts/font_ter16x32.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -#include + #include =20 +#include "font.h" + #define FONTDATAMAX 16384 =20 static const struct font_data fontdata_ter16x32 =3D { diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 1830e6ae9c87..198aae869be2 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -13,7 +13,6 @@ */ =20 #include -#include #include #include #include @@ -26,12 +25,19 @@ #include #endif =20 +#include "font.h" + #define console_font_pitch(font) DIV_ROUND_UP((font)->width, 8) =20 /* * Helpers for font_data_t */ =20 +/* Extra word getters */ +#define REFCOUNT(fd) (((int *)(fd))[-1]) +#define FNTSIZE(fd) (((int *)(fd))[-2]) +#define FNTSUM(fd) (((int *)(fd))[-4]) + static struct font_data *to_font_data_struct(font_data_t *fd) { return container_of(fd, struct font_data, data[0]); --=20 2.52.0