Skip to contentSkip to conversation

drm: zpos normalization cleanup and omapdrm to use it

PATCH In review Peter Ujfalusi 2 participants 8 messages Mar 21, 2018 – Mar 23, 2018

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

v5 cover drm: zpos normalization cleanup and omapdrm to use it

Hi,

Changes since v4:
- rebased the series on drm-next

NOTE on the tegra patch: since the v4 series the atomic check of tegra got additional call to tegra_display_hub_atomic_check().
Based on the code the order, placement of the hub check is not strict, it can be done as the last step as well.
But if the hub check needs to be called in certain step, then I can drop the tegra patch.

Changes since v3:
- Moved the new normalize_zpos bool to be around another bools
- Extended the commit message for sti that the drm_atomic_helper_check() is going to ask for async_update due to the legacy cursor usage.

Changes since v2:
- Fixed commit messages (s/drm_device/drm_mode_config)
- Added ack from Benjamin Gaignard to drm/sti patch

Changes since v1:
- normalize_zpos flag moved to drm_mode_config
- Added comment to note the side effect of normalization and updated the comment for normalized_zpos in the header file as well.
- Added Acked-by from Daniel to patch 2-6 but not for patch 1 as I'm not sure if the comments I have added matches with what is expected to be.

The first patch is adding a flag to drm_device that drivers can set if they want the zpos to be normalized.

Then convert exynos, tegra, sti and rcar-du to use this flag instead of re-implementing the drm_atomic_helper_check() locally just to add the call to drm_atomic_normalize_zpos().

The last patch is moving omapdrm to use the zpos normalization as well to comply with the UAPI documentation regarding to zpos.

Laurent's note in an earlier thread:
https://marc.info/?l=dri-devel&m=151567355225029&w=2

"The problem is that zpos normalization requires accessing the state of all enabled planes for a CRTC in order to compute (and store) the normalized zpos values. This thus forces all planes to be added to the commit state, even when the commit doesn't touch the zpos property. I assume this caused issues (possibly performance issues) in drivers that then performed hardware setup of all planes as a result."

can be addressed later in the core for all users of drm_atomic_normalize_zpos()

Regards,
Peter
---
Peter Ujfalusi (6):
drm: Add drm_mode_config->normalize_zpos boolean drm/exynos: Let core take care of normalizing the zpos drm/tegra: Let core take care of normalizing the zpos drm/sti: Let core take care of normalizing the zpos
drm: rcar-du: Let core take care of normalizing the zpos drm/omap: Use normalized zpos for plane placement

 drivers/gpu/drm/drm_atomic_helper.c     | 11 +++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 20 --------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  4 +++-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  3 +++
 drivers/gpu/drm/omapdrm/omap_plane.c    |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 11 ++---------
 drivers/gpu/drm/sti/sti_drv.c           | 24 +++---------------------
 drivers/gpu/drm/tegra/drm.c             | 21 ++++-----------------
 include/drm/drm_mode_config.h           |  8 ++++++++
 include/drm/drm_plane.h                 |  4 ++--
 11 files changed, 37 insertions(+), 72 deletions(-)
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

PATCH v5 1/6 drm: Add drm_mode_config->normalize_zpos boolean

Instead of drivers duplicating the drm_atomic_helper_check() code to be able to normalize the zpos they can use the normalize_zpos flag to let the drm core to do it.

---
 drivers/gpu/drm/drm_atomic_helper.c | 11 +++++++++++
 include/drm/drm_mode_config.h       |  8 ++++++++
 include/drm/drm_plane.h             |  4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +11 -0
index 00c78c1c9681..a2d06ca1570c 100644
@@ -875,6 +875,11 @@ EXPORT_SYMBOL(drm_atomic_helper_check_planes);
  * functions depend upon an updated adjusted_mode.clock to e.g. properly compute
  * watermarks.
  *
+ * Note that zpos normalization will add all enable planes to the state which
+ * might not desired for some drivers.
+ * For example enable/disable of a cursor plane which have fixed zpos value
+ * would trigger all other enabled planes to be forced to the state change.
+ *
  * RETURNS:
  * Zero for success or -errno
  */
@@ -887,6 +892,12 @@ int drm_atomic_helper_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
+	if (dev->mode_config.normalize_zpos) {
+		ret = drm_atomic_normalize_zpos(dev, state);
+		if (ret)
+			return ret;
+	}
+
 	ret = drm_atomic_helper_check_planes(dev, state);
 	if (ret)
 		return ret;
include/drm/drm_mode_config.h +8 -0
index 7569f22ffef6..33b3a96d66d0 100644
@@ -795,6 +795,14 @@ struct drm_mode_config {
 	 */
 	bool allow_fb_modifiers;
 
+	/**
+	 * @normalize_zpos:
+	 *
+	 * If true the drm core will call drm_atomic_normalize_zpos() as part of
+	 * atomic mode checking from drm_atomic_helper_check()
+	 */
+	bool normalize_zpos;
+
 	/**
 	 * @modifiers_property: Plane property to list support modifier/format
 	 * combination.
include/drm/drm_plane.h +2 -2
index f7bf4a48b1c3..d6da26d66a4b 100644
@@ -51,8 +51,8 @@ struct drm_modeset_acquire_ctx;
  *	plane with a lower ID.
  * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
  *	where N is the number of active planes for given crtc. Note that
- *	the driver must call drm_atomic_normalize_zpos() to update this before
- *	it can be trusted.
+ *	the driver must set drm_mode_config.normalize_zpos or call
+ *	drm_atomic_normalize_zpos() to update this before it can be trusted.
  * @src: clipped source coordinates of the plane (in 16.16)
  * @dst: clipped destination coordinates of the plane
  * @state: backpointer to global drm_atomic_state
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

PATCH v5 2/6 drm/exynos: Let core take care of normalizing the zpos

In reply to Peter Ujfalusi

Instead of re-implementing the drm_atomic_helper_check() locally with just adding drm_atomic_normalize_zpos() into it, set the drm_mode_config->normalize_zpos.

CC Inki Dae <[email protected]>
CC Joonyoung Shim <[email protected]>
CC Seung-Woo Kim <[email protected]>
CC Kyungmin Park <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 20 --------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  4 +++-
 3 files changed, 3 insertions(+), 22 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +0 -20
index a518e9c6d6cc..39284bb7c2c2 100644
@@ -37,26 +37,6 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-int exynos_atomic_check(struct drm_device *dev,
-			struct drm_atomic_state *state)
-{
-	int ret;
-
-	ret = drm_atomic_helper_check_modeset(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_normalize_zpos(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_helper_check_planes(dev, state);
-	if (ret)
-		return ret;
-
-	return ret;
-}
-
 static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_exynos_file_private *file_priv;
drivers/gpu/drm/exynos/exynos_drm_drv.h +0 -1
index df2262f70d91..075957cb6ba1 100644
@@ -275,7 +275,6 @@ static inline int exynos_dpi_bind(struct drm_device *dev,
 
 int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
 			 bool nonblock);
-int exynos_atomic_check(struct drm_device *dev, struct drm_atomic_state *state);
 
 
 extern struct platform_driver fimd_driver;
drivers/gpu/drm/exynos/exynos_drm_fb.c +3 -1
index 0faaf829f5bf..2379d732da67 100644
@@ -206,7 +206,7 @@ static struct drm_mode_config_helper_funcs exynos_drm_mode_config_helpers = {
 static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = {
 	.fb_create = exynos_user_fb_create,
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
-	.atomic_check = exynos_atomic_check,
+	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
@@ -227,4 +227,6 @@ void exynos_drm_mode_config_init(struct drm_device *dev)
 	dev->mode_config.helper_private = &exynos_drm_mode_config_helpers;
 
 	dev->mode_config.allow_fb_modifiers = true;
+
+	dev->mode_config.normalize_zpos = true;
 }
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by on v5 2/6
#3 lore raw

Re: [PATCH v5 2/6] drm/exynos: Let core take care of normalizing the zpos

2018년 03월 21일 19:20에 Peter Ujfalusi 이(가) 쓴 글:

Quoted 10 lines

Instead of re-implementing the drm_atomic_helper_check() locally with just adding drm_atomic_normalize_zpos() into it, set the drm_mode_config->normalize_zpos.

CC Inki Dae <[email protected]>
CC Joonyoung Shim <[email protected]>
CC Seung-Woo Kim <[email protected]>
CC Kyungmin Park <[email protected]>

Thanks,
Inki Dae

Quoted 64 lines
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 20 --------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  4 +++-
 3 files changed, 3 insertions(+), 22 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +0 -20
index a518e9c6d6cc..39284bb7c2c2 100644
@@ -37,26 +37,6 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-int exynos_atomic_check(struct drm_device *dev,
-			struct drm_atomic_state *state)
-{
-	int ret;
-
-	ret = drm_atomic_helper_check_modeset(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_normalize_zpos(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_helper_check_planes(dev, state);
-	if (ret)
-		return ret;
-
-	return ret;
-}
-
 static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_exynos_file_private *file_priv;
drivers/gpu/drm/exynos/exynos_drm_drv.h +0 -1
index df2262f70d91..075957cb6ba1 100644
@@ -275,7 +275,6 @@ static inline int exynos_dpi_bind(struct drm_device *dev,
 
 int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
 			 bool nonblock);
-int exynos_atomic_check(struct drm_device *dev, struct drm_atomic_state *state);
 
 
 extern struct platform_driver fimd_driver;
drivers/gpu/drm/exynos/exynos_drm_fb.c +1 -1
index 0faaf829f5bf..2379d732da67 100644
@@ -206,7 +206,7 @@ static struct drm_mode_config_helper_funcs exynos_drm_mode_config_helpers = {
 static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = {
 	.fb_create = exynos_user_fb_create,
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
-	.atomic_check = exynos_atomic_check,
+	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
 

drivers/gpu/drm/exynos/exynos_drm_fb.c void exynos_drm_mode_config_init(struct drm_device *dev) · line 232

Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fb.c +2 -0
@@ -227,4 +227,6 @@ void exynos_drm_mode_config_init(struct drm_device *dev)
 	dev->mode_config.helper_private = &exynos_drm_mode_config_helpers;
 
 	dev->mode_config.allow_fb_modifiers = true;
+
+	dev->mode_config.normalize_zpos = true;
 }

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

#4 lore raw

PATCH v5 3/6 drm/tegra: Let core take care of normalizing the zpos

In reply to Peter Ujfalusi

Set the drm_mode_config->normalize_zpos and call the generic drm_atomic_helper_check() instead of duplicating it within tegra_atomic_check().

Call tegra_display_hub_atomic_check() after the drm_atomic_helpre_check() returned without error.

---
Thierry,

since the v4 series the atomic check of tegra got additional call to tegra_display_hub_atomic_check().
Based on the code the order, placement of the hub check is not strict, it can be done as the last step as well.
But if the hub check needs to be called in certain step, then I can drop the tegra patch.

Can you check if this patch is OK or not?

Regards,
Peter

 drivers/gpu/drm/tegra/drm.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/gpu/drm/tegra/drm.c +4 -17
index e20e013151f0..ac1121172dc9 100644
@@ -38,26 +38,11 @@ static int tegra_atomic_check(struct drm_device *drm,
 {
 	int err;
 
-	err = drm_atomic_helper_check_modeset(drm, state);
+	err = drm_atomic_helper_check(drm, state);
 	if (err < 0)
 		return err;
 
-	err = tegra_display_hub_atomic_check(drm, state);
-	if (err < 0)
-		return err;
-
-	err = drm_atomic_normalize_zpos(drm, state);
-	if (err < 0)
-		return err;
-
-	err = drm_atomic_helper_check_planes(drm, state);
-	if (err < 0)
-		return err;
-
-	if (state->legacy_cursor_update)
-		state->async_update = !drm_atomic_helper_async_check(drm, state);
-
-	return 0;
+	return tegra_display_hub_atomic_check(drm, state);
 }
 
 static const struct drm_mode_config_funcs tegra_drm_mode_config_funcs = {
@@ -151,6 +136,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 
 	drm->mode_config.allow_fb_modifiers = true;
 
+	drm->mode_config.normalize_zpos = true;
+
 	drm->mode_config.funcs = &tegra_drm_mode_config_funcs;
 	drm->mode_config.helper_private = &tegra_drm_mode_config_helpers;
 
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

PATCH v5 4/6 drm/sti: Let core take care of normalizing the zpos

In reply to Peter Ujfalusi

Instead of re-implementing the drm_atomic_helper_check() locally with just adding drm_atomic_normalize_zpos() into it, set the drm_mode_config->normalize_zpos.

Note: the drm_atomic_helper_check() now includes

if (state->legacy_cursor_update)

	state->async_update = !drm_atomic_helper_async_check(drm, state);

which was added after the driver moved away from using it (38d868e41c4b9250d5a115c049dc2d48f4909581 drm: Don't force all planes to be added to the state due to zpos)

---
 drivers/gpu/drm/sti/sti_drv.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +3 -21
index 55b6967d27e1..90c46b49c931 100644
@@ -119,30 +119,10 @@ static int sti_drm_dbg_init(struct drm_minor *minor)
 	return ret;
 }
 
-static int sti_atomic_check(struct drm_device *dev,
-			    struct drm_atomic_state *state)
-{
-	int ret;
-
-	ret = drm_atomic_helper_check_modeset(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_normalize_zpos(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_helper_check_planes(dev, state);
-	if (ret)
-		return ret;
-
-	return ret;
-}
-
 static const struct drm_mode_config_funcs sti_mode_config_funcs = {
 	.fb_create = drm_gem_fb_create,
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
-	.atomic_check = sti_atomic_check,
+	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
@@ -160,6 +140,8 @@ static void sti_mode_config_init(struct drm_device *dev)
 	dev->mode_config.max_height = STI_MAX_FB_HEIGHT;
 
 	dev->mode_config.funcs = &sti_mode_config_funcs;
+
+	dev->mode_config.normalize_zpos = true;
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(sti_driver_fops);
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

PATCH v5 5/6 drm: rcar-du: Let core take care of normalizing the zpos

In reply to Peter Ujfalusi

Set the drm_mode_config->normalize_zpos and call drm_atomic_helper_check() from rcar_du_atomic_check() instead of re implementing the function locally.

---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2 -9
index 0329b354bfa0..ab59d2061e06 100644
@@ -233,15 +233,7 @@ static int rcar_du_atomic_check(struct drm_device *dev,
 	struct rcar_du_device *rcdu = dev->dev_private;
 	int ret;
 
-	ret = drm_atomic_helper_check_modeset(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_normalize_zpos(dev, state);
-	if (ret)
-		return ret;
-
-	ret = drm_atomic_helper_check_planes(dev, state);
+	ret = drm_atomic_helper_check(dev, state);
 	if (ret)
 		return ret;
 
@@ -529,6 +521,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 	dev->mode_config.min_height = 0;
 	dev->mode_config.max_width = 4095;
 	dev->mode_config.max_height = 2047;
+	dev->mode_config.normalize_zpos = true;
 	dev->mode_config.funcs = &rcar_du_mode_config_funcs;
 	dev->mode_config.helper_private = &rcar_du_mode_config_helper;
 
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

PATCH v5 6/6 drm/omap: Use normalized zpos for plane placement

In reply to Peter Ujfalusi

Planes with identical zpos value will result undefined behavior:
disappearing planes, screen flickering and it is not supported by the hardware.

Use normalized zpos to make sure that we don't encounter invalid configuration.

---
 drivers/gpu/drm/omapdrm/omap_drv.c   | 3 +++
 drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_drv.c +3 -0
index 3632854c2b91..ef3b0e3571ec 100644
@@ -319,6 +319,9 @@ static int omap_modeset_init(struct drm_device *dev)
 	dev->mode_config.max_width = 8192;
 	dev->mode_config.max_height = 8192;
 
+	/* We want the zpos to be normalized */
+	dev->mode_config.normalize_zpos = true;
+
 	dev->mode_config.funcs = &omap_mode_config_funcs;
 	dev->mode_config.helper_private = &omap_mode_config_helper_funcs;
 
drivers/gpu/drm/omapdrm/omap_plane.c +1 -1
index 2899435cad6e..161233cbc9a0 100644
@@ -65,7 +65,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
 	info.rotation_type = OMAP_DSS_ROT_NONE;
 	info.rotation = DRM_MODE_ROTATE_0;
 	info.global_alpha = 0xff;
-	info.zorder = state->zpos;
+	info.zorder = state->normalized_zpos;
 
 	/* update scanout: */
 	omap_framebuffer_update_scanout(state->fb, state, &info);
Signature · 9 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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