Skip to contentSkip to conversation

drm/amdgpu: only save and restore GPU device config at GPU error

PATCH In review Prike Liang 2 participants 3 messages Jul 27, 2023 – Jul 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: only save and restore GPU device config at GPU error

There's need a check on the GPU error state before save and restore GPU device config space.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index 358dcc1070c5..5ef3c5c49bee 100644
@@ -3946,7 +3946,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 		dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
 	/* Have stored pci confspace at hand for restore in sudden PCI error */
-	if (amdgpu_device_cache_pci_state(adev->pdev))
+	if (adev->pdev->error_state != pci_channel_io_normal &&
+			amdgpu_device_cache_pci_state(adev->pdev))
 		pci_restore_state(pdev);
 
 	/* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 13 lines · Prike Liang

There's need a check on the GPU error state before save and restore GPU device config space.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 358dcc1070c5..5ef3c5c49bee 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 3950

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -3946,7 +3946,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  		dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
  	/* Have stored pci confspace at hand for restore in sudden PCI error */
-	if (amdgpu_device_cache_pci_state(adev->pdev))
+	if (adev->pdev->error_state != pci_channel_io_normal &&
+			amdgpu_device_cache_pci_state(adev->pdev))

We need the clean state to be cached, not the state when there is an error. This state is later used to restore later, say when a mode-2 reset happens.

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
  		pci_restore_state(pdev);
 
  	/* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
#2 lore raw

[Public]

Hi, Lijo

Quoted 34 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, July 27, 2023 6:49 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: only save and restore GPU device config at GPU error

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 14 lines · Prike Liang

There's need a check on the GPU error state before save and restore GPU device config space.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 358dcc1070c5..5ef3c5c49bee 100644
@@ -3946,7 +3946,8 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev,

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
            dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
    /* Have stored pci confspace at hand for restore in sudden PCI error

*/

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 3950

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
-   if (amdgpu_device_cache_pci_state(adev->pdev))
+   if (adev->pdev->error_state != pci_channel_io_normal &&
+                   amdgpu_device_cache_pci_state(adev->pdev))
Quoted 6 lines

We need the clean state to be cached, not the state when there is an error. This state is later used to restore later, say when a mode-2 reset happens.

Thanks,
Lijo

But the original code in the amdgpu_device_init () is trying to restore the GPU config space immediately after the GPU config space saved, so that looks this GPU save state restored unconditionally and that's not only for the GPU error case? Meanwhile, as to the mode-2 or some other reset case the reset function will do the save and restore GPU state separately and not use the GPU state saved in amdgpu_device_init() process. In the amdgpu_device_init(), how about restore the GPU state only for the GPU error case?

Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
            pci_restore_state(pdev);
 
    /* if we have > 1 VGA cards, then disable the amdgpu VGA resources

*/