dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
@ 2023-05-23 20:40 Ashutosh Dixit
  0 siblings, 0 replies; 6+ messages in thread
From: Ashutosh Dixit @ 2023-05-23 20:40 UTC (permalink / raw)
  To: intel-gfx; +Cc: Umesh Nerlige Ramappa, Lionel Landwerlin, dri-devel

Clearing out report id and timestamp as means to detect unlanded reports
only works if report size is power of 2. That is, only when report size is
a sub-multiple of the OA buffer size can we be certain that reports will
land at the same place each time in the OA buffer (after rewind). If report
size is not a power of 2, we need to zero out the entire report to be able
to detect unlanded reports reliably.

v2: Add Fixes tag (Umesh)

Fixes: 1cc064dce4ed ("drm/i915/perf: Add support for OA media units")
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 19d5652300eeb..58284156428dc 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 			stream->oa_buffer.last_ctx_id = ctx_id;
 		}
 
-		/*
-		 * Clear out the report id and timestamp as a means to detect unlanded
-		 * reports.
-		 */
-		oa_report_id_clear(stream, report32);
-		oa_timestamp_clear(stream, report32);
+		if (is_power_of_2(report_size)) {
+			/*
+			 * Clear out the report id and timestamp as a means
+			 * to detect unlanded reports.
+			 */
+			oa_report_id_clear(stream, report32);
+			oa_timestamp_clear(stream, report32);
+		} else {
+			/* Zero out the entire report */
+			memset(report32, 0, report_size);
+		}
 	}
 
 	if (start_offset != *offset) {
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
  2023-05-22 21:50   ` Dixit, Ashutosh
@ 2023-05-23 17:50     ` Umesh Nerlige Ramappa
  0 siblings, 0 replies; 6+ messages in thread
From: Umesh Nerlige Ramappa @ 2023-05-23 17:50 UTC (permalink / raw)
  To: Dixit, Ashutosh; +Cc: intel-gfx, Lionel Landwerlin, dri-devel

On Mon, May 22, 2023 at 02:50:51PM -0700, Dixit, Ashutosh wrote:
>On Mon, 22 May 2023 14:34:18 -0700, Umesh Nerlige Ramappa wrote:
>>
>> On Mon, May 22, 2023 at 01:17:49PM -0700, Ashutosh Dixit wrote:
>> > Clearing out report id and timestamp as means to detect unlanded reports
>> > only works if report size is power of 2. That is, only when report size is
>> > a sub-multiple of the OA buffer size can we be certain that reports will
>> > land at the same place each time in the OA buffer (after rewind). If report
>> > size is not a power of 2, we need to zero out the entire report to be able
>> > to detect unlanded reports reliably.
>> >
>> > Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
>> > ---
>> > drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
>> > 1 file changed, 11 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
>> > index 19d5652300eeb..58284156428dc 100644
>> > --- a/drivers/gpu/drm/i915/i915_perf.c
>> > +++ b/drivers/gpu/drm/i915/i915_perf.c
>> > @@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
>> >			stream->oa_buffer.last_ctx_id = ctx_id;
>> >		}
>> >
>> > -		/*
>> > -		 * Clear out the report id and timestamp as a means to detect unlanded
>> > -		 * reports.
>> > -		 */
>> > -		oa_report_id_clear(stream, report32);
>> > -		oa_timestamp_clear(stream, report32);
>> > +		if (is_power_of_2(report_size)) {
>> > +			/*
>> > +			 * Clear out the report id and timestamp as a means
>> > +			 * to detect unlanded reports.
>> > +			 */
>> > +			oa_report_id_clear(stream, report32);
>> > +			oa_timestamp_clear(stream, report32);
>> > +		} else {
>> > +			/* Zero out the entire report */
>> > +			memset(report32, 0, report_size);
>>
>> Indeed, this was a bug. For a minute, I started wondering if this is the
>> issue I am running into with the other patch posted for DG2, but then I see
>> the issue within the first fill of the OA buffer where chunks of the
>> reports are zeroed out, so this is a new issue.
>
>Yes I saw this while reviewing your patch. And also I thought your issue
>was happening on DG2 with power of 2 report size, only on MTL OAM we
>introduce non power of 2 report size.
>
>> lgtm,
>>
>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Maybe this should include Fixes: tag pointing to the patch that 
introduced the OAM non-power-of-2 format.

Umesh

>
>Thanks.
>--
>Ashutosh
>
>>
>> > +		}
>> >	}
>> >
>> >	if (start_offset != *offset) {
>> > --
>> > 2.38.0
>> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
  2023-05-22 20:17 Ashutosh Dixit
  2023-05-22 21:34 ` Umesh Nerlige Ramappa
@ 2023-05-23 14:31 ` Lionel Landwerlin
  1 sibling, 0 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2023-05-23 14:31 UTC (permalink / raw)
  To: Ashutosh Dixit, intel-gfx; +Cc: Umesh Nerlige Ramappa, dri-devel

On 22/05/2023 23:17, Ashutosh Dixit wrote:
> Clearing out report id and timestamp as means to detect unlanded reports
> only works if report size is power of 2. That is, only when report size is
> a sub-multiple of the OA buffer size can we be certain that reports will
> land at the same place each time in the OA buffer (after rewind). If report
> size is not a power of 2, we need to zero out the entire report to be able
> to detect unlanded reports reliably.
>
> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>

Sad but necessary unfortunately....


Reviewed-by:  Lionel Landwerlin <lionel.g.landwerlin@intel.com>


> ---
>   drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 19d5652300eeb..58284156428dc 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
>   			stream->oa_buffer.last_ctx_id = ctx_id;
>   		}
>   
> -		/*
> -		 * Clear out the report id and timestamp as a means to detect unlanded
> -		 * reports.
> -		 */
> -		oa_report_id_clear(stream, report32);
> -		oa_timestamp_clear(stream, report32);
> +		if (is_power_of_2(report_size)) {
> +			/*
> +			 * Clear out the report id and timestamp as a means
> +			 * to detect unlanded reports.
> +			 */
> +			oa_report_id_clear(stream, report32);
> +			oa_timestamp_clear(stream, report32);
> +		} else {
> +			/* Zero out the entire report */
> +			memset(report32, 0, report_size);
> +		}
>   	}
>   
>   	if (start_offset != *offset) {



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
  2023-05-22 21:34 ` Umesh Nerlige Ramappa
@ 2023-05-22 21:50   ` Dixit, Ashutosh
  2023-05-23 17:50     ` Umesh Nerlige Ramappa
  0 siblings, 1 reply; 6+ messages in thread
From: Dixit, Ashutosh @ 2023-05-22 21:50 UTC (permalink / raw)
  To: Umesh Nerlige Ramappa; +Cc: intel-gfx, Lionel Landwerlin, dri-devel

On Mon, 22 May 2023 14:34:18 -0700, Umesh Nerlige Ramappa wrote:
>
> On Mon, May 22, 2023 at 01:17:49PM -0700, Ashutosh Dixit wrote:
> > Clearing out report id and timestamp as means to detect unlanded reports
> > only works if report size is power of 2. That is, only when report size is
> > a sub-multiple of the OA buffer size can we be certain that reports will
> > land at the same place each time in the OA buffer (after rewind). If report
> > size is not a power of 2, we need to zero out the entire report to be able
> > to detect unlanded reports reliably.
> >
> > Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> > index 19d5652300eeb..58284156428dc 100644
> > --- a/drivers/gpu/drm/i915/i915_perf.c
> > +++ b/drivers/gpu/drm/i915/i915_perf.c
> > @@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
> >			stream->oa_buffer.last_ctx_id = ctx_id;
> >		}
> >
> > -		/*
> > -		 * Clear out the report id and timestamp as a means to detect unlanded
> > -		 * reports.
> > -		 */
> > -		oa_report_id_clear(stream, report32);
> > -		oa_timestamp_clear(stream, report32);
> > +		if (is_power_of_2(report_size)) {
> > +			/*
> > +			 * Clear out the report id and timestamp as a means
> > +			 * to detect unlanded reports.
> > +			 */
> > +			oa_report_id_clear(stream, report32);
> > +			oa_timestamp_clear(stream, report32);
> > +		} else {
> > +			/* Zero out the entire report */
> > +			memset(report32, 0, report_size);
>
> Indeed, this was a bug. For a minute, I started wondering if this is the
> issue I am running into with the other patch posted for DG2, but then I see
> the issue within the first fill of the OA buffer where chunks of the
> reports are zeroed out, so this is a new issue.

Yes I saw this while reviewing your patch. And also I thought your issue
was happening on DG2 with power of 2 report size, only on MTL OAM we
introduce non power of 2 report size.

> lgtm,
>
> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Thanks.
--
Ashutosh

>
> > +		}
> >	}
> >
> >	if (start_offset != *offset) {
> > --
> > 2.38.0
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
  2023-05-22 20:17 Ashutosh Dixit
@ 2023-05-22 21:34 ` Umesh Nerlige Ramappa
  2023-05-22 21:50   ` Dixit, Ashutosh
  2023-05-23 14:31 ` Lionel Landwerlin
  1 sibling, 1 reply; 6+ messages in thread
From: Umesh Nerlige Ramappa @ 2023-05-22 21:34 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: intel-gfx, Lionel Landwerlin, dri-devel

On Mon, May 22, 2023 at 01:17:49PM -0700, Ashutosh Dixit wrote:
>Clearing out report id and timestamp as means to detect unlanded reports
>only works if report size is power of 2. That is, only when report size is
>a sub-multiple of the OA buffer size can we be certain that reports will
>land at the same place each time in the OA buffer (after rewind). If report
>size is not a power of 2, we need to zero out the entire report to be able
>to detect unlanded reports reliably.
>
>Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
>---
> drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
>index 19d5652300eeb..58284156428dc 100644
>--- a/drivers/gpu/drm/i915/i915_perf.c
>+++ b/drivers/gpu/drm/i915/i915_perf.c
>@@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
> 			stream->oa_buffer.last_ctx_id = ctx_id;
> 		}
>
>-		/*
>-		 * Clear out the report id and timestamp as a means to detect unlanded
>-		 * reports.
>-		 */
>-		oa_report_id_clear(stream, report32);
>-		oa_timestamp_clear(stream, report32);
>+		if (is_power_of_2(report_size)) {
>+			/*
>+			 * Clear out the report id and timestamp as a means
>+			 * to detect unlanded reports.
>+			 */
>+			oa_report_id_clear(stream, report32);
>+			oa_timestamp_clear(stream, report32);
>+		} else {
>+			/* Zero out the entire report */
>+			memset(report32, 0, report_size);

Indeed, this was a bug. For a minute, I started wondering if this is the 
issue I am running into with the other patch posted for DG2, but then I 
see the issue within the first fill of the OA buffer where chunks of the 
reports are zeroed out, so this is a new issue.

lgtm,

Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Thanks,
Umesh


>+		}
> 	}
>
> 	if (start_offset != *offset) {
>-- 
>2.38.0
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size
@ 2023-05-22 20:17 Ashutosh Dixit
  2023-05-22 21:34 ` Umesh Nerlige Ramappa
  2023-05-23 14:31 ` Lionel Landwerlin
  0 siblings, 2 replies; 6+ messages in thread
From: Ashutosh Dixit @ 2023-05-22 20:17 UTC (permalink / raw)
  To: intel-gfx; +Cc: Umesh Nerlige Ramappa, Lionel Landwerlin, dri-devel

Clearing out report id and timestamp as means to detect unlanded reports
only works if report size is power of 2. That is, only when report size is
a sub-multiple of the OA buffer size can we be certain that reports will
land at the same place each time in the OA buffer (after rewind). If report
size is not a power of 2, we need to zero out the entire report to be able
to detect unlanded reports reliably.

Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 19d5652300eeb..58284156428dc 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -877,12 +877,17 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 			stream->oa_buffer.last_ctx_id = ctx_id;
 		}
 
-		/*
-		 * Clear out the report id and timestamp as a means to detect unlanded
-		 * reports.
-		 */
-		oa_report_id_clear(stream, report32);
-		oa_timestamp_clear(stream, report32);
+		if (is_power_of_2(report_size)) {
+			/*
+			 * Clear out the report id and timestamp as a means
+			 * to detect unlanded reports.
+			 */
+			oa_report_id_clear(stream, report32);
+			oa_timestamp_clear(stream, report32);
+		} else {
+			/* Zero out the entire report */
+			memset(report32, 0, report_size);
+		}
 	}
 
 	if (start_offset != *offset) {
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-23 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 20:40 [PATCH] drm/i915/perf: Clear out entire reports after reading if not power of 2 size Ashutosh Dixit
  -- strict thread matches above, loose matches on Subject: below --
2023-05-22 20:17 Ashutosh Dixit
2023-05-22 21:34 ` Umesh Nerlige Ramappa
2023-05-22 21:50   ` Dixit, Ashutosh
2023-05-23 17:50     ` Umesh Nerlige Ramappa
2023-05-23 14:31 ` Lionel Landwerlin

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).