All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/9] Add video damage tracking
@ 2023-01-03 21:49 Alexander Graf
  2023-01-03 21:49 ` [PATCH v4 1/9] dm: video: Add damage tracking API Alexander Graf
                   ` (10 more replies)
  0 siblings, 11 replies; 25+ messages in thread
From: Alexander Graf @ 2023-01-03 21:49 UTC (permalink / raw)
  To: u-boot
  Cc: Matthias Brugger, Heinrich Schuchardt, Anatolij Gustschin,
	Simon Glass, Da Xue, Ilias Apalodimas, Jagan Teki,
	Andre Przywara, Neil Armstrong, Philipp Tomsich, Kever Yang,
	Patrick Delaunay, Patrice Chotard, uboot-stm32, u-boot-amlogic

This patch set speeds up graphics output on ARM by a factor of 60x.

On most ARM SBCs, we keep the frame buffer in DRAM and map it as cached,
but need it accessible by the display controller which reads directly
from a later point of consistency. Hence, we flush the frame buffer to
DRAM on every change. The full frame buffer.

Unfortunately, with the advent of 4k displays, we are seeing frame buffers
that can take a while to flush out. This was reported by Da Xue with grub,
which happily print 1000s of spaces on the screen to draw a menu. Every
printed space triggers a cache flush.

This patch set implements the easiest mitigation against this problem:
Damage tracking. We remember the lowest common denominator region that was
touched since the last video_sync() call and only flush that. The most
typical writer to the frame buffer is the video console, which always
writes rectangles of characters on the screen and syncs afterwards.

With this patch set applied, we reduce drawing a large grub menu (with
serial console attached for size information) on an RK3399-ROC system
at 1440p from 55 seconds to less than 1 second.

Version 2 also implements VIDEO_COPY using this mechanism, reducing its
overhead compared to before as well. So even x86 systems should be faster
with this now :).


Alternatives considered:

  1) Lazy sync - Sandbox does this. It only calls video_sync(true) ever
     so often. We are missing timers to do this generically.

  2) Double buffering - We could try to identify whether anything changed
     at all and only draw to the FB if it did. That would require
     maintaining a second buffer that we need to scan.

  3) Text buffer - Maintain a buffer of all text printed on the screen with
     respective location. Don't write if the old and new character are
     identical. This would limit applicability to text only and is an
     optimization on top of this patch set.

  4) Hash screen lines - Create a hash (sha256?) over every line when it
     changes. Only flush when it does. I'm not sure if this would waste
     more time, memory and cache than the current approach. It would make
     full screen updates much more expensive.

v1 -> v2:

  - new patch: video: Use VIDEO_DAMAGE for VIDEO_COPY
  - Remove ifdefs
  - Fix dcache range; we were flushing too much before
  - Fix ranges in truetype target
  - Limit rotate to necessary damange

v2 -> v3:

  - Rebase
  - Adapt to DM_VIDEO always
  - Make CONFIG_COPY always select VIDEO_DAMAGE

v3 -> v4:

  - New patch: video: Always compile cache flushing code
  - New patch: video: Enable VIDEO_DAMAGE for drivers that need it
  - Simplify first damage logic
  - Skip damage on EfiBltVideoToBltBuffer
  - Move damage clear from patch 6 to patch 1
  - Remove VIDEO_DAMAGE default for ARM

Alexander Graf (9):
  dm: video: Add damage tracking API
  dm: video: Add damage notification on display clear
  vidconsole: Add damage notifications to all vidconsole drivers
  video: Add damage notification on bmp display
  efi_loader: GOP: Add damage notification on BLT
  video: Only dcache flush damaged lines
  video: Use VIDEO_DAMAGE for VIDEO_COPY
  video: Always compile cache flushing code
  video: Enable VIDEO_DAMAGE for drivers that need it

 arch/arm/mach-omap2/omap3/Kconfig |   1 +
 arch/arm/mach-sunxi/Kconfig       |   1 +
 drivers/video/Kconfig             |  27 +++++
 drivers/video/console_normal.c    |  22 ++--
 drivers/video/console_rotate.c    |  87 +++++++++-----
 drivers/video/console_truetype.c  |  30 ++---
 drivers/video/exynos/Kconfig      |   1 +
 drivers/video/imx/Kconfig         |   1 +
 drivers/video/meson/Kconfig       |   1 +
 drivers/video/rockchip/Kconfig    |   1 +
 drivers/video/stm32/Kconfig       |   1 +
 drivers/video/vidconsole-uclass.c |  16 ---
 drivers/video/video-uclass.c      | 187 +++++++++++++++++-------------
 drivers/video/video_bmp.c         |   7 +-
 include/video.h                   |  54 ++++-----
 include/video_console.h           |  49 --------
 lib/efi_loader/efi_gop.c          |   6 +
 17 files changed, 251 insertions(+), 241 deletions(-)

-- 
2.37.1 (Apple Git-137.1)


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

end of thread, other threads:[~2023-04-19  1:48 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 21:49 [PATCH v4 0/9] Add video damage tracking Alexander Graf
2023-01-03 21:49 ` [PATCH v4 1/9] dm: video: Add damage tracking API Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:49 ` [PATCH v4 2/9] dm: video: Add damage notification on display clear Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:49 ` [PATCH v4 3/9] vidconsole: Add damage notifications to all vidconsole drivers Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:49 ` [PATCH v4 4/9] video: Add damage notification on bmp display Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 5/9] efi_loader: GOP: Add damage notification on BLT Alexander Graf
2023-01-04 12:50   ` Heinrich Schuchardt
2023-01-03 21:50 ` [PATCH v4 6/9] video: Only dcache flush damaged lines Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 7/9] video: Use VIDEO_DAMAGE for VIDEO_COPY Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-07 22:40     ` Heinrich Schuchardt
2023-01-08 15:48       ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 8/9] video: Always compile cache flushing code Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 9/9] video: Enable VIDEO_DAMAGE for drivers that need it Alexander Graf
2023-01-04 12:32   ` Neil Armstrong
2023-01-07  0:13   ` Simon Glass
2023-01-07  0:13 ` [PATCH v4 0/9] Add video damage tracking Simon Glass
2023-04-14  7:35 ` Antonio Murdaca
2023-04-19  1:45   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.