History

drm: document expectations for GETFB2 handles

There are two important details missing from the docs: - If the memory object backing the FB already has a GEM handle, it's not re-used, a new one is generated. - Aliased planes will return the same GEM handle. v2: document how user-space can obtain DMA-BUF FDs without leaking handles (Pekka)

Simon Ser committed 3 years ago

Commit 61a55f81 parent c2f2c721 file · +12 −2Browse files

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

Unified · Split

include/uapi/drm/drm.h+12−2
@@ -1117,8 +1117,13 @@ extern "C" { · 1116 unmodified lines
11171117 * struct as the output.
11181118 *
11191119 * If the client is DRM master or has &CAP_SYS_ADMIN, &drm_mode_fb_cmd2.handles
1120− * will be filled with GEM buffer handles. Planes are valid until one has a
1121− * zero handle -- this can be used to compute the number of planes.
1120+ * will be filled with GEM buffer handles. Fresh new GEM handles are always
1121+ * returned, even if another GEM handle referring to the same memory object
1122+ * already exists on the DRM file description. The caller is responsible for
1123+ * removing the new handles, e.g. via the &DRM_IOCTL_GEM_CLOSE IOCTL. The same
1124+ * new handle will be returned for multiple planes in case they use the same
1125+ * memory object. Planes are valid until one has a zero handle -- this can be
1126+ * used to compute the number of planes.
11221127 *
11231128 * Otherwise, &drm_mode_fb_cmd2.handles will be zeroed and planes are valid
11241129 * until one has a zero &drm_mode_fb_cmd2.pitches.
@@ -1126,6 +1131,11 @@ extern "C" { · 1 unmodified line
11261131 * If the framebuffer has a format modifier, &DRM_MODE_FB_MODIFIERS will be set
11271132 * in &drm_mode_fb_cmd2.flags and &drm_mode_fb_cmd2.modifier will contain the
11281133 * modifier. Otherwise, user-space must ignore &drm_mode_fb_cmd2.modifier.
1134+ *
1135+ * To obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space
1136+ * can export each handle via &DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately
1137+ * close each unique handle via &DRM_IOCTL_GEM_CLOSE, making sure to not
1138+ * double-close handles which are specified multiple times in the array.
11291139 */
11301140 #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
11311141

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