From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Thierry Reding <treding@nvidia.com>,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Subject: Re: [PATCH] drm/atomic-helper: Add option to update planes only on active crtc
Date: Thu, 23 Jul 2015 05:53:43 +0200 [thread overview]
Message-ID: <55B06547.4000905@linux.intel.com> (raw)
In-Reply-To: <1437580947-18097-1-git-send-email-daniel.vetter@ffwll.ch>
Op 22-07-15 om 18:02 schreef Daniel Vetter:
> With drivers supporting runtime pm it's generally not a good idea to
> touch the hardware when it's off. Add an option to the commit_planes
> helper to support this case.
>
> Note that the helpers already add all planes on a crtc when a modeset
> happens, hence plane updates will not be lost if drivers set this to
> true.
>
> v2: Check for NULL state->crtc before chasing the pointer. Also check
> both old and new crtc if there's a switch. Finally just outright
> disallow switching crtcs for a plane if the plane is in active use, on
> most hardware that doesn't make sense.
>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 29 +++++++++++++++++++++++++++--
> drivers/gpu/drm/exynos/exynos_drm_fb.c | 2 +-
> drivers/gpu/drm/msm/msm_atomic.c | 2 +-
> drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
> drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +-
> drivers/gpu/drm/sti/sti_drm_drv.c | 2 +-
> drivers/gpu/drm/tegra/drm.c | 2 +-
> include/drm/drm_atomic_helper.h | 3 ++-
> 8 files changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 99656815641d..2122c2b844da 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -471,6 +471,14 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
> if (!funcs || !funcs->atomic_check)
> continue;
>
> + if (plane->state->crtc && plane_state->crtc &&
> + plane->state->crtc != plane_state->crtc &&
> + plane->state->crtc->state->active) {
> + DRM_DEBUG_ATOMIC("[PLANE:%d] changing crtc while still active\n",
> + plane->base.id);
> + return -EINVAL;
> + }
> +
> ret = funcs->atomic_check(plane, plane_state);
> if (ret) {
> DRM_DEBUG_ATOMIC("[PLANE:%d] atomic driver check failed\n",
> @@ -995,7 +1003,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>
> drm_atomic_helper_commit_modeset_disables(dev, state);
>
> - drm_atomic_helper_commit_planes(dev, state);
> + drm_atomic_helper_commit_planes(dev, state, false);
>
> drm_atomic_helper_commit_modeset_enables(dev, state);
>
> @@ -1110,10 +1118,16 @@ fail:
> }
> EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
>
> +bool plane_crtc_active(struct drm_plane_state *state)
> +{
> + return state->crtc && state->crtc->state->active;
> +}
> +
> /**
> * drm_atomic_helper_commit_planes - commit plane state
> * @dev: DRM device
> * @old_state: atomic state object with old state structures
> + * @active_only: Only commit on active CRTC if set
> *
> * This function commits the new plane state using the plane and atomic helper
> * functions for planes and crtcs. It assumes that the atomic state has already
> @@ -1128,7 +1142,8 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
> * drm_atomic_helper_commit_planes_on_crtc() instead.
> */
> void drm_atomic_helper_commit_planes(struct drm_device *dev,
> - struct drm_atomic_state *old_state)
> + struct drm_atomic_state *old_state,
> + bool active_only)
> {
> struct drm_crtc *crtc;
> struct drm_crtc_state *old_crtc_state;
> @@ -1144,6 +1159,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
> if (!funcs || !funcs->atomic_begin)
> continue;
>
> + if (active_only && !crtc->state->active)
> + continue;
> +
> funcs->atomic_begin(crtc);
> }
>
> @@ -1155,6 +1173,10 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
> if (!funcs)
> continue;
>
> + if (active_only && !plane_crtc_active(plane->state) &&
> + !plane_crtc_active(old_plane_state))
> + continue;
> +
> /*
> * Special-case disabling the plane if drivers support it.
> */
>
The check is still wrong. It should only check if the new plane_state->crtc is active, if it's not call the disable_plane hook, but only when get_existing_crtc_state(old_plane_state->crtc)->active && !needs_modeset(old_plane_state->crtc->state).
The other helper should be a disable_planes helper that blindly calls disable_plane for planes that are on crtc's and require modeset for the crtc on the previous plane_state.
~Maarten
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-07-23 3:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 14:30 [PATCH 1/2] drm/atomic-helper: Add option to update planes only on active crtc Daniel Vetter
2015-07-22 14:30 ` [PATCH 2/2] drm/rcar: Only update planes " Daniel Vetter
2015-07-22 15:32 ` [PATCH 1/2] drm/atomic-helper: Add option to update planes only " Maarten Lankhorst
2015-07-22 16:02 ` [PATCH] " Daniel Vetter
2015-07-23 3:53 ` Maarten Lankhorst [this message]
2015-07-23 7:00 ` Daniel Vetter
2015-07-27 12:44 ` Thierry Reding
2015-07-27 13:07 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2015-07-29 12:01 [PATCH 1/3] " Daniel Vetter
2015-08-26 14:02 ` [PATCH] " Daniel Vetter
2015-09-08 10:02 ` Daniel Vetter
2015-09-08 11:10 ` Thierry Reding
2015-09-08 11:50 ` Daniel Vetter
2015-09-08 11:27 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55B06547.4000905@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=treding@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.