From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CA70C41513 for ; Mon, 27 May 2024 01:43:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E49010EBD0; Mon, 27 May 2024 01:43:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Zz+hNVgA"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35A0C10ECF7 for ; Mon, 27 May 2024 01:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716774220; x=1748310220; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=6xYwSc+3KHccwJUvFS1VnHIc5UeyX4sBl/tJy7L6Gzs=; b=Zz+hNVgAxb8kR1xKlWsr5joN1T3igdg58Ca1j0gLMKNGC+O4dWfH3nyn brLCG/EM2UWp9yHlUbE4w0yqOP7V8Ru6mOy0atLSpreOFGQJkPCPoP2gv EVP0t+Cpuh9GsCx3QGNOEbyMuS1D9YY7sEk9Zv/CbHv7bqIY1S1KHAb3e Q2gX1cKvBqLvXcAmpzFaNA1juMsWCfWSfdrEaV0dILa9H5WaQ+cbl1oTB UGRrwPacOnccj6DUJUOdDuEMno12gk8LvWaGkWnv2MOkAHU4QJpcu2Dr2 GNSlJHlXLJtgk+QYuIzMKofIT8WLiCgS6JeehMtNeDK+IzrLxnzjU+p2a Q==; X-CSE-ConnectionGUID: Unl0PL8CTfOpdxtbSyWgVQ== X-CSE-MsgGUID: Gt+vO7vLRUWHh8FQY2cLBw== X-IronPort-AV: E=McAfee;i="6600,9927,11084"; a="11707477" X-IronPort-AV: E=Sophos;i="6.08,191,1712646000"; d="scan'208";a="11707477" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2024 18:43:39 -0700 X-CSE-ConnectionGUID: /YgGqZwrSYmuEaLBBslJTA== X-CSE-MsgGUID: uPobN4OMQaSYarXZ0eKfRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,191,1712646000"; d="scan'208";a="65821718" Received: from orsosgc001.jf.intel.com ([10.165.21.138]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2024 18:43:39 -0700 From: Ashutosh Dixit To: intel-xe@lists.freedesktop.org Subject: [PATCH 16/17] drm/xe/oa: Changes to OA_TAKEN Date: Sun, 26 May 2024 18:43:32 -0700 Message-ID: <20240527014333.603914-17-ashutosh.dixit@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240527014333.603914-1-ashutosh.dixit@intel.com> References: <20240527014333.603914-1-ashutosh.dixit@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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. Reviewed-by: Umesh Nerlige Ramappa Signed-off-by: Ashutosh Dixit --- drivers/gpu/drm/xe/xe_oa.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c index 5eef533a637f..5ef4c4abea32 100644 --- a/drivers/gpu/drm/xe/xe_oa.c +++ b/drivers/gpu/drm/xe/xe_oa.c @@ -33,7 +33,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 @@ -110,6 +109,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 = @@ -214,11 +218,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; @@ -230,24 +234,24 @@ 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, - stream->oa_buffer.head) >= report_size; + 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); @@ -320,7 +324,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); -- 2.41.0