public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/7] drm/atomic: Add new iterators over all state, v3.
Date: Thu, 19 Jan 2017 00:56:29 +0200	[thread overview]
Message-ID: <47899038.tYoqOOta5G@avalon> (raw)
In-Reply-To: <043826dc-0598-7ac9-ea8b-9b3cce03ebfd@linux.intel.com>

Hi Maarten,

On Tuesday 17 Jan 2017 08:41:03 Maarten Lankhorst wrote:
> Op 17-01-17 om 00:11 schreef Laurent Pinchart:
> > On Monday 16 Jan 2017 10:37:38 Maarten Lankhorst wrote:
> >> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
> >> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
> >> depth and getting rid of all xxx->state dereferences.
> >> 
> >> This requires extra fixups done when committing a state after
> >> duplicating, which in general isn't valid but is used by suspend/resume.
> >> To handle these, introduce drm_atomic_helper_commit_duplicated_state
> >> which performs those fixups before checking & committing the state.
> >> 
> >> Changes since v1:
> >> - Remove nonblock parameter for commit_duplicated_state.
> >> Changes since v2:
> >> - Use commit_duplicated_state for i915 load detection.
> >> - Add WARN_ON(old_state != obj->state) before swapping.
> >> 
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> ---
> >> 
> >>  drivers/gpu/drm/drm_atomic.c         |  6 +++
> >>  drivers/gpu/drm/drm_atomic_helper.c  | 65 +++++++++++++++++++++++++----
> >>  drivers/gpu/drm/i915/intel_display.c | 13 +++---
> >>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++--
> >>  include/drm/drm_atomic_helper.h      |  2 +
> >>  5 files changed, 149 insertions(+), 18 deletions(-)

[snip]

> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c
> >> b/drivers/gpu/drm/drm_atomic_helper.c index b26e3419027e..d153e8a72921
> >> 100644
> >> --- a/drivers/gpu/drm/drm_atomic_helper.c
> >> +++ b/drivers/gpu/drm/drm_atomic_helper.c

[snip]

> >> @@ -2512,6 +2518,47 @@ struct drm_atomic_state
> >> *drm_atomic_helper_suspend(struct drm_device *dev)
> >> EXPORT_SYMBOL(drm_atomic_helper_suspend);
> >> 
> >>  /**
> >> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
> >> + * @state: duplicated atomic state to commit
> >> + * @ctx: pointer to acquire_ctx to use for commit.
> >> + *
> >> + * The state returned by drm_atomic_helper_duplicate_state() and
> >> + * drm_atomic_helper_suspend() is partially invalid, and needs to
> >> + * be fixed up before commit.
> > 
> > Can't you fix the state in drm_atomic_helper_suspend() to avoid the need
> > for this function ?
> 
> We would have to fix up other areas that duplicate state too, like i915
> suspend and load detect. This means moving it to a helper.
> 
> It was my original approach, but Daniel preferred this approach.

We have to fix it somewhere, that's for sure. I think it's better to fix it as 
close as possible to state duplication, instead of carrying a state that we 
know is invalid and fix it at the last minute. The drawback of this approach 
is that the window during which the state will be invalid is much larger, 
which could cause bugs later when new code will try to touch that state.

Daniel, is there a specific reason why you prefer this approach ?

> > Apart from this the patch looks good to me. I don't like the fact that we
> > now have two sets of states though (state and old_state/new_state). I
> > understand that you'd like to address this as part of a separate patch
> > series, which I'm fine with to avoid delaying this one, but I think we
> > should address this sooner rather than latter, or the API will become
> > very confusing. Yes, that means mass-patching drivers I'm afraid. Could
> > you confirm that this is your plan ?
> 
> Yes, working on it.
> 
> >> + * Returns:
> >> + * 0 on success or a negative error code on failure.
> >> + *
> >> + * See also:
> >> + * drm_atomic_helper_suspend()
> >> + */
> >> +int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state
> >> *state,
> >> +					      struct drm_modeset_acquire_ctx
> >> *ctx)
> >> +{
> >> +	int i;
> >> +	struct drm_plane *plane;
> >> +	struct drm_plane_state *plane_state;
> >> +	struct drm_connector *connector;
> >> +	struct drm_connector_state *conn_state;
> >> +	struct drm_crtc *crtc;
> >> +	struct drm_crtc_state *crtc_state;
> >> +
> >> +	state->acquire_ctx = ctx;
> >> +
> >> +	for_each_new_plane_in_state(state, plane, plane_state, i)
> >> +		state->planes[i].old_state = plane->state;
> >> +
> >> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
> >> +		state->crtcs[i].old_state = crtc->state;
> >> +
> >> +	for_each_new_connector_in_state(state, connector, conn_state, i)
> >> +		state->connectors[i].old_state = connector->state;
> >> +
> >> +	return drm_atomic_commit(state);
> >> +}
> >> +EXPORT_SYMBOL(drm_atomic_helper_commit_duplicated_state);

[snip]

-- 
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-01-18 22:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16  9:37 [PATCH v3 0/7] drm/atomic: Add accessor macros for all atomic state Maarten Lankhorst
2017-01-16  9:37 ` [PATCH v3 1/7] drm/atomic: Add new iterators over all state, v3 Maarten Lankhorst
2017-01-16 23:11   ` Laurent Pinchart
2017-01-17  7:41     ` Maarten Lankhorst
2017-01-18 22:56       ` Laurent Pinchart [this message]
2017-01-23  8:48         ` Daniel Vetter
2017-02-12 12:11           ` Laurent Pinchart
2017-02-12 12:13   ` Laurent Pinchart
2017-01-16  9:37 ` [PATCH v3 2/7] drm/atomic: Make add_affected_connectors look at crtc_state Maarten Lankhorst
2017-01-16 23:29   ` Laurent Pinchart
2017-01-16  9:37 ` [PATCH v3 3/7] drm/atomic: Use new atomic iterator macros Maarten Lankhorst
2017-01-16 23:55   ` Laurent Pinchart
2017-02-14 20:03     ` Daniel Vetter
2017-02-14 20:07       ` Laurent Pinchart
2017-01-16  9:37 ` [PATCH v3 4/7] drm/atomic: Fix atomic helpers to use the new " Maarten Lankhorst
2017-01-17  1:01   ` Laurent Pinchart
2017-01-18 14:49     ` Maarten Lankhorst
2017-01-18 18:03       ` Laurent Pinchart
2017-01-16  9:37 ` [PATCH v3 5/7] drm/atomic: Add macros to access existing old/new state Maarten Lankhorst
2017-01-17  1:05   ` Laurent Pinchart
2017-01-16  9:37 ` [PATCH v3 6/7] drm/atomic: Convert get_existing_state callers to get_old/new_state, v2 Maarten Lankhorst
2017-01-17  1:12   ` Laurent Pinchart
2017-02-16 14:37     ` Maarten Lankhorst
2017-01-17  1:27   ` Laurent Pinchart
2017-02-16 14:34     ` Maarten Lankhorst
2017-01-16  9:37 ` [PATCH v3 7/7] drm/blend: Use new atomic iterator macros Maarten Lankhorst
2017-01-17  1:14   ` Laurent Pinchart
2017-01-16 11:24 ` ✗ Fi.CI.BAT: warning for drm/atomic: Add accessor macros for all atomic state. (rev4) Patchwork
2017-01-17  0:45 ` [PATCH v3 0/7] drm/atomic: Add accessor macros for all atomic state Laurent Pinchart
2017-01-23  8:50   ` [Intel-gfx] " Daniel Vetter
2017-01-17  1:34 ` Laurent Pinchart
2017-02-12 12:35 ` 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=47899038.tYoqOOta5G@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox