[PATCH] drm/nouveau: Skip fence context seqno check if notifies are enabled

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 7 20:40:37 UTC 2016


On Wed, Sep 07, 2016 at 09:21:05PM +0100, Chris Wilson wrote:
> If the fence context has notifies enabled, each of the fences'
> FENCE_FLAG_SIGNALED_BIT will be updated from the interrupt. We can rely
> on this status for reporting the current fence_is_signaled() and so
> avoid an expensive uncached read.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Ben Skeggs <bskeggs at redhat.com>
> Cc: dri-devel at lists.freedesktop.org
> Cc: nouveau at lists.freedesktop.org
> ---
>  drivers/gpu/drm/nouveau/nouveau_fence.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
> index 4bb9ab892ae1..7daed5c33043 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
> @@ -510,6 +510,16 @@ static bool nouveau_fence_is_signaled(struct fence *f)
>  	struct nouveau_channel *chan;
>  	bool ret = false;
>  
> +	/* If the notify is already active, we can rely on
> +	 * FENCE_FLAG_SIGNALED_BIT being accurate and skip checking the
> +	 * current seqno as fctx->read() requires an expensive uncached read.
> +	 */
> +	if (test_bit(FENCE_FLAG_USER_BITS, &fence->base.flags))
> +		return false;
> +
> +	if (READ_ONCE(fctx->notify_ref))
> +		return false;

Missed that nouveau_fence_is_signaled() is called after first enabling
the interrupt - and there the uncached read is required in case the
seqno passed before the interrupts were enabled.

In that case we just want the test_bit and not the fctx->notify_ref
check.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the dri-devel mailing list