Skip to content

Commit 30d1cda

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amd/pm: Restore config space after reset
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 <[email protected]> Reviewed-by: Asad Kamal <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 661d71e commit 30d1cda

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,17 @@ static ssize_t smu_v13_0_6_get_gpu_metrics(struct smu_context *smu, void **table
22942294
return sizeof(*gpu_metrics);
22952295
}
22962296

2297+
static void smu_v13_0_6_restore_pci_config(struct smu_context *smu)
2298+
{
2299+
struct amdgpu_device *adev = smu->adev;
2300+
int i;
2301+
2302+
for (i = 0; i < 16; i++)
2303+
pci_write_config_dword(adev->pdev, i * 4,
2304+
adev->pdev->saved_config_space[i]);
2305+
pci_restore_msi_state(adev->pdev);
2306+
}
2307+
22972308
static int smu_v13_0_6_mode2_reset(struct smu_context *smu)
22982309
{
22992310
int ret = 0, index;
@@ -2315,6 +2326,20 @@ static int smu_v13_0_6_mode2_reset(struct smu_context *smu)
23152326
/* Restore the config space saved during init */
23162327
amdgpu_device_load_pci_state(adev->pdev);
23172328

2329+
/* Certain platforms have switches which assign virtual BAR values to
2330+
* devices. OS uses the virtual BAR values and device behind the switch
2331+
* is assgined another BAR value. When device's config space registers
2332+
* are queried, switch returns the virtual BAR values. When mode-2 reset
2333+
* is performed, switch is unaware of it, and will continue to return
2334+
* the same virtual values to the OS.This affects
2335+
* pci_restore_config_space() API as it doesn't write the value saved if
2336+
* the current value read from config space is the same as what is
2337+
* saved. As a workaround, make sure the config space is restored
2338+
* always.
2339+
*/
2340+
if (!(adev->flags & AMD_IS_APU))
2341+
smu_v13_0_6_restore_pci_config(smu);
2342+
23182343
dev_dbg(smu->adev->dev, "wait for reset ack\n");
23192344
do {
23202345
ret = smu_cmn_wait_for_response(smu);

0 commit comments

Comments
 (0)