[PATCH v3 1/4] drm: Define user readable error codes for atomic ioctl
Xaver Hugl
xaver.hugl at kde.org
Fri Aug 22 16:14:54 UTC 2025
> +#define DRM_MODE_ATOMIC_FAILURE_REASON \
> + FAILURE_REASON(DRM_MODE_ATOMIC_CAP_NOT_ENABLED, "DRM_ATOMIC capability not enabled") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_INVALID_FLAG, "invalid flag") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_PAGE_FLIP_ASYNC, "Legacy DRM_MODE_PAGE_FLIP_ASYNC not to be used in atomic ioctl") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_FLIP_EVENT_WITH_CHECKONLY, "requesting page-flip event with TEST_ONLY") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_CRTC_NEED_FULL_MODESET, "Need full modeset on this crtc") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_NEED_FULL_MODESET, "Need full modeset on all the connected crtc's") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_ASYNC_NOT_SUP_PLANE, "Async flip not supported on this plane") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_ASYNC_MODIFIER_NOT_SUPPORTED, "Modifier not supported on this plane with async flip") \
> + FAILURE_REASON(DRM_MODE_ATOMIC_ASYNC_PROP_CHANGED, "No property change allowed when async flip is enabled")
As mentioned before, some of these errors are a bit too specific. We
don't need to have an enum value for every way the API can be used
wrongly - CAP_NOT_ENABLED, INVALID_FLAG, PAGE_FLIP_ASYNC and
MODIFIER_NOT_SUPPORTED should all just be one enum value for "invalid
API usage".
In general, there should only be enum values that the compositor
implementation can actually use on end-user systems. For further
information when debugging a broken compositor implementation, other
tools can be used instead, like drm debug logging or the returned
string.
> +#define FAILURE_REASON(flag, reason) flag,
> +typedef enum {
> + DRM_MODE_ATOMIC_FAILURE_REASON
> +} drm_mode_atomic_failure_flag;
> +#undef FAILURE_REASON
> +
> +#define FAILURE_REASON(flag, reason) #reason,
> +extern const char *drm_mode_atomic_failure_string[];
> +#undef FAILURE_REASON
The intention for the string wasn't for the enum values to be paired
with a description of the enum - that belongs into documentation, not
uAPI.
The idea behind it was that drivers could add driver-specific
information in the string for compositors to log (only in commits
where failure isn't normally expected), so we have an easier time
debugging issues a user system experienced by looking at the
compositor logs. Sending the enum value again in string form isn't
useful.
- Xaver
More information about the Intel-xe
mailing list