Commit 7441ef0b authored by Mario Limonciello's avatar Mario Limonciello Committed by Alex Deucher

drm/amd: Propagate failures in dc_set_power_state()

During the suspend process dc_set_power_state() will use kzalloc
to allocate memory, but this potentially fails with memory pressure.
If it fails, the suspend should be aborted.

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2362Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Cc: Harry.Wentland@amd.com
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 41801c6b
...@@ -2671,9 +2671,7 @@ static int dm_suspend(void *handle) ...@@ -2671,9 +2671,7 @@ static int dm_suspend(void *handle)
hpd_rx_irq_work_suspend(dm); hpd_rx_irq_work_suspend(dm);
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3); return dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
return 0;
} }
struct amdgpu_dm_connector * struct amdgpu_dm_connector *
...@@ -2867,7 +2865,10 @@ static int dm_resume(void *handle) ...@@ -2867,7 +2865,10 @@ static int dm_resume(void *handle)
if (r) if (r)
DRM_ERROR("DMUB interface failed to initialize: status=%d\n", r); DRM_ERROR("DMUB interface failed to initialize: status=%d\n", r);
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0); r = dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
if (r)
return r;
dc_resume(dm->dc); dc_resume(dm->dc);
amdgpu_dm_irq_resume_early(adev); amdgpu_dm_irq_resume_early(adev);
...@@ -2916,7 +2917,9 @@ static int dm_resume(void *handle) ...@@ -2916,7 +2917,9 @@ static int dm_resume(void *handle)
} }
/* power on hardware */ /* power on hardware */
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0); r = dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
if (r)
return r;
/* program HPD filter */ /* program HPD filter */
dc_resume(dm->dc); dc_resume(dm->dc);
......
...@@ -4723,7 +4723,7 @@ void dc_power_down_on_boot(struct dc *dc) ...@@ -4723,7 +4723,7 @@ void dc_power_down_on_boot(struct dc *dc)
dc->hwss.power_down_on_boot(dc); dc->hwss.power_down_on_boot(dc);
} }
void dc_set_power_state( int dc_set_power_state(
struct dc *dc, struct dc *dc,
enum dc_acpi_cm_power_state power_state) enum dc_acpi_cm_power_state power_state)
{ {
...@@ -4731,7 +4731,7 @@ void dc_set_power_state( ...@@ -4731,7 +4731,7 @@ void dc_set_power_state(
struct display_mode_lib *dml; struct display_mode_lib *dml;
if (!dc->current_state) if (!dc->current_state)
return; return 0;
switch (power_state) { switch (power_state) {
case DC_ACPI_CM_POWER_STATE_D0: case DC_ACPI_CM_POWER_STATE_D0:
...@@ -4758,7 +4758,7 @@ void dc_set_power_state( ...@@ -4758,7 +4758,7 @@ void dc_set_power_state(
ASSERT(dml); ASSERT(dml);
if (!dml) if (!dml)
return; return -ENOMEM;
/* Preserve refcount */ /* Preserve refcount */
refcount = dc->current_state->refcount; refcount = dc->current_state->refcount;
...@@ -4776,6 +4776,8 @@ void dc_set_power_state( ...@@ -4776,6 +4776,8 @@ void dc_set_power_state(
break; break;
} }
return 0;
} }
void dc_resume(struct dc *dc) void dc_resume(struct dc *dc)
......
...@@ -2283,7 +2283,7 @@ void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bo ...@@ -2283,7 +2283,7 @@ void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bo
/* Power Interfaces */ /* Power Interfaces */
void dc_set_power_state( int dc_set_power_state(
struct dc *dc, struct dc *dc,
enum dc_acpi_cm_power_state power_state); enum dc_acpi_cm_power_state power_state);
void dc_resume(struct dc *dc); void dc_resume(struct dc *dc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment