Skip to content

Commit 11cc465

Browse files
vprosyakalexdeucher
authored andcommitted
drm/amdgpu: always sending PSP messages LOAD_ASD and UNLOAD_TA
We allow sending PSP messages LOAD_ASD and UNLOAD_TA without acquiring a lock in drm_dev_enter during driver unload because we must call drm_dev_unplug as the beginning of unload driver sequence. Added WARNING if other PSP messages are sent without a lock. After this commit, the following commands would work -sudo modprobe -r amdgpu -sudo modprobe amdgpu Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com> Reviewed-by Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent febb414 commit 11cc465

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,21 @@ psp_cmd_submit_buf(struct psp_context *psp,
606606
int timeout = 20000;
607607
bool ras_intr = false;
608608
bool skip_unsupport = false;
609+
bool dev_entered;
609610

610611
if (psp->adev->no_hw_access)
611612
return 0;
612613

613-
if (!drm_dev_enter(adev_to_drm(psp->adev), &idx))
614-
return 0;
614+
dev_entered = drm_dev_enter(adev_to_drm(psp->adev), &idx);
615+
/*
616+
* We allow sending PSP messages LOAD_ASD and UNLOAD_TA without acquiring
617+
* a lock in drm_dev_enter during driver unload because we must call
618+
* drm_dev_unplug as the beginning of unload driver sequence . It is very
619+
* crucial that userspace can't access device instances anymore.
620+
*/
621+
if (!dev_entered)
622+
WARN_ON(psp->cmd_buf_mem->cmd_id != GFX_CMD_ID_LOAD_ASD &&
623+
psp->cmd_buf_mem->cmd_id != GFX_CMD_ID_UNLOAD_TA);
615624

616625
memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE);
617626

@@ -676,7 +685,8 @@ psp_cmd_submit_buf(struct psp_context *psp,
676685
}
677686

678687
exit:
679-
drm_dev_exit(idx);
688+
if (dev_entered)
689+
drm_dev_exit(idx);
680690
return ret;
681691
}
682692

0 commit comments

Comments
 (0)