Skip to contentSkip to conversation

drm/doc: Document that modifiers are always required for fb

PATCH Applied Daniel Vetter 3 participants 3 messages Sep 17, 2020 – Sep 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/doc: Document that modifiers are always required for fb

Even for legacy userspace, since otherwise GETFB2 is broken and if you switch between modifier-less and modifier-aware compositors, smooth transitions break.

Also it's just best practice to make sure modifiers are invariant for a given drm_fb, and that a modifier-aware kms drivers only has one place to store them, ignoring any old implicit bo flags or whatever else might float around.

Motivated by some irc discussion with Bas about amdgpu modifier support.

Fixes 455e00f1412f ("drm: Add getfb2 ioctl")
Cc Daniel Stone <[email protected]>
Cc Juston Li <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Bas Nieuwenhuizen <[email protected]>
Cc Marek Olšák <[email protected]>
Cc "Wentland, Harry" <[email protected]>

---
Sending this out again to double-check there's no objections or concerns. From what I understand looking at the code the latest modifier patches for amdgpu follow this now.

Cheers, Daniel

---
 include/drm/drm_mode_config.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/drm/drm_mode_config.h +13 -0
index a18f73eb3cf6..5ffbb4ed5b35 100644
@@ -58,6 +58,12 @@ struct drm_mode_config_funcs {
 	 * actual modifier used if the request doesn't have it specified,
 	 * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
 	 *
+	 * IMPORTANT: These implied modifiers for legacy userspace must be
+	 * stored in struct &drm_framebuffer, including all relevant metadata
+	 * like &drm_framebuffer.pitches and &drm_framebuffer.offsets if the
+	 * modifier enables additional planes beyond the fourcc pixel format
+	 * code. This is required by the GETFB2 ioctl.
+	 *
 	 * If the parameters are deemed valid and the backing storage objects in
 	 * the underlying memory manager all exist, then the driver allocates
 	 * a new &drm_framebuffer structure, subclassed to contain
@@ -915,6 +921,13 @@ struct drm_mode_config {
 	 * @allow_fb_modifiers:
 	 *
 	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
+	 *
+	 * IMPORTANT:
+	 *
+	 * If this is set the driver must fill out the full implicit modifier
+	 * information in their &drm_mode_config_funcs.fb_create hook for legacy
+	 * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
+	 * broken for modifier aware userspace.
 	 */
 	bool allow_fb_modifiers;
 
Signature · 6 lines
2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 67 lines · Daniel Vetter

Even for legacy userspace, since otherwise GETFB2 is broken and if you switch between modifier-less and modifier-aware compositors, smooth transitions break.

Also it's just best practice to make sure modifiers are invariant for a given drm_fb, and that a modifier-aware kms drivers only has one place to store them, ignoring any old implicit bo flags or whatever else might float around.

Motivated by some irc discussion with Bas about amdgpu modifier support.

Fixes 455e00f1412f ("drm: Add getfb2 ioctl")
Cc Daniel Stone <[email protected]>
Cc Juston Li <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Bas Nieuwenhuizen <[email protected]>
Cc Marek Olšák <[email protected]>
Cc "Wentland, Harry" <[email protected]>

---
Sending this out again to double-check there's no objections or concerns. From what I understand looking at the code the latest modifier patches for amdgpu follow this now.

Cheers, Daniel

---
 include/drm/drm_mode_config.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/drm/drm_mode_config.h +13 -1
index a18f73eb3cf6..5ffbb4ed5b35 100644
@@ -58,6 +58,12 @@ struct drm_mode_config_funcs {
         * actual modifier used if the request doesn't have it specified,
         * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
         *
+        * IMPORTANT: These implied modifiers for legacy userspace must be
+        * stored in struct &drm_framebuffer, including all relevant metadata
+        * like &drm_framebuffer.pitches and &drm_framebuffer.offsets if the
+        * modifier enables additional planes beyond the fourcc pixel format
+        * code. This is required by the GETFB2 ioctl.
+        *
         * If the parameters are deemed valid and the backing storage objects in
         * the underlying memory manager all exist, then the driver allocates
         * a new &drm_framebuffer structure, subclassed to contain
@@ -915,6 +921,13 @@ struct drm_mode_config {
         * @allow_fb_modifiers:
         *
         * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
+        *
+        * IMPORTANT:
+        *
+        * If this is set the driver must fill out the full implicit modifier
+        * information in their &drm_mode_config_funcs.fb_create hook for legacy
+        * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
+        * broken for modifier aware userspace.
         */
        bool allow_fb_modifiers;
 
--
Quoted 2 lines

2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 28 lines · Bas Nieuwenhuizen
Quoted 25 lines · Daniel Vetter

Even for legacy userspace, since otherwise GETFB2 is broken and if you switch between modifier-less and modifier-aware compositors, smooth transitions break.

Also it's just best practice to make sure modifiers are invariant for a given drm_fb, and that a modifier-aware kms drivers only has one place to store them, ignoring any old implicit bo flags or whatever else might float around.

Motivated by some irc discussion with Bas about amdgpu modifier support.

Fixes 455e00f1412f ("drm: Add getfb2 ioctl")
Cc Daniel Stone <[email protected]>
Cc Juston Li <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Bas Nieuwenhuizen <[email protected]>
Cc Marek Olšák <[email protected]>
Cc "Wentland, Harry" <[email protected]>

Pushed to drm-misc-next, thanks for all the feedback. -Daniel

Quoted 44 lines
Quoted 44 lines

---
Sending this out again to double-check there's no objections or concerns. From what I understand looking at the code the latest modifier patches for amdgpu follow this now.

Cheers, Daniel

---
 include/drm/drm_mode_config.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/drm/drm_mode_config.h +13 -1
index a18f73eb3cf6..5ffbb4ed5b35 100644
@@ -58,6 +58,12 @@ struct drm_mode_config_funcs {
         * actual modifier used if the request doesn't have it specified,
         * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
         *
+        * IMPORTANT: These implied modifiers for legacy userspace must be
+        * stored in struct &drm_framebuffer, including all relevant metadata
+        * like &drm_framebuffer.pitches and &drm_framebuffer.offsets if the
+        * modifier enables additional planes beyond the fourcc pixel format
+        * code. This is required by the GETFB2 ioctl.
+        *
         * If the parameters are deemed valid and the backing storage objects in
         * the underlying memory manager all exist, then the driver allocates
         * a new &drm_framebuffer structure, subclassed to contain
@@ -915,6 +921,13 @@ struct drm_mode_config {
         * @allow_fb_modifiers:
         *
         * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
+        *
+        * IMPORTANT:
+        *
+        * If this is set the driver must fill out the full implicit modifier
+        * information in their &drm_mode_config_funcs.fb_create hook for legacy
+        * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
+        * broken for modifier aware userspace.
         */
        bool allow_fb_modifiers;
 
--

2.28.0

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel