Commit 44f3dd09 authored by Alex Deucher's avatar Alex Deucher

drm/amd/display: use kvmalloc for dc_state (v2)

It's large and doesn't need contiguous memory.  Fixes
allocation failures in some cases.

v2: kvfree the memory.
Reviewed-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 62cfcb9e
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mm.h>
#include "dm_services.h" #include "dm_services.h"
...@@ -1183,8 +1184,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc) ...@@ -1183,8 +1184,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
struct dc_state *dc_create_state(struct dc *dc) struct dc_state *dc_create_state(struct dc *dc)
{ {
struct dc_state *context = kzalloc(sizeof(struct dc_state), struct dc_state *context = kvzalloc(sizeof(struct dc_state),
GFP_KERNEL); GFP_KERNEL);
if (!context) if (!context)
return NULL; return NULL;
...@@ -1204,11 +1205,11 @@ struct dc_state *dc_create_state(struct dc *dc) ...@@ -1204,11 +1205,11 @@ struct dc_state *dc_create_state(struct dc *dc)
struct dc_state *dc_copy_state(struct dc_state *src_ctx) struct dc_state *dc_copy_state(struct dc_state *src_ctx)
{ {
int i, j; int i, j;
struct dc_state *new_ctx = kmemdup(src_ctx, struct dc_state *new_ctx = kvmalloc(sizeof(struct dc_state), GFP_KERNEL);
sizeof(struct dc_state), GFP_KERNEL);
if (!new_ctx) if (!new_ctx)
return NULL; return NULL;
memcpy(new_ctx, src_ctx, sizeof(struct dc_state));
for (i = 0; i < MAX_PIPES; i++) { for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i]; struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i];
...@@ -1242,7 +1243,7 @@ static void dc_state_free(struct kref *kref) ...@@ -1242,7 +1243,7 @@ static void dc_state_free(struct kref *kref)
{ {
struct dc_state *context = container_of(kref, struct dc_state, refcount); struct dc_state *context = container_of(kref, struct dc_state, refcount);
dc_resource_state_destruct(context); dc_resource_state_destruct(context);
kfree(context); kvfree(context);
} }
void dc_release_state(struct dc_state *context) void dc_release_state(struct dc_state *context)
......
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