Skip to content

Commit 5419a20

Browse files
Nicholas Kazlauskasalexdeucher
authored andcommitted
drm/amd/display: Notify idle link detection through shared state
[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>
1 parent d2c5cb0 commit 5419a20

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,36 @@ void dc_dmub_srv_set_power_state(struct dc_dmub_srv *dc_dmub_srv, enum dc_acpi_c
14601460
dmub_srv_set_power_state(dmub, DMUB_POWER_STATE_D3);
14611461
}
14621462

1463+
bool dc_dmub_srv_should_detect(struct dc_dmub_srv *dc_dmub_srv)
1464+
{
1465+
volatile const struct dmub_shared_state_ips_fw *ips_fw;
1466+
bool reallow_idle = false, should_detect = false;
1467+
1468+
if (!dc_dmub_srv || !dc_dmub_srv->dmub)
1469+
return false;
1470+
1471+
if (dc_dmub_srv->dmub->shared_state &&
1472+
dc_dmub_srv->dmub->meta_info.feature_bits.bits.shared_state_link_detection) {
1473+
ips_fw = &dc_dmub_srv->dmub->shared_state[DMUB_SHARED_SHARE_FEATURE__IPS_FW].data.ips_fw;
1474+
return ips_fw->signals.bits.detection_required;
1475+
}
1476+
1477+
/* Detection may require reading scratch 0 - exit out of idle prior to the read. */
1478+
if (dc_dmub_srv->idle_allowed) {
1479+
dc_dmub_srv_apply_idle_power_optimizations(dc_dmub_srv->ctx->dc, false);
1480+
reallow_idle = true;
1481+
}
1482+
1483+
should_detect = dmub_srv_should_detect(dc_dmub_srv->dmub);
1484+
1485+
/* Re-enter idle if we're not about to immediately redetect links. */
1486+
if (!should_detect && reallow_idle && dc_dmub_srv->idle_exit_counter == 0 &&
1487+
!dc_dmub_srv->ctx->dc->debug.disable_dmub_reallow_idle)
1488+
dc_dmub_srv_apply_idle_power_optimizations(dc_dmub_srv->ctx->dc, true);
1489+
1490+
return should_detect;
1491+
}
1492+
14631493
void dc_dmub_srv_apply_idle_power_optimizations(const struct dc *dc, bool allow_idle)
14641494
{
14651495
struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;

drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ void dc_dmub_srv_apply_idle_power_optimizations(const struct dc *dc, bool allow_
111111

112112
void dc_dmub_srv_set_power_state(struct dc_dmub_srv *dc_dmub_srv, enum dc_acpi_cm_power_state powerState);
113113

114+
/**
115+
* @dc_dmub_srv_should_detect() - Checks if link detection is required.
116+
*
117+
* While in idle power states we may need driver to manually redetect in
118+
* the case of a missing hotplug. Should be called from a polling timer.
119+
*
120+
* Return: true if redetection is required.
121+
*/
122+
bool dc_dmub_srv_should_detect(struct dc_dmub_srv *dc_dmub_srv);
123+
114124
/**
115125
* dc_wake_and_execute_dmub_cmd() - Wrapper for DMUB command execution.
116126
*

drivers/gpu/drm/amd/display/dmub/dmub_srv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ struct dmub_srv {
529529
uint32_t psp_version;
530530

531531
/* Feature capabilities reported by fw */
532+
struct dmub_fw_meta_info meta_info;
532533
struct dmub_feature_caps feature_caps;
533534
struct dmub_visual_confirm_color visual_confirm_color;
534535

drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,17 @@ struct dmub_visual_confirm_color {
496496
/* Offset from the end of the file to the dmub_fw_meta_info */
497497
#define DMUB_FW_META_OFFSET 0x24
498498

499+
/**
500+
* union dmub_fw_meta_feature_bits - Static feature bits for pre-initialization
501+
*/
502+
union dmub_fw_meta_feature_bits {
503+
struct {
504+
uint32_t shared_state_link_detection : 1; /**< 1 supports link detection via shared state */
505+
uint32_t reserved : 31;
506+
} bits; /**< status bits */
507+
uint32_t all; /**< 32-bit access to status bits */
508+
};
509+
499510
/**
500511
* struct dmub_fw_meta_info - metadata associated with fw binary
501512
*
@@ -521,6 +532,7 @@ struct dmub_fw_meta_info {
521532
uint32_t shared_state_size; /**< size of the shared state region in bytes */
522533
uint16_t shared_state_features; /**< number of shared state features */
523534
uint16_t reserved2; /**< padding bytes */
535+
union dmub_fw_meta_feature_bits feature_bits; /**< static feature bits */
524536
};
525537

526538
/**
@@ -698,7 +710,8 @@ union dmub_shared_state_ips_fw_signals {
698710
uint32_t ips1_commit : 1; /**< 1 if in IPS1 */
699711
uint32_t ips2_commit : 1; /**< 1 if in IPS2 */
700712
uint32_t in_idle : 1; /**< 1 if DMCUB is in idle */
701-
uint32_t reserved_bits : 29; /**< Reversed */
713+
uint32_t detection_required : 1; /**< 1 if detection is required */
714+
uint32_t reserved_bits : 28; /**< Reversed */
702715
} bits;
703716
uint32_t all;
704717
};

drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ enum dmub_status
510510
fw_info = dmub_get_fw_meta_info(params);
511511

512512
if (fw_info) {
513+
memcpy(&dmub->meta_info, fw_info, sizeof(*fw_info));
514+
513515
fw_state_size = fw_info->fw_region_size;
514516
trace_buffer_size = fw_info->trace_buffer_size;
515517

0 commit comments

Comments
 (0)