drm: zpos normalization cleanup and omapdrm to use it
Subsystems (9)
v2 cover drm: zpos normalization cleanup and omapdrm to use it
Hi,
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 | 27 +++------------------------ include/drm/drm_mode_config.h | 8 ++++++++ include/drm/drm_plane.h | 4 ++-- 11 files changed, 36 insertions(+), 79 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
PATCH v2 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
@@ -873,6 +873,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 */
@@ -885,6 +890,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
@@ -792,6 +792,14 @@ struct drm_mode_config {/* cursor size */ uint32_t cursor_width, cursor_height; +/** +* @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; +/** * @suspend_state: *
include/drm/drm_plane.h +2 -2
@@ -50,8 +50,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
PATCH v2 2/6 drm/exynos: Let core take care of normalizing the zpos
In reply to Peter UjfalusiInstead 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/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
@@ -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;
drivers/gpu/drm/exynos/exynos_drm_drv.h +0 -1
@@ -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 +3 -1
@@ -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
PATCH v2 3/6 drm/tegra: Let core take care of normalizing the zpos
In reply to Peter UjfalusiInstead 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
@@ -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,
@@ -179,6 +156,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
PATCH v2 4/6 drm/sti: Let core take care of normalizing the zpos
In reply to Peter UjfalusiInstead 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/sti/sti_drv.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +3 -21
@@ -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
Re: [PATCH v2 4/6] drm/sti: Let core take care of normalizing the zpos
2018-01-12 14:21 GMT+01:00 Peter Ujfalusi <[email protected]>:
Quoted 4 lines
Instead of re-implementing the
drm_atomic_helper_check()locally with just addingdrm_atomic_normalize_zpos()into it, set thedrm_device->normalize_zpos.
Quoted 56 lines
Signed-off-by Peter Ujfalusi <[email protected]>CC Benjamin Gaignard <[email protected]>CC Vincent Abriou <[email protected]>Acked-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/sti/sti_drv.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)drivers/gpu/drm/sti/sti_drv.c +3
-22@@ -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); --Peter
Quoted 2 lines
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
Re: [PATCH v2 4/6] drm/sti: Let core take care of normalizing the zpos
Hi,
Quoted 7 lines · Benjamin Gaignard
2018-01-12 14:21 GMT+01:00 Peter Ujfalusi <[email protected]>:
Quoted 4 lines
Instead of re-implementing the
drm_atomic_helper_check()locally with just addingdrm_atomic_normalize_zpos()into it, set thedrm_device->normalize_zpos.
Thanks Benjamin!
I just noticed that I forgot to update the commit message with s/drm_device/drm_mode_config
I will resend with updated commit message on Monday.
Quoted 53 lines
Quoted 53 lines
Signed-off-by Peter Ujfalusi <[email protected]>CC Benjamin Gaignard <[email protected]>CC Vincent Abriou <[email protected]>Acked-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/sti/sti_drv.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)drivers/gpu/drm/sti/sti_drv.c +3
-21@@ -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; }
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/sti/sti_drv.c +0
-1DEFINE_DRM_GEM_CMA_FOPS (sti_driver_fops); --Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
- Péter
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
PATCH v2 5/6 drm: rcar-du: Let core take care of normalizing the zpos
In reply to Peter UjfalusiSet the drm_device->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
@@ -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;
@@ -531,6 +523,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
PATCH v2 6/6 drm/omap: Use normalized zpos for plane placement
In reply to Peter UjfalusiPlanes 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
@@ -422,6 +422,9 @@ static int omap_modeset_init(struct drm_device *dev) dev->mode_config.max_width =2048 ; dev->mode_config.max_height =2048 ; +/* 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
@@ -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