drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Thu, 19 Oct 2017 12:57:48 +0000 (14:57 +0200)
committerEric Anholt <eric@anholt.net>
Thu, 19 Oct 2017 17:34:49 +0000 (10:34 -0700)
commitb9f19259b84dc648f207a46f3581d15eeaedf4b6
tree858b3e10d5cb59abf3066511ccde15b8fd310a19
parent06e733e41f87d75a60347b0c93a18fc0104d709d
drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl

This ioctl will allow us to purge inactive userspace buffers when the
system is running out of contiguous memory.

For now, the purge logic is rather dumb in that it does not try to
release only the amount of BO needed to meet the last CMA alloc request
but instead purges all objects placed in the purgeable pool as soon as
we experience a CMA allocation failure.

Note that the in-kernel BO cache is always purged before the purgeable
cache because those objects are known to be unused while objects marked
as purgeable by a userspace application/library might have to be
restored when they are marked back as unpurgeable, which can be
expensive.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20171019125748.3152-1-boris.brezillon@free-electrons.com
drivers/gpu/drm/vc4/vc4_bo.c
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_gem.c
drivers/gpu/drm/vc4/vc4_plane.c
include/uapi/drm/vc4_drm.h