Stable Archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lijo Lazar <lijo.lazar@amd.com>, Asad Kamal <asad.kamal@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Sasha Levin <sashal@kernel.org>,
	evan.quan@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com,
	airlied@gmail.com, daniel@ffwll.ch, Hawking.Zhang@amd.com,
	kevinyang.wang@amd.com, le.ma@amd.com,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 6.6 09/19] drm/amd/pm: Restore config space after reset
Date: Tue,  7 May 2024 18:58:31 -0400	[thread overview]
Message-ID: <20240507225910.390914-9-sashal@kernel.org> (raw)
In-Reply-To: <20240507225910.390914-1-sashal@kernel.org>

From: Lijo Lazar <lijo.lazar@amd.com>

[ Upstream commit 30d1cda8ce31ab49051ff7159280c542a738b23d ]

During mode-2 reset, pci config space registers are affected at device
side. However, certain platforms have switches which assign virtual BAR
addresses and returns the same even after device is reset. This
affects pci_restore_state() as it doesn't issue another config write, if
the value read is same as the saved value.

Add a workaround to write saved config space values from driver side.
Presently, these switches are in platforms with SMU v13.0.6 SOCs, hence
restrict the workaround only to those.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 6a28f8d5bff7d..be4b7b64f8785 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -2039,6 +2039,17 @@ static ssize_t smu_v13_0_6_get_gpu_metrics(struct smu_context *smu, void **table
 	return sizeof(struct gpu_metrics_v1_3);
 }
 
+static void smu_v13_0_6_restore_pci_config(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+	int i;
+
+	for (i = 0; i < 16; i++)
+		pci_write_config_dword(adev->pdev, i * 4,
+				       adev->pdev->saved_config_space[i]);
+	pci_restore_msi_state(adev->pdev);
+}
+
 static int smu_v13_0_6_mode2_reset(struct smu_context *smu)
 {
 	int ret = 0, index;
@@ -2060,6 +2071,20 @@ static int smu_v13_0_6_mode2_reset(struct smu_context *smu)
 	/* Restore the config space saved during init */
 	amdgpu_device_load_pci_state(adev->pdev);
 
+	/* Certain platforms have switches which assign virtual BAR values to
+	 * devices. OS uses the virtual BAR values and device behind the switch
+	 * is assgined another BAR value. When device's config space registers
+	 * are queried, switch returns the virtual BAR values. When mode-2 reset
+	 * is performed, switch is unaware of it, and will continue to return
+	 * the same virtual values to the OS.This affects
+	 * pci_restore_config_space() API as it doesn't write the value saved if
+	 * the current value read from config space is the same as what is
+	 * saved. As a workaround, make sure the config space is restored
+	 * always.
+	 */
+	if (!(adev->flags & AMD_IS_APU))
+		smu_v13_0_6_restore_pci_config(smu);
+
 	dev_dbg(smu->adev->dev, "wait for reset ack\n");
 	do {
 		ret = smu_cmn_wait_for_response(smu);
-- 
2.43.0


  parent reply	other threads:[~2024-05-07 22:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07 22:58 [PATCH AUTOSEL 6.6 01/19] wifi: mac80211: don't use rate mask for scanning Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 02/19] wifi: mac80211: ensure beacon is non-S1G prior to extracting the beacon timestamp field Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 03/19] wifi: cfg80211: fix the order of arguments for trace events of the tx_rx_evt class Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 04/19] dt-bindings: rockchip: grf: Add missing type to 'pcie-phy' node Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 05/19] HID: mcp-2221: cancel delayed_work only when CONFIG_IIO is enabled Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 06/19] net: usb: qmi_wwan: add Telit FN920C04 compositions Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 07/19] drm/amd/display: Set color_mgmt_changed to true on unsuspend Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 08/19] drm/amdgpu: Update BO eviction priorities Sasha Levin
2024-05-07 22:58 ` Sasha Levin [this message]
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 10/19] drm/amdkfd: Add VRAM accounting for SVM migration Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 11/19] drm/amdgpu: Fix the ring buffer size for queue VM flush Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 12/19] drm/amdgpu/mes: fix use-after-free issue Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 13/19] Revert "net: txgbe: fix i2c dev name cannot match clkdev" Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 14/19] Revert "net: txgbe: fix clk_name exceed MAX_DEV_ID limits" Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 15/19] cpu: Ignore "mitigations" kernel parameter if CPU_MITIGATIONS=n Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 16/19] LoongArch: Lately init pmu after smp is online Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 17/19] drm/etnaviv: fix tx clock gating on some GC7000 variants Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 18/19] selftests: sud_test: return correct emulated syscall value on RISC-V Sasha Levin
2024-05-07 22:58 ` [PATCH AUTOSEL 6.6 19/19] sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU Sasha Levin

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=20240507225910.390914-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Hawking.Zhang@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=asad.kamal@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=evan.quan@amd.com \
    --cc=kevinyang.wang@amd.com \
    --cc=le.ma@amd.com \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).