From: Lijo Lazar <[email protected]>

Add interface to send completion command to ASPs after processing ualink
notifications.

Signed-off-by: Lijo Lazar <[email protected]>
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 28 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  3 +++
 2 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 4fc7aed58bfc3..cb34148269160 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1426,6 +1426,34 @@ int psp_ual_set_npa_config(struct psp_context *psp, 
uint32_t intf_ver,
        return ret;
 }
 
+int psp_ual_send_completion(struct psp_context *psp, uint32_t intf_ver,
+                           uint32_t cmd_id, uint32_t status)
+{
+       struct psp_gfx_cmd_resp *cmd;
+       int ret;
+
+       /* TBD check interface version 1.x */
+       if (intf_ver > 0x1ffff) {
+               pr_warn("PSP UAL interface version mismatch: 0x%x\n", intf_ver);
+               return -EOPNOTSUPP;
+       }
+
+       cmd = acquire_psp_cmd_buf(psp);
+
+       cmd->cmd_id = GFX_CMD_ID_UAL_SEND_COMPLETION;
+       cmd->cmd.cmd_send_completion_ual.cmd_id = cmd_id;
+       cmd->cmd.cmd_send_completion_ual.status = status;
+
+       ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
+
+       if (!ret && cmd->resp.status)
+               ret = -EINVAL;
+
+       release_psp_cmd_buf(psp);
+
+       return ret;
+}
+
 int psp_update_fw_reservation(struct psp_context *psp)
 {
        int ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 2ba7ced36b7cc..35839f42b8a08 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -730,4 +730,7 @@ int psp_ual_set_station_config(struct psp_context *psp, 
uint32_t intf_ver,
 int psp_ual_set_npa_config(struct psp_context *psp, uint32_t intf_ver,
                           unsigned int vmid, bool enable);
 
+int psp_ual_send_completion(struct psp_context *psp, uint32_t intf_ver,
+                           uint32_t cmd_id, uint32_t status);
+
 #endif
-- 
2.55.0

Reply via email to