On 6/8/26 13:25, Thomas Zimmermann wrote:
Hi

Am 07.06.26 um 23:02 schrieb Helge Deller:
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.

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.
Fixes: 97df8960240a ("lib/fonts: Provide helpers for calculating glyph pitch and 
size")
Reported-by: Ethan Nelson-Moore <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
---
  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;

Ok by me, if that's what's necessary.
But can we try to keep a documented macro for the division to make the code 
explain itself?

I'd expect everyone who messes with this kind of low-level graphics and bitmaps
to understand this math addition and bit shift, and as such I think it should
be self-explained.

Does it work with DIV_ROUND_UP_POW2() ?
IMHO that's even worse than DIV_ROUND_UP().

Heleg

Reply via email to