[PATCH 5.17 003/146] drm/amd/display: Only set PSR version when valid

From: Greg Kroah-Hartman
Date: Tue Apr 26 2022 - 05:19:41 EST

From: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx>

commit 1210b17dd4ece454d68a9283f391e3b036aeb010 upstream.

DMCUB will hang if we send a PSR unsupported set version command.

This can occur if we fall-through into the default case in the switch
statement for PSR version.

Add an unsupported check after the switch statement.

Tested-by: Daniel Wheeler <daniel.wheeler@xxxxxxx>
Reviewed-by: Anthony Koo <Anthony.Koo@xxxxxxx>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@xxxxxxx>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx>
Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
Cc: "Limonciello, Mario" <Mario.Limonciello@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
@@ -138,6 +138,10 @@ static bool dmub_psr_set_version(struct
cmd.psr_set_version.psr_set_version_data.version = PSR_VERSION_UNSUPPORTED;
+ if (cmd.psr_set_version.psr_set_version_data.version == PSR_VERSION_UNSUPPORTED)
+ return false;
cmd.psr_set_version.psr_set_version_data.cmd_version = DMUB_CMD_PSR_CONTROL_VERSION_1;
cmd.psr_set_version.psr_set_version_data.panel_inst = panel_inst;
cmd.psr_set_version.header.payload_bytes = sizeof(struct dmub_cmd_psr_set_version_data);