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: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Este cometimento está contido em:

cometido por
Alex Deucher

ascendente
f333625426
cometimento
f7dbe9186d
@@ -1274,19 +1274,19 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
|
||||
|
||||
output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
|
||||
|
||||
rgb_user = kzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_user)
|
||||
goto rgb_user_alloc_fail;
|
||||
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_regamma)
|
||||
goto rgb_regamma_alloc_fail;
|
||||
axix_x = kzalloc(sizeof(*axix_x) * (ramp->num_entries + 3),
|
||||
GFP_KERNEL);
|
||||
axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + 3),
|
||||
GFP_KERNEL);
|
||||
if (!axix_x)
|
||||
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)
|
||||
goto coeff_alloc_fail;
|
||||
|
||||
@@ -1338,13 +1338,13 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
|
||||
|
||||
ret = true;
|
||||
|
||||
kfree(coeff);
|
||||
kvfree(coeff);
|
||||
coeff_alloc_fail:
|
||||
kfree(axix_x);
|
||||
kvfree(axix_x);
|
||||
axix_x_alloc_fail:
|
||||
kfree(rgb_regamma);
|
||||
kvfree(rgb_regamma);
|
||||
rgb_regamma_alloc_fail:
|
||||
kfree(rgb_user);
|
||||
kvfree(rgb_user);
|
||||
rgb_user_alloc_fail:
|
||||
return ret;
|
||||
}
|
||||
@@ -1480,19 +1480,19 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
|
||||
|
||||
input_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
|
||||
|
||||
rgb_user = kzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_user)
|
||||
goto rgb_user_alloc_fail;
|
||||
curve = kzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
curve = kvzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!curve)
|
||||
goto curve_alloc_fail;
|
||||
axix_x = kzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!axix_x)
|
||||
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)
|
||||
goto coeff_alloc_fail;
|
||||
|
||||
@@ -1534,13 +1534,13 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
|
||||
|
||||
ret = true;
|
||||
|
||||
kfree(coeff);
|
||||
kvfree(coeff);
|
||||
coeff_alloc_fail:
|
||||
kfree(axix_x);
|
||||
kvfree(axix_x);
|
||||
axix_x_alloc_fail:
|
||||
kfree(curve);
|
||||
kvfree(curve);
|
||||
curve_alloc_fail:
|
||||
kfree(rgb_user);
|
||||
kvfree(rgb_user);
|
||||
rgb_user_alloc_fail:
|
||||
|
||||
return ret;
|
||||
@@ -1569,8 +1569,9 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
} else if (trans == TRANSFER_FUNCTION_PQ) {
|
||||
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS +
|
||||
_EXTRA_POINTS), GFP_KERNEL);
|
||||
rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
|
||||
(MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_regamma)
|
||||
goto rgb_regamma_alloc_fail;
|
||||
points->end_exponent = 7;
|
||||
@@ -1590,11 +1591,12 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
|
||||
kfree(rgb_regamma);
|
||||
kvfree(rgb_regamma);
|
||||
} else if (trans == TRANSFER_FUNCTION_SRGB ||
|
||||
trans == TRANSFER_FUNCTION_BT709) {
|
||||
rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS +
|
||||
_EXTRA_POINTS), GFP_KERNEL);
|
||||
rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
|
||||
(MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_regamma)
|
||||
goto rgb_regamma_alloc_fail;
|
||||
points->end_exponent = 0;
|
||||
@@ -1612,7 +1614,7 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
|
||||
kfree(rgb_regamma);
|
||||
kvfree(rgb_regamma);
|
||||
}
|
||||
rgb_regamma_alloc_fail:
|
||||
return ret;
|
||||
@@ -1636,8 +1638,9 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
} else if (trans == TRANSFER_FUNCTION_PQ) {
|
||||
rgb_degamma = kzalloc(sizeof(*rgb_degamma) * (MAX_HW_POINTS +
|
||||
_EXTRA_POINTS), GFP_KERNEL);
|
||||
rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
|
||||
(MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_degamma)
|
||||
goto rgb_degamma_alloc_fail;
|
||||
|
||||
@@ -1652,11 +1655,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
|
||||
kfree(rgb_degamma);
|
||||
kvfree(rgb_degamma);
|
||||
} else if (trans == TRANSFER_FUNCTION_SRGB ||
|
||||
trans == TRANSFER_FUNCTION_BT709) {
|
||||
rgb_degamma = kzalloc(sizeof(*rgb_degamma) * (MAX_HW_POINTS +
|
||||
_EXTRA_POINTS), GFP_KERNEL);
|
||||
rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
|
||||
(MAX_HW_POINTS + _EXTRA_POINTS),
|
||||
GFP_KERNEL);
|
||||
if (!rgb_degamma)
|
||||
goto rgb_degamma_alloc_fail;
|
||||
|
||||
@@ -1670,7 +1674,7 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
|
||||
}
|
||||
ret = true;
|
||||
|
||||
kfree(rgb_degamma);
|
||||
kvfree(rgb_degamma);
|
||||
}
|
||||
points->end_exponent = 0;
|
||||
points->x_point_at_y1_red = 1;
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador