[PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user
Umesh Nerlige Ramappa <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
When running heavy workloads, reading the OA reports too soon does not guarantee that the report has landed in memory. To make sure correct reports are copied to user buffer, only return reports that lag the current HW_TAIL register by 32 reports. This is an empirical number based on a heavy render workload and several test iterations. The reports that user reads will always lag the HW tail by 32 reports, however since OA is used for post processing analysis, this should not affect any current use cases. When the stream is closed or disabled, we let the user read the remaining reports up until HW tail. Signed-off-by: Umesh Nerlige Ramappa <[email protected]> --- v2: Fix the LAG logic by using sliding window (Sashiko) v3: Fix checkpatch warning v4: Update sw tail on stream disable (Ashutosh) --- drivers/gpu/drm/xe/xe_oa.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c index d7647f37ab02..2a88f7d9e67c 100644 --- a/drivers/gpu/drm/xe/xe_oa.c +++ b/drivers/gpu/drm/xe/xe_oa.c @@ -224,7 +224,7 @@ static bool mert_wa_14026633728(struct xe_oa_stream *s) static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream) { u32 gtt_offset = xe_bo_ggtt_addr(stream->oa_buffer.bo); - u32 hw_tail, partial_report_size, available; + u32 hw_tail, partial_report_size, available, lag; int report_size = stream->oa_buffer.format->size; unsigned long flags; @@ -234,17 +234,23 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream) hw_tail -= gtt_offset; /* - * The tail pointer increases in 64 byte (cacheline size), not in report_size + * The hw_tail pointer increases in 64 byte (cacheline size), not in report_size * increments. Also report size may not be a power of 2. Compute potential * partially landed report in OA buffer. */ partial_report_size = xe_oa_circ_diff(stream, hw_tail, stream->oa_buffer.tail); partial_report_size %= report_size; - /* Subtract partial amount off the tail */ + /* Subtract partial amount off the hw_tail */ hw_tail = xe_oa_circ_diff(stream, hw_tail, partial_report_size); - stream->oa_buffer.tail = hw_tail; +#define LAG_REPORTS 32 + lag = xe_oa_circ_diff(stream, hw_tail, stream->oa_buffer.tail); + if (!stream->enabled) + stream->oa_buffer.tail = hw_tail; + else if (lag > LAG_REPORTS * report_size) + stream->oa_buffer.tail = xe_oa_circ_diff(stream, hw_tail, + LAG_REPORTS * report_size); available = xe_oa_circ_diff(stream, stream->oa_buffer.tail, stream->oa_buffer.head); stream->pollin = available >= stream->wait_num_reports * report_size; -- 2.51.0