diff mbox series

[1/2] drm/i915/perf: Subtract gtt_offset from hw_tail

Message ID 20230718024318.2911899-2-ashutosh.dixit@intel.com (mailing list archive)
State New, archived
Headers show
Series gtt_offset and OA buffer cached head/tail | expand

Commit Message

Dixit, Ashutosh July 18, 2023, 2:43 a.m. UTC
The code in oa_buffer_check_unlocked() is correct only if the OA buffer is
16 MB aligned (which seems to be the case today in i915). However when the
16 MB alignment is dropped, when we "Subtract partial amount off the tail",
the "& (OA_BUFFER_SIZE - 1)" operation in OA_TAKEN() will result in an
incorrect hw_tail value.

Therefore hw_tail must be brought to the same base as head and read_tail
prior to OA_TAKEN by subtracting gtt_offset from hw_tail.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Lionel Landwerlin July 18, 2023, 8:39 a.m. UTC | #1
On 18/07/2023 05:43, Ashutosh Dixit wrote:
> The code in oa_buffer_check_unlocked() is correct only if the OA buffer is
> 16 MB aligned (which seems to be the case today in i915). However when the
> 16 MB alignment is dropped, when we "Subtract partial amount off the tail",
> the "& (OA_BUFFER_SIZE - 1)" operation in OA_TAKEN() will result in an
> incorrect hw_tail value.
>
> Therefore hw_tail must be brought to the same base as head and read_tail
> prior to OA_TAKEN by subtracting gtt_offset from hw_tail.
>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_perf.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 49c6f1ff11284..f7888a44d1284 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -565,6 +565,7 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream)
>   	partial_report_size %= report_size;
>   
>   	/* Subtract partial amount off the tail */
> +	hw_tail -= gtt_offset;
>   	hw_tail = OA_TAKEN(hw_tail, partial_report_size);
>   
>   	/* NB: The head we observe here might effectively be a little


You should squash this patch with the next one. Otherwise further down 
this function there is another

hw_tail -= gtt_offset;


-Lionel
Dixit, Ashutosh July 18, 2023, 5:17 p.m. UTC | #2
On Tue, 18 Jul 2023 01:39:35 -0700, Lionel Landwerlin wrote:
>

Hi Lionel,

> On 18/07/2023 05:43, Ashutosh Dixit wrote:
> > The code in oa_buffer_check_unlocked() is correct only if the OA buffer is
> > 16 MB aligned (which seems to be the case today in i915). However when the
> > 16 MB alignment is dropped, when we "Subtract partial amount off the tail",
> > the "& (OA_BUFFER_SIZE - 1)" operation in OA_TAKEN() will result in an
> > incorrect hw_tail value.
> >
> > Therefore hw_tail must be brought to the same base as head and read_tail
> > prior to OA_TAKEN by subtracting gtt_offset from hw_tail.
> >
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_perf.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> > index 49c6f1ff11284..f7888a44d1284 100644
> > --- a/drivers/gpu/drm/i915/i915_perf.c
> > +++ b/drivers/gpu/drm/i915/i915_perf.c
> > @@ -565,6 +565,7 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream)
> >	partial_report_size %= report_size;
> >		/* Subtract partial amount off the tail */
> > +	hw_tail -= gtt_offset;
> >	hw_tail = OA_TAKEN(hw_tail, partial_report_size);
> >		/* NB: The head we observe here might effectively be a little
>
>
> You should squash this patch with the next one. Otherwise further down this
> function there is another
>
> hw_tail -= gtt_offset;

Are you looking at old code, because this line is not there in this
function any more. There have been several changes to the function lately,
aging tail etc. is gone e.g.

But otherwise you are right, Patch 2 basically writes over Patch 1, so the
two patches can be squashed. I separated out Patch 1 since it shows the bug
(incidentally the bug doesn't show up in i915 since a 16 MB BO in i915 is
16 MB aligned, I discovered the bug while porting stuff to xe).

So if you are going to R-b this series I can repost after squashing. But if
we wait for Umesh to return (he is out till the end of the month) and
review this, I'd rather leave the two patches as they are till Umesh
reviews them.

Thanks.
--
Ashutosh
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 49c6f1ff11284..f7888a44d1284 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -565,6 +565,7 @@  static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream)
 	partial_report_size %= report_size;
 
 	/* Subtract partial amount off the tail */
+	hw_tail -= gtt_offset;
 	hw_tail = OA_TAKEN(hw_tail, partial_report_size);
 
 	/* NB: The head we observe here might effectively be a little