[v3,4/5] fbdev: Improve performance of cfb_imageblit()

Marek Szyprowski m.szyprowski at samsung.com
Wed Mar 9 09:22:09 UTC 2022


Hi,

On 09.03.2022 09:22, Thomas Zimmermann wrote:
> Am 08.03.22 um 23:52 schrieb Marek Szyprowski:
>> On 23.02.2022 20:38, Thomas Zimmermann wrote:
>>> Improve the performance of cfb_imageblit() by manually unrolling
>>> the inner blitting loop and moving some invariants out. The compiler
>>> failed to do this automatically. This change keeps cfb_imageblit()
>>> in sync with sys_imagebit().
>>>
>>> A microbenchmark measures the average number of CPU cycles
>>> for cfb_imageblit() after a stabilizing period of a few minutes
>>> (i7-4790, FullHD, simpledrm, kernel with debugging).
>>>
>>> cfb_imageblit(), new: 15724 cycles
>>> cfb_imageblit(): old: 30566 cycles
>>>
>>> In the optimized case, cfb_imageblit() is now ~2x faster than before.
>>>
>>> v3:
>>>     * fix commit description (Pekka)
>>>
>>> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
>>> Acked-by: Sam Ravnborg <sam at ravnborg.org>
>>> Reviewed-by: Javier Martinez Canillas <javierm at redhat.com>
>> This patch landed recently in linux next-20220308 as commit 0d03011894d2
>> ("fbdev: Improve performance of cfb_imageblit()"). Sadly it causes a
>> freeze after DRM and emulated fbdev initialization on various Samsung
>> Exynos ARM 32bit based boards. This happens when kernel is compiled from
>> exynos_defconfig. Surprisingly when kernel is compiled from
>> multi_v7_defconfig all those boards boot fine, so this is a matter of
>> one of the debugging options enabled in the exynos_defconfig. I will try
>> to analyze this further and share the results. Reverting $subject on top
>> of next-20220308 fixes the boot issue.
>
> Thanks for reporting. I don't have the hardware to reproduce it and 
> there's no obvious difference to the original version. It's supposed 
> to be the same algorithm with a different implementation. Unless you 
> can figure out the issue, we can also revert the patch easily.

I've played a bit with .config options and found that the issue is 
caused by the compiled-in fonts used for the framebuffer. For some 
reasons (so far unknown to me), exynos_defconfig has the following odd 
setup:

CONFIG_FONT_SUPPORT=y
CONFIG_FONTS=y
# CONFIG_FONT_8x8 is not set
# CONFIG_FONT_8x16 is not set
# CONFIG_FONT_6x11 is not set
CONFIG_FONT_7x14=y
# CONFIG_FONT_PEARL_8x8 is not set
# CONFIG_FONT_ACORN_8x8 is not set
# CONFIG_FONT_MINI_4x6 is not set
# CONFIG_FONT_6x10 is not set
# CONFIG_FONT_10x18 is not set
# CONFIG_FONT_SUN8x16 is not set
# CONFIG_FONT_SUN12x22 is not set
# CONFIG_FONT_TER16x32 is not set
# CONFIG_FONT_6x8 is not set

Such setup causes a freeze during framebuffer initialization (or just 
after it got registered). I've reproduced this even on Raspberry Pi 3B 
with multi_v7_defconfig and changed fonts configuration (this also 
required to disable vivid driver, which forces 8x16 font), where I got 
the following panic:

