[PATCH v4] powerpc: Use shared font data
Finn Thain
fthain at linux-m68k.org
Thu Nov 6 10:48:25 AEDT 2025
On Wed, 5 Nov 2025, Christophe Leroy wrote:
> > I wonder if bodging those in lib/fonts/Makefile for
> > lib/fonts/font_sun8x16.c fixes it?
> > But... this is data - there's no code is there - are any of those
> > flags relevant for data only?
>
> I think -fPIC is relevant for data-only here because font_sun_8x16
> contains a pointer to fontdata_sun8x16 in font_sun_8x16.data
>
> I see two things to try:
>
> 1/ Either build font_sun8x16.o with -fPIC
>
> diff --git a/lib/fonts/Makefile b/lib/fonts/Makefile
> index e16f68492174a..844306d7b15e9 100644
> --- a/lib/fonts/Makefile
> +++ b/lib/fonts/Makefile
> @@ -20,3 +20,5 @@ font-objs-$(CONFIG_FONT_6x8) += font_6x8.o
> font-objs += $(font-objs-y)
>
> obj-$(CONFIG_FONT_SUPPORT) += font.o
> +
> +CFLAGS_font_sun8x16.o += -fPIC
>
> 2/ Or add a PTRRELOC:
>
> diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
> index 7f63f1cdc6c39..fc461cfaf4a34 100644
> --- a/arch/powerpc/kernel/btext.c
> +++ b/arch/powerpc/kernel/btext.c
> @@ -20,6 +20,7 @@
> #include <asm/io.h>
> #include <asm/processor.h>
> #include <asm/udbg.h>
> +#include <asm/setup.h>
>
> #define NO_SCROLL
>
> @@ -463,7 +464,7 @@ static noinline void draw_byte(unsigned char c, long locX,
> long locY)
> {
> unsigned char *base = calc_base(locX << 3, locY << 4);
> unsigned int font_index = c * 16;
> - const unsigned char *font = font_sun_8x16.data + font_index;
> + const unsigned char *font = PTRRELOC(font_sun_8x16.data) +
> font_index;
> int rb = dispDeviceRowBytes;
>
> rmci_maybe_on();
>
Patch 2 has the virtue that it only needs to be tested on powerpc.
Patch 1 has the virtue that other architectures might benefit.
Commit 0ebc7feae79a ("powerpc: Use shared font data"), which caused the
regression, has a sparc equivalent in commit 0f1991949d9b ("sparc: Use
shared font data"). So I wonder whether CONFIG_EARLYFB has also regressed
(for CONFIG_SPARC64). Maybe QEMU could help answer that question.
More information about the Linuxppc-dev
mailing list