public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: mika.kuoppala@intel.com
Subject: Re: [PATCH 02/22] drm/i915/gtt: Serialise both updates to PDE and our shadow
Date: Mon, 17 Jun 2019 11:36:36 +0100	[thread overview]
Message-ID: <5fcbdb69-4b40-f433-4977-381bdb4907c3@intel.com> (raw)
In-Reply-To: <20190617071912.20256-2-chris@chris-wilson.co.uk>

On 17/06/2019 08:18, Chris Wilson wrote:
> Currently, we perform a locked update of the shadow entry when
> allocating a page directory entry such that if two clients are
> concurrently allocating neighbouring ranges we only insert one new entry
> for the pair of them. However, we also need to serialise both clients
> wrt to the actual entry in the HW table, or else we may allow one client
> or even a third client to proceed ahead of the HW write. My handwave
> before was that under the _pathological_ condition we would see the
> scratch entry instead of the expected entry, causing a temporary
> glitch. That starvation condition will eventually show up in practice, so
> fix it.
> 
> The reason for the previous cheat was to avoid having to free the extra
> allocation while under the spinlock. Now, we keep the extra entry
> allocated until the end instead.
> 
> Fixes: 1d1b5490b91c ("drm/i915/gtt: Replace struct_mutex serialisation for allocation")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> ---

[snip]

>   
>   static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
> @@ -1819,11 +1831,13 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>   			       u64 start, u64 length)
>   {
>   	struct gen6_ppgtt *ppgtt = to_gen6_ppgtt(i915_vm_to_ppgtt(vm));
> +	struct i915_page_table *alloc = NULL;
>   	struct i915_page_table *pt;
>   	intel_wakeref_t wakeref;
>   	u64 from = start;
>   	unsigned int pde;
>   	bool flush = false;
> +	int ret;

ret = 0;

>   
>   	wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm);
>   
> @@ -1832,19 +1846,18 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>   		const unsigned int count = gen6_pte_count(start, length);
>   
>   		if (pt == vm->scratch_pt) {
> -			struct i915_page_table *old;
> -
>   			spin_unlock(&ppgtt->base.pd.lock);
>   
> -			pt = alloc_pt(vm);
> +			pt = alloc;

We have to reset this, no?

> +			if (!pt)
> +				pt = alloc_pt(vm);
>   			if (IS_ERR(pt))
>   				goto unwind_out;

ret = PTR_ERR();

>   
>   			gen6_initialize_pt(vm, pt);
>   
> -			old = cmpxchg(&ppgtt->base.pd.page_table[pde],
> -				      vm->scratch_pt, pt);
> -			if (old == vm->scratch_pt) {
> +			spin_lock(&ppgtt->base.pd.lock);
> +			if (ppgtt->base.pd.page_table[pde] == vm->scratch_pt) {
>   				ppgtt->base.pd.page_table[pde] = pt;
>   				if (i915_vma_is_bound(ppgtt->vma,
>   						      I915_VMA_GLOBAL_BIND)) {
> @@ -1852,11 +1865,9 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>   					flush = true;
>   				}
>   			} else {
> -				free_pt(vm, pt);
> -				pt = old;
> +				alloc = pt;
> +				pt = ppgtt->base.pd.page_table[pde];
>   			}
> -
> -			spin_lock(&ppgtt->base.pd.lock);
>   		}
>   
>   		atomic_add(count, &pt->used_ptes);
> @@ -1868,14 +1879,15 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
>   		gen6_ggtt_invalidate(vm->i915);
>   	}
>   
> -	intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref);
> -
> -	return 0;
> +	goto out;
>   
>   unwind_out:
> -	intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref);
>   	gen6_ppgtt_clear_range(vm, from, start - from);
> -	return -ENOMEM;
> +out:
> +	if (alloc)
> +		free_pt(vm, alloc);
> +	intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref);
> +	return ret;
>   }
>   
>   static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-06-17 10:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17  7:18 [PATCH 01/22] drm/i915: Restore -Wunused-but-set-variable Chris Wilson
2019-06-17  7:18 ` [PATCH 02/22] drm/i915/gtt: Serialise both updates to PDE and our shadow Chris Wilson
2019-06-17 10:36   ` Matthew Auld [this message]
2019-06-17 10:40     ` Chris Wilson
2019-06-17  7:18 ` [PATCH 03/22] drm/i915: Skip shrinking already freed pages Chris Wilson
2019-06-17  7:18 ` [PATCH 04/22] drm/i915: Stop passing I915_WAIT_LOCKED to i915_request_wait() Chris Wilson
2019-06-17  7:18 ` [PATCH 05/22] drm/i915: Flush the execution-callbacks on retiring Chris Wilson
2019-06-17  7:18 ` [PATCH 06/22] drm/i915/execlists: Preempt-to-busy Chris Wilson
2019-06-17  7:18 ` [PATCH 07/22] drm/i915/execlists: Minimalistic timeslicing Chris Wilson
2019-06-17  7:18 ` [PATCH 08/22] drm/i915/execlists: Force preemption Chris Wilson
2019-06-17  7:18 ` [PATCH 09/22] drm/i915: Make the semaphore saturation mask global Chris Wilson
2019-06-17  7:19 ` [PATCH 10/22] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-06-17  7:19 ` [PATCH 11/22] dma-fence: Report the composite sync_file status Chris Wilson
2019-06-17  7:19 ` [PATCH 12/22] dma-fence: Refactor signaling for manual invocation Chris Wilson
2019-06-17  7:19 ` [PATCH 13/22] dma-fence: Always execute signal callbacks Chris Wilson
2019-06-17  7:19 ` [PATCH 14/22] drm/i915: Throw away the active object retirement complexity Chris Wilson
2019-06-17 13:43   ` Matthew Auld
2019-06-17 13:49     ` Chris Wilson
2019-06-17  7:19 ` [PATCH 15/22] drm/i915: Provide an i915_active.acquire callback Chris Wilson
2019-06-17 18:58   ` Matthew Auld
2019-06-17  7:19 ` [PATCH 16/22] drm/i915: Push the i915_active.retire into a worker Chris Wilson
2019-06-17 19:25   ` Matthew Auld
2019-06-17  7:19 ` [PATCH 17/22] drm/i915/overlay: Switch to using i915_active tracking Chris Wilson
2019-06-17  7:19 ` [PATCH 18/22] drm/i915: Forgo last_fence active request tracking Chris Wilson
2019-06-17 19:34   ` Matthew Auld
2019-06-17  7:19 ` [PATCH 19/22] drm/i915: Extract intel_frontbuffer active tracking Chris Wilson
2019-06-17  7:19 ` [PATCH 20/22] drm/i915: Coordinate i915_active with its own mutex Chris Wilson
2019-06-17  7:19 ` [PATCH 21/22] drm/i915: Replace struct_mutex for batch pool serialisation Chris Wilson
2019-06-17  7:19 ` [PATCH 22/22] drm/i915: Move idle barrier cleanup into engine-pm Chris Wilson
2019-06-17  7:56 ` [PATCH 01/22] drm/i915: Restore -Wunused-but-set-variable Chris Wilson
2019-06-17  8:02 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/22] " Patchwork
2019-06-17  8:13 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-17 13:05 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-06-17 13:18   ` Chris Wilson
2019-06-18  7:54 ` [PATCH 01/22] " Jani Nikula

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=5fcbdb69-4b40-f433-4977-381bdb4907c3@intel.com \
    --to=matthew.auld@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kuoppala@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