[PATCH 01/11] drm/vram: Add struct drm_vram_buffer to VRAM helpers

Gerd Hoffmann kraxel at redhat.com
Thu Sep 19 05:58:33 UTC 2019

On Wed, Sep 18, 2019 at 04:22:57PM +0200, Thomas Zimmermann wrote:
> Drivers with dedicated video memory occasionally need to reserve a memory
> area for a specific purpose, such as cursor images or sprites. Using GEM
> VRAM buffer objects can be problematic. For small buffers, GEM VRAM buffer
> objects are inefficient as they are aligned to page boundaries.

I would still allocate gem objects for that.  Then use them as pool
instead of using them directly.

Not sure this is worth the trouble just for the cursors though as they
are big enough that page-sized allocations don't waste memory.

> And they cannot easily be placed at specific memory offsets. This can
> lead to memory fragmentation and is a problem for hardware with only a
> small amount of memory.

Note that there is a flag to change the allocation strategy
(TTM_PL_FLAG_TOPDOWN).  You could allocate the cursor objects
with the flag set.  Should be good enough to avoid fragmentation.

I have a patch doing exactly that for qxl, for the same reason:
(no, that patch wasn't sent to the list yet).

We could do the same for vram and either let the driver explicitly ask
for top-down allocation, or use some threshold like the qxl patch.

So, I'm not convinced we actually need the drm_vram_buffer


More information about the dri-devel mailing list