Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools headers UAPI: Sync the drm/drm.h with the kernel sources

Picking the changes from:

6068771673a38efc ("drm: document DRM_IOCTL_PRIME_HANDLE_TO_FD and PRIME_FD_TO_HANDLE")
61a55f8b1ebcde68 ("drm: document expectations for GETFB2 handles")
158350aae16a4e66 ("drm: document DRM_IOCTL_GEM_CLOSE")

Silencing these perf build warnings:

Warning: Kernel ABI header at 'tools/include/uapi/drm/drm.h' differs from latest version at 'include/uapi/drm/drm.h'
diff -u tools/include/uapi/drm/drm.h include/uapi/drm/drm.h

No changes in tooling as these are just C comment documentation changes.

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: loongson-kernel@lists.loongnix.cn
Link: https://lore.kernel.org/r/7552c61660bf079f2979fdcbcef8e921255f877a.1683712945.git.siyanteng@loongson.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Yanteng Si and committed by
Arnaldo Carvalho de Melo
e6232180 5d1ac59f

+55 -2
+55 -2
tools/include/uapi/drm/drm.h
··· 972 972 #define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats) 973 973 #define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version) 974 974 #define DRM_IOCTL_MODESET_CTL DRM_IOW(0x08, struct drm_modeset_ctl) 975 + /** 976 + * DRM_IOCTL_GEM_CLOSE - Close a GEM handle. 977 + * 978 + * GEM handles are not reference-counted by the kernel. User-space is 979 + * responsible for managing their lifetime. For example, if user-space imports 980 + * the same memory object twice on the same DRM file description, the same GEM 981 + * handle is returned by both imports, and user-space needs to ensure 982 + * &DRM_IOCTL_GEM_CLOSE is performed once only. The same situation can happen 983 + * when a memory object is allocated, then exported and imported again on the 984 + * same DRM file description. The &DRM_IOCTL_MODE_GETFB2 IOCTL is an exception 985 + * and always returns fresh new GEM handles even if an existing GEM handle 986 + * already refers to the same memory object before the IOCTL is performed. 987 + */ 975 988 #define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close) 976 989 #define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink) 977 990 #define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open) ··· 1025 1012 #define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock) 1026 1013 #define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock) 1027 1014 1015 + /** 1016 + * DRM_IOCTL_PRIME_HANDLE_TO_FD - Convert a GEM handle to a DMA-BUF FD. 1017 + * 1018 + * User-space sets &drm_prime_handle.handle with the GEM handle to export and 1019 + * &drm_prime_handle.flags, and gets back a DMA-BUF file descriptor in 1020 + * &drm_prime_handle.fd. 1021 + * 1022 + * The export can fail for any driver-specific reason, e.g. because export is 1023 + * not supported for this specific GEM handle (but might be for others). 1024 + * 1025 + * Support for exporting DMA-BUFs is advertised via &DRM_PRIME_CAP_EXPORT. 1026 + */ 1028 1027 #define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle) 1028 + /** 1029 + * DRM_IOCTL_PRIME_FD_TO_HANDLE - Convert a DMA-BUF FD to a GEM handle. 1030 + * 1031 + * User-space sets &drm_prime_handle.fd with a DMA-BUF file descriptor to 1032 + * import, and gets back a GEM handle in &drm_prime_handle.handle. 1033 + * &drm_prime_handle.flags is unused. 1034 + * 1035 + * If an existing GEM handle refers to the memory object backing the DMA-BUF, 1036 + * that GEM handle is returned. Therefore user-space which needs to handle 1037 + * arbitrary DMA-BUFs must have a user-space lookup data structure to manually 1038 + * reference-count duplicated GEM handles. For more information see 1039 + * &DRM_IOCTL_GEM_CLOSE. 1040 + * 1041 + * The import can fail for any driver-specific reason, e.g. because import is 1042 + * only supported for DMA-BUFs allocated on this DRM device. 1043 + * 1044 + * Support for importing DMA-BUFs is advertised via &DRM_PRIME_CAP_IMPORT. 1045 + */ 1029 1046 #define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle) 1030 1047 1031 1048 #define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30) ··· 1147 1104 * struct as the output. 1148 1105 * 1149 1106 * If the client is DRM master or has &CAP_SYS_ADMIN, &drm_mode_fb_cmd2.handles 1150 - * will be filled with GEM buffer handles. Planes are valid until one has a 1151 - * zero handle -- this can be used to compute the number of planes. 1107 + * will be filled with GEM buffer handles. Fresh new GEM handles are always 1108 + * returned, even if another GEM handle referring to the same memory object 1109 + * already exists on the DRM file description. The caller is responsible for 1110 + * removing the new handles, e.g. via the &DRM_IOCTL_GEM_CLOSE IOCTL. The same 1111 + * new handle will be returned for multiple planes in case they use the same 1112 + * memory object. Planes are valid until one has a zero handle -- this can be 1113 + * used to compute the number of planes. 1152 1114 * 1153 1115 * Otherwise, &drm_mode_fb_cmd2.handles will be zeroed and planes are valid 1154 1116 * until one has a zero &drm_mode_fb_cmd2.pitches. ··· 1161 1113 * If the framebuffer has a format modifier, &DRM_MODE_FB_MODIFIERS will be set 1162 1114 * in &drm_mode_fb_cmd2.flags and &drm_mode_fb_cmd2.modifier will contain the 1163 1115 * modifier. Otherwise, user-space must ignore &drm_mode_fb_cmd2.modifier. 1116 + * 1117 + * To obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space 1118 + * can export each handle via &DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately 1119 + * close each unique handle via &DRM_IOCTL_GEM_CLOSE, making sure to not 1120 + * double-close handles which are specified multiple times in the array. 1164 1121 */ 1165 1122 #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2) 1166 1123