simple-framebuffer 3eace000.framebuffer: framebuffer at 0x3eace000, 
0x12c000 bytes
simple-framebuffer 3eace000.framebuffer: format=a8r8g8b8, 
mode=640x480x32, linelength=2560
8<--- cut here ---
Unable to handle kernel paging request at virtual address f0aac000
[f0aac000] *pgd=01d8b811, *pte=00000000, *ppte=00000000
Internal error: Oops: 807 [#1] SMP ARM
Modules linked in:
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 
5.17.0-rc7-next-20220308-00002-g9e9894c98f8c #11471
Hardware name: BCM2835
PC is at cfb_imageblit+0x52c/0x64c
LR is at 0x1
pc : [<c0603dd8>]    lr : [<00000001>]    psr: a0000013
sp : f081da68  ip : c1d5ffff  fp : f081dad8
r10: f0980000  r9 : c1d69600  r8 : fffb5007
r7 : 00000000  r6 : 00000001  r5 : 00000a00  r4 : 00000001
r3 : 00000055  r2 : f0aac000  r1 : f081dad8  r0 : 00000007
Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5383d  Table: 0000406a  DAC: 00000051
Register r0 information: non-paged memory
Register r1 information: 2-page vmalloc region starting at 0xf081c000 
allocated at kernel_clone+0xc0/0x428
Register r2 information: 0-page vmalloc region starting at 0xf0980000 
allocated at simplefb_probe+0x284/0x9b0
Register r3 information: non-paged memory
Register r4 information: non-paged memory
Register r5 information: non-paged memory
Register r6 information: non-paged memory
Register r7 information: NULL pointer
Register r8 information: non-paged memory
Register r9 information: non-slab/vmalloc memory
Register r10 information: 0-page vmalloc region starting at 0xf0980000 
allocated at simplefb_probe+0x284/0x9b0
Register r11 information: 2-page vmalloc region starting at 0xf081c000 
allocated at kernel_clone+0xc0/0x428
Register r12 information: non-slab/vmalloc memory
Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
Stack: (0xf081da68 to 0xf081e000)
...
  cfb_imageblit from soft_cursor+0x164/0x1cc
  soft_cursor from bit_cursor+0x4c0/0x4fc
  bit_cursor from fbcon_cursor+0xf8/0x108
  fbcon_cursor from hide_cursor+0x34/0x94
  hide_cursor from redraw_screen+0x13c/0x22c
  redraw_screen from fbcon_prepare_logo+0x164/0x444
  fbcon_prepare_logo from fbcon_init+0x38c/0x4bc
  fbcon_init from visual_init+0xc0/0x108
  visual_init from do_bind_con_driver+0x1ac/0x38c
  do_bind_con_driver from do_take_over_console+0x13c/0x1c8
  do_take_over_console from do_fbcon_takeover+0x74/0xcc
  do_fbcon_takeover from register_framebuffer+0x1bc/0x2cc
  register_framebuffer from simplefb_probe+0x8dc/0x9b0
  simplefb_probe from platform_probe+0x80/0xc0
  platform_probe from really_probe+0xc0/0x304
  really_probe from __driver_probe_device+0x88/0xe0
  __driver_probe_device from driver_probe_device+0x34/0xd4
  driver_probe_device from __driver_attach+0x8c/0xe0
  __driver_attach from bus_for_each_dev+0x64/0xb0
  bus_for_each_dev from bus_add_driver+0x160/0x1e4
  bus_add_driver from driver_register+0x78/0x10c
  driver_register from do_one_initcall+0x44/0x1e0
  do_one_initcall from kernel_init_freeable+0x1bc/0x20c
  kernel_init_freeable from kernel_init+0x18/0x12c
  kernel_init from ret_from_fork+0x14/0x2c
Code: e28db070 e00473a3 e08b7107 e5177044 (e5827000)
---[ end trace 0000000000000000 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
CPU0: stopping
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G      D 
5.17.0-rc7-next-20220308-00002-g9e9894c98f8c #11471
Hardware name: BCM2835
  unwind_backtrace from show_stack+0x10/0x14
  show_stack from 0xc1201e64
CPU2: stopping
CPU: 2 PID: 0 Comm: swapper/2 Tainted: G      D 
5.17.0-rc7-next-20220308-00002-g9e9894c98f8c #11471
Hardware name: BCM2835
  unwind_backtrace from show_stack+0x10/0x14
  show_stack from 0xf0809f5c
CPU1: stopping
CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D 
5.17.0-rc7-next-20220308-00002-g9e9894c98f8c #11471
Hardware name: BCM2835
  unwind_backtrace from show_stack+0x10/0x14
  show_stack from 0xf0805f5c
---[ end Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x0000000b ]---

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



More information about the dri-devel mailing list