From: Duncan Ma <[email protected]>

[Why & How]
DMUB shall be notified on driver hardware
release. Implement notification.

Reviewed-by: Duncan Ma <[email protected]>
Signed-off-by: Duncan Ma <[email protected]>
Signed-off-by: Ivan Lipski <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 17 +++++++++++++++++
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h |  6 ++++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index c10e603b54af..b4525b1fc11b 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -2176,3 +2176,20 @@ bool dmub_lsdma_send_poll_reg_write_command(struct 
dc_dmub_srv *dc_dmub_srv, uin
        return result;
 }
 
+void dc_dmub_srv_release_hw(const struct dc *dc)
+{
+       struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;
+       union dmub_rb_cmd cmd = {0};
+
+       if (!dc_dmub_srv || !dc_dmub_srv->dmub)
+               return;
+
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.idle_opt_notify_idle.header.type = DMUB_CMD__IDLE_OPT;
+       cmd.idle_opt_notify_idle.header.sub_type = 
DMUB_CMD__IDLE_OPT_RELEASE_HW;
+       cmd.idle_opt_notify_idle.header.payload_bytes =
+               sizeof(cmd.idle_opt_notify_idle) -
+               sizeof(cmd.idle_opt_notify_idle.header);
+
+       dm_execute_dmub_cmd(dc->ctx, &cmd,  DM_DMUB_WAIT_TYPE_WAIT);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
index 1f1c155be30e..8ea320f21269 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
@@ -291,4 +291,10 @@ bool dc_dmub_srv_ips_query_residency_info(const struct 
dc_context *ctx, uint8_t
                                          struct dmub_ips_residency_info 
*driver_info,
                                          enum ips_residency_mode ips_mode);
 
+/**
+ * dc_dmub_srv_release_hw() - Notifies DMUB service that HW access is no 
longer required.
+ *
+ * @dc - pointer to DC object
+ */
+void dc_dmub_srv_release_hw(const struct dc *dc);
 #endif /* _DMUB_DC_SRV_H_ */
-- 
2.43.0

Reply via email to