dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/12] drm/arm: Don't set allow_fb_modifiers explicitly
@ 2021-04-13  9:48 Daniel Vetter
  2021-04-13  9:48 ` [PATCH 02/12] drm/arm/malidp: Always list modifiers Daniel Vetter
                   ` (10 more replies)
  0 siblings, 11 replies; 36+ messages in thread
From: Daniel Vetter @ 2021-04-13  9:48 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, Liviu Dudau,
	James (Qian) Wang, Daniel Vetter, Mihail Atanassov

Since

commit 890880ddfdbe256083170866e49c87618b706ac7
Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Date:   Fri Jan 4 09:56:10 2019 +0100

    drm: Auto-set allow_fb_modifiers when given modifiers at plane init

this is done automatically as part of plane init, if drivers set the
modifier list correctly. Which is the case here for both komeda and
malidp.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>
Cc: Brian Starkey <brian.starkey@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 1 -
 drivers/gpu/drm/arm/malidp_drv.c                | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index aeda4e5ec4f4..ff45f23f3d56 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -247,7 +247,6 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
 	config->min_height	= 0;
 	config->max_width	= 4096;
 	config->max_height	= 4096;
-	config->allow_fb_modifiers = true;
 
 	config->funcs = &komeda_mode_config_funcs;
 	config->helper_private = &komeda_mode_config_helpers;
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index d83c7366b348..de59f3302516 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -403,7 +403,6 @@ static int malidp_init(struct drm_device *drm)
 	drm->mode_config.max_height = hwdev->max_line_size;
 	drm->mode_config.funcs = &malidp_mode_config_funcs;
 	drm->mode_config.helper_private = &malidp_mode_config_helpers;
-	drm->mode_config.allow_fb_modifiers = true;
 
 	ret = malidp_crtc_init(drm);
 	if (ret)
-- 
2.31.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread
* [PATCH] drm/modifiers: Enforce consistency between the cap an IN_FORMATS
@ 2021-05-06 13:23 Daniel Vetter
  2021-05-12  9:31 ` Daniel Vetter
  0 siblings, 1 reply; 36+ messages in thread
From: Daniel Vetter @ 2021-05-06 13:23 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Daniel Vetter, Intel Graphics Development,
	David Airlie, Maxime Ripard, Thomas Zimmermann, Pekka Paalanen,
	Emil Velikov

It's very confusing for userspace to have to deal with inconsistencies
here, and some drivers screwed this up a bit. Most just ommitted the
format list when they meant to say that only linear modifier is
allowed, but some also meant that only implied modifiers are
acceptable (because actually none of the planes registered supported
modifiers).

Now that this is all done consistently across all drivers, document
the rules and enforce it in the drm core.

v2:
- Make the capability a link (Simon)
- Note that all is lost before 5.1.

v3:
- Use drm_WARN_ON (Lyude)

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Cc: Simon Ser <contact@emersion.fr>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/drm_plane.c   | 18 +++++++++++++++++-
 include/drm/drm_mode_config.h |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 0dd43882fe7c..b373958ecb30 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -128,6 +128,13 @@
  *     pairs supported by this plane. The blob is a struct
  *     drm_format_modifier_blob. Without this property the plane doesn't
  *     support buffers with modifiers. Userspace cannot change this property.
+ *
+ *     Note that userspace can check the &DRM_CAP_ADDFB2_MODIFIERS driver
+ *     capability for general modifier support. If this flag is set then every
+ *     plane will have the IN_FORMATS property, even when it only supports
+ *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
+ *     various bugs in this area with inconsistencies between the capability
+ *     flag and per-plane properties.
  */
 
 static unsigned int drm_num_planes(struct drm_device *dev)
@@ -277,8 +284,14 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 			format_modifier_count++;
 	}
 
-	if (format_modifier_count)
+	/* autoset the cap and check for consistency across all planes */
+	if (format_modifier_count) {
+		drm_WARN_ON(dev, !config->allow_fb_modifiers &&
+			    !list_empty(&config->plane_list));
 		config->allow_fb_modifiers = true;
+	} else {
+		drm_WARN_ON(dev, config->allow_fb_modifiers);
+	}
 
 	plane->modifier_count = format_modifier_count;
 	plane->modifiers = kmalloc_array(format_modifier_count,
@@ -360,6 +373,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
+ * Drivers supporting modifiers must set @format_modifiers on all their planes,
+ * even those that only support DRM_FORMAT_MOD_LINEAR.
+ *
  * Returns:
  * Zero on success, error code on failure.
  */
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index ab424ddd7665..1ddf7783fdf7 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -909,6 +909,8 @@ struct drm_mode_config {
 	 * @allow_fb_modifiers:
 	 *
 	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
+	 * Note that drivers should not set this directly, it is automatically
+	 * set in drm_universal_plane_init().
 	 *
 	 * IMPORTANT:
 	 *
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2021-05-12  9:32 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  9:48 [PATCH 01/12] drm/arm: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-13  9:48 ` [PATCH 02/12] drm/arm/malidp: Always list modifiers Daniel Vetter
2021-04-13  9:48 ` [PATCH 03/12] drm/exynos: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-20  6:31   ` Inki Dae
2021-04-20  8:41     ` Daniel Vetter
2021-04-13  9:48 ` [PATCH 04/12] drm/i915: " Daniel Vetter
2021-04-13  9:48 ` [PATCH 05/12] drm/imx: " Daniel Vetter
2021-04-13 11:47   ` Lucas Stach
2021-04-13 14:04     ` Daniel Vetter
2021-04-13 14:14       ` Lucas Stach
2021-04-14  2:24         ` Liu Ying
2021-04-14  9:10           ` Daniel Vetter
2021-04-15 11:35     ` Daniel Vetter
2021-04-13  9:48 ` [PATCH 06/12] drm/msm/dpu1: " Daniel Vetter
2021-04-13  9:48 ` [PATCH 07/12] drm/msm/mdp4: Fix modifier support enabling Daniel Vetter
2021-04-13  9:48 ` [PATCH 08/12] drm/nouveau: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-13  9:49 ` [PATCH 09/12] drm/stm: " Daniel Vetter
2021-04-13  9:49 ` [PATCH 10/12] drm/tegra: " Daniel Vetter
2021-04-13 11:37   ` Thierry Reding
2021-04-15 11:33     ` Daniel Vetter
2021-04-13  9:49 ` [PATCH 11/12] drm/vc4: " Daniel Vetter
2021-04-14  8:51   ` Maxime Ripard
2021-04-13  9:49 ` [PATCH 12/12] drm/modifiers: Enforce consistency between the cap an IN_FORMATS Daniel Vetter
2021-04-13 11:54   ` Lucas Stach
2021-04-13 14:17     ` Daniel Vetter
2021-04-13 11:56   ` Pekka Paalanen
2021-04-13 14:11     ` Daniel Vetter
2021-04-13 14:19       ` Daniel Vetter
2021-04-14  7:45       ` Pekka Paalanen
2021-04-13 15:22   ` Simon Ser
2021-04-14  8:52   ` Maxime Ripard
2021-04-14  9:08   ` [PATCH] " Daniel Vetter
2021-04-14 12:14     ` Pekka Paalanen
2021-04-16  6:30     ` Simon Ser
2021-05-06 13:23 Daniel Vetter
2021-05-12  9:31 ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).