Re: [PATCH v4] powerpc: Use shared font data
From: Christophe Leroy <hidden>
Date: 2025-11-05 22:20:04
Also in:
lkml
Subsystem:
framebuffer console, library code, linux for powerpc (32-bit and 64-bit), the rest · Maintainers:
Helge Deller, Thomas Zimmermann, Andrew Morton, Madhavan Srinivasan, Linus Torvalds
Le 03/11/2025 à 02:48, Dr. David Alan Gilbert a écrit :
* Finn Thain (fthain@linux-m68k.org) wrote:quoted
On Sun, 2 Nov 2025, Dr. David Alan Gilbert wrote:quoted
So I'm not a PPC person specifically; so lets see if the PPC people have any suggestions, but: a) Do you know if there's any way to recreate the same hang/works combination in qemu; I know it has a g3beige model but I don't know how to get something similar to your failing combo.I guess we could probably reproduce this in QEMU if the BootX bootloader could be made to work there. In theory, 'qemu-system-ppc -M g3beige' might work.quoted
b) Can you get any diagnostics out of the prom on the mac? Like a PC or anything to have some idea where it hung?Well, that's the problem: if you enable the CONFIG_BOOTX_TEXT diagnostics, the system hangs instead of printing stuff. If you disable the CONFIG_BOOTX_TEXT diagnostics (in favour of serial diagnostics) the hang goes away.Ah, a bug that doesn't like to be seen :-)quoted
Anyway, I imagine that the problem with your patch was that it relies on font data from a different (read only) section, which is unavailable for some reason (MMU not fully configured yet?) So I've asked Stan to test a patch that simply removes the relevant 'const' keywords. It's not a solution, but might narrow-down the search.I wonder if this is a compiler-flag-ism; I see arch/powerpc/kernel/Makefile has a pile of special flags, and for btext.o it has a -fPIC (as well as turning off some other flags). 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();
Christophe