summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShijie Qin <shijie.qin@nxp.com>2020-04-18 09:55:53 +0800
committerShijie Qin <shijie.qin@nxp.com>2020-04-18 11:14:29 +0800
commit252217e0dc992ffed64f76fabf79cedae95e09f5 (patch)
treebcc5640c10fbe5442d73aae4cc1ef07c63963a44
parent02e96760b8fbeffcab1769f9a9a45da661409cc2 (diff)
LF-1236 mxc: vpu_malone: roundup allocated kfifo size to power-of-two
kfifo memory size must roundup to power-of-two if it is allocated by driver. Because kfifo elements size will roundup to power-of-two in kfifo_init(), must guarantee allocated memory is enough. Signed-off-by: Shijie Qin <shijie.qin@nxp.com> Reviewed-by: ming_qian <ming.qian@nxp.com> (cherry picked from commit c900bb4cd98efc43dddfb18d96c8af358e804481)
-rw-r--r--drivers/mxc/vpu_malone/vpu_b0.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mxc/vpu_malone/vpu_b0.c b/drivers/mxc/vpu_malone/vpu_b0.c
index 6482a05fca24..7ee3e8a5f570 100644
--- a/drivers/mxc/vpu_malone/vpu_b0.c
+++ b/drivers/mxc/vpu_malone/vpu_b0.c
@@ -5819,6 +5819,8 @@ static int v4l2_open(struct file *filp)
atomic64_set(&ctx->statistic.total_alloc_size, 0);
ctx->msg_buffer_size = sizeof(struct event_msg) * VID_API_MESSAGE_LIMIT;
+ if (!is_power_of_2(ctx->msg_buffer_size))
+ ctx->msg_buffer_size = roundup_pow_of_two(ctx->msg_buffer_size);
ctx->msg_buffer = vzalloc(ctx->msg_buffer_size);
if (!ctx->msg_buffer) {
vpu_err("fail to alloc fifo when open\n");
@@ -6348,6 +6350,8 @@ static int vpu_probe(struct platform_device *pdev)
dev->mu_msg_buffer_size =
sizeof(u_int32) * VPU_MAX_NUM_STREAMS * VID_API_MESSAGE_LIMIT;
+ if (!is_power_of_2(dev->mu_msg_buffer_size))
+ dev->mu_msg_buffer_size = roundup_pow_of_two(dev->mu_msg_buffer_size);
dev->mu_msg_buffer = vzalloc(dev->mu_msg_buffer_size);
if (!dev->mu_msg_buffer) {
vpu_err("error: fail to alloc mu msg fifo\n");