Skip to contentSkip to conversation

drm: zpos normalization cleanup and omapdrm to use it

PATCH In review Peter Ujfalusi 2 participants 8 messages Jan 12, 2018 – Jan 13, 2018

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

cover drm: zpos normalization cleanup and omapdrm to use it

Hi,

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_device->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     |  6 ++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 21 +--------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  1 +
 drivers/gpu/drm/omapdrm/omap_plane.c    |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   |  1 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 10 +---------
 drivers/gpu/drm/sti/sti_drv.c           | 23 ++---------------------
 drivers/gpu/drm/tegra/drm.c             | 27 +++------------------------
 include/drm/drm_device.h                |  8 ++++++++
 11 files changed, 25 insertions(+), 77 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
Acked-by on the v1 series
#1 lore raw
Quoted 4 lines · Peter Ujfalusi

Hi,

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

If we go with the flag it should imo be put into struct drm_mode_config.

Quoted 10 lines

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

Quoted 6 lines

"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."

I've dug some more and per Ville the issue seems to have been cursor updates starting to block. Gustavo Padovan has created patches to handle async cursor plane updates like the cursor much better, in a side-path, which would resolve this. Once that has landed we wouldn't need to make the zpos normalization optional anymore. See Ville's original removal of all this.

Can you pls add a comment to the atomic_check function to that effect.

With those two things addressed the series is:

Quoted 33 lines

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

Regards,
Peter
---
Peter Ujfalusi (6):
drm: Add drm_device->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     |  6 ++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 21 +--------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c      |  1 +
 drivers/gpu/drm/omapdrm/omap_plane.c    |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   |  1 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 10 +---------
 drivers/gpu/drm/sti/sti_drv.c           | 23 ++---------------------
 drivers/gpu/drm/tegra/drm.c             | 27 +++------------------------
 include/drm/drm_device.h                |  8 ++++++++
 11 files changed, 25 insertions(+), 77 deletions(-)
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
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
#2 lore raw

PATCH 1/6 drm: Add drm_device->normalize_zpos boolean

In reply to Peter Ujfalusi

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 | 6 ++++++
 include/drm/drm_device.h            | 8 ++++++++
 2 files changed, 14 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +6 -0
index ab4032167094..143cab4b2a89 100644
@@ -885,6 +885,12 @@ int drm_atomic_helper_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
+	if (dev->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_device.h +8 -0
index 7c4fa32f3fc6..9c45d1155bfd 100644
@@ -121,6 +121,14 @@ struct drm_device {
 	 */
 	bool vblank_disable_immediate;
 
+	/**
+	 * @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;
+
 	/**
 	 * @vblank:
 	 *
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
#3 lore raw

PATCH 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_device->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 | 21 +--------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.h |  1 -
 drivers/gpu/drm/exynos/exynos_drm_fb.c  |  2 +-
 3 files changed, 2 insertions(+), 22 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -20
index b96bd5a781b2..181ebd42fc9f 100644
@@ -38,26 +38,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;
@@ -339,6 +319,7 @@ static int exynos_drm_bind(struct device *dev)
 
 	dev_set_drvdata(dev, drm);
 	drm->dev_private = (void *)private;
+	drm->normalize_zpos = true;
 
 	/* the first real CRTC device is used for all dma mapping operations */
 	private->dma_dev = exynos_drm_get_dma_device();
drivers/gpu/drm/exynos/exynos_drm_drv.h +0 -1
index 589d465a7f88..4585d9e00c87 100644
@@ -276,7 +276,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..d388231e43e1 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,
 };
 
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
#4 lore raw

PATCH 3/6 drm/tegra: 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_device->normalize_zpos.

---
 drivers/gpu/drm/tegra/drm.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
drivers/gpu/drm/tegra/drm.c +3 -24
index d50bddb2e447..1ef9f4eede07 100644
@@ -33,29 +33,6 @@ struct tegra_drm_file {
 	struct mutex lock;
 };
 
-static int tegra_atomic_check(struct drm_device *drm,
-			      struct drm_atomic_state *state)
-{
-	int err;
-
-	err = drm_atomic_helper_check_modeset(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;
-}
-
 static struct drm_atomic_state *
 tegra_atomic_state_alloc(struct drm_device *drm)
 {
@@ -90,7 +67,7 @@ static const struct drm_mode_config_funcs tegra_drm_mode_config_funcs = {
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 	.output_poll_changed = drm_fb_helper_output_poll_changed,
 #endif
-	.atomic_check = tegra_atomic_check,
+	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 	.atomic_state_alloc = tegra_atomic_state_alloc,
 	.atomic_state_clear = tegra_atomic_state_clear,
@@ -1230,6 +1207,8 @@ static int host1x_drm_probe(struct host1x_device *dev)
 
 	dev_set_drvdata(&dev->dev, drm);
 
+	drm->normalize_zpos = true;
+
 	err = drm_dev_register(drm, 0);
 	if (err < 0)
 		goto unref;
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 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_device->normalize_zpos.

CC Benjamin Gaignard <[email protected]>
CC Vincent Abriou <[email protected]>
---
 drivers/gpu/drm/sti/sti_drv.c | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +2 -21
index 55b6967d27e1..a0ffbb1ea3ba 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,
 };
 
@@ -208,6 +188,7 @@ static int sti_init(struct drm_device *ddev)
 		return -ENOMEM;
 
 	ddev->dev_private = (void *)private;
+	ddev->normalize_zpos = true;
 	dev_set_drvdata(ddev->dev, ddev);
 	private->drm_dev = ddev;
 
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 5/6 drm: rcar-du: Let core take care of normalizing the zpos

In reply to Peter Ujfalusi

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

CC Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  1 +
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 10 +---------
 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -0
index 6e02c762a557..61dc773b9df0 100644
@@ -405,6 +405,7 @@ static int rcar_du_probe(struct platform_device *pdev)
 	}
 
 	ddev->irq_enabled = 1;
+	ddev->normalize_zpos = true;
 
 	/*
 	 * Register the DRM device with the core and the connectors with
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -9
index 566d1a948c8f..fa82adfe0982 100644
@@ -234,15 +234,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;
 
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 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   | 1 +
 drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_drv.c +1 -0
index 2c02b955dd52..25f06f09fbe2 100644
@@ -651,6 +651,7 @@ static int pdev_probe(struct platform_device *pdev)
 		return PTR_ERR(ddev);
 
 	ddev->dev_private = priv;
+	ddev->normalize_zpos = true;
 	platform_set_drvdata(pdev, ddev);
 
 	omap_crtc_pre_init();
drivers/gpu/drm/omapdrm/omap_plane.c +1 -1
index 7d789d1551a1..2c19d2239bc5 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