Commit bd4caed4 authored by Michel Dänzer's avatar Michel Dänzer Committed by Alex Deucher

drm/amd/display: Use kvzalloc for potentially large allocations

Allocating up to 32 physically contiguous pages can easily fail (and has
failed for me), and isn't necessary anyway.
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 018d82e5
...@@ -66,8 +66,8 @@ struct dc_plane_state *dc_create_plane_state(struct dc *dc) ...@@ -66,8 +66,8 @@ struct dc_plane_state *dc_create_plane_state(struct dc *dc)
{ {
struct dc *core_dc = dc; struct dc *core_dc = dc;
struct dc_plane_state *plane_state = kzalloc(sizeof(*plane_state), struct dc_plane_state *plane_state = kvzalloc(sizeof(*plane_state),
GFP_KERNEL); GFP_KERNEL);
if (NULL == plane_state) if (NULL == plane_state)
return NULL; return NULL;
...@@ -120,7 +120,7 @@ static void dc_plane_state_free(struct kref *kref) ...@@ -120,7 +120,7 @@ static void dc_plane_state_free(struct kref *kref)
{ {
struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount); struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount);
destruct(plane_state); destruct(plane_state);
kfree(plane_state); kvfree(plane_state);
} }
void dc_plane_state_release(struct dc_plane_state *plane_state) void dc_plane_state_release(struct dc_plane_state *plane_state)
...@@ -136,7 +136,7 @@ void dc_gamma_retain(struct dc_gamma *gamma) ...@@ -136,7 +136,7 @@ void dc_gamma_retain(struct dc_gamma *gamma)
static void dc_gamma_free(struct kref *kref) static void dc_gamma_free(struct kref *kref)
{ {
struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount); struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount);
kfree(gamma); kvfree(gamma);
} }
void dc_gamma_release(struct dc_gamma **gamma) void dc_gamma_release(struct dc_gamma **gamma)
...@@ -147,7 +147,7 @@ void dc_gamma_release(struct dc_gamma **gamma) ...@@ -147,7 +147,7 @@ void dc_gamma_release(struct dc_gamma **gamma)
struct dc_gamma *dc_create_gamma(void) struct dc_gamma *dc_create_gamma(void)
{ {
struct dc_gamma *gamma = kzalloc(sizeof(*gamma), GFP_KERNEL); struct dc_gamma *gamma = kvzalloc(sizeof(*gamma), GFP_KERNEL);
if (gamma == NULL) if (gamma == NULL)
goto alloc_fail; goto alloc_fail;
...@@ -167,7 +167,7 @@ void dc_transfer_func_retain(struct dc_transfer_func *tf) ...@@ -167,7 +167,7 @@ void dc_transfer_func_retain(struct dc_transfer_func *tf)
static void dc_transfer_func_free(struct kref *kref) static void dc_transfer_func_free(struct kref *kref)
{ {
struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount); struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
kfree(tf); kvfree(tf);
} }
void dc_transfer_func_release(struct dc_transfer_func *tf) void dc_transfer_func_release(struct dc_transfer_func *tf)
...@@ -177,7 +177,7 @@ void dc_transfer_func_release(struct dc_transfer_func *tf) ...@@ -177,7 +177,7 @@ void dc_transfer_func_release(struct dc_transfer_func *tf)
struct dc_transfer_func *dc_create_transfer_func(void) struct dc_transfer_func *dc_create_transfer_func(void)
{ {
struct dc_transfer_func *tf = kzalloc(sizeof(*tf), GFP_KERNEL); struct dc_transfer_func *tf = kvzalloc(sizeof(*tf), GFP_KERNEL);
if (tf == NULL) if (tf == NULL)
goto alloc_fail; goto alloc_fail;
......
...@@ -1093,19 +1093,19 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, ...@@ -1093,19 +1093,19 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
rgb_user = kzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS), rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
GFP_KERNEL); GFP_KERNEL);
if (!rgb_user) if (!rgb_user)
goto rgb_user_alloc_fail; goto rgb_user_alloc_fail;
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS), rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL); GFP_KERNEL);
if (!rgb_regamma) if (!rgb_regamma)
goto rgb_regamma_alloc_fail; goto rgb_regamma_alloc_fail;
axix_x = kzalloc(sizeof(*axix_x) * (ramp->num_entries + 3), axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + 3),
GFP_KERNEL); GFP_KERNEL);
if (!axix_x) if (!axix_x)
goto axix_x_alloc_fail; goto axix_x_alloc_fail;
coeff = kzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL); coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
if (!coeff) if (!coeff)
goto coeff_alloc_fail; goto coeff_alloc_fail;
...@@ -1157,13 +1157,13 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, ...@@ -1157,13 +1157,13 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
ret = true; ret = true;
kfree(coeff); kvfree(coeff);
coeff_alloc_fail: coeff_alloc_fail:
kfree(axix_x); kvfree(axix_x);
axix_x_alloc_fail: axix_x_alloc_fail:
kfree(rgb_regamma); kvfree(rgb_regamma);
rgb_regamma_alloc_fail: rgb_regamma_alloc_fail:
kfree(rgb_user); kvfree(rgb_user);
rgb_user_alloc_fail: rgb_user_alloc_fail:
return ret; return ret;
} }
...@@ -1192,19 +1192,19 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, ...@@ -1192,19 +1192,19 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
input_tf->type = TF_TYPE_DISTRIBUTED_POINTS; input_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
rgb_user = kzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS), rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
GFP_KERNEL); GFP_KERNEL);
if (!rgb_user) if (!rgb_user)
goto rgb_user_alloc_fail; goto rgb_user_alloc_fail;
curve = kzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS), curve = kvzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL); GFP_KERNEL);
if (!curve) if (!curve)
goto curve_alloc_fail; goto curve_alloc_fail;
axix_x = kzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS), axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS),
GFP_KERNEL); GFP_KERNEL);
if (!axix_x) if (!axix_x)
goto axix_x_alloc_fail; goto axix_x_alloc_fail;
coeff = kzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL); coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
if (!coeff) if (!coeff)
goto coeff_alloc_fail; goto coeff_alloc_fail;
...@@ -1246,13 +1246,13 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, ...@@ -1246,13 +1246,13 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
ret = true; ret = true;
kfree(coeff); kvfree(coeff);
coeff_alloc_fail: coeff_alloc_fail:
kfree(axix_x); kvfree(axix_x);
axix_x_alloc_fail: axix_x_alloc_fail:
kfree(curve); kvfree(curve);
curve_alloc_fail: curve_alloc_fail:
kfree(rgb_user); kvfree(rgb_user);
rgb_user_alloc_fail: rgb_user_alloc_fail:
return ret; return ret;
...@@ -1281,8 +1281,9 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, ...@@ -1281,8 +1281,9 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
} else if (trans == TRANSFER_FUNCTION_PQ) { } else if (trans == TRANSFER_FUNCTION_PQ) {
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
_EXTRA_POINTS), GFP_KERNEL); (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL);
if (!rgb_regamma) if (!rgb_regamma)
goto rgb_regamma_alloc_fail; goto rgb_regamma_alloc_fail;
points->end_exponent = 7; points->end_exponent = 7;
...@@ -1302,11 +1303,12 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, ...@@ -1302,11 +1303,12 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
kfree(rgb_regamma); kvfree(rgb_regamma);
} else if (trans == TRANSFER_FUNCTION_SRGB || } else if (trans == TRANSFER_FUNCTION_SRGB ||
trans == TRANSFER_FUNCTION_BT709) { trans == TRANSFER_FUNCTION_BT709) {
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
_EXTRA_POINTS), GFP_KERNEL); (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL);
if (!rgb_regamma) if (!rgb_regamma)
goto rgb_regamma_alloc_fail; goto rgb_regamma_alloc_fail;
points->end_exponent = 0; points->end_exponent = 0;
...@@ -1324,7 +1326,7 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, ...@@ -1324,7 +1326,7 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
kfree(rgb_regamma); kvfree(rgb_regamma);
} }
rgb_regamma_alloc_fail: rgb_regamma_alloc_fail:
return ret; return ret;
...@@ -1348,8 +1350,9 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, ...@@ -1348,8 +1350,9 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
} else if (trans == TRANSFER_FUNCTION_PQ) { } else if (trans == TRANSFER_FUNCTION_PQ) {
rgb_degamma = kzalloc(sizeof(*rgb_degamma) * (MAX_HW_POINTS + rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
_EXTRA_POINTS), GFP_KERNEL); (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL);
if (!rgb_degamma) if (!rgb_degamma)
goto rgb_degamma_alloc_fail; goto rgb_degamma_alloc_fail;
...@@ -1364,11 +1367,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, ...@@ -1364,11 +1367,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
kfree(rgb_degamma); kvfree(rgb_degamma);
} else if (trans == TRANSFER_FUNCTION_SRGB || } else if (trans == TRANSFER_FUNCTION_SRGB ||
trans == TRANSFER_FUNCTION_BT709) { trans == TRANSFER_FUNCTION_BT709) {
rgb_degamma = kzalloc(sizeof(*rgb_degamma) * (MAX_HW_POINTS + rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
_EXTRA_POINTS), GFP_KERNEL); (MAX_HW_POINTS + _EXTRA_POINTS),
GFP_KERNEL);
if (!rgb_degamma) if (!rgb_degamma)
goto rgb_degamma_alloc_fail; goto rgb_degamma_alloc_fail;
...@@ -1382,7 +1386,7 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, ...@@ -1382,7 +1386,7 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
} }
ret = true; ret = true;
kfree(rgb_degamma); kvfree(rgb_degamma);
} }
points->end_exponent = 0; points->end_exponent = 0;
points->x_point_at_y1_red = 1; points->x_point_at_y1_red = 1;
......
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