]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Notify idle link detection through shared state
authorNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Thu, 18 Apr 2024 13:51:36 +0000 (09:51 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 30 Apr 2024 13:57:17 +0000 (09:57 -0400)
[Why]
We can hang in IPS2 checking DMCUB_SCRATCH0 for link detection state.

[How]
Replace the HW access with a check on the shared state bit. This will
work the same way as the SCRATCH0 but won't require a wake in the case
where link detection isn't required.

Reviewed-by: Duncan Ma <duncan.ma@amd.com>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
drivers/gpu/drm/amd/display/dmub/dmub_srv.h
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c

index 33d3307f5c1cffb6407dc89cb666a48ad026c82c..364ef9ae32f107162b07584584c4176cc5020f4f 100644 (file)
@@ -1460,6 +1460,36 @@ void dc_dmub_srv_set_power_state(struct dc_dmub_srv *dc_dmub_srv, enum dc_acpi_c
                dmub_srv_set_power_state(dmub, DMUB_POWER_STATE_D3);
 }
 
+bool dc_dmub_srv_should_detect(struct dc_dmub_srv *dc_dmub_srv)
+{
+       volatile const struct dmub_shared_state_ips_fw *ips_fw;
+       bool reallow_idle = false, should_detect = false;
+
+       if (!dc_dmub_srv || !dc_dmub_srv->dmub)
+               return false;
+
+       if (dc_dmub_srv->dmub->shared_state &&
+           dc_dmub_srv->dmub->meta_info.feature_bits.bits.shared_state_link_detection) {
+               ips_fw = &dc_dmub_srv->dmub->shared_state[DMUB_SHARED_SHARE_FEATURE__IPS_FW].data.ips_fw;
+               return ips_fw->signals.bits.detection_required;
+       }
+
+       /* Detection may require reading scratch 0 - exit out of idle prior to the read. */
+       if (dc_dmub_srv->idle_allowed) {
+               dc_dmub_srv_apply_idle_power_optimizations(dc_dmub_srv->ctx->dc, false);
+               reallow_idle = true;
+       }
+
+       should_detect = dmub_srv_should_detect(dc_dmub_srv->dmub);
+
+       /* Re-enter idle if we're not about to immediately redetect links. */
+       if (!should_detect && reallow_idle && dc_dmub_srv->idle_exit_counter == 0 &&
+           !dc_dmub_srv->ctx->dc->debug.disable_dmub_reallow_idle)
+               dc_dmub_srv_apply_idle_power_optimizations(dc_dmub_srv->ctx->dc, true);
+
+       return should_detect;
+}
+
 void dc_dmub_srv_apply_idle_power_optimizations(const struct dc *dc, bool allow_idle)
 {
        struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;
index 3297c5b332652bea62a1c4a880bfacc32230768d..580940222777eac187e8970ba004f733fa040519 100644 (file)
@@ -111,6 +111,16 @@ void dc_dmub_srv_apply_idle_power_optimizations(const struct dc *dc, bool allow_
 
 void dc_dmub_srv_set_power_state(struct dc_dmub_srv *dc_dmub_srv, enum dc_acpi_cm_power_state powerState);
 
+/**
+ * @dc_dmub_srv_should_detect() - Checks if link detection is required.
+ *
+ * While in idle power states we may need driver to manually redetect in
+ * the case of a missing hotplug. Should be called from a polling timer.
+ *
+ * Return: true if redetection is required.
+ */
+bool dc_dmub_srv_should_detect(struct dc_dmub_srv *dc_dmub_srv);
+
 /**
  * dc_wake_and_execute_dmub_cmd() - Wrapper for DMUB command execution.
  *
index cec8aa1face5ba959299ac29f22cb849087f36ec..cd51c91a822b6d0e2918b875f30fef96104cd54f 100644 (file)
@@ -529,6 +529,7 @@ struct dmub_srv {
        uint32_t psp_version;
 
        /* Feature capabilities reported by fw */
+       struct dmub_fw_meta_info meta_info;
        struct dmub_feature_caps feature_caps;
        struct dmub_visual_confirm_color visual_confirm_color;
 
index 7a0574e6c129b89a4f1047f655886c48bea875f1..35096aa3d85b517f4b117a3f9caea0a5351903cf 100644 (file)
@@ -496,6 +496,17 @@ struct dmub_visual_confirm_color {
 /* Offset from the end of the file to the dmub_fw_meta_info */
 #define DMUB_FW_META_OFFSET 0x24
 
+/**
+ * union dmub_fw_meta_feature_bits - Static feature bits for pre-initialization
+ */
+union dmub_fw_meta_feature_bits {
+       struct {
+               uint32_t shared_state_link_detection : 1; /**< 1 supports link detection via shared state */
+               uint32_t reserved : 31;
+       } bits; /**< status bits */
+       uint32_t all; /**< 32-bit access to status bits */
+};
+
 /**
  * struct dmub_fw_meta_info - metadata associated with fw binary
  *
@@ -521,6 +532,7 @@ struct dmub_fw_meta_info {
        uint32_t shared_state_size; /**< size of the shared state region in bytes */
        uint16_t shared_state_features; /**< number of shared state features */
        uint16_t reserved2; /**< padding bytes */
+       union dmub_fw_meta_feature_bits feature_bits; /**< static feature bits */
 };
 
 /**
@@ -698,7 +710,8 @@ union dmub_shared_state_ips_fw_signals {
                uint32_t ips1_commit : 1;  /**< 1 if in IPS1 */
                uint32_t ips2_commit : 1; /**< 1 if in IPS2 */
                uint32_t in_idle : 1; /**< 1 if DMCUB is in idle */
-               uint32_t reserved_bits : 29; /**< Reversed */
+               uint32_t detection_required : 1; /**< 1 if detection is required */
+               uint32_t reserved_bits : 28; /**< Reversed */
        } bits;
        uint32_t all;
 };
index 9bb4c51b1f5bf906bc1245ef04a622bf890c18ee..db16066bc8939b88ebc132b807a9857485884639 100644 (file)
@@ -510,6 +510,8 @@ enum dmub_status
        fw_info = dmub_get_fw_meta_info(params);
 
        if (fw_info) {
+               memcpy(&dmub->meta_info, fw_info, sizeof(*fw_info));
+
                fw_state_size = fw_info->fw_region_size;
                trace_buffer_size = fw_info->trace_buffer_size;