Skip to contentSkip to conversation

drm: uapi: Add macro for chipset specific event ID region

PATCH RESEND Superseded Bence Csokas 2 participants 2 messages Jun 15

Subsystems (5)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drm: uapi: Add macro for chipset specific event ID region

uapi/drm/drm.h states:

Event types 0 - 0x7fffffff are generic DRM events, 0x80000000 and up are chipset specific.

However, this distinction was not put in the code. To elevate the contract between the generic DRM framework and the driver from the comment to code, put this in a macro for clarity and convenience.

---
 include/uapi/drm/drm.h         | 8 ++++++++
 include/uapi/drm/exynos_drm.h  | 4 ++--
 include/uapi/drm/virtgpu_drm.h | 2 +-
 include/uapi/drm/vmwgfx_drm.h  | 2 +-
 4 files changed, 12 insertions(+), 4 deletions(-)
include/uapi/drm/drm.h +8 -0
index 27cc159c1d27..aa745e643ef4 100644
@@ -1419,6 +1419,14 @@ struct drm_event {
  * The event payload is a struct drm_event_crtc_sequence.
  */
 #define DRM_EVENT_CRTC_SEQUENCE	0x03
+/**
+ * DRM_EVENT_VENDOR_SPECIFIC - vendor/chipset specific event
+ *
+ * These event IDs are reserved for chipset and driver specific events.
+ *
+ * Refer to the chipset driver's header for details and payload struct.
+ */
+#define DRM_EVENT_VENDOR_SPECIFIC(_v) ((_v) | 0x80000000)
 
 struct drm_event_vblank {
 	struct drm_event base;
include/uapi/drm/exynos_drm.h +2 -2
index a51aa1c618c1..8d3156fb129c 100644
@@ -395,8 +395,8 @@ struct drm_exynos_ioctl_ipp_commit {
 		DRM_EXYNOS_IPP_COMMIT, struct drm_exynos_ioctl_ipp_commit)
 
 /* Exynos specific events */
-#define DRM_EXYNOS_G2D_EVENT		0x80000000
-#define DRM_EXYNOS_IPP_EVENT		0x80000002
+#define DRM_EXYNOS_G2D_EVENT		DRM_EVENT_VENDOR_SPECIFIC(0x0)
+#define DRM_EXYNOS_IPP_EVENT		DRM_EVENT_VENDOR_SPECIFIC(0x2)
 
 struct drm_exynos_g2d_event {
 	struct drm_event	base;
include/uapi/drm/virtgpu_drm.h +1 -1
index 9debb320c34b..03e8a0c7f778 100644
@@ -224,7 +224,7 @@ struct drm_virtgpu_context_init {
  * effect.  The event size is sizeof(drm_event), since there is no additional
  * payload.
  */
-#define VIRTGPU_EVENT_FENCE_SIGNALED 0x90000000
+#define VIRTGPU_EVENT_FENCE_SIGNALED DRM_EVENT_VENDOR_SPECIFIC(0x10000000)
 
 #define DRM_IOCTL_VIRTGPU_MAP \
 	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
include/uapi/drm/vmwgfx_drm.h +1 -1
index 7d786a0cc835..5e5878384e60 100644
@@ -715,7 +715,7 @@ struct drm_vmw_fence_arg {
 /*
  * The event type
  */
-#define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
+#define DRM_VMW_EVENT_FENCE_SIGNALED DRM_EVENT_VENDOR_SPECIFIC(0x0)
 
 struct drm_vmw_event_fence {
 	struct drm_event base;

base-commit: 0e0611827f3349d0a2ac121c023a6d3260dcecdb

Signature · 1 line
2.54.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Missing parameter documentation for `_v` in the kernel-doc of `DRM_EVENT_VENDOR_SPECIFIC` macro.…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Missing parameter documentation for _v in the kernel-doc of DRM_EVENT_VENDOR_SPECIFIC macro.
- [Low] The chipset-specific event DRM_NOUVEAU_EVENT_NVIF was not converted to use the new DRM_EVENT_VENDOR_SPECIFIC macro. --

commit cc8100201e0dfb32c2f9528073691e1aff91810c
Author: Bence Csokas <[email protected]>

drm: uapi: Add macro for chipset specific event ID region

This commit introduces the DRM_EVENT_VENDOR_SPECIFIC macro to UAPI. It also updates several drivers to use this macro instead of hardcoded event IDs.

Quoted 8 lines

uapi/drm/drm.h states:

Event types 0 - 0x7fffffff are generic DRM events, 0x80000000 and up are chipset specific.

However, this distinction was not put in the code. To elevate the contract between the generic DRM framework and the driver from the comment to code, put this in a macro for clarity and convenience.

[Severity: Low]
This isn't a bug, but it looks like include/uapi/drm/nouveau_drm.h was missed during this refactoring. Should DRM_NOUVEAU_EVENT_NVIF also be updated to use the new macro?

include/uapi/drm/nouveau_drm.h:
#define DRM_NOUVEAU_EVENT_NVIF 0x80000000

Quoted 6 lines
include/uapi/drm/drm.h +0 -0
index 27cc159c1d275..aa745e643ef48 100644
@@ -1419,6 +1419,14 @@ struct drm_event {
  * The event payload is a struct drm_event_crtc_sequence.

include/uapi/drm/drm.h struct drm_event { · line 1429

Quoted 10 lines
include/uapi/drm/drm.h +8 -0
  */
 #define DRM_EVENT_CRTC_SEQUENCE	0x03
+/**
+ * DRM_EVENT_VENDOR_SPECIFIC - vendor/chipset specific event
+ *
+ * These event IDs are reserved for chipset and driver specific events.
+ *
+ * Refer to the chipset driver's header for details and payload struct.
+ */
+#define DRM_EVENT_VENDOR_SPECIFIC(_v) ((_v) | 0x80000000)

[Severity: Low]
This isn't a bug, but should the _v parameter be documented here? Missing the @_v: description in the kernel-doc block might trigger a warning during documentation generation.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1