[PATCH 00/11] drm/vram: Add VRAM buffers for HW cursors

Thomas Zimmermann tzimmermann at suse.de
Wed Sep 18 14:22:56 UTC 2019


This patchset adds dedicated VRAM buffers and cleans up the memory
management of HW cursors in ast and mgag200.

The ast and mgag200 drivers support HW cursors of uncommon pixel formats.
Both drivers manage cursor memory in dedicated GEM VRAM buffer objects
with a double buffering scheme; either by alternating between two GEM BOs,
or by alternating between offsets within the same GEM BO. The code is
convoluted and can lead to memory fragmentation if the BO is stored the
middle of VRAM. This is especially a problem on devices with only a small
amount of video memory.

This patchset introduces VRAM buffers, a simple data structure that
manages dedicated areas of VRAM. The VRAM buffer supports double-
buffering (or more) to allow for flicker-free updates. A typical use
case is in managing small, static buffers, such as cursors or sprites.

The patchset then cleans up cursor memory management in ast and mgag200.
To avoid the fragmentation issue, at the high end of each device's VRAM,
a few KiB are reserved for the HW cursor. This memory is maintained by a
double-buffered VRAM buffer. For updating the cursor image, each driver's
cursor_set() functions fills the current back buffer and then makes it the
front buffer.

The patchset has been tested on ast and mgag200 hardware.

Thomas Zimmermann (11):
  drm/vram: Add struct drm_vram_buffer to VRAM helpers
  drm/ast: Don't call ast_show_cursor() from ast_cursor_move()
  drm/ast: Move cursor update code to ast_show_cursor()
  drm/ast: Reserve space for double-buffered cursor image
  drm/ast: Store cursor in reserved memory area
  drm/mgag200: Rename cursor functions to use mgag200_ prefix
  drm/mgag200: Add init and fini functions for cursor handling
  drm/mgag200: Add separate move-cursor function
  drm/mgag200: Move cursor-image update to mgag200_show_cursor()
  drm/mgag200: Reserve video memory for cursor plane
  drm/mgag200: Implement cursor buffer with struct drm_vram_buffer

 Documentation/gpu/drm-mm.rst             |  19 +-
 drivers/gpu/drm/ast/ast_drv.h            |   5 +-
 drivers/gpu/drm/ast/ast_mode.c           | 198 +++++++++--------
 drivers/gpu/drm/ast/ast_ttm.c            |  13 +-
 drivers/gpu/drm/drm_vram_helper_common.c | 259 ++++++++++++++++++++++-
 drivers/gpu/drm/mgag200/mgag200_cursor.c | 252 +++++++++++-----------
 drivers/gpu/drm/mgag200/mgag200_drv.h    |  24 +--
 drivers/gpu/drm/mgag200/mgag200_main.c   |  20 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c   |   6 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c    |  15 +-
 include/drm/drm_vram_helper.h            |  64 ++++++
 11 files changed, 607 insertions(+), 268 deletions(-)
 create mode 100644 include/drm/drm_vram_helper.h

--
2.23.0



More information about the dri-devel mailing list