public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: cphealy@gmail.com, dri-devel@lists.freedesktop.org,
	linux+etnaviv@armlinux.org.uk
Subject: Re: [PATCH 08/10] drm/etnaviv: make it possible to reconfigure perf counter
Date: Mon, 30 Jan 2017 12:01:18 +0100	[thread overview]
Message-ID: <1485774078.21479.8.camel@pengutronix.de> (raw)
In-Reply-To: <20161209112131.3924-9-christian.gmeiner@gmail.com>

Am Freitag, den 09.12.2016, 12:21 +0100 schrieb Christian Gmeiner:
> Each perf counter 'unit' consits of a multipler configuration register
> and a register to read the selected value. Extend the uapi to handle
> this case gracefully. Before the readback is done the mux (config_reg)
> get reconfigured (vale).
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 7 +++++--
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c        | 3 +++
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.h        | 3 +++
>  include/uapi/drm/etnaviv_drm.h               | 6 +++++-
>  4 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index a69eff7..08f9b3d 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -298,14 +298,17 @@ static int submit_readback(struct etnaviv_gem_submit *submit,
>  			return -EINVAL;
>  		}
>  
> -		if (r->flags) {
> -			DRM_ERROR("readback flags not 0");
> +		if (r->flags > ETNA_READBACK_PERF) {
> +			DRM_ERROR("invalid readback flags");
>  			return -EINVAL;
>  		}
>  
>  		cmdbuf->readbacks[i].bo_vma = etnaviv_gem_vmap(&bo->obj->base);
>  		cmdbuf->readbacks[i].offset = r->readback_offset;
>  		cmdbuf->readbacks[i].reg = r->reg;
> +		cmdbuf->readbacks[i].flags = r->flags;
> +		cmdbuf->readbacks[i].perf_reg = r->perf_reg;
> +		cmdbuf->readbacks[i].perf_value = r->perf_value;

Woha, this absolutely _needs_ validation. We can't allow userspace to
freely mess with the GPU state like this.

Regards,
Lucas

>  	}
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 2aa1a26..b22212c 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1379,6 +1379,9 @@ static void etnaviv_process_readbacks(struct etnaviv_gpu *gpu,
>  		const u32 val = gpu_read(gpu, readback->reg);
>  		u32 *bo = readback->bo_vma;
>  
> +		if (readback->flags & ETNA_READBACK_PERF)
> +			gpu_write(gpu, readback->perf_reg, readback->perf_value);
> +
>  		*(bo + readback->offset) = val;
>  	}
>  }
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> index 21a4314..02f15c0 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> @@ -91,6 +91,9 @@ struct etnaviv_readback {
>  	u32 *bo_vma;
>  	u32 offset;
>  	u32 reg;
> +	u32 flags;
> +	u32 perf_reg;
> +	u32 perf_value;
>  };
>  
>  struct etnaviv_event {
> diff --git a/include/uapi/drm/etnaviv_drm.h b/include/uapi/drm/etnaviv_drm.h
> index 0d30604..f2e24bb 100644
> --- a/include/uapi/drm/etnaviv_drm.h
> +++ b/include/uapi/drm/etnaviv_drm.h
> @@ -150,11 +150,15 @@ struct drm_etnaviv_gem_submit_bo {
>  	__u64 presumed;       /* in/out, presumed buffer address */
>  };
>  
> +#define ETNA_READBACK_ONLY     0x0000
> +#define ETNA_READBACK_PERF     0x0001
>  struct drm_etnaviv_gem_submit_readback {
>  	__u32 readback_offset;/* in, offset from readback_bo */
>  	__u32 readback_idx;   /* in, index of readback_bo buffer */
>  	__u32 reg;            /* in, register to read */
> -	__u32 flags;          /* in, needs to be 0 */
> +	__u32 flags;          /* in, ETNA_READBACK_* */
> +	__u32 perf_reg;       /* in, register to write */
> +	__u32 perf_value;     /* in, value to write */
>  };
>  
>  /* Each cmdstream submit consists of a table of buffers involved, and


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

  parent reply	other threads:[~2017-01-30 11:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09 11:21 [PATCH 00/10] drm/etnaviv: add readout support Christian Gmeiner
2016-12-09 11:21 ` [PATCH 01/10] drm/etnaviv: add uapi for register read feature Christian Gmeiner
2017-01-30 10:50   ` Lucas Stach
2017-01-30 20:18   ` Thierry Reding
2017-01-30 23:45     ` Russell King - ARM Linux
2017-01-31  7:40       ` Daniel Vetter
2016-12-09 11:21 ` [PATCH 02/10] drm/etnaviv: add internal representation of readback Christian Gmeiner
2016-12-09 11:21 ` [PATCH 03/10] drm/etnaviv: rework error handling Christian Gmeiner
2016-12-09 11:21 ` [PATCH 04/10] drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_readbacks Christian Gmeiner
2016-12-09 11:21 ` [PATCH 05/10] drm/etnaviv: copy readbacks from userspace Christian Gmeiner
2016-12-09 11:21 ` [PATCH 06/10] drm/etnaviv: store readback data in struct etnaviv_event Christian Gmeiner
2016-12-09 11:21 ` [PATCH 07/10] drm/etnaviv: process readbacks in interrupt handler Christian Gmeiner
2016-12-09 11:21 ` [PATCH 08/10] drm/etnaviv: make it possible to reconfigure perf counter Christian Gmeiner
2016-12-09 15:48   ` Wladimir J. van der Laan
2016-12-09 17:56     ` Christian Gmeiner
2017-01-30 11:01   ` Lucas Stach [this message]
2017-01-30 23:40     ` Russell King - ARM Linux
2016-12-09 11:21 ` [PATCH 09/10] drm/etnaviv: validate readback register address Christian Gmeiner
2017-01-30 10:58   ` Lucas Stach
2017-01-30 23:38     ` Russell King - ARM Linux
2016-12-09 11:21 ` [PATCH 10/10] drm/etnaviv: add readout param 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=1485774078.21479.8.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=christian.gmeiner@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=dri-devel@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