Commit 3a1fc394 authored by Ashutosh Dixit's avatar Ashutosh Dixit
Browse files

drm/xe/oa: Changes to OA_TAKEN



Rename OA_TAKEN to xe_oa_circ_diff, since xe_oa_circ_diff better describes
what the macro actually does. Also convert to function and add xe_oa_stream
arg. These will be used in the following patch.

Acked-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: default avatarUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Signed-off-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240618014609.3233427-17-ashutosh.dixit@intel.com
parent 70af432b
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include "xe_pm.h"
#include "xe_sched_job.h"

#define OA_TAKEN(tail, head)	(((tail) - (head)) & (XE_OA_BUFFER_SIZE - 1))
#define DEFAULT_POLL_FREQUENCY_HZ 200
#define DEFAULT_POLL_PERIOD_NS (NSEC_PER_SEC / DEFAULT_POLL_FREQUENCY_HZ)
#define XE_OA_UNIT_INVALID U32_MAX
@@ -113,6 +112,11 @@ static const struct xe_oa_format oa_formats[] = {
	[XE_OA_FORMAT_PEC36u64_G1_4_G2_32]	= { 4, 320, DRM_FMT(PEC), HDR_64_BIT, 1, 0 },
};

static u32 xe_oa_circ_diff(struct xe_oa_stream *stream, u32 tail, u32 head)
{
	return (tail - head) & (XE_OA_BUFFER_SIZE - 1);
}

static void xe_oa_config_release(struct kref *ref)
{
	struct xe_oa_config *oa_config =
@@ -217,11 +221,11 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
	 * increments. Also report size may not be a power of 2. Compute potential
	 * partially landed report in OA buffer.
	 */
	partial_report_size = OA_TAKEN(hw_tail, stream->oa_buffer.tail);
	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 */
	hw_tail = OA_TAKEN(hw_tail, partial_report_size);
	hw_tail = xe_oa_circ_diff(stream, hw_tail, partial_report_size);

	tail = hw_tail;

@@ -233,23 +237,23 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
	 * This is assuming that the writes of the OA unit land in memory in the order
	 * they were written.  If not : (╯°□°)╯︵ ┻━┻
	 */
	while (OA_TAKEN(tail, stream->oa_buffer.tail) >= report_size) {
	while (xe_oa_circ_diff(stream, tail, stream->oa_buffer.tail) >= report_size) {
		void *report = stream->oa_buffer.vaddr + tail;

		if (oa_report_id(stream, report) || oa_timestamp(stream, report))
			break;

		tail = OA_TAKEN(tail, report_size);
		tail = xe_oa_circ_diff(stream, tail, report_size);
	}

	if (OA_TAKEN(hw_tail, tail) > report_size)
	if (xe_oa_circ_diff(stream, hw_tail, tail) > report_size)
		drm_dbg(&stream->oa->xe->drm,
			"unlanded report(s) head=0x%x tail=0x%x hw_tail=0x%x\n",
			stream->oa_buffer.head, tail, hw_tail);

	stream->oa_buffer.tail = tail;

	pollin = OA_TAKEN(stream->oa_buffer.tail,
	pollin = xe_oa_circ_diff(stream, stream->oa_buffer.tail,
				 stream->oa_buffer.head) >= report_size;

	spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
@@ -323,7 +327,7 @@ static int xe_oa_append_reports(struct xe_oa_stream *stream, char __user *buf,

	xe_assert(stream->oa->xe, head < XE_OA_BUFFER_SIZE && tail < XE_OA_BUFFER_SIZE);

	for (; OA_TAKEN(tail, head); head = (head + report_size) & mask) {
	for (; xe_oa_circ_diff(stream, tail, head); head = (head + report_size) & mask) {
		u8 *report = oa_buf_base + head;

		ret = xe_oa_append_report(stream, buf, count, offset, report);