public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 18/21] drm/i915: Make unpin async.
Date: Wed, 25 May 2016 09:03:08 +0200	[thread overview]
Message-ID: <00d68f83-0666-2a69-7431-097861453094@linux.intel.com> (raw)
In-Reply-To: <20160524140050.GX27098@phenom.ffwll.local>

Op 24-05-16 om 16:00 schreef Daniel Vetter:
> On Tue, May 17, 2016 at 03:08:01PM +0200, Maarten Lankhorst wrote:
>> All of intel_post_plane_update is handled there now, so move it over.
>> This is run after the hw state checker because it can't handle checking
>> crtc's separately yet.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> First this patch is massive, and imo too big and should have been split
> up.
>
>> ---
>>  drivers/gpu/drm/i915/intel_atomic.c  |  11 ++
>>  drivers/gpu/drm/i915/intel_display.c | 344 ++++++++++++++++++++++-------------
>>  drivers/gpu/drm/i915/intel_drv.h     |   5 +-
>>  3 files changed, 228 insertions(+), 132 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
>> index 50ff90aea721..b4927f6bbeac 100644
>> --- a/drivers/gpu/drm/i915/intel_atomic.c
>> +++ b/drivers/gpu/drm/i915/intel_atomic.c
>> @@ -311,6 +311,17 @@ intel_atomic_state_alloc(struct drm_device *dev)
>>  void intel_atomic_state_clear(struct drm_atomic_state *s)
>>  {
>>  	struct intel_atomic_state *state = to_intel_atomic_state(s);
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(state->work); i++) {
>> +		struct intel_flip_work *work = state->work[i];
>> +
>> +		if (work)
>> +			intel_free_flip_work(work);
>> +
>> +		state->work[i] = NULL;
>> +	}
>> +
>>  	drm_atomic_state_default_clear(&state->base);
>>  	state->dpll_set = state->modeset = false;
>>  }
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 69abc808a2c4..16d8e299994d 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -4537,39 +4537,6 @@ intel_pre_disable_primary_noatomic(struct drm_crtc *crtc)
>>  	}
>>  }
>>  
>> -static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state)
>> -{
>> -	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
>> -	struct drm_atomic_state *old_state = old_crtc_state->base.state;
>> -	struct intel_crtc_state *pipe_config =
>> -		to_intel_crtc_state(crtc->base.state);
>> -	struct drm_device *dev = crtc->base.dev;
>> -	struct drm_plane *primary = crtc->base.primary;
>> -	struct drm_plane_state *old_pri_state =
>> -		drm_atomic_get_existing_plane_state(old_state, primary);
>> -
>> -	intel_frontbuffer_flip(dev, pipe_config->fb_bits);
>> -
>> -	crtc->wm.cxsr_allowed = true;
>> -
>> -	if (pipe_config->update_wm_post && pipe_config->base.active)
>> -		intel_update_watermarks(&crtc->base);
>> -
>> -	if (old_pri_state) {
>> -		struct intel_plane_state *primary_state =
>> -			to_intel_plane_state(primary->state);
>> -		struct intel_plane_state *old_primary_state =
>> -			to_intel_plane_state(old_pri_state);
>> -
>> -		intel_fbc_post_update(crtc);
>> -
>> -		if (primary_state->visible &&
>> -		    (needs_modeset(&pipe_config->base) ||
>> -		     !old_primary_state->visible))
>> -			intel_post_enable_primary(&crtc->base);
>> -	}
>> -}
> The above seems to have moved/disappeared entirely, and is definitely not
> unpin related. Really, this must be split up. I guess another reason to
> revert this for now.
>
> Or at least the commit should have a more accurate summary. But since I
> can't even find the new callsite of these functions in this diff here
> something seems fishy, but I didn't look at the entire series.
>
> Anyway, with that rant out of the way see below for what I really wanted
> to comment on.
>
>
> [snip]
>
>> +static void intel_prepare_work(struct drm_crtc *crtc,
>> +			       struct intel_flip_work *work,
>> +			       struct drm_atomic_state *state,
>> +			       struct drm_crtc_state *old_crtc_state)
>>  {
>> -	unsigned last_vblank_count[I915_MAX_PIPES];
>> -	enum pipe pipe;
>> -	int ret;
>> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> +	struct drm_plane_state *old_plane_state;
>> +	struct drm_plane *plane;
>> +	int i, j = 0;
>>  
>> -	if (!crtc_mask)
>> -		return;
>> +	INIT_WORK(&work->unpin_work, intel_unpin_work_fn);
>> +	INIT_WORK(&work->mmio_work, intel_mmio_flip_work_func);
>> +	atomic_inc(&intel_crtc->unpin_work_count);
>>  
>> -	for_each_pipe(dev_priv, pipe) {
>> -		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
>> +	for_each_plane_in_state(state, plane, old_plane_state, i) {
>> +		struct intel_plane_state *old_state = to_intel_plane_state(old_plane_state);
>> +		struct intel_plane_state *new_state = to_intel_plane_state(plane->state);
>>  
>> -		if (!((1 << pipe) & crtc_mask))
>> +		if (old_state->base.crtc != crtc &&
>> +		    new_state->base.crtc != crtc)
>>  			continue;
>>  
>> -		ret = drm_crtc_vblank_get(crtc);
>> -		if (WARN_ON(ret != 0)) {
>> -			crtc_mask &= ~(1 << pipe);
>> -			continue;
>> +		if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
>> +			plane->fb = new_state->base.fb;
>> +			crtc->x = new_state->base.src_x >> 16;
>> +			crtc->y = new_state->base.src_y >> 16;
>>  		}
>>  
>> -		last_vblank_count[pipe] = drm_crtc_vblank_count(crtc);
>> +		old_state->wait_req = new_state->wait_req;
>> +		new_state->wait_req = NULL;
>> +
>> +		old_state->base.fence = new_state->base.fence;
>> +		new_state->base.fence = NULL;
>> +
>> +		/* remove plane state from the atomic state and move it to work */
>> +		old_plane_state->state = NULL;
>> +		state->planes[i] = NULL;
>> +		state->plane_states[i] = NULL;
>> +
>> +		work->old_plane_state[j] = old_state;
>> +		work->new_plane_state[j++] = new_state;
>>  	}
>>  
>> -	for_each_pipe(dev_priv, pipe) {
>> -		struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
>> -		long lret;
>> +	old_crtc_state->state = NULL;
>> +	state->crtcs[drm_crtc_index(crtc)] = NULL;
>> +	state->crtc_states[drm_crtc_index(crtc)] = NULL;
>>  
>> -		if (!((1 << pipe) & crtc_mask))
>> -			continue;
>> +	work->old_crtc_state = to_intel_crtc_state(old_crtc_state);
>> +	work->new_crtc_state = to_intel_crtc_state(crtc->state);
>> +	work->num_planes = j;
>>  
>> -		lret = wait_event_timeout(dev->vblank[pipe].queue,
>> -				last_vblank_count[pipe] !=
>> -					drm_crtc_vblank_count(crtc),
>> -				msecs_to_jiffies(50));
>> +	work->event = crtc->state->event;
>> +	crtc->state->event = NULL;
>>  
>> -		WARN(!lret, "pipe %c vblank wait timed out\n", pipe_name(pipe));
>> +	if (needs_modeset(crtc->state) || work->new_crtc_state->update_pipe) {
>> +		struct drm_connector *conn;
>> +		struct drm_connector_state *old_conn_state;
>> +		int k = 0;
>>  
>> -		drm_crtc_vblank_put(crtc);
>> -	}
>> +		j = 0;
>> +
>> +		/*
>> +		 * intel_unpin_work_fn cannot depend on the connector list
>> +		 * because it may be freed from underneath it, so add
>> +		 * them all to the work struct while we're holding locks.
>> +		 */
> Thanks to connector refcounting no longer true, and as long as you hold
> onto drm_atomic_state the connectors will no longer disappear. Please
> revise/update.
This comment only became true thanks to connector refcounting. unpin_work
cannot take connection_mutex or mode_config->mutex because that would deadlock
if flushed from intel_atomic_commit with those locks held, but needs it for the
hw state verifier.

Before connector refcounting I could perform a flush in intel_dp_destroy_mst_connector
so even though unpin_work wouldn't have the locks, it would never see a modified list.

With connector refcounting I move the connector_states to the work, and free them there.
But it looks like the locking for unreferencing a connector seems to be messed up.

drm_atomic_state_free can be called without locking anything,
so drm_connector_free needs to handle its own locking when removing
the connector from the list. This affects all atomic drivers, and probably means
requiring a work item to free all connectors with the right locks..

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

  reply	other threads:[~2016-05-25  7:03 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 13:07 [PATCH v2 00/21] Rework page flip, remove cs flips, async unpin and unified pageflip Maarten Lankhorst
2016-05-17 13:07 ` [PATCH v2 01/21] drm/core: Add drm_accurate_vblank_count, v5 Maarten Lankhorst
2016-05-18 13:44   ` Mario Kleiner
2016-05-17 13:07 ` [PATCH v2 02/21] drm/i915: Remove stallcheck special handling, v3 Maarten Lankhorst
2016-05-18  9:21   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 03/21] drm/i915: Remove intel_finish_page_flip_plane Maarten Lankhorst
2016-05-18  9:29   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 04/21] drm/i915: Remove intel_prepare_page_flip, v3 Maarten Lankhorst
2016-05-18 11:06   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 05/21] drm/i915: Add support for detecting vblanks when hw frame counter is unavailable Maarten Lankhorst
2016-05-18 11:09   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 06/21] drm/i915: Unify unpin_work and mmio_work into flip_work, v2 Maarten Lankhorst
2016-05-18 11:50   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 07/21] Revert "drm/i915: Avoid stalling on pending flips for legacy cursor updates" Maarten Lankhorst
2016-05-18 11:51   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 08/21] drm/i915: Allow mmio updates on all platforms, v2 Maarten Lankhorst
2016-05-18 11:58   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 09/21] drm/i915: Convert flip_work to a list Maarten Lankhorst
2016-05-18 13:56   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 10/21] drm/i915: Add the exclusive fence to plane_state Maarten Lankhorst
2016-05-18 14:30   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 11/21] drm/i915: Rework intel_crtc_page_flip to be almost atomic, v3 Maarten Lankhorst
2016-05-19 11:24   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 12/21] drm/i915: Remove cs based page flip support Maarten Lankhorst
2016-05-18 20:31   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 13/21] drm/i915: Remove use_mmio_flip kernel parameter Maarten Lankhorst
2016-05-18 20:32   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 14/21] drm/i915: Remove queue_flip pointer Maarten Lankhorst
2016-05-18 20:34   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 15/21] drm/i915: Remove reset_counter from intel_crtc Maarten Lankhorst
2016-05-18 23:20   ` Patrik Jakobsson
2016-05-17 13:07 ` [PATCH v2 16/21] drm/i915: Pass atomic states to fbc update functions Maarten Lankhorst
2016-05-18 23:29   ` Patrik Jakobsson
2016-05-17 13:08 ` [PATCH v2 17/21] drm/i915: Prepare connectors for nonblocking checks Maarten Lankhorst
2016-05-19 11:26   ` Patrik Jakobsson
2016-05-17 13:08 ` [PATCH v2 18/21] drm/i915: Make unpin async Maarten Lankhorst
2016-05-19 11:55   ` Patrik Jakobsson
2016-05-24 14:00   ` Daniel Vetter
2016-05-25  7:03     ` Maarten Lankhorst [this message]
2016-05-17 13:08 ` [PATCH v2 19/21] Reapply "drm/i915: Avoid stalling on pending flips for legacy cursor updates" Maarten Lankhorst
2016-05-18 23:45   ` Patrik Jakobsson
2016-05-17 13:08 ` [PATCH v2 20/21] drm/i915: Check for unpin correctness Maarten Lankhorst
2016-05-19  8:21   ` Patrik Jakobsson
2016-05-17 13:08 ` [PATCH v2 21/21] drm/i915: Allow async update of pageflips Maarten Lankhorst
2016-05-19 12:10   ` Patrik Jakobsson
2016-05-19 15:36     ` Daniel Vetter
2016-05-17 13:49 ` ✗ Ro.CI.BAT: failure for Rework page flip, remove cs flips, async unpin and unified pageflip. (rev5) Patchwork
2016-05-19 12:16 ` [PATCH v2 00/21] Rework page flip, remove cs flips, async unpin and unified pageflip Patrik Jakobsson

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=00d68f83-0666-2a69-7431-097861453094@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /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