All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Jordan Crouse <jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 11/11] drm/msm: Implement preemption for A5XX targets
Date: Wed, 8 Feb 2017 12:30:08 -0800	[thread overview]
Message-ID: <8696f3b7-1fbd-309a-1d68-b2f8ad89a30c@codeaurora.org> (raw)
In-Reply-To: <1486402779-9024-12-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

On 02/06/2017 09:39 AM, Jordan Crouse wrote:
> diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
> new file mode 100644
> index 0000000..348ead7
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
> @@ -0,0 +1,367 @@
>
> +/*
> + * Try to transition the preemption state from old to new. Return
> + * true on success or false if the original state wasn't 'old'
> + */
> +static inline bool try_preempt_state(struct a5xx_gpu *a5xx_gpu,
> +		enum preempt_state old, enum preempt_state new)
> +{
> +	enum preempt_state cur = atomic_cmpxchg(&a5xx_gpu->preempt_state,
> +		old, new);
> +
> +	return (cur == old);
> +}
> +
> +/*
> + * Force the preemption state to the specified state.  This is used in cases
> + * where the current state is known and won't change
> + */
> +static inline void set_preempt_state(struct a5xx_gpu *gpu,
> +		enum preempt_state new)
> +{
> +	/* atomic_set() doesn't automatically do barriers, so one before.. */
> +	smp_wmb();
> +	atomic_set(&gpu->preempt_state, new);
> +	/* ... and one after*/
> +	smp_wmb();

Should these smp_wmb()s be replaced with smp_mb__before_atomic() and
smp_mb__after_atomic()? The latter is stronger (mb() instead of wmb())
but otherwise that's typically what is used with atomics. Also, it would
be nice if the comments described what we're synchronizing with.


> +
> +static void a5xx_preempt_worker(struct work_struct *work)
> +{
> +	struct a5xx_gpu *a5xx_gpu =
> +		container_of(work, struct a5xx_gpu, preempt_work);
> +	struct msm_gpu *gpu = &a5xx_gpu->base.base;
> +	struct drm_device *dev = gpu->dev;
> +	struct msm_drm_private *priv = dev->dev_private;
> +
> +	if (atomic_read(&a5xx_gpu->preempt_state) == PREEMPT_COMPLETE) {
> +		uint32_t status = gpu_read(gpu,
> +			REG_A5XX_CP_CONTEXT_SWITCH_CNTL);

Why does this worker check the status again? The irq may fire but the
hardware is still indicating "pending"? And why do we fork off this code
to a workqueue? Can't we do this stuff in the irq handler or timer
handler and drop this worker?

> +
> +		if (status == 0) {
> +			del_timer(&a5xx_gpu->preempt_timer);
> +			a5xx_gpu->cur_ring = a5xx_gpu->next_ring;
> +			a5xx_gpu->next_ring = NULL;
> +
> +			update_wptr(gpu, a5xx_gpu->cur_ring);
> +
> +			set_preempt_state(a5xx_gpu, PREEMPT_NONE);
> +			return;
> +		}
> +
> +		dev_err(dev->dev, "%s: Preemption failed to complete\n",
> +			gpu->name);
> +	} else if (atomic_read(&a5xx_gpu->preempt_state) == PREEMPT_FAULTED)
> +		dev_err(dev->dev, "%s: preemption timed out\n", gpu->name);
> +	else
> +		return;
> +
> +	/* Trigger recovery */
> +	queue_work(priv->wq, &gpu->recover_work);
> +}
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> index f5118ad..4fcccd4 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> @@ -334,6 +334,11 @@ static inline void adreno_gpu_write64(struct adreno_gpu *gpu,
>  	adreno_gpu_write(gpu, hi, upper_32_bits(data));
>  }
>  
> +static inline uint32_t get_wptr(struct msm_ringbuffer *ring)

const struct msm_ringbuffer?

> +{
> +	return ring->cur - ring->start;
> +}
> +
>  /*
>   * Given a register and a count, return a value to program into
>   * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len
>
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2017-02-08 20:30 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-06 17:39 [PATCH 00/11] drm/msm: A5XX preemption Jordan Crouse
2017-02-06 17:39 ` [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA Jordan Crouse
2017-02-06 19:20   ` Emil Velikov
     [not found]     ` <CACvgo513+d19O2rzZ8NXEFgojUQkm2XPae-AdOXXReLM_a1euw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-06 19:57       ` Rob Clark
     [not found]         ` <CAF6AEGvUoW2695_HjgfGbpbPaSnOB2gfPa=3UMTDGvom+DxcwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-06 20:24           ` Emil Velikov
2017-02-06 21:01             ` Rob Clark
2017-02-06 17:39 ` [PATCH 04/11] drm/msm: Remove idle function hook Jordan Crouse
2017-02-06 17:39 ` [PATCH 05/11] drm/msm: get an iova from the address space instead of an id Jordan Crouse
2017-02-09  5:01   ` Archit Taneja
2017-02-06 17:39 ` [PATCH 06/11] drm/msm: Add a struct to pass configuration to msm_gpu_init() Jordan Crouse
2017-02-06 17:39 ` [PATCH 07/11] drm/msm: Remove memptrs->wptr Jordan Crouse
2017-02-06 17:39 ` [PATCH 08/11] drm/msm: Support multiple ringbuffers Jordan Crouse
2017-02-06 17:39 ` [PATCH 09/11] drm/msm: Shadow current pointer in the ring until command is complete Jordan Crouse
2017-02-06 17:39 ` [PATCH 10/11] drm/msm: Make the value of RB_CNTL (almost) generic Jordan Crouse
2017-02-06 17:39 ` [PATCH 11/11] drm/msm: Implement preemption for A5XX targets Jordan Crouse
     [not found]   ` <1486402779-9024-12-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-02-08 20:30     ` Stephen Boyd [this message]
     [not found]       ` <8696f3b7-1fbd-309a-1d68-b2f8ad89a30c-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-02-08 23:00         ` Jordan Crouse
2017-02-09  0:03           ` Stephen Boyd
2017-02-06 17:59 ` [PATCH 00/11] drm/msm: A5XX preemption Daniel Vetter
2017-02-06 18:23   ` Daniel Stone
2017-02-06 18:29     ` [Intel-gfx] " Rob Clark
2017-02-06 18:29   ` Alex Deucher
     [not found] ` <1486402779-9024-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-02-06 17:39   ` [PATCH 01/11] drm/msm: Make sure to detach the MMU during GPU cleanup Jordan Crouse
2017-02-06 17:39   ` [PATCH 02/11] drm/msm: Improve the zap shader Jordan Crouse
2017-03-07 16:58   ` [v2] [PATCH 00/11] drm/msm: A5XX preemption Jordan Crouse
2017-03-07 16:58     ` [PATCH 01/11] drm/msm: Make sure to detach the MMU during GPU cleanup Jordan Crouse
     [not found]     ` <1488905900-6603-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-07 16:58       ` [PATCH 02/11] drm/msm: Improve the zap shader Jordan Crouse
2017-03-07 16:58       ` [PATCH 03/11] drm/msm: Remove idle function hook Jordan Crouse
2017-03-07 16:58       ` [PATCH 04/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA Jordan Crouse
2017-03-07 16:58       ` [PATCH 05/11] drm/msm: get an iova from the address space instead of an id Jordan Crouse
2017-03-07 16:58       ` [PATCH 06/11] drm/msm: Add a struct to pass configuration to msm_gpu_init() Jordan Crouse
2017-03-07 16:58       ` [PATCH 07/11] drm/msm: Remove memptrs->wptr Jordan Crouse
2017-03-07 16:58       ` [PATCH 08/11] drm/msm: Support multiple ringbuffers Jordan Crouse
2017-03-07 16:58       ` [PATCH 09/11] drm/msm: Shadow current pointer in the ring until command is complete Jordan Crouse
2017-03-07 16:58       ` [PATCH 10/11] drm/msm: Make the value of RB_CNTL (almost) generic Jordan Crouse
2017-03-07 16:58       ` [PATCH 11/11] drm/msm: Implement preemption for A5XX targets Jordan Crouse

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=8696f3b7-1fbd-309a-1d68-b2f8ad89a30c@codeaurora.org \
    --to=sboyd-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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.