Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp434571rdb; Mon, 22 Jan 2024 08:35:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IExnihatnurTmeSltB3Vpd+83npt6ICMdAH4rB8osQBZRerTQu54Kh+goCLGJ9/ReIjWTL/ X-Received: by 2002:a05:6a21:3103:b0:19b:68d6:47eb with SMTP id yz3-20020a056a21310300b0019b68d647ebmr7215957pzb.12.1705941344173; Mon, 22 Jan 2024 08:35:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705941344; cv=pass; d=google.com; s=arc-20160816; b=skliwl+RU0cGlZwS+uWl4z/QuZYvmda9NUGsduo1WChnxIK/TXKYLvdcDDd8ucT4eX KGBsIcTRfRtq18vQl/i8PYX4NvhEeCiAIwv2JNomR66ostJ+FjoyvSTZIJC3H73mLThu QyoxD7ffjOgtpJy2uCBBxVZKZ7ZPYCkZNq0N7cl7Mw+SNAyoJSCaxeHU787c7T2jnZ7k W866iVRk7n5CgfW6FcQdqF4YsnG+epbiU/OAhBWNhbk7+CD7tZUyVJQnkZDncpHGlPC/ +wZrgxmWQSQGet2Of4pVey0Lz+7mOBFyOE6UsdKc3bLamnPj5CqnBXUULyPg2JASJQ/X 4dpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=H5eITV5XPQRnXrKrM8Wk5na3SYx8i8V6Q+KAPbE4KwU=; fh=PhfDbAQtt6gYkU8hRoutjZ62Qp/ApGctOs2UphC/G80=; b=ZyBdcAcEBiwnPbhPMfePvwCo/FjvkzzCfKzyVwumeTuUv/Wk/Gpnyq+dbw1sy/SsCo XUylW24R6JdldMgYyqLeEdNNayhcrBtLWqU03mH/wIFBu4XDV9LaLRDp/usL8RGnTz45 DBcnYNHqsoBOph4kcu7Ks62ql3J7Y2wBXTMsa7ktlzfWlYYYR7MOEU5Mjwq1+70FUE7p zS58byTTldzoPe+7aKqLssDkBr2rmVw2frIZy6PYJUgOaq9C5ztc/QwxBpcrPydxWzhm 7dhvt6JxnuCaOtq8PPrkDcU+r6Fwdj5Wu6pQNSxdHH/5HuasEJe9cAgVKQjUn/wt47Q6 6g2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Bf6d/CG3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33436-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n38-20020a634d66000000b005cec854edacsi8129654pgl.371.2024.01.22.08.35.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 08:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33436-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Bf6d/CG3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33436-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D139FB25D6C for ; Mon, 22 Jan 2024 16:08:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEC593EA8E; Mon, 22 Jan 2024 15:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bf6d/CG3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B782A3F8C2; Mon, 22 Jan 2024 15:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936283; cv=none; b=hvEpp+HjbMMU5reAQiGgVIoxZomtcEyYrKrlmKKSP8fkOEIK9yWWYBJTuWUCsSm+lnBO8MGgZ2LgBOYuTHiV2oQNIZmLgQp4rwhVcOJslTuC0twTTgAXEq2qSvt2welsprbuV5i34ZGFXZhrWJk3IHuWbKGiC85kDQ25pesnxko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936283; c=relaxed/simple; bh=PP7MnsU8r66tscKqn/gDwHVvvt4DQEWEcE/k6anhdSg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rrsrD9ezmMBsCnEttsiNfmtBpy2YENAL4nDWKPQoPjZlEvNebH7udUPkmHciEzuhWMzkzb6nZUjKfmX+fmM8mS0LNJGmDT0p3x6AMUgK2ypx2tUkpevxHg5LJjoID0QYBo5iLPRiioLFHwDfJD0QWhff9zvnqVS1j0UOlWzWXTU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bf6d/CG3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DE40C43390; Mon, 22 Jan 2024 15:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705936283; bh=PP7MnsU8r66tscKqn/gDwHVvvt4DQEWEcE/k6anhdSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bf6d/CG3c/XATGFHzSzw6KsO9IcGVB2svprsKe0tybztvYUg8qESdt/w/AyN8+Yrl Dve1cukW7MDSa4ORtCYav9mkV1htGZFiYb0xPr4dtUKVFleNwMLkynolxrwDWd5CTd RTBpUh5I873MHcTaRfaMxJA8PqauXATVmVruBaSxWsrmaBlddYX4f+XMBTgBymieMX fz4naPwlcJFi2BiHvUzZSfzHOu0rockmfu+kw/quuVYQ4k6dSIYg3pi3cMNlOxn835 7+5dFt7VWbFxGSUu14rvdolYtuCFMn5zhgBrm8xxD/NQEIBOcuTYtWIWOmheaSEEjB 9Qun6hSDKBejw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alvin Lee , Jun Lei , Aurabindo Pillai , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, nevenko.stupar@amd.com, qingqing.zhuo@amd.com, Ilya.Bakoulin@amd.com, Paul.Hsieh@amd.com, drv@mailo.com, wenjing.liu@amd.com, hanghong.ma@amd.com, srinivasan.shanmugam@amd.com, Dillon.Varone@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.1 35/53] drm/amd/display: For prefetch mode > 0, extend prefetch if possible Date: Mon, 22 Jan 2024 10:08:36 -0500 Message-ID: <20240122150949.994249-35-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122150949.994249-1-sashal@kernel.org> References: <20240122150949.994249-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.74 Content-Transfer-Encoding: 8bit From: Alvin Lee [ Upstream commit dd4e4bb28843393065eed279e869fac248d03f0f ] [Description] For mode programming we want to extend the prefetch as much as possible (up to oto, or as long as we can for equ) if we're not already applying the 60us prefetch requirement. This is to avoid intermittent underflow issues during prefetch. The prefetch extension is applied under the following scenarios: 1. We're in prefetch mode 1 (i.e. we don't support MCLK switch in blank) 2. We're using subvp or drr methods of p-state switch, in which case we we don't care if prefetch takes up more of the blanking time Mode programming typically chooses the smallest prefetch time possible (i.e. highest bandwidth during prefetch) presumably to create margin between p-states / c-states that happen in vblank and prefetch. Therefore we only apply this prefetch extension when p-state in vblank is not required (UCLK p-states take up the most vblank time). Reviewed-by: Jun Lei Acked-by: Aurabindo Pillai Signed-off-by: Alvin Lee Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../dc/dml/dcn32/display_mode_vba_32.c | 3 ++ .../dc/dml/dcn32/display_mode_vba_util_32.c | 33 +++++++++++++++---- .../dc/dml/dcn32/display_mode_vba_util_32.h | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c index 19f55657272e..cc8c1a48c5c4 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c @@ -810,6 +810,8 @@ static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerforman (v->DRAMSpeedPerState[mode_lib->vba.VoltageLevel] <= MEM_STROBE_FREQ_MHZ || v->DCFCLKPerState[mode_lib->vba.VoltageLevel] <= DCFCLK_FREQ_EXTRA_PREFETCH_REQ_MHZ) ? mode_lib->vba.ip.min_prefetch_in_strobe_us : 0, + mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] > 0 || mode_lib->vba.DRAMClockChangeRequirementFinal == false, + /* Output */ &v->DSTXAfterScaler[k], &v->DSTYAfterScaler[k], @@ -3291,6 +3293,7 @@ void dml32_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l v->SwathHeightCThisState[k], v->TWait, (v->DRAMSpeedPerState[i] <= MEM_STROBE_FREQ_MHZ || v->DCFCLKState[i][j] <= DCFCLK_FREQ_EXTRA_PREFETCH_REQ_MHZ) ? mode_lib->vba.ip.min_prefetch_in_strobe_us : 0, + mode_lib->vba.PrefetchModePerState[i][j] > 0 || mode_lib->vba.DRAMClockChangeRequirementFinal == false, /* Output */ &v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.DSTXAfterScaler[k], diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c index 23e4be2ad63f..7f4fc49be35c 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c @@ -3418,6 +3418,7 @@ bool dml32_CalculatePrefetchSchedule( unsigned int SwathHeightC, double TWait, double TPreReq, + bool ExtendPrefetchIfPossible, /* Output */ double *DSTXAfterScaler, double *DSTYAfterScaler, @@ -3887,12 +3888,32 @@ bool dml32_CalculatePrefetchSchedule( /* Clamp to oto for bandwidth calculation */ LinesForPrefetchBandwidth = dst_y_prefetch_oto; } else { - *DestinationLinesForPrefetch = dst_y_prefetch_equ; - TimeForFetchingMetaPTE = Tvm_equ; - TimeForFetchingRowInVBlank = Tr0_equ; - *PrefetchBandwidth = prefetch_bw_equ; - /* Clamp to equ for bandwidth calculation */ - LinesForPrefetchBandwidth = dst_y_prefetch_equ; + /* For mode programming we want to extend the prefetch as much as possible + * (up to oto, or as long as we can for equ) if we're not already applying + * the 60us prefetch requirement. This is to avoid intermittent underflow + * issues during prefetch. + * + * The prefetch extension is applied under the following scenarios: + * 1. We're in prefetch mode > 0 (i.e. we don't support MCLK switch in blank) + * 2. We're using subvp or drr methods of p-state switch, in which case we + * we don't care if prefetch takes up more of the blanking time + * + * Mode programming typically chooses the smallest prefetch time possible + * (i.e. highest bandwidth during prefetch) presumably to create margin between + * p-states / c-states that happen in vblank and prefetch. Therefore we only + * apply this prefetch extension when p-state in vblank is not required (UCLK + * p-states take up the most vblank time). + */ + if (ExtendPrefetchIfPossible && TPreReq == 0 && VStartup < MaxVStartup) { + MyError = true; + } else { + *DestinationLinesForPrefetch = dst_y_prefetch_equ; + TimeForFetchingMetaPTE = Tvm_equ; + TimeForFetchingRowInVBlank = Tr0_equ; + *PrefetchBandwidth = prefetch_bw_equ; + /* Clamp to equ for bandwidth calculation */ + LinesForPrefetchBandwidth = dst_y_prefetch_equ; + } } *DestinationLinesToRequestVMInVBlank = dml_ceil(4.0 * TimeForFetchingMetaPTE / LineTime, 1.0) / 4.0; diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.h b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.h index 779c6805f599..1823434d8ede 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.h +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.h @@ -744,6 +744,7 @@ bool dml32_CalculatePrefetchSchedule( unsigned int SwathHeightC, double TWait, double TPreReq, + bool ExtendPrefetchIfPossible, /* Output */ double *DSTXAfterScaler, double *DSTYAfterScaler, -- 2.43.0