Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code
From: Helge Deller @ 2026-06-08 20:26 UTC (permalink / raw)
  To: Ethan Nelson-Moore
  Cc: Helge Deller, Thomas Zimmermann, linux-fbdev, dri-devel
In-Reply-To: <CADkSEUg948W-XT3_ODe_6p4i5Y8AKEcP=rmJ+7qJq30Uq0d_EQ@mail.gmail.com>

* Ethan Nelson-Moore <enelsonmoore@gmail.com>:
> Hi, Helge and Thomas,
> 
> On Mon, Jun 8, 2026 at 12:58 PM Helge Deller <deller@gmx.de> wrote:
> >
> > On 6/8/26 13:25, Thomas Zimmermann wrote:
> > > Why is there a 64-bit division at all?
> >
> > Not sure. Might be platform specific.
> > Maybe, because you add two integers and divide by an integer, that the
> > compiler then chooses to use 64-bit integer division by 32-bit integer.
> 
> Actually, I think the real issue is that
> arch/arm/boot/compressed/Makefile defines "static" to nothing when
> compiling its copy of lib/fonts/font_acorn_8x8.c (via font.c), so that
> the font array is available outside of the object file. I assume that
> this causes various unused static inline functions in the headers it
> includes (such as <linux/math.h>) to be included in the object file
> because they become normal inline functions.

Does this patch fix the issue then?

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index a159120d1e42..e3f550d62857 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -157,4 +157,4 @@ $(obj)/piggy_data: $(obj)/../Image FORCE
 
 $(obj)/piggy.o: $(obj)/piggy_data
 
-CFLAGS_font.o := -Dstatic=
+CFLAGS_font.o := -DBOOTLOADER
diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c
index 36c51016769d..3327aa6d161d 100644
--- a/lib/fonts/font_acorn_8x8.c
+++ b/lib/fonts/font_acorn_8x8.c
@@ -5,7 +5,11 @@
 
 #define FONTDATAMAX 2048
 
+#ifndef BOOTLOADER
 static const struct font_data acorndata_8x8 = {
+#else
+const struct font_data acorndata_8x8 = {
+#endif
 { 0, 0, FONTDATAMAX, 0 }, {
 /* 00 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
 /* 01 */  0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */

^ permalink raw reply related

* [PATCH] staging: sm750fb: make g_fbmode array const
From: Brock Haftner @ 2026-06-09  1:17 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman, outreachy
  Cc: linux-fbdev, linux-staging, linux-kernel, Brock Haftner

The g_fbmode array is a static array of constant strings, but the pointer
array itself is not marked as const. Fix the checkpatch.pl warning by
adding the const modifier to the array declaration.

Signed-off-by: Brock Haftner <brockhaftner@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 89c811e0806c..8f533f3b1b42 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -21,7 +21,7 @@
 static int g_hwcursor = 1;
 static int g_noaccel __ro_after_init;
 static int g_nomtrr __ro_after_init;
-static const char *g_fbmode[] = {NULL, NULL};
+static const char * const g_fbmode[] = {NULL, NULL};
 static const char *g_def_fbmode = "1024x768-32@60";
 static char *g_settings;
 static int g_dualview __ro_after_init;
-- 
2.54.0


^ permalink raw reply related

* Re: [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code
From: Ethan Nelson-Moore @ 2026-06-09  1:50 UTC (permalink / raw)
  To: Helge Deller; +Cc: Helge Deller, Thomas Zimmermann, linux-fbdev, dri-devel
In-Reply-To: <aiclYUfQvMokMu64@carbonx1>

Hi, Helge,

On Mon, Jun 8, 2026 at 1:26 PM Helge Deller <deller@kernel.org> wrote:
> Does this patch fix the issue then?

Yes, it does. I remember you suggested this solution a while ago. Thank you.

Ethan

^ permalink raw reply

* Re: [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code
From: Thomas Zimmermann @ 2026-06-09  6:14 UTC (permalink / raw)
  To: Helge Deller, Ethan Nelson-Moore; +Cc: Helge Deller, linux-fbdev, dri-devel
In-Reply-To: <aiclYUfQvMokMu64@carbonx1>

Hi,

thanks for the fix.

Am 08.06.26 um 22:26 schrieb Helge Deller:
> * Ethan Nelson-Moore <enelsonmoore@gmail.com>:
>> Hi, Helge and Thomas,
>>
>> On Mon, Jun 8, 2026 at 12:58 PM Helge Deller <deller@gmx.de> wrote:
>>> On 6/8/26 13:25, Thomas Zimmermann wrote:
>>>> Why is there a 64-bit division at all?
>>> Not sure. Might be platform specific.
>>> Maybe, because you add two integers and divide by an integer, that the
>>> compiler then chooses to use 64-bit integer division by 32-bit integer.
>> Actually, I think the real issue is that
>> arch/arm/boot/compressed/Makefile defines "static" to nothing when
>> compiling its copy of lib/fonts/font_acorn_8x8.c (via font.c), so that
>> the font array is available outside of the object file. I assume that
>> this causes various unused static inline functions in the headers it
>> includes (such as <linux/math.h>) to be included in the object file
>> because they become normal inline functions.
> Does this patch fix the issue then?
>
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index a159120d1e42..e3f550d62857 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -157,4 +157,4 @@ $(obj)/piggy_data: $(obj)/../Image FORCE
>   
>   $(obj)/piggy.o: $(obj)/piggy_data
>   
> -CFLAGS_font.o := -Dstatic=
> +CFLAGS_font.o := -DBOOTLOADER
> diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c
> index 36c51016769d..3327aa6d161d 100644
> --- a/lib/fonts/font_acorn_8x8.c
> +++ b/lib/fonts/font_acorn_8x8.c
> @@ -5,7 +5,11 @@
>   
>   #define FONTDATAMAX 2048
>   
> +#ifndef BOOTLOADER
>   static const struct font_data acorndata_8x8 = {
> +#else
> +const struct font_data acorndata_8x8 = {
> +#endif
>   { 0, 0, FONTDATAMAX, 0 }, {
>   /* 00 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
>   /* 01 */  0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

I do like this better than the other patch.

Best regards
Thomas


-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



^ permalink raw reply

* Re: [PATCH] fbcon: correct CONFIG_FB_TILEBLITTING macro name in #endif comment
From: Thomas Zimmermann @ 2026-06-09  6:16 UTC (permalink / raw)
  To: Ethan Nelson-Moore, linux-fbdev; +Cc: Helge Deller, Simona Vetter
In-Reply-To: <20260609033503.23428-1-enelsonmoore@gmail.com>



Am 09.06.26 um 05:35 schrieb Ethan Nelson-Moore:
> A comment in drivers/video/fbdev/core/fbcon.c incorrectly refers to
> CONFIG_MISC_TILEBLITTING instead of CONFIG_FB_TILEBLITTING. Correct it.
>
> Discovered while searching for CONFIG_* symbols referenced in code but
> not defined in any Kconfig file.
>
> Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/video/fbdev/core/fbcon.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index b0e3e765360d..07eab2729895 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -769,7 +769,7 @@ static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount)
>   	return 0;
>   }
>   
> -#endif /* CONFIG_MISC_TILEBLITTING */
> +#endif /* CONFIG_FB_TILEBLITTING */
>   
>   static void fbcon_release(struct fb_info *info)
>   {

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



^ permalink raw reply

* Re: [PATCH] staging: sm750fb: make g_fbmode array const
From: Ahmet Sezgin Duran @ 2026-06-09  6:12 UTC (permalink / raw)
  To: Brock Haftner, Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman,
	outreachy
  Cc: linux-fbdev, linux-staging, linux-kernel
In-Reply-To: <20260609011736.17401-1-brockhaftner@gmail.com>

On 6/9/26 4:17 AM, Brock Haftner wrote:
> The g_fbmode array is a static array of constant strings, but the pointer
> array itself is not marked as const. Fix the checkpatch.pl warning by
> adding the const modifier to the array declaration.
> 
> Signed-off-by: Brock Haftner <brockhaftner@gmail.com>
> ---
>   drivers/staging/sm750fb/sm750.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 89c811e0806c..8f533f3b1b42 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -21,7 +21,7 @@
>   static int g_hwcursor = 1;
>   static int g_noaccel __ro_after_init;
>   static int g_nomtrr __ro_after_init;
> -static const char *g_fbmode[] = {NULL, NULL};
> +static const char * const g_fbmode[] = {NULL, NULL};
>   static const char *g_def_fbmode = "1024x768-32@60";
>   static char *g_settings;
>   static int g_dualview __ro_after_init;

Did you compile this patch while enabling sm750fb driver in the config?

Regards,
Ahmet Sezgin Duran

^ permalink raw reply

* Re: [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code
From: Helge Deller @ 2026-06-09  9:03 UTC (permalink / raw)
  To: Thomas Zimmermann, Helge Deller, Ethan Nelson-Moore
  Cc: linux-fbdev, dri-devel
In-Reply-To: <aaf75c58-c9d5-464a-9651-0021e6784e09@suse.de>

On 6/9/26 08:14, Thomas Zimmermann wrote:
> Hi,
> 
> thanks for the fix.
> 
> Am 08.06.26 um 22:26 schrieb Helge Deller:
>> * Ethan Nelson-Moore <enelsonmoore@gmail.com>:
>>> Hi, Helge and Thomas,
>>>
>>> On Mon, Jun 8, 2026 at 12:58 PM Helge Deller <deller@gmx.de> wrote:
>>>> On 6/8/26 13:25, Thomas Zimmermann wrote:
>>>>> Why is there a 64-bit division at all?
>>>> Not sure. Might be platform specific.
>>>> Maybe, because you add two integers and divide by an integer, that the
>>>> compiler then chooses to use 64-bit integer division by 32-bit integer.
>>> Actually, I think the real issue is that
>>> arch/arm/boot/compressed/Makefile defines "static" to nothing when
>>> compiling its copy of lib/fonts/font_acorn_8x8.c (via font.c), so that
>>> the font array is available outside of the object file. I assume that
>>> this causes various unused static inline functions in the headers it
>>> includes (such as <linux/math.h>) to be included in the object file
>>> because they become normal inline functions.
>> Does this patch fix the issue then?
>>
>> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
>> index a159120d1e42..e3f550d62857 100644
>> --- a/arch/arm/boot/compressed/Makefile
>> +++ b/arch/arm/boot/compressed/Makefile
>> @@ -157,4 +157,4 @@ $(obj)/piggy_data: $(obj)/../Image FORCE
>>   $(obj)/piggy.o: $(obj)/piggy_data
>> -CFLAGS_font.o := -Dstatic=
>> +CFLAGS_font.o := -DBOOTLOADER
>> diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c
>> index 36c51016769d..3327aa6d161d 100644
>> --- a/lib/fonts/font_acorn_8x8.c
>> +++ b/lib/fonts/font_acorn_8x8.c
>> @@ -5,7 +5,11 @@
>>   #define FONTDATAMAX 2048
>> +#ifndef BOOTLOADER
>>   static const struct font_data acorndata_8x8 = {
>> +#else
>> +const struct font_data acorndata_8x8 = {
>> +#endif
>>   { 0, 0, FONTDATAMAX, 0 }, {
>>   /* 00 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
>>   /* 01 */  0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for review!

> I do like this better than the other patch.

Yes, I'll drop the other patch and re-send this one properly.

Helge

^ permalink raw reply

* [PATCH] fbdev/arm: Export acorndata_8x8 font symbol for bootloader
From: Helge Deller @ 2026-06-09  9:10 UTC (permalink / raw)
  To: linux-fbdev, dri-devel
  Cc: Ethan Nelson-Moore, Thomas Zimmermann, linux-arm-kernel,
	Russell King

The text display code used in the Risc PC kernel image decompression
code uses arch/arm/boot/compressed/font.c, which includes
lib/fonts/font_acorn_8x8.c, which further includes <linux/font.h>.

Since commit 97df8960240a ("lib/fonts: Provide helpers for calculating
glyph pitch and size") <linux/font.h> contains inline functions that
require __do_div64, which is not linked into the ARM kernel
decompressor. This makes Risc PC zImages fail to build.

Resolve this issue by defining the BOOTLOADER symbol and use it to avoid
a static declaration of the acorndata_8x8 symbol. That way it can be
referenced by the arm bootloader, and other static math functions and
symbols (like __do_div64) stay static and don't get unneccesary included
in the ARM kernel bootloader decompressor object file.

Fixes: 97df8960240a ("lib/fonts: Provide helpers for calculating glyph pitch and size")
Reported-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/arm/boot/compressed/Makefile | 2 +-
 lib/fonts/font_acorn_8x8.c        | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index a159120d1e42..e3f550d62857 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -157,4 +157,4 @@ $(obj)/piggy_data: $(obj)/../Image FORCE
 
 $(obj)/piggy.o: $(obj)/piggy_data
 
-CFLAGS_font.o := -Dstatic=
+CFLAGS_font.o := -DBOOTLOADER
diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c
index 36c51016769d..4ff52c79f8c4 100644
--- a/lib/fonts/font_acorn_8x8.c
+++ b/lib/fonts/font_acorn_8x8.c
@@ -5,7 +5,12 @@
 
 #define FONTDATAMAX 2048
 
+#ifdef BOOTLOADER
+/* The acorndata_8x8 symbol is needed by the ARM bootloader too. */
+const struct font_data acorndata_8x8 = {
+#else
 static const struct font_data acorndata_8x8 = {
+#endif
 { 0, 0, FONTDATAMAX, 0 }, {
 /* 00 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
 /* 01 */  0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
-- 
2.54.0


^ permalink raw reply related

* Re: [PATCH] fbcon: correct CONFIG_FB_TILEBLITTING macro name in #endif comment
From: Helge Deller @ 2026-06-09  9:13 UTC (permalink / raw)
  To: Thomas Zimmermann, Ethan Nelson-Moore, linux-fbdev; +Cc: Simona Vetter
In-Reply-To: <64b807ea-649c-4ee6-9db4-631e310465ff@suse.de>

On 6/9/26 08:16, Thomas Zimmermann wrote:
> Am 09.06.26 um 05:35 schrieb Ethan Nelson-Moore:
>> A comment in drivers/video/fbdev/core/fbcon.c incorrectly refers to
>> CONFIG_MISC_TILEBLITTING instead of CONFIG_FB_TILEBLITTING. Correct it.
>>
>> Discovered while searching for CONFIG_* symbols referenced in code but
>> not defined in any Kconfig file.
>>
>> Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

applied.

Thanks!
Helge

^ permalink raw reply

* Re: [PATCH] fbdev/arm: Export acorndata_8x8 font symbol for bootloader
From: Russell King (Oracle) @ 2026-06-09  9:46 UTC (permalink / raw)
  To: Helge Deller
  Cc: linux-fbdev, dri-devel, Ethan Nelson-Moore, Thomas Zimmermann,
	linux-arm-kernel
In-Reply-To: <20260609091056.265794-1-deller@gmx.de>

On Tue, Jun 09, 2026 at 11:10:56AM +0200, Helge Deller wrote:
> The text display code used in the Risc PC kernel image decompression
> code uses arch/arm/boot/compressed/font.c, which includes
> lib/fonts/font_acorn_8x8.c, which further includes <linux/font.h>.
> 
> Since commit 97df8960240a ("lib/fonts: Provide helpers for calculating
> glyph pitch and size") <linux/font.h> contains inline functions that
> require __do_div64, which is not linked into the ARM kernel
> decompressor. This makes Risc PC zImages fail to build.
> 
> Resolve this issue by defining the BOOTLOADER symbol and use it to avoid
> a static declaration of the acorndata_8x8 symbol. That way it can be
> referenced by the arm bootloader, and other static math functions and
> symbols (like __do_div64) stay static and don't get unneccesary included
> in the ARM kernel bootloader decompressor object file.

The decompressor font support has actually been broken since:

commit 6735b4632def0640dbdf4eb9f99816aca18c4f16
Author: Peilin Ye <yepeilin.cs@gmail.com>
Date:   Thu Sep 24 09:42:22 2020 -0400

    Fonts: Support FONT_EXTRA_WORDS macros for built-in fonts

which added extra data to the beginning of the array of font
information:

ENTRY(ll_write_char)
        stmfd   sp!, {r4 - r7, lr}
...
        /*
         * calculate offset into character table
         */
        mov     r1, r1, lsl #3

r1 is the character, this multiplies the character value by 8.

        adr     ip, LC0
        ldmia   ip, {r3, r4, r5, r6, lr}
        sub     ip, ip, r3
        add     r6, r6, ip

in conjunction with the data table:

LC0:    .word   LC0
        .word   bytes_per_char_h
        .word   video_size_row
        .word   acorndata_8x8
        .word   con_charconvtable

results in r6 pointing at acorndata_8x8. We then index this using the
modified character value above:

        orr     r1, r1, #7
        ldrb    r7, [r6, r1]

This breaks if extra data is added to the start, and thus has been
broken since the above commit.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox