]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
drm/amd/display: do not allocate display_mode_lib unnecessarily
authorDor Askayo <dor.askayo@gmail.com>
Sat, 4 Jan 2020 12:22:15 +0000 (14:22 +0200)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 24 Feb 2020 15:33:00 +0000 (16:33 +0100)
BugLink: https://bugs.launchpad.net/bugs/1864488
[ Upstream commit bb67bfd2e7101bf2ac5327b0b7a847cd9fb9723f ]

This allocation isn't required and can fail when resuming from suspend.

Bug: https://gitlab.freedesktop.org/drm/amd/issues/1009
Signed-off-by: Dor Askayo <dor.askayo@gmail.com>
Reviewed-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/gpu/drm/amd/display/dc/core/dc.c

index 4b8819c27fcda3a3011e58f2a5de081cd8ccd25d..4704aac336c293b9c8efdda7eb2308db5381b95f 100644 (file)
@@ -2267,12 +2267,7 @@ void dc_set_power_state(
        enum dc_acpi_cm_power_state power_state)
 {
        struct kref refcount;
-       struct display_mode_lib *dml = kzalloc(sizeof(struct display_mode_lib),
-                                               GFP_KERNEL);
-
-       ASSERT(dml);
-       if (!dml)
-               return;
+       struct display_mode_lib *dml;
 
        switch (power_state) {
        case DC_ACPI_CM_POWER_STATE_D0:
@@ -2294,6 +2289,12 @@ void dc_set_power_state(
                 * clean state, and dc hw programming optimizations will not
                 * cause any trouble.
                 */
+               dml = kzalloc(sizeof(struct display_mode_lib),
+                               GFP_KERNEL);
+
+               ASSERT(dml);
+               if (!dml)
+                       return;
 
                /* Preserve refcount */
                refcount = dc->current_state->refcount;
@@ -2307,10 +2308,10 @@ void dc_set_power_state(
                dc->current_state->refcount = refcount;
                dc->current_state->bw_ctx.dml = *dml;
 
+               kfree(dml);
+
                break;
        }
-
-       kfree(dml);
 }
 
 void dc_resume(struct dc *dc)