Skip to content

Commit 3b7329c

Browse files
bokun-xxmtgalexdeucher
authored andcommitted
drm/amdgpu: Add amdgpu suspend-resume code path under SRIOV
- Under SRIOV, we need to send REQ_GPU_FINI to the hypervisor during the suspend time. Furthermore, we cannot request a mode 1 reset under SRIOV as VF. Therefore, we will skip it as it is called in suspend_noirq() function. - In the resume code path, we need to send REQ_GPU_INIT to the hypervisor and also resume PSP IP block under SRIOV. Signed-off-by: Bokun Zhang <Bokun.Zhang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 11e3836 commit 3b7329c

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,10 @@ bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev)
10501050
{
10511051
if (adev->flags & AMD_IS_APU)
10521052
return false;
1053+
1054+
if (amdgpu_sriov_vf(adev))
1055+
return false;
1056+
10531057
return pm_suspend_target_state != PM_SUSPEND_TO_IDLE;
10541058
}
10551059

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3152,7 +3152,8 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)
31523152
continue;
31533153
if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON ||
31543154
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC ||
3155-
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH) {
3155+
adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH ||
3156+
(adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP && amdgpu_sriov_vf(adev))) {
31563157

31573158
r = adev->ip_blocks[i].version->funcs->resume(adev);
31583159
if (r) {
@@ -4064,12 +4065,20 @@ static void amdgpu_device_evict_resources(struct amdgpu_device *adev)
40644065
int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
40654066
{
40664067
struct amdgpu_device *adev = drm_to_adev(dev);
4068+
int r = 0;
40674069

40684070
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
40694071
return 0;
40704072

40714073
adev->in_suspend = true;
40724074

4075+
if (amdgpu_sriov_vf(adev)) {
4076+
amdgpu_virt_fini_data_exchange(adev);
4077+
r = amdgpu_virt_request_full_gpu(adev, false);
4078+
if (r)
4079+
return r;
4080+
}
4081+
40734082
if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3))
40744083
DRM_WARN("smart shift update failed\n");
40754084

@@ -4093,6 +4102,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
40934102

40944103
amdgpu_device_ip_suspend_phase2(adev);
40954104

4105+
if (amdgpu_sriov_vf(adev))
4106+
amdgpu_virt_release_full_gpu(adev, false);
4107+
40964108
return 0;
40974109
}
40984110

@@ -4111,6 +4123,12 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
41114123
struct amdgpu_device *adev = drm_to_adev(dev);
41124124
int r = 0;
41134125

4126+
if (amdgpu_sriov_vf(adev)) {
4127+
r = amdgpu_virt_request_full_gpu(adev, true);
4128+
if (r)
4129+
return r;
4130+
}
4131+
41144132
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
41154133
return 0;
41164134

@@ -4125,6 +4143,13 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
41254143
}
41264144

41274145
r = amdgpu_device_ip_resume(adev);
4146+
4147+
/* no matter what r is, always need to properly release full GPU */
4148+
if (amdgpu_sriov_vf(adev)) {
4149+
amdgpu_virt_init_data_exchange(adev);
4150+
amdgpu_virt_release_full_gpu(adev, true);
4151+
}
4152+
41284153
if (r) {
41294154
dev_err(adev->dev, "amdgpu_device_ip_resume failed (%d).\n", r);
41304155
return r;

0 commit comments

Comments
 (0)