History

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.

Boris Brezillon committed 9 years ago

Commit b9f19251 parent 06e733e6 files · +507 −15Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/drm/vc4_drm.h+19−0
@@ -41,6 +41,7 @@ extern "C" { · 40 unmodified lines
4141 #define DRM_VC4_SET_TILING 0x08
4242 #define DRM_VC4_GET_TILING 0x09
4343 #define DRM_VC4_LABEL_BO 0x0a
44+#define DRM_VC4_GEM_MADVISE 0x0b
4445
4546 #define DRM_IOCTL_VC4_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
4647 #define DRM_IOCTL_VC4_WAIT_SEQNO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
@@ -53,6 +54,7 @@ extern "C" { · 6 unmodified lines
5354 #define DRM_IOCTL_VC4_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SET_TILING, struct drm_vc4_set_tiling)
5455 #define DRM_IOCTL_VC4_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_TILING, struct drm_vc4_get_tiling)
5556 #define DRM_IOCTL_VC4_LABEL_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_LABEL_BO, struct drm_vc4_label_bo)
57+#define DRM_IOCTL_VC4_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GEM_MADVISE, struct drm_vc4_gem_madvise)
5658
5759 struct drm_vc4_submit_rcl_surface {
5860 __u32 hindex; /* Handle index, or ~0 if not present. */
@@ -305,6 +307,7 @@ struct drm_vc4_get_hang_state { · 246 unmodified lines
305307 #define DRM_VC4_PARAM_SUPPORTS_ETC1 4
306308 #define DRM_VC4_PARAM_SUPPORTS_THREADED_FS 5
307309 #define DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER 6
310+#define DRM_VC4_PARAM_SUPPORTS_MADVISE 7
308311
309312 struct drm_vc4_get_param {
310313 __u32 param;
@@ -333,6 +336,22 @@ struct drm_vc4_label_bo { · 22 unmodified lines
333336 __u64 name;
334337 };
335338
339+/*
340+ * States prefixed with '__' are internal states and cannot be passed to the
341+ * DRM_IOCTL_VC4_GEM_MADVISE ioctl.
342+ */
343+#define VC4_MADV_WILLNEED 0
344+#define VC4_MADV_DONTNEED 1
345+#define __VC4_MADV_PURGED 2
346+#define __VC4_MADV_NOTSUPP 3
347+
348+struct drm_vc4_gem_madvise {
349+ __u32 handle;
350+ __u32 madv;
351+ __u32 retained;
352+ __u32 pad;
353+};
354+
336355 #if defined(__cplusplus)
337356 }
338357 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t