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 808F4CCD185 for ; Mon, 6 Oct 2025 04:42:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1361510E2F2; Mon, 6 Oct 2025 04:42:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="H9MI3qOu"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5F9410E2EF; Mon, 6 Oct 2025 04:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759725731; x=1791261731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lcqoCud+107fk6QGjC06EUZzZljtGOI54TD1kPRrINY=; b=H9MI3qOuIyXiv4i+AdEk2dL0lsgiWJv6JxpErHIkmBQCVrJznSG8Z+Yn C0/5QKGRKYgysq4TDo1y3cCyC0/gF6+GXcpaRiRp71fWq6qpW8ro5xC39 JHzqwULz4VwWY8gMByEboZ3QplmSQVYJq57i+TU9yP7FkNAKdOl2BhA8G vNc1EiWfwQwUjC4fOeZnFgymkTkTMeptqTEuPPpgj4F61V/GvFZDty8N5 uFNPLiqTEM6tIZDjM6wxheflZS59SxIJcfoUqnn6XXmw3RZNR2+/hn2Wr as7WdsLt1N6w3Lc0lXAnCjfMiKdKb8+wuXCqCtoEVqD1vCr4VdYKTCcdN w==; X-CSE-ConnectionGUID: 2J+jVmOHTMC3iFE318TFoA== X-CSE-MsgGUID: BtTblGaeRYWk5Gg94YAJ9g== X-IronPort-AV: E=McAfee;i="6800,10657,11573"; a="61996411" X-IronPort-AV: E=Sophos;i="6.18,319,1751266800"; d="scan'208";a="61996411" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2025 21:42:11 -0700 X-CSE-ConnectionGUID: HGB2jcmSQF+/nVWLYW2hZw== X-CSE-MsgGUID: SJ3acq5pQyaG7dD+tSL1Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,319,1751266800"; d="scan'208";a="179062994" Received: from srr4-3-linux-103-aknautiy.iind.intel.com ([10.223.34.160]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2025 21:42:10 -0700 From: Ankit Nautiyal To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: ville.syrjala@linux.intel.com Subject: [PATCH 03/16] drm/i915/skl_watermark: Pass linetime as argument to latency helpers Date: Mon, 6 Oct 2025 09:58:39 +0530 Message-ID: <20251006042852.263249-4-ankit.k.nautiyal@intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251006042852.263249-1-ankit.k.nautiyal@intel.com> References: <20251006042852.263249-1-ankit.k.nautiyal@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Refactor dsc_prefill_latency and scaler_prefill_latency to take linetime as an explicit parameter instead of computing it internally. This avoids redundant calculations and simplifies scanline conversion logic in skl_is_vblank_too_short(). This change also facilitates future extraction of these helpers for use cases where latencies are computed for an optimized guardband, based on the highest resolution mode, rather than the current mode. v2: Sum all latency numbers and use intel_usecs_to_scanlines() to convert to scanlines. (Ville). Signed-off-by: Ankit Nautiyal Reviewed-by: Mitul Golani --- drivers/gpu/drm/i915/display/skl_watermark.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c b/drivers/gpu/drm/i915/display/skl_watermark.c index 4b1ef4fa8ed2..be87a861eb70 100644 --- a/drivers/gpu/drm/i915/display/skl_watermark.c +++ b/drivers/gpu/drm/i915/display/skl_watermark.c @@ -2179,13 +2179,11 @@ cdclk_prefill_adjustment(const struct intel_crtc_state *crtc_state) } static int -dsc_prefill_latency(const struct intel_crtc_state *crtc_state) +dsc_prefill_latency(const struct intel_crtc_state *crtc_state, int linetime) { struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); const struct intel_crtc_scaler_state *scaler_state = &crtc_state->scaler_state; - int linetime = DIV_ROUND_UP(1000 * crtc_state->hw.adjusted_mode.htotal, - crtc_state->hw.adjusted_mode.clock); int num_scaler_users = hweight32(scaler_state->scaler_users); int chroma_downscaling_factor = crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ? 4 : 1; @@ -2209,18 +2207,16 @@ dsc_prefill_latency(const struct intel_crtc_state *crtc_state) dsc_prefill_latency *= cdclk_prefill_adjustment(crtc_state); - return intel_usecs_to_scanlines(&crtc_state->hw.adjusted_mode, dsc_prefill_latency); + return dsc_prefill_latency; } static int -scaler_prefill_latency(const struct intel_crtc_state *crtc_state) +scaler_prefill_latency(const struct intel_crtc_state *crtc_state, int linetime) { const struct intel_crtc_scaler_state *scaler_state = &crtc_state->scaler_state; int num_scaler_users = hweight32(scaler_state->scaler_users); int scaler_prefill_latency = 0; - int linetime = DIV_ROUND_UP(1000 * crtc_state->hw.adjusted_mode.htotal, - crtc_state->hw.adjusted_mode.clock); if (!num_scaler_users) return scaler_prefill_latency; @@ -2241,7 +2237,7 @@ scaler_prefill_latency(const struct intel_crtc_state *crtc_state) scaler_prefill_latency *= cdclk_prefill_adjustment(crtc_state); - return intel_usecs_to_scanlines(&crtc_state->hw.adjusted_mode, scaler_prefill_latency); + return scaler_prefill_latency; } static bool @@ -2250,11 +2246,14 @@ skl_is_vblank_too_short(const struct intel_crtc_state *crtc_state, { const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; + int linetime = DIV_ROUND_UP(1000 * adjusted_mode->htotal, + adjusted_mode->clock); + + latency += scaler_prefill_latency(crtc_state, linetime) + + dsc_prefill_latency(crtc_state, linetime); return crtc_state->framestart_delay + intel_usecs_to_scanlines(adjusted_mode, latency) + - scaler_prefill_latency(crtc_state) + - dsc_prefill_latency(crtc_state) + wm0_lines > adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vblank_start; } -- 2.45.2