From patchwork Tue May 28 18:56:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677092 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 504DEC25B78 for ; Tue, 28 May 2024 18:56:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84EF810E8B2; Tue, 28 May 2024 18:56:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="NfPSxvdc"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 206B110E8B2 for ; Tue, 28 May 2024 18:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922613; x=1748458613; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=rg/GGCHaH6DEqwmWJUtKW76DCUFtTGEtKJLWoTR9hI0=; b=NfPSxvdckT1N5oXWNkmnJ1eg1LL8udaFpk4RhqyR85fbs8TQA15Byltp i9lmzDiQOTFedheLHdidpjs/w01W9VBXnph/mNyb70aeceuWngqfBmPkf 6/VJgHZeCYUllDgdEgTHmfunB+NUn4im29z7jyfTdpkUCeOsSPaYMjeeJ DZv0n9Z5kK+OQ5hIiS8XfwOxrfK0xy5pGILynfEi9cNTINOhnRZu43k6V lY1pAS6mFw98Ty7lMfLog13zZQKJcLvWdlmV7QXtvLH931Sg4CbpIpiul W3ZPdaztk2aFGKqyYGD+TsP4OEgbA2+3FSGLNydCFbXHc90Do+pohyQRi Q==; X-CSE-ConnectionGUID: VBfKsl66QUKaBv7jwkabBw== X-CSE-MsgGUID: nFCt6UteRFuk8R+wCRDK9Q== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815203" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815203" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:56:52 -0700 X-CSE-ConnectionGUID: fu+Dssu4Tqiivo94Fyskig== X-CSE-MsgGUID: EElOMyZyQ/+mWzxAL7j7DQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144436" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:56:51 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:56:50 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 1/7] drm/i915: Reuse intel_mode_vblank_start() Date: Tue, 28 May 2024 21:56:41 +0300 Message-ID: <20240528185647.7765-2-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä Replace a few hand rolled copies of intel_mode_vblank_start() with the real thing. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_dsb.c | 10 +++------- drivers/gpu/drm/i915/display/intel_vblank.c | 9 +++------ drivers/gpu/drm/i915/display/intel_vblank.h | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c index 4baaa92ceaec..319fbebd7008 100644 --- a/drivers/gpu/drm/i915/display/intel_dsb.c +++ b/drivers/gpu/drm/i915/display/intel_dsb.c @@ -328,14 +328,10 @@ static int intel_dsb_dewake_scanline(const struct intel_crtc_state *crtc_state) unsigned int latency = skl_watermark_max_latency(i915, 0); int vblank_start; - if (crtc_state->vrr.enable) { + if (crtc_state->vrr.enable) vblank_start = intel_vrr_vmin_vblank_start(crtc_state); - } else { - vblank_start = adjusted_mode->crtc_vblank_start; - - if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) - vblank_start = DIV_ROUND_UP(vblank_start, 2); - } + else + vblank_start = intel_mode_vblank_start(adjusted_mode); return max(0, vblank_start - intel_usecs_to_scanlines(adjusted_mode, latency)); } diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index 951190bcbc50..1f57596f8208 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -89,9 +89,7 @@ u32 i915_get_vblank_counter(struct drm_crtc *crtc) htotal = mode->crtc_htotal; hsync_start = mode->crtc_hsync_start; - vbl_start = mode->crtc_vblank_start; - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - vbl_start = DIV_ROUND_UP(vbl_start, 2); + vbl_start = intel_mode_vblank_start(mode); /* Convert to pixel count */ vbl_start *= htotal; @@ -313,11 +311,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc, htotal = mode->crtc_htotal; hsync_start = mode->crtc_hsync_start; vtotal = mode->crtc_vtotal; - vbl_start = mode->crtc_vblank_start; + vbl_start = intel_mode_vblank_start(mode); vbl_end = mode->crtc_vblank_end; if (mode->flags & DRM_MODE_FLAG_INTERLACE) { - vbl_start = DIV_ROUND_UP(vbl_start, 2); vbl_end /= 2; vtotal /= 2; } @@ -577,7 +574,7 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, spin_unlock_irqrestore(&i915->drm.vblank_time_lock, irqflags); } -static int intel_mode_vblank_start(const struct drm_display_mode *mode) +int intel_mode_vblank_start(const struct drm_display_mode *mode) { int vblank_start = mode->crtc_vblank_start; diff --git a/drivers/gpu/drm/i915/display/intel_vblank.h b/drivers/gpu/drm/i915/display/intel_vblank.h index ec6c3da3eeac..08825a4d8fb7 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.h +++ b/drivers/gpu/drm/i915/display/intel_vblank.h @@ -10,6 +10,7 @@ #include struct drm_crtc; +struct drm_display_mode; struct intel_crtc; struct intel_crtc_state; @@ -19,6 +20,8 @@ struct intel_vblank_evade_ctx { bool need_vlv_dsi_wa; }; +int intel_mode_vblank_start(const struct drm_display_mode *mode); + void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *new_crtc_state, struct intel_vblank_evade_ctx *evade); From patchwork Tue May 28 18:56:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677096 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 4A165C25B78 for ; Tue, 28 May 2024 18:57:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A86E610EA18; Tue, 28 May 2024 18:57:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="dutAvI2A"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id CCCFF10E8BE for ; Tue, 28 May 2024 18:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922615; x=1748458615; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=hNHD4XarBA/mrCtuCONNNbDkKaIS6O1OIM9RbVMN6a4=; b=dutAvI2AlN2AOu2btzRUeqf9QhuoC4d7WrCZk3Nqmv7o+1KPWMIbJG/N TrvszdHBUSrXk+4UVsKTjywVO17P5tZ2snEGJCr+Y5F/hqoqWDn3C/8+9 F6SUOtDWuy/HWIWlcuTphj37zVlBkA6neF0NfU2+TuoCgWMdhwTraZ8C1 N09p5dAWKKhw2Yhl7F14rR4n3X9ZnWAJ584xgkkm/BhNvPCmZiGqtm4LM n/TcLRYbLsWQGj6sSKp99tzqIiMKNYoLH07TbOvqrt/8g1xfAoNnWQD0g oY0weU87OTsDLCIss0xgp9XHtJCZnW2XLYgsCOttaJXOEgMCerPi/jUUl A==; X-CSE-ConnectionGUID: KDyYbVr7RqS0W5UMkyMoVA== X-CSE-MsgGUID: w2Zy0QotQJODikDtv5JKPA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815206" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815206" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:56:55 -0700 X-CSE-ConnectionGUID: vo8ZQ9cPSvqED3fqQEEHVg== X-CSE-MsgGUID: vPCJqBjjQTul4g/ThaY9QQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144452" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:56:53 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:56:53 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 2/7] drm/i915: Extract intel_mode_vblank_end() Date: Tue, 28 May 2024 21:56:42 +0300 Message-ID: <20240528185647.7765-3-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä Extract intel_mode_vblank_end() in the same vein as intel_mode_vblank_start(). While we have only one use of this it seems nicer to unify the approach. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_vblank.c | 16 ++++++++++++---- drivers/gpu/drm/i915/display/intel_vblank.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index 1f57596f8208..ba56015f2c40 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -312,12 +312,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc, hsync_start = mode->crtc_hsync_start; vtotal = mode->crtc_vtotal; vbl_start = intel_mode_vblank_start(mode); - vbl_end = mode->crtc_vblank_end; + vbl_end = intel_mode_vblank_end(mode); - if (mode->flags & DRM_MODE_FLAG_INTERLACE) { - vbl_end /= 2; + if (mode->flags & DRM_MODE_FLAG_INTERLACE) vtotal /= 2; - } /* * Enter vblank critical section, as we will do multiple @@ -584,6 +582,16 @@ int intel_mode_vblank_start(const struct drm_display_mode *mode) return vblank_start; } +int intel_mode_vblank_end(const struct drm_display_mode *mode) +{ + int vblank_end = mode->crtc_vblank_end; + + if (mode->flags & DRM_MODE_FLAG_INTERLACE) + vblank_end /= 2; + + return vblank_end; +} + void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *new_crtc_state, struct intel_vblank_evade_ctx *evade) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.h b/drivers/gpu/drm/i915/display/intel_vblank.h index 08825a4d8fb7..6f11fd070f19 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.h +++ b/drivers/gpu/drm/i915/display/intel_vblank.h @@ -21,6 +21,7 @@ struct intel_vblank_evade_ctx { }; int intel_mode_vblank_start(const struct drm_display_mode *mode); +int intel_mode_vblank_end(const struct drm_display_mode *mode); void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *new_crtc_state, From patchwork Tue May 28 18:56:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677093 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 C100AC25B78 for ; Tue, 28 May 2024 18:57:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E11910EBBA; Tue, 28 May 2024 18:57:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ahKo2RK6"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6ED010EBBA for ; Tue, 28 May 2024 18:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922618; x=1748458618; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=A1t4umHowCEF/7wFTJrlfpG16OPZVcwIGvky5r9vbsQ=; b=ahKo2RK6fFWDm6ILekqvR5XYuP/08hZAnPsXd9LAQlsnC+P3l7g3WcTG tsmDqFQwS1M/dDZo9PfTccovWZXZkaZwHk5Upqa4eYwB6qfuTJRRheD9/ XtoY3mkFOhNtJR5A/wQuLt+3Kvk4Nqjdnv9UYZ/QiKJ039CKU/PE0gQJ+ 111p1VeWOi//6JbEXRP3blpfYHZyeBfoDV0ifbiji2/3SCL8nkBYU1SfF 7TA7y53UYsQVVtQ1BAtzOQxCiZJZfXG2/PdkkNnJr6dqO2GHwpzFTlco+ Xe9SrUPdNDA/2xugIhMjoA22K3alncwc2DUMJYuAnPdwSOsilAy5PbVs+ Q==; X-CSE-ConnectionGUID: QW/dw5pHSWe+me/Lc8l8Ng== X-CSE-MsgGUID: c1LzfdgmSNCkz2lgwDFZsA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815208" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815208" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:56:58 -0700 X-CSE-ConnectionGUID: bHub4+ooT5ytF7ahfh5LRw== X-CSE-MsgGUID: W6fnAHU3SJG6Ts/WXIQ0Uw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144468" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:56:56 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:56:55 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 3/7] drm/i915: Extract intel_mode_vtotal() Date: Tue, 28 May 2024 21:56:43 +0300 Message-ID: <20240528185647.7765-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä We have several copies of code calculating the hardware's idea of vtotal. Pull that to a helper, similar to intel_mode_vblank_{start,end}(). Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_vblank.c | 40 +++++++++------------ drivers/gpu/drm/i915/display/intel_vblank.h | 1 + 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index ba56015f2c40..31fa5867e1a7 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -207,9 +207,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) return __intel_get_crtc_scanline_from_timestamp(crtc); - vtotal = mode->crtc_vtotal; - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - vtotal /= 2; + vtotal = intel_mode_vtotal(mode); position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK; @@ -249,11 +247,7 @@ int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) { const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); const struct drm_display_mode *mode = &vblank->hwmode; - int vtotal; - - vtotal = mode->crtc_vtotal; - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - vtotal /= 2; + int vtotal = intel_mode_vtotal(mode); return (scanline + vtotal - crtc->scanline_offset) % vtotal; } @@ -310,13 +304,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc, htotal = mode->crtc_htotal; hsync_start = mode->crtc_hsync_start; - vtotal = mode->crtc_vtotal; + vtotal = intel_mode_vtotal(mode); vbl_start = intel_mode_vblank_start(mode); vbl_end = intel_mode_vblank_end(mode); - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - vtotal /= 2; - /* * Enter vblank critical section, as we will do multiple * timing critical raw register reads, potentially with @@ -508,19 +499,12 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) * However if queried just before the start of vblank we'll get an * answer that's slightly in the future. */ - if (DISPLAY_VER(i915) == 2) { - int vtotal; - - vtotal = adjusted_mode->crtc_vtotal; - if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) - vtotal /= 2; - - return vtotal - 1; - } else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) { + if (DISPLAY_VER(i915) == 2) + return intel_mode_vtotal(adjusted_mode) - 1; + else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) return 2; - } else { + else return 1; - } } void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, @@ -592,6 +576,16 @@ int intel_mode_vblank_end(const struct drm_display_mode *mode) return vblank_end; } +int intel_mode_vtotal(const struct drm_display_mode *mode) +{ + int vtotal = mode->crtc_vtotal; + + if (mode->flags & DRM_MODE_FLAG_INTERLACE) + vtotal /= 2; + + return vtotal; +} + void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *new_crtc_state, struct intel_vblank_evade_ctx *evade) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.h b/drivers/gpu/drm/i915/display/intel_vblank.h index 6f11fd070f19..b51ae2c1039e 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.h +++ b/drivers/gpu/drm/i915/display/intel_vblank.h @@ -22,6 +22,7 @@ struct intel_vblank_evade_ctx { int intel_mode_vblank_start(const struct drm_display_mode *mode); int intel_mode_vblank_end(const struct drm_display_mode *mode); +int intel_mode_vtotal(const struct drm_display_mode *mode); void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *new_crtc_state, From patchwork Tue May 28 18:56:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677094 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 31D74C25B78 for ; Tue, 28 May 2024 18:57:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 945A010EEC4; Tue, 28 May 2024 18:57:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="HyHZk6z3"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C02A10EE46 for ; Tue, 28 May 2024 18:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922621; x=1748458621; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=apumwDrmoP3uR8MR/GzJBYGMrnvEzT1bDtflTuFCCGM=; b=HyHZk6z3kmr668rMAoXxZuag91aQT3I7vzRYV+EY/hW8Lg3mezXbKXxb 84lOB8Eck2WwX8IMzdhJtbrI2ErwQ6jmpJjcY5JR7CThs/62E+gpGZEzM xNhHf9XCB3iHk9TDoc8zOGQ1kDicCmKM3yN+Ostplei5Lk8+pP/y0gBuQ DpA5NW3PAJPv8mvTHnrLTkdzwuHAlTthH+ho6l+pWsE1RShSZoM00eHns irwZhSTSznbkvNmd2U0QHnWPwIQMT01e4XXeptpXHc8xPTibZCcNmN05W ATLotDKo5IJzk8LD88sSRKXUFiFmHge7qRcZjyuLAt3QDXi8Bsgt/wRVX g==; X-CSE-ConnectionGUID: HIiHb2PBSCGMnh4wA4CqUQ== X-CSE-MsgGUID: tHpS1soxQTqi36m0l4gP3g== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815210" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815210" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:57:01 -0700 X-CSE-ConnectionGUID: y/5rebleT+KJkdDzcIHYoA== X-CSE-MsgGUID: Ck7oBpoWQ9Kz24ZgaGbC4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144481" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:56:59 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:56:58 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 4/7] drm/i915: Simplify scanline_offset handling for gen2 Date: Tue, 28 May 2024 21:56:44 +0300 Message-ID: <20240528185647.7765-5-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä Currently intel_crtc_scanline_offset() is careful to always return a positive offset. That is not actually necessary as long as we take care of negative values when applying the offset in __intel_get_crtc_scanline(). This simplifies intel_crtc_scanline_offset(), and makes the scanline_offfset arithmetic more symmetric between the forwad (__intel_get_crtc_scanline()) and reverse (intel_crtc_scanline_to_hw()) directions. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_vblank.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index 31fa5867e1a7..b0e95a4c680d 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -240,7 +240,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) * See update_scanline_offset() for the details on the * scanline_offset adjustment. */ - return (position + crtc->scanline_offset) % vtotal; + return (position + vtotal + crtc->scanline_offset) % vtotal; } int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) @@ -470,7 +470,6 @@ void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc) static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) { struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); - const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; /* * The scanline counter increments at the leading edge of hsync. @@ -482,8 +481,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) * last active line), the scanline counter will read vblank_start-1. * * On gen2 the scanline counter starts counting from 1 instead - * of vtotal-1, so we have to subtract one (or rather add vtotal-1 - * to keep the value positive), instead of adding one. + * of vtotal-1, so we have to subtract one. * * On HSW+ the behaviour of the scanline counter depends on the output * type. For DP ports it behaves like most other platforms, but on HDMI @@ -500,7 +498,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) * answer that's slightly in the future. */ if (DISPLAY_VER(i915) == 2) - return intel_mode_vtotal(adjusted_mode) - 1; + return -1; else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) return 2; else From patchwork Tue May 28 18:56:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677095 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 E934BC25B7E for ; Tue, 28 May 2024 18:57:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1323010EED8; Tue, 28 May 2024 18:57:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Qtl3zLg1"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 523D210EED8 for ; Tue, 28 May 2024 18:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922624; x=1748458624; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=KJL8bk58yp4IngxgJE6WV0qmHF+lyMua/k1oLGcWO5Y=; b=Qtl3zLg1pjpW+lZLzMw6PP4LFZZhzYZgaPTMoEce+9E4HuMNMPMpIMTY IeOziH69oolTGsAtQKDA+BBkdk+l8x+7982zfq9edQ0Rd2atDN6QcgZ5m UFdCtfnTt5Hdv9zsHtp108tctNyn5M9MrVPiLQX3IqdgD0vcZJJohhoYc NsbH7BSiMwI73+QarMZ2r8CyEPgTPvcLZQ/BDA5BuOHvZj4gvUKDzAuEQ 5nnACfBYfs91O5uop5sZFM8s0iFY5WWOcbgkIrMmfKOLhnk3sFEPBoeKb 28vjApiK9zpxLYaKTX5+eHMbNn6ictLPQW0IB8QTbAWRCUIRVSP/ZUsPP w==; X-CSE-ConnectionGUID: mYT0MNOkQaWzJLVQm+0e1Q== X-CSE-MsgGUID: 41kWAJT2T2CMQlrU/qy8Nw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815244" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815244" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:57:04 -0700 X-CSE-ConnectionGUID: Fvu/tgKNTg6XJ+hFgrzXuQ== X-CSE-MsgGUID: T2WtWuU5RH2/r/0S2H90/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144521" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:57:02 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:57:01 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 5/7] drm/i915: Move intel_crtc_scanline_offset() Date: Tue, 28 May 2024 21:56:45 +0300 Message-ID: <20240528185647.7765-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä I want to use intel_crtc_scanline_offset() in intel_crtc_scanline_to_hw(). Relocate intel_crtc_scanline_offset() a bit to avoid a forward declaration. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_vblank.c | 76 ++++++++++----------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index b0e95a4c680d..eb80952b0cfd 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -188,6 +188,44 @@ static u32 __intel_get_crtc_scanline_from_timestamp(struct intel_crtc *crtc) return scanline; } +static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) +{ + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); + + /* + * The scanline counter increments at the leading edge of hsync. + * + * On most platforms it starts counting from vtotal-1 on the + * first active line. That means the scanline counter value is + * always one less than what we would expect. Ie. just after + * start of vblank, which also occurs at start of hsync (on the + * last active line), the scanline counter will read vblank_start-1. + * + * On gen2 the scanline counter starts counting from 1 instead + * of vtotal-1, so we have to subtract one. + * + * On HSW+ the behaviour of the scanline counter depends on the output + * type. For DP ports it behaves like most other platforms, but on HDMI + * there's an extra 1 line difference. So we need to add two instead of + * one to the value. + * + * On VLV/CHV DSI the scanline counter would appear to increment + * approx. 1/3 of a scanline before start of vblank. Unfortunately + * that means we can't tell whether we're in vblank or not while + * we're on that particular line. We must still set scanline_offset + * to 1 so that the vblank timestamps come out correct when we query + * the scanline counter from within the vblank interrupt handler. + * However if queried just before the start of vblank we'll get an + * answer that's slightly in the future. + */ + if (DISPLAY_VER(i915) == 2) + return -1; + else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) + return 2; + else + return 1; +} + /* * intel_de_read_fw(), only for fast reads of display block, no need for * forcewake etc. @@ -467,44 +505,6 @@ void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc) wait_for_pipe_scanline_moving(crtc, true); } -static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) -{ - struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); - - /* - * The scanline counter increments at the leading edge of hsync. - * - * On most platforms it starts counting from vtotal-1 on the - * first active line. That means the scanline counter value is - * always one less than what we would expect. Ie. just after - * start of vblank, which also occurs at start of hsync (on the - * last active line), the scanline counter will read vblank_start-1. - * - * On gen2 the scanline counter starts counting from 1 instead - * of vtotal-1, so we have to subtract one. - * - * On HSW+ the behaviour of the scanline counter depends on the output - * type. For DP ports it behaves like most other platforms, but on HDMI - * there's an extra 1 line difference. So we need to add two instead of - * one to the value. - * - * On VLV/CHV DSI the scanline counter would appear to increment - * approx. 1/3 of a scanline before start of vblank. Unfortunately - * that means we can't tell whether we're in vblank or not while - * we're on that particular line. We must still set scanline_offset - * to 1 so that the vblank timestamps come out correct when we query - * the scanline counter from within the vblank interrupt handler. - * However if queried just before the start of vblank we'll get an - * answer that's slightly in the future. - */ - if (DISPLAY_VER(i915) == 2) - return -1; - else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) - return 2; - else - return 1; -} - void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, bool vrr_enable) { From patchwork Tue May 28 18:56:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677098 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 5E6E7C25B78 for ; Tue, 28 May 2024 18:57:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D4E0310F088; Tue, 28 May 2024 18:57:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="aCQNgZKS"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3CE010EE46 for ; Tue, 28 May 2024 18:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716922627; x=1748458627; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=/qsooOdsPNXa+TL/is71rnSX7gSOp9U1GnXld313cG4=; b=aCQNgZKSyHaTfQAKzlcm+tt02OmG32/wpyuATtyXy5pnKCdtL8br95dE g40Sv3RwdapqMjPeaIxjopsW7ObIRRPHiwmyh6G9ap8fidTUHxjELcwzZ /pRJsiGqbOGnRk2sl1ZJNq7AOVanKVPiHW5oX+dBM3vAd/YaycO64O52p nsMFNAGdZFM/4ReFse/eMJfCnmT+wQHDFDHcKBflc99/Cst9bJjMe/UfI FkqGXw5hUN/j9Hbg9SVs8LXeLl8SHRDyUYAMh2I1sEpmXu+qd7FfWvZEo E+JdWdpAXP0DjfyKDpvWDMdJnQP0MEIf2shkPOTP4HQAwgZ8Nj/g+wETL Q==; X-CSE-ConnectionGUID: TzYe3GgFRU+OXegpLarMVg== X-CSE-MsgGUID: nHdAAPc/R22gEvHVzzXB0g== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815257" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815257" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:57:06 -0700 X-CSE-ConnectionGUID: vrH7ZKHzSA+80fWahwKMRA== X-CSE-MsgGUID: +w2OzbfWR8Kd+k4w+S+UFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144569" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:57:05 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:57:04 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 6/7] drm/i915: Switch intel_usecs_to_scanlines() to 64bit maths Date: Tue, 28 May 2024 21:56:46 +0300 Message-ID: <20240528185647.7765-7-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä Dotclocks can reach ~1GHz these days, so intel_usecs_to_scanlines(), with its 32bit maths, is currently limited to a few milliseconds. I want bigger numbers in DSB selftests, so switch over to 64bit maths. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c index ca6dc1dc56c8..17edd6099287 100644 --- a/drivers/gpu/drm/i915/display/intel_crtc.c +++ b/drivers/gpu/drm/i915/display/intel_crtc.c @@ -454,8 +454,8 @@ int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode, if (!adjusted_mode->crtc_htotal) return 1; - return DIV_ROUND_UP(usecs * adjusted_mode->crtc_clock, - 1000 * adjusted_mode->crtc_htotal); + return DIV_ROUND_UP_ULL(mul_u32_u32(usecs, adjusted_mode->crtc_clock), + 1000 * adjusted_mode->crtc_htotal); } /** From patchwork Tue May 28 18:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 13677097 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 B3BF6C25B78 for ; Tue, 28 May 2024 18:57:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1959610EE46; Tue, 28 May 2024 18:57:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="kYgYTvcS"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEA7C10E8BE for ; Tue, 28 May 2024 18:57: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=1716922631; x=1748458631; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=bE09i4XJLxJZvNFXCe67KmaxqxDWOoS56vTGi+NSTQg=; b=kYgYTvcSa+sb6GgfjHv9zD9Upce3kpcsQuIMeMcKJELr9HPGkEfd6Zce JulQ0Q8iwhH9iXUTbiSvvQC9Ezcma5Rt5MZSGmb+gkeI+bYeLUVEqFqCE n2Jjyznzz3EVR0hg65yc+Tm+rlCNseYdURtLLsfb3OKhoQ4yb60ADZTfR Ri0F9yhAEJfS0132QHXenERacnSfbeWe/N1zphHRJDdzY4xoCR5GGBOHb LC7omt9hL/qGcQSrQboMul3bDKJNzwVl2dw9x4r4LwkjvEBgynNuGSKLv YBc97mlMpZSe9Oey2l164Vt4grYVbkvc5ZWgImbnjMSqVMEI5vOsm4UoV A==; X-CSE-ConnectionGUID: CGbsBVaCQ6SJpAr8Jnr7LA== X-CSE-MsgGUID: ZgcL1ZviTCabMppj17WhJQ== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="35815277" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35815277" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 11:57:09 -0700 X-CSE-ConnectionGUID: 62dvfN/PR5GpSeyO6ohdMg== X-CSE-MsgGUID: 8wFJg9DrTTWH3APQkXlLjg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="35144582" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by fmviesa008.fm.intel.com with SMTP; 28 May 2024 11:57:07 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 28 May 2024 21:57:06 +0300 From: Ville Syrjala To: intel-gfx@lists.freedesktop.org Subject: [PATCH 7/7] drm/i915/dsb: Convert dewake_scanline to a hw scanline number earlier Date: Tue, 28 May 2024 21:56:47 +0300 Message-ID: <20240528185647.7765-8-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240528185647.7765-1-ville.syrjala@linux.intel.com> References: <20240528185647.7765-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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" From: Ville Syrjälä Currently we switch from out software idea of a scanline to the hw's idea of a scanline during the commit phase in _intel_dsb_commit(). While that is slightly easier due to fastsets fiddling with the timings, we'll also need to generate proper hw scanline numbers already when emitting DSB scanline wait instructions. So this approach won't do in the future. Switch to hw scanline numbers earlier. Also intel_dsb_dewake_scanline() itself already makes some assumptions about VRR that don't take into account VRR toggling during fastsets, so technically delaying the sw->hw conversion doesn't even help us. The other reason for delaying the conversion was that we are using intel_get_crtc_scanline() during intel_dsb_commit() which gives us the current sw scanline. But this is pretty low level stuff anyway so just using raw PIPEDSL reads seems fine here, and that of course gives us the hw scanline directly, reducing the need to do so many conversions. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_dsb.c | 16 +++++++++------- drivers/gpu/drm/i915/display/intel_vblank.c | 9 ++++----- drivers/gpu/drm/i915/display/intel_vblank.h | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c index 319fbebd7008..63268ed2e53f 100644 --- a/drivers/gpu/drm/i915/display/intel_dsb.c +++ b/drivers/gpu/drm/i915/display/intel_dsb.c @@ -326,14 +326,16 @@ static int intel_dsb_dewake_scanline(const struct intel_crtc_state *crtc_state) struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; unsigned int latency = skl_watermark_max_latency(i915, 0); - int vblank_start; + int vblank_start, dewake_scanline; if (crtc_state->vrr.enable) vblank_start = intel_vrr_vmin_vblank_start(crtc_state); else vblank_start = intel_mode_vblank_start(adjusted_mode); - return max(0, vblank_start - intel_usecs_to_scanlines(adjusted_mode, latency)); + dewake_scanline = max(0, vblank_start - intel_usecs_to_scanlines(adjusted_mode, latency)); + + return intel_crtc_scanline_to_hw(crtc_state, dewake_scanline); } static u32 dsb_chicken(struct intel_crtc *crtc) @@ -376,19 +378,19 @@ static void _intel_dsb_commit(struct intel_dsb *dsb, u32 ctrl, intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf)); if (dewake_scanline >= 0) { - int diff, hw_dewake_scanline; - - hw_dewake_scanline = intel_crtc_scanline_to_hw(crtc, dewake_scanline); + int diff, position; intel_de_write_fw(dev_priv, DSB_PMCTRL(pipe, dsb->id), DSB_ENABLE_DEWAKE | - DSB_SCANLINE_FOR_DEWAKE(hw_dewake_scanline)); + DSB_SCANLINE_FOR_DEWAKE(dewake_scanline)); /* * Force DEwake immediately if we're already past * or close to racing past the target scanline. */ - diff = dewake_scanline - intel_get_crtc_scanline(crtc); + position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK; + diff = dewake_scanline - position; + intel_de_write_fw(dev_priv, DSB_PMCTRL_2(pipe, dsb->id), (diff >= 0 && diff < 5 ? DSB_FORCE_DEWAKE : 0) | DSB_BLOCK_DEWAKE_EXTENSION); diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index eb80952b0cfd..2e3442fe5a5d 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -281,13 +281,12 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) return (position + vtotal + crtc->scanline_offset) % vtotal; } -int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) +int intel_crtc_scanline_to_hw(const struct intel_crtc_state *crtc_state, + int scanline) { - const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); - const struct drm_display_mode *mode = &vblank->hwmode; - int vtotal = intel_mode_vtotal(mode); + int vtotal = intel_mode_vtotal(&crtc_state->hw.adjusted_mode); - return (scanline + vtotal - crtc->scanline_offset) % vtotal; + return (scanline + vtotal - intel_crtc_scanline_offset(crtc_state)) % vtotal; } /* diff --git a/drivers/gpu/drm/i915/display/intel_vblank.h b/drivers/gpu/drm/i915/display/intel_vblank.h index b51ae2c1039e..b5b8bcbf0bf0 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.h +++ b/drivers/gpu/drm/i915/display/intel_vblank.h @@ -39,6 +39,7 @@ void intel_wait_for_pipe_scanline_stopped(struct intel_crtc *crtc); void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc); void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, bool vrr_enable); -int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline); +int intel_crtc_scanline_to_hw(const struct intel_crtc_state *crtc_state, + int scanline); #endif /* __INTEL_VBLANK_H__ */