All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
	Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
	James Lin <PingLei.Lin@amd.com>,
	Chenyu Chen <Chen-Yu.Chen@amd.com>
Subject: [PATCH 07/28] drm/amd/display: Configure alternate-channel apertures
Date: Tue, 27 Oct 2026 17:17:03 -0600	[thread overview]
Message-ID: <20261027232005.2879750-8-alex.hung@amd.com> (raw)
In-Reply-To: <20261027232005.2879750-1-alex.hung@amd.com>

From: Ivan Lipski <ivan.lipski@amd.com>

[WHY]
Alternate channel P-State switching enables in-frame P-State changes by
streaming scanout from carved DRAM apertures on one memory channel set
while the other is optimized.

[HOW]
Read both aperture regions from IP discovery, translate their
addresses for DMUB and DML2, and populate their base and size fields.

Cc: Sun peng (Leo) Li <sunpeng.li@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_dmub.c    | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c
index b0325d686b28..614709fe11a6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c
@@ -160,6 +160,68 @@ bool dm_register_dmub_notify_callback(struct amdgpu_device *adev,
 }
 EXPORT_IF_KUNIT(dm_register_dmub_notify_callback);
 
+
+/**
+ * dm_get_alt_channel_pstate_switch_aperture - Set the vactive p-state switch apertures.
+ * @adev: amdgpu device containing the discovered apertures
+ * @hw_params: DMUB hardware parameters to populate
+ *
+ * Reads both apertures before populating the DMUB parameters and DML2 config.
+ * Translates their base addresses into MC space for DML2. If either aperture
+ * is unavailable, the feature remains disabled.
+ */
+static void
+dm_get_alt_channel_pstate_switch_aperture(struct amdgpu_device *adev,
+					   struct dmub_srv_hw_params *hw_params)
+{
+	static const u32 region_ids[] = {
+		G7_PSTATE_APERTURE1_ID,
+		G7_PSTATE_APERTURE2_ID,
+	};
+	struct mem_reserved_info apertures[ARRAY_SIZE(region_ids)];
+	u64 aperture_mc_bases[ARRAY_SIZE(region_ids)];
+	u32 i;
+	int r;
+
+	/* Region IDs 5 and 6 identify the p-state switch apertures 1 and 2.
+	 * Do not publish partial aperture configuration if either lookup fails.
+	 */
+	for (i = 0; i < ARRAY_SIZE(region_ids); i++) {
+		r = amdgpu_discovery_get_mem_reserved_region_by_id(adev,
+								region_ids[i], &apertures[i]);
+		if (r) {
+			drm_warn(adev_to_drm(adev),
+				 "P-state switching during vactive unavailable: aperture %u lookup failed (%d)\n",
+				 region_ids[i], r);
+			return;
+		}
+
+		if (!apertures[i].reserved_region_size ||
+		    apertures[i].reserved_region_size >= (0xfffULL << 20)) {
+			drm_warn(adev_to_drm(adev),
+				 "P-state switching during vactive unavailable: aperture %u has invalid size\n",
+				 region_ids[i]);
+			return;
+		}
+
+		/* DML2 requires the reserved-region base in MC address space. */
+		aperture_mc_bases[i] = apertures[i].reserved_region_start +
+			adev->gmc.fb_start - adev->vm_manager.vram_base_offset;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(region_ids); i++) {
+		hw_params->soc_fb_info.alt_channel_region_base[i] = aperture_mc_bases[i];
+		hw_params->soc_fb_info.alt_channel_region_size[i] =
+			apertures[i].reserved_region_size;
+		/* DML consumes the MC base address bits [47:16]. */
+		adev->dm.dc->dml2_options.alt_ch_cfg.region_base_addr_47_16[i] =
+				(u32)(aperture_mc_bases[i] >> 16);
+		adev->dm.dc->dml2_options.alt_ch_cfg.region_size_bytes[i] =
+				(u32)apertures[i].reserved_region_size;
+	}
+}
+
+
 int dm_dmub_hw_init(struct amdgpu_device *adev)
 {
 	const struct dmcub_firmware_header_v1_0 *hdr;
@@ -261,6 +323,7 @@ int dm_dmub_hw_init(struct amdgpu_device *adev)
 	memset(&hw_params, 0, sizeof(hw_params));
 	hw_params.soc_fb_info.fb_base = adev->gmc.fb_start;
 	hw_params.soc_fb_info.fb_offset = adev->vm_manager.vram_base_offset;
+	dm_get_alt_channel_pstate_switch_aperture(adev, &hw_params);
 
 	/* backdoor load firmware and trigger dmub running */
 	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-- 
2.53.0


  parent reply	other threads:[~2026-10-27 23:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 23:16 [PATCH 00/28] DC Patches Oct 27, 2026 Alex Hung
2026-10-27 23:16 ` [PATCH 01/28] drm/amd/display: Use DCN6 driver_if for PPCLK_e enum Alex Hung
2026-10-27 23:16 ` [PATCH 02/28] drm/amd/display: Allow bypassing link_off_frame_count check for replay debug mode Alex Hung
2026-10-27 23:16 ` [PATCH 03/28] drm/amd/display: Clarify endianness error Alex Hung
2026-10-27 23:17 ` [PATCH 04/28] drm/amd/display: Add visual confirm full viewport debug option Alex Hung
2026-10-27 23:17 ` [PATCH 05/28] drm/amd/display: Remove DCN401 RDPCS PHY state reads Alex Hung
2026-10-27 23:17 ` [PATCH 06/28] drm/amd/display: Adjust DSC slice calc. policy Alex Hung
2026-10-27 23:17 ` Alex Hung [this message]
2026-10-27 23:17 ` [PATCH 08/28] drm/amd/display: Avoid closing unowned DDC pins Alex Hung
2026-10-27 23:17 ` [PATCH 09/28] drm/amd/display: Support replay frame update interval Alex Hung
2026-10-27 23:17 ` [PATCH 10/28] drm/amd/display: Indicate wait_resp based on FAMS even in disable path Alex Hung
2026-10-27 23:17 ` [PATCH 11/28] drm/amd/display: Update Rounding For VM stage groups Alex Hung
2026-10-27 23:17 ` [PATCH 12/28] drm/amd/display: Fix unadvertised mode detection Alex Hung
2026-10-27 23:17 ` [PATCH 13/28] drm/amd/display: Parameterize FCLK/PPT/Temp Read P-State Optimizer Alex Hung
2026-10-27 23:17 ` [PATCH 14/28] drm/amd/display: Reset DET of HUBPs without a plane before outstanding updates Alex Hung
2026-10-27 23:17 ` [PATCH 15/28] drm/amd/display: Decouple FAMS2 config update from dc/dc_state and add BLS opcode Alex Hung
2026-10-27 23:17 ` [PATCH 16/28] drm/amd/display: Add missing OTG_CRC1 reg/mask entries for DCN3.1.4 Alex Hung
2026-10-27 23:17 ` [PATCH 17/28] drm/amd/display: Add missing OTG_CRC1 reg/mask entries for DCN3.1.2 Alex Hung
2026-10-27 23:17 ` [PATCH 18/28] drm/amd/display: Skip dsc sequence for stream if dpms off Alex Hung
2026-10-27 23:17 ` [PATCH 19/28] drm/amd/display: Add debugfs override for HDMI VRR Alex Hung
2026-10-27 23:17 ` [PATCH 20/28] drm/amd/display: Enable immediate restore for FAMS on DCN6 Alex Hung
2026-10-27 23:17 ` [PATCH 21/28] drm/amd/display: Expand DSCCLK support check Alex Hung
2026-10-27 23:17 ` [PATCH 22/28] drm/amd/display: Add more backlight Kunit tests Alex Hung
2026-10-27 23:17 ` [PATCH 23/28] drm/amd/display: Add more color KUnit tests Alex Hung
2026-10-27 23:17 ` [PATCH 24/28] drm/amd/display: Add more CRC " Alex Hung
2026-10-27 23:17 ` [PATCH 25/28] drm/amd/display: Add more connector " Alex Hung
2026-10-27 23:17 ` [PATCH 26/28] drm/amd/display: Update alt shared lib to use dynamic state Alex Hung
2026-10-27 23:17 ` [PATCH 27/28] drm/amd/display: [FW Promotion] Release 0.1.82.0 Alex Hung
2026-10-27 23:17 ` [PATCH 28/28] drm/amd/display: Promote DC to 3.2.405 Alex Hung
2026-10-30 15:42 ` [PATCH 00/28] DC Patches Oct 27, 2026 Leo Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027232005.2879750-8-alex.hung@amd.com \
    --to=alex.hung@amd.com \
    --cc=Chen-Yu.Chen@amd.com \
    --cc=PingLei.Lin@amd.com \
    --cc=Ray.Wu@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.