diff mbox

[v3,3/3] etnaviv: support performance monitor requests

Message ID 20171215074340.4501-4-christian.gmeiner@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Gmeiner Dec. 15, 2017, 7:43 a.m. UTC
Add etna_cmd_stream_perf(..) to submit perform requests.
Userspace can submit pmrs via submit ioctl to sample perfmon
signals.

v3:
 - mark perfmon bos as RW

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 etnaviv/etnaviv-symbol-check |  1 +
 etnaviv/etnaviv_cmd_stream.c | 20 ++++++++++++++++++++
 etnaviv/etnaviv_drmif.h      | 12 ++++++++++++
 etnaviv/etnaviv_priv.h       |  4 ++++
 4 files changed, 37 insertions(+)

Comments

Lucas Stach Dec. 15, 2017, 9:33 a.m. UTC | #1
Am Freitag, den 15.12.2017, 08:43 +0100 schrieb Christian Gmeiner:
> Add etna_cmd_stream_perf(..) to submit perform requests.
> Userspace can submit pmrs via submit ioctl to sample perfmon
> signals.
> 
> v3:
>  - mark perfmon bos as RW
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---

[...]

>  #endif /* ETNAVIV_DRMIF_H_ */
> diff --git a/etnaviv/etnaviv_priv.h b/etnaviv/etnaviv_priv.h
> index 7b289b61..e45d364c 100644
> --- a/etnaviv/etnaviv_priv.h
> +++ b/etnaviv/etnaviv_priv.h
> @@ -140,6 +140,10 @@ struct etna_cmd_stream_priv {
>  		/* reloc's table: */
>  		struct drm_etnaviv_gem_submit_reloc *relocs;
>  		uint32_t nr_relocs, max_relocs;
> +
> +		/* perf's table: */
> +		struct drm_etnaviv_gem_submit_pmr *pmrs;
> +		uint32_t nr_pmrs, max_pmrs;

On v2 I commented that I don't see max_pmrs used anywhere. If it's
unused please remove before pushing the patch.

Since this is a nitpick, you have my

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

Regards,
Lucas
Lucas Stach Dec. 15, 2017, 10:25 a.m. UTC | #2
Am Freitag, den 15.12.2017, 10:33 +0100 schrieb Lucas Stach:
> Am Freitag, den 15.12.2017, 08:43 +0100 schrieb Christian Gmeiner:
> > Add etna_cmd_stream_perf(..) to submit perform requests.
> > Userspace can submit pmrs via submit ioctl to sample perfmon
> > signals.
> > 
> > v3:
> >  - mark perfmon bos as RW
> > 
> > Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> > ---
> 
> [...]
> 
> >  #endif /* ETNAVIV_DRMIF_H_ */
> > diff --git a/etnaviv/etnaviv_priv.h b/etnaviv/etnaviv_priv.h
> > index 7b289b61..e45d364c 100644
> > --- a/etnaviv/etnaviv_priv.h
> > +++ b/etnaviv/etnaviv_priv.h
> > @@ -140,6 +140,10 @@ struct etna_cmd_stream_priv {
> >  		/* reloc's table: */
> >  		struct drm_etnaviv_gem_submit_reloc *relocs;
> >  		uint32_t nr_relocs, max_relocs;
> > +
> > +		/* perf's table: */
> > +		struct drm_etnaviv_gem_submit_pmr *pmrs;
> > +		uint32_t nr_pmrs, max_pmrs;
> 
> On v2 I commented that I don't see max_pmrs used anywhere. If it's
> unused please remove before pushing the patch.

... And I just saw your reply to my v2 review explaining this stuff. So
please disregard this comment.

> Since this is a nitpick, you have my
> 
> Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
> 
> Regards,
> Lucas
diff mbox

Patch

diff --git a/etnaviv/etnaviv-symbol-check b/etnaviv/etnaviv-symbol-check
index bd95b459..bc509615 100755
--- a/etnaviv/etnaviv-symbol-check
+++ b/etnaviv/etnaviv-symbol-check
@@ -41,6 +41,7 @@  etna_cmd_stream_timestamp
 etna_cmd_stream_flush
 etna_cmd_stream_flush2
 etna_cmd_stream_finish
+etna_cmd_stream_perf
 etna_cmd_stream_reloc
 etna_perfmon_create
 etna_perfmon_del
diff --git a/etnaviv/etnaviv_cmd_stream.c b/etnaviv/etnaviv_cmd_stream.c
index 8d0e8135..e8c58cd5 100644
--- a/etnaviv/etnaviv_cmd_stream.c
+++ b/etnaviv/etnaviv_cmd_stream.c
@@ -105,6 +105,7 @@  void etna_cmd_stream_del(struct etna_cmd_stream *stream)
 
 	free(stream->buffer);
 	free(priv->submit.relocs);
+	free(priv->submit.pmrs);
 	free(priv);
 }
 
@@ -115,6 +116,7 @@  static void reset_buffer(struct etna_cmd_stream *stream)
 	stream->offset = 0;
 	priv->submit.nr_bos = 0;
 	priv->submit.nr_relocs = 0;
+	priv->submit.nr_pmrs = 0;
 	priv->nr_bos = 0;
 
 	if (priv->reset_notify)
@@ -191,6 +193,8 @@  static void flush(struct etna_cmd_stream *stream, int in_fence_fd,
 		.nr_bos = priv->submit.nr_bos,
 		.relocs = VOID2U64(priv->submit.relocs),
 		.nr_relocs = priv->submit.nr_relocs,
+		.pmrs = VOID2U64(priv->submit.pmrs),
+		.nr_pmrs = priv->submit.nr_pmrs,
 		.stream = VOID2U64(stream->buffer),
 		.stream_size = stream->offset * 4, /* in bytes */
 	};
@@ -260,3 +264,19 @@  void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, const struct etna_rel
 
 	etna_cmd_stream_emit(stream, addr);
 }
+
+void etna_cmd_stream_perf(struct etna_cmd_stream *stream, const struct etna_perf *p)
+{
+	struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream);
+	struct drm_etnaviv_gem_submit_pmr *pmr;
+	uint32_t idx = APPEND(&priv->submit, pmrs);
+
+	pmr = &priv->submit.pmrs[idx];
+
+	pmr->flags = p->flags;
+	pmr->sequence = p->sequence;
+	pmr->read_offset = p->offset;
+	pmr->read_idx = bo2idx(stream, p->bo, ETNA_SUBMIT_BO_READ | ETNA_SUBMIT_BO_WRITE);
+	pmr->domain = p->signal->domain->id;
+	pmr->signal = p->signal->signal;
+}
diff --git a/etnaviv/etnaviv_drmif.h b/etnaviv/etnaviv_drmif.h
index 949b9b62..5a6bef8d 100644
--- a/etnaviv/etnaviv_drmif.h
+++ b/etnaviv/etnaviv_drmif.h
@@ -201,4 +201,16 @@  void etna_perfmon_del(struct etna_perfmon *perfmon);
 struct etna_perfmon_domain *etna_perfmon_get_dom_by_name(struct etna_perfmon *pm, const char *name);
 struct etna_perfmon_signal *etna_perfmon_get_sig_by_name(struct etna_perfmon_domain *dom, const char *name);
 
+struct etna_perf {
+#define ETNA_PM_PROCESS_PRE             0x0001
+#define ETNA_PM_PROCESS_POST            0x0002
+	uint32_t flags;
+	uint32_t sequence;
+	struct etna_perfmon_signal *signal;
+	struct etna_bo *bo;
+	uint32_t offset;
+};
+
+void etna_cmd_stream_perf(struct etna_cmd_stream *stream, const struct etna_perf *p);
+
 #endif /* ETNAVIV_DRMIF_H_ */
diff --git a/etnaviv/etnaviv_priv.h b/etnaviv/etnaviv_priv.h
index 7b289b61..e45d364c 100644
--- a/etnaviv/etnaviv_priv.h
+++ b/etnaviv/etnaviv_priv.h
@@ -140,6 +140,10 @@  struct etna_cmd_stream_priv {
 		/* reloc's table: */
 		struct drm_etnaviv_gem_submit_reloc *relocs;
 		uint32_t nr_relocs, max_relocs;
+
+		/* perf's table: */
+		struct drm_etnaviv_gem_submit_pmr *pmrs;
+		uint32_t nr_pmrs, max_pmrs;
 	} submit;
 
 	/* should have matching entries in submit.bos: */