From: James Lin <[email protected]>

[Why & How]
Request cursor offload in dc_config and initialize it after DMUB is up
(dc_dmub_srv_cursor_offload_init), which self-gates on the firmware
cursor_offload_v1_support capability, so cursor programming no longer takes
the inbox0 lock on alt-in-use streams.

Reviewed-by: Leo Li <[email protected]>
Signed-off-by: James Lin <[email protected]>
Signed-off-by: Chenyu Chen <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c      |  9 ++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9c7fdd2844e5..24cd21a39690 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -608,6 +608,13 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
        init_data.flags.enable_mipi_converter_optimization = true;
 
+       /*
+        * Request HW cursor offload so DMUB programs the cursor; cursor
+        * updates then avoid the DMUB inbox0 HW lock during mclk switches.
+        * dc_dmub_srv_cursor_offload_init() self-gates on FW capability.
+        */
+       init_data.flags.enable_cursor_offload = true;
+
        init_data.dcn_reg_offsets = adev->reg_offset[DCE_HWIP][0];
        init_data.nbio_reg_offsets = adev->reg_offset[NBIO_HWIP][0];
        init_data.clk_reg_offsets = adev->reg_offset[CLK_HWIP][0];
@@ -725,6 +732,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
        dc_hardware_init(adev->dm.dc);
 
+       /* Enable cursor offload if the DMUB firmware supports it. */
+       dc_dmub_srv_cursor_offload_init(adev->dm.dc);
+
        /* GOP/vBIOS may leave an OPTC enabled for a display present at power-on
         * but no longer driven (e.g. an external DP unplugged at boot). Such a
         * dangling pipe keeps DCN out of idle and blocks s0i3. Power it down
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 e23137034130..1e7071f8d53f 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -1211,9 +1211,16 @@ void dc_dmub_srv_subvp_save_surf_addr(const struct 
dc_dmub_srv *dc_dmub_srv, con
 void dc_dmub_srv_cursor_offload_init(struct dc *dc)
 {
        struct dmub_rb_cmd_cursor_offload_init *init;
-       struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;
+       struct dc_dmub_srv *dc_dmub_srv;
        union dmub_rb_cmd cmd;
 
+       if (!dc || !dc->ctx)
+               return;
+
+       dc_dmub_srv = dc->ctx->dmub_srv;
+       if (!dc_dmub_srv || !dc_dmub_srv->dmub)
+               return;
+
        if (!dc->config.enable_cursor_offload)
                return;
 
-- 
2.43.0

Reply via email to