Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code
@ 2026-06-07 21:02 Helge Deller
  2026-06-08  4:50 ` Ethan Nelson-Moore
  2026-06-08 11:25 ` Thomas Zimmermann
  0 siblings, 2 replies; 8+ messages in thread
From: Helge Deller @ 2026-06-07 21:02 UTC (permalink / raw)
  To: linux-fbdev, dri-devel; +Cc: Ethan Nelson-Moore

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.

There is no need to use 64-bit division code here, so resolve this issue
by using plain standard addition and shift maths.

Fixes: 97df8960240a ("lib/fonts: Provide helpers for calculating glyph pitch and size")
Reported-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 include/linux/font.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/font.h b/include/linux/font.h
index 6845f02d739a..67d32268989d 100644
--- a/include/linux/font.h
+++ b/include/linux/font.h
@@ -11,7 +11,6 @@
 #ifndef _VIDEO_FONT_H
 #define _VIDEO_FONT_H
 
-#include <linux/math.h>
 #include <linux/types.h>
 
 struct console_font;
@@ -35,7 +34,7 @@ struct console_font;
  */
 static inline unsigned int font_glyph_pitch(unsigned int width)
 {
-	return DIV_ROUND_UP(width, 8);
+	return (width + 7) >> 3;
 }
 
 /**
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-09  6:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 21:02 [PATCH] lib/fonts: Avoid unncessary 64-bit math in font code Helge Deller
2026-06-08  4:50 ` Ethan Nelson-Moore
2026-06-08 11:25 ` Thomas Zimmermann
2026-06-08 19:57   ` Helge Deller
2026-06-08 20:14     ` Ethan Nelson-Moore
2026-06-08 20:26       ` Helge Deller
2026-06-09  1:50         ` Ethan Nelson-Moore
2026-06-09  6:14         ` Thomas Zimmermann

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