mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/amdgpu: validate suspend before function call
Before making a function call to suspend, validate the function pointer like we do in sw_init. Use the helper function amdgpu_ip_block_suspend where same checks and calls are repeated. Signed-off-by: Sunil Khatri <sunil.khatri@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
dad01f93f4
commit
e095026f00
@@ -85,16 +85,9 @@ static int aldebaran_mode2_suspend_ip(struct amdgpu_device *adev)
|
|||||||
AMD_IP_BLOCK_TYPE_SDMA))
|
AMD_IP_BLOCK_TYPE_SDMA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
r = amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
|
if (r)
|
||||||
if (r) {
|
|
||||||
dev_err(adev->dev,
|
|
||||||
"suspend of IP block <%s> failed %d\n",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev,
|
|||||||
enum amd_ip_block_type block_type);
|
enum amd_ip_block_type block_type);
|
||||||
bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
|
bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
|
||||||
enum amd_ip_block_type block_type);
|
enum amd_ip_block_type block_type);
|
||||||
|
int amdgpu_ip_block_suspend(struct amdgpu_ip_block *ip_block);
|
||||||
|
|
||||||
#define AMDGPU_MAX_IP_NUM 16
|
#define AMDGPU_MAX_IP_NUM 16
|
||||||
|
|
||||||
|
|||||||
@@ -272,6 +272,24 @@ void amdgpu_reg_state_sysfs_fini(struct amdgpu_device *adev)
|
|||||||
sysfs_remove_bin_file(&adev->dev->kobj, &bin_attr_reg_state);
|
sysfs_remove_bin_file(&adev->dev->kobj, &bin_attr_reg_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int amdgpu_ip_block_suspend(struct amdgpu_ip_block *ip_block)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (ip_block->version->funcs->suspend) {
|
||||||
|
r = ip_block->version->funcs->suspend(ip_block);
|
||||||
|
if (r) {
|
||||||
|
dev_err(ip_block->adev->dev,
|
||||||
|
"suspend of IP block <%s> failed %d\n",
|
||||||
|
ip_block->version->funcs->name, r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ip_block->status.hw = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DOC: board_info
|
* DOC: board_info
|
||||||
*
|
*
|
||||||
@@ -3473,15 +3491,9 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* XXX handle errors */
|
/* XXX handle errors */
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
r = amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
/* XXX handle errors */
|
if (r)
|
||||||
if (r) {
|
|
||||||
DRM_ERROR("suspend of IP block <%s> failed %d\n",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3555,13 +3567,9 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* XXX handle errors */
|
/* XXX handle errors */
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
r = amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
/* XXX handle errors */
|
|
||||||
if (r) {
|
|
||||||
DRM_ERROR("suspend of IP block <%s> failed %d\n",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
}
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
adev->ip_blocks[i].status.hw = false;
|
||||||
|
|
||||||
/* handle putting the SMC in the appropriate state */
|
/* handle putting the SMC in the appropriate state */
|
||||||
if (!amdgpu_sriov_vf(adev)) {
|
if (!amdgpu_sriov_vf(adev)) {
|
||||||
if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
|
if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
static int amdgpu_reset_xgmi_reset_on_init_suspend(struct amdgpu_device *adev)
|
static int amdgpu_reset_xgmi_reset_on_init_suspend(struct amdgpu_device *adev)
|
||||||
{
|
{
|
||||||
int i, r;
|
int i;
|
||||||
|
|
||||||
for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
|
for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
|
||||||
if (!adev->ip_blocks[i].status.valid)
|
if (!adev->ip_blocks[i].status.valid)
|
||||||
@@ -40,12 +40,7 @@ static int amdgpu_reset_xgmi_reset_on_init_suspend(struct amdgpu_device *adev)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* XXX handle errors */
|
/* XXX handle errors */
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
/* XXX handle errors */
|
|
||||||
if (r) {
|
|
||||||
dev_err(adev->dev, "suspend of IP block <%s> failed %d",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
}
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
adev->ip_blocks[i].status.hw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,15 +81,9 @@ static int sienna_cichlid_mode2_suspend_ip(struct amdgpu_device *adev)
|
|||||||
AMD_IP_BLOCK_TYPE_SDMA))
|
AMD_IP_BLOCK_TYPE_SDMA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
r = amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
|
if (r)
|
||||||
if (r) {
|
|
||||||
dev_err(adev->dev,
|
|
||||||
"suspend of IP block <%s> failed %d\n",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -80,15 +80,9 @@ static int smu_v13_0_10_mode2_suspend_ip(struct amdgpu_device *adev)
|
|||||||
AMD_IP_BLOCK_TYPE_MES))
|
AMD_IP_BLOCK_TYPE_MES))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
r = adev->ip_blocks[i].version->funcs->suspend(&adev->ip_blocks[i]);
|
r = amdgpu_ip_block_suspend(&adev->ip_blocks[i]);
|
||||||
|
if (r)
|
||||||
if (r) {
|
|
||||||
dev_err(adev->dev,
|
|
||||||
"suspend of IP block <%s> failed %d\n",
|
|
||||||
adev->ip_blocks[i].version->funcs->name, r);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
adev->ip_blocks[i].status.hw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user