dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: cphealy@gmail.com, etnaviv@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux+etnaviv@armlinux.org.uk
Subject: Re: [PATCH V2 12/23] drm/etnaviv: use 'sync points' for performance monitor requests
Date: Tue, 08 Aug 2017 12:49:58 +0200	[thread overview]
Message-ID: <1502189398.2934.68.camel@pengutronix.de> (raw)
In-Reply-To: <20170722095323.9964-13-christian.gmeiner@gmail.com>

Am Samstag, den 22.07.2017, 11:53 +0200 schrieb Christian Gmeiner:
> With 'sync points' we can sample the reqeustes perform signals
> before and/or after the submited command buffer.
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 106 +++++++++++++++++++++++++++-------
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.h |   1 +
>  2 files changed, 86 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 93e3f14c0599..c176781788ac 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1318,12 +1318,48 @@ void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu)
>  	pm_runtime_put_autosuspend(gpu->dev);
>  }
>  
> +static void sync_point_perfmon_sample(struct etnaviv_gpu *gpu,
> +	struct etnaviv_event *event, unsigned int flags)
> +{
> +	const struct etnaviv_cmdbuf *cmdbuf = event->cmdbuf;
> +	unsigned int i;
> +
> +	for (i = 0; i < cmdbuf->nr_pmrs; i++) {
> +		const struct etnaviv_perfmon_request *pmr = cmdbuf->pmrs + i;
> +
> +		if (pmr->flags == flags)
> +			etnaviv_perfmon_process(gpu, pmr);
> +	}
> +}
> +
> +static void sync_point_perfmon_sample_pre(struct etnaviv_gpu *gpu,
> +	struct etnaviv_event *event)
> +{
> +	sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_PRE);
> +}
> +
> +static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
> +	struct etnaviv_event *event)
> +{
> +	const struct etnaviv_cmdbuf *cmdbuf = event->cmdbuf;
> +	unsigned int i;
> +
> +	sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_POST);
> +
> +	for (i = 0; i < cmdbuf->nr_pmrs; i++) {
> +		const struct etnaviv_perfmon_request *pmr = cmdbuf->pmrs + i;
> +
> +		*pmr->bo_vma = pmr->sequence;
> +	}
> +}
> +
> +
>  /* add bo's to gpu's ring, and kick gpu: */
>  int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
>  	struct etnaviv_gem_submit *submit, struct etnaviv_cmdbuf *cmdbuf)
>  {
>  	struct dma_fence *fence;
> -	unsigned int event, i;
> +	unsigned int i, nr_events, event[3];
>  	int ret;
>  
>  	ret = etnaviv_gpu_pm_get_sync(gpu);
> @@ -1339,9 +1375,21 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
>  	 *
>  	 */
>  
> -	ret = event_alloc(gpu, 1, &event);
> -	if (!ret) {
> -		DRM_ERROR("no free event\n");
> +	 /*
> + 	 * if there are performance monitor requests we need to have
> +	 * - a sync point to re-configure gpu and process ETNA_PM_PROCESS_PRE
> +	 *   requests.
> +	 * - a sync point to re-configure gpu, process ETNA_PM_PROCESS_POST requests
> +	 *   and update the sequence number for userspace.
> + 	 */
> +	 if (cmdbuf->nr_pmrs)
> +	 	nr_events = 3;
> +	else
> +		nr_events = 1;

Indentation of comment and code is off here. Also I would prefer if
nr_events is just initialized to 1, so we can spare the else path.

> +
> +	ret = event_alloc(gpu, nr_events, event);
> +	if (ret < 0) {
> +		DRM_ERROR("no free events\n");
>  		goto out_pm_put;
>  	}
>  
> @@ -1349,12 +1397,14 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
>  
>  	fence = etnaviv_gpu_fence_alloc(gpu);
>  	if (!fence) {
> -		event_free(gpu, event);
> +		for (i = 0; i < nr_events; i++)
> +			event_free(gpu, event[i]);
> +
>  		ret = -ENOMEM;
>  		goto out_unlock;
>  	}
>  
> -	gpu->event[event].fence = fence;
> +	gpu->event[event[0]].fence = fence;
>  	submit->fence = dma_fence_get(fence);
>  	gpu->active_fence = submit->fence->seqno;
>  
> @@ -1364,7 +1414,19 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
>  		gpu->lastctx = cmdbuf->ctx;
>  	}
>  
> -	etnaviv_buffer_queue(gpu, event, cmdbuf);
> +	if (cmdbuf->nr_pmrs) {
> +		gpu->event[event[1]].sync_point = &sync_point_perfmon_sample_pre;
> +		gpu->event[event[1]].cmdbuf = cmdbuf;
> +		etnaviv_sync_point_queue(gpu, event[1]);
> +	}
> +
> +	etnaviv_buffer_queue(gpu, event[0], cmdbuf);
> +
> +	if (cmdbuf->nr_pmrs) {
> +		gpu->event[event[2]].sync_point = &sync_point_perfmon_sample_post;
> +		gpu->event[event[2]].cmdbuf = cmdbuf;
> +		etnaviv_sync_point_queue(gpu, event[2]);
> +	}
>  
>  	cmdbuf->fence = fence;
>  	list_add_tail(&cmdbuf->node, &gpu->active_cmd_list);
> @@ -1469,20 +1531,22 @@ static irqreturn_t irq_handler(int irq, void *data)
>  			}
>  
>  			fence = gpu->event[event].fence;
> -			gpu->event[event].fence = NULL;
> -			dma_fence_signal(fence);
> -
> -			/*
> -			 * Events can be processed out of order.  Eg,
> -			 * - allocate and queue event 0
> -			 * - allocate event 1
> -			 * - event 0 completes, we process it
> -			 * - allocate and queue event 0
> -			 * - event 1 and event 0 complete
> -			 * we can end up processing event 0 first, then 1.
> -			 */
> -			if (fence_after(fence->seqno, gpu->completed_fence))
> -				gpu->completed_fence = fence->seqno;
> +			if (fence) {
> +				gpu->event[event].fence = NULL;
> +				dma_fence_signal(fence);
> +
> +				/*
> +				 * Events can be processed out of order.  Eg,
> +				 * - allocate and queue event 0
> +				 * - allocate event 1
> +				 * - event 0 completes, we process it
> +				 * - allocate and queue event 0
> +				 * - event 1 and event 0 complete
> +				 * we can end up processing event 0 first, then 1.
> +				 */
> +				if (fence_after(fence->seqno, gpu->completed_fence))
> +					gpu->completed_fence = fence->seqno;
> +			}
>  
>  			event_free(gpu, event);
>  		}
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> index 7d5f785b0f08..c75a7b5c397c 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> @@ -89,6 +89,7 @@ struct etnaviv_chip_identity {
>  
>  struct etnaviv_event {
>  	struct dma_fence *fence;
> +	struct etnaviv_cmdbuf *cmdbuf;
>  
>  	void (*sync_point)(struct etnaviv_gpu *gpu, struct etnaviv_event *event);
>  };


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-08-08 10:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-22  9:53 [PATCH V2 00/23] drm/etnaviv: support performance counters Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 01/23] drm/etnaviv: use bitmap to keep track of events Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 02/23] drm/etnaviv: make it possible to allocate multiple events Christian Gmeiner
2017-08-08 10:00   ` Lucas Stach
2017-08-22  8:27     ` Christian Gmeiner
2017-08-22  8:39       ` Lucas Stach
2017-08-22  8:55         ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 03/23] drm/etnaviv: add infrastructure to query perf counter Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 04/23] drm/etnaviv: add uapi for perfmon feature Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 05/23] drm/etnaviv: add internal representation of perfmon_request Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 06/23] drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_pmrs Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 07/23] drm/etnaviv: add performance monitor request validation Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 08/23] drm/etnaviv: copy pmrs from userspace Christian Gmeiner
2017-08-08 10:13   ` Lucas Stach
2017-08-22  8:34     ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 09/23] drm/etnaviv: add performance monitor request processing Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 10/23] drm/etnaviv: add 'sync point' support Christian Gmeiner
2017-08-08 10:34   ` Lucas Stach
2017-08-22  9:58     ` Christian Gmeiner
2017-08-22 10:17       ` Lucas Stach
2017-07-22  9:53 ` [PATCH V2 11/23] drm/etnaviv: clear alloced event Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 12/23] drm/etnaviv: use 'sync points' for performance monitor requests Christian Gmeiner
2017-08-08 10:49   ` Lucas Stach [this message]
2017-08-22  8:39     ` Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 13/23] drm/etnaviv: add HI perf domain Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 14/23] drm/etnaviv: add PE " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 15/23] drm/etnaviv: add SH " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 16/23] drm/etnaviv: add PA " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 17/23] drm/etnaviv: add SE " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 18/23] drm/etnaviv: add RA " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 19/23] drm/etnaviv: add TX " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 20/23] drm/etnaviv: add MC " Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 21/23] drm/etnaviv: need to disable clock gating when doing profiling Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 22/23] drm/etnaviv: enable debug registers on demand Christian Gmeiner
2017-07-22  9:53 ` [PATCH V2 23/23] drm/etnaviv: submit supports performance monitor requests Christian Gmeiner

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=1502189398.2934.68.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=christian.gmeiner@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=linux+etnaviv@armlinux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).