From e2c7021a080cf74bb679ae5e91fa736ca85464ab Mon Sep 17 00:00:00 2001 From: Nanxin Qin Date: Mon, 02 Dec 2019 03:05:46 +0000 Subject: v4l: fixed the issue of parser. [1/1] PD#SWPL-17646 Problem: the stream parse err when the memory alloc failed. Solution: 1. replace the kmalloc to vmalloc, when there are more memory fragments and order that maybe cause alloc failed. 2. reference a unique struct of file_private_data Verify: U212 Change-Id: I499c1bb128c929d2144dc3f9f17e8555bd62d5d3 Signed-off-by: Nanxin Qin --- diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c index 5702039..6989153 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.c +++ b/drivers/amvdec_ports/aml_vcodec_dec.c @@ -279,8 +279,8 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) void vdec_frame_buffer_release(void *data) { - struct file_privdata *priv_data = - (struct file_privdata *) data; + struct file_private_data *priv_data = + (struct file_private_data *) data; struct vframe_s *vf = &priv_data->vf; if (decoder_bmmu_box_valide_check(vf->mm_box.bmmu_box)) { @@ -300,7 +300,7 @@ void vdec_frame_buffer_release(void *data) aml_v4l2_debug(2, "%s vf idx: %d, mmu_idx: %d, mmu_box: %p", __func__, vf->index, vf->mm_box.mmu_idx, vf->mm_box.mmu_box); - memset(data, 0, sizeof(struct file_privdata)); + memset(data, 0, sizeof(struct file_private_data)); kfree(data); } @@ -491,6 +491,8 @@ void trans_vframe_to_user(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *f /* binding vframe handle. */ vf->flag |= VFRAME_FLAG_VIDEO_LINEAR; dstbuf->privdata.vf = *vf; + dstbuf->privdata.vf.omx_index = + dstbuf->vb.vb2_buf.index; v4l2_m2m_buf_done(&dstbuf->vb, VB2_BUF_STATE_DONE); } @@ -1178,11 +1180,11 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv, file = fget(vb2_v4l2->private); if (is_v4l2_buf_file(file) && - !aml_buf->privdata.is_install) { + !aml_buf->is_install_privdata) { dmabuf_fd_install_data(vb2_v4l2->private, (void*)&aml_buf->privdata, - sizeof(struct file_privdata)); - aml_buf->privdata.is_install = true; + sizeof(struct file_private_data)); + aml_buf->is_install_privdata = true; } fput(file); mutex_unlock(&ctx->lock); @@ -1721,6 +1723,7 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) if (!buf->que_in_m2m) { aml_v4l2_debug(2, "[%d] enque capture buf idx %d, %p", ctx->id, vb->index, vb); + v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2); buf->que_in_m2m = true; buf->queued_in_vb2 = true; @@ -1952,7 +1955,7 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q) buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); buf->frame_buffer.status = FB_ST_NORMAL; buf->que_in_m2m = false; - buf->privdata.is_install = false; + buf->is_install_privdata = false; if (vb2_v4l2->vb2_buf.state == VB2_BUF_STATE_ACTIVE) v4l2_m2m_buf_done(vb2_v4l2, VB2_BUF_STATE_ERROR); diff --git a/drivers/amvdec_ports/aml_vcodec_dec.h b/drivers/amvdec_ports/aml_vcodec_dec.h index 7ca3337..765b788 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.h +++ b/drivers/amvdec_ports/aml_vcodec_dec.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "aml_vcodec_util.h" #define VCODEC_CAPABILITY_4K_DISABLED 0x10 @@ -39,16 +40,6 @@ #define AML_V4L2_SET_DECMODE (V4L2_CID_USER_AMLOGIC_BASE + 0) -/* for video composer metafd private_data struct */ -struct file_privdata { - struct vframe_s vf; - struct vframe_s *vf_p; - bool is_keep; - int keep_id; - int keep_head_id; - bool is_install; -}; - /** * struct vdec_fb - decoder frame buffer * @mem_type : gather or scatter memory. @@ -93,7 +84,7 @@ struct aml_video_dec_buf { struct list_head list; struct vdec_v4l2_buffer frame_buffer; - struct file_privdata privdata; + struct file_private_data privdata; struct codec_mm_s *mem[2]; char mem_onwer[32]; bool used; @@ -103,6 +94,7 @@ struct aml_video_dec_buf { bool queued_in_v4l2; bool lastframe; bool error; + bool is_install_privdata; }; extern const struct v4l2_ioctl_ops aml_vdec_ioctl_ops; diff --git a/drivers/amvdec_ports/aml_vcodec_dec_drv.c b/drivers/amvdec_ports/aml_vcodec_dec_drv.c index 6307e5b..d35d738 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec_drv.c +++ b/drivers/amvdec_ports/aml_vcodec_dec_drv.c @@ -199,7 +199,7 @@ int v4l2_alloc_fd(int *fd) } file->private_data = - kzalloc(sizeof(struct file_privdata), GFP_KERNEL); + kzalloc(sizeof(struct file_private_data), GFP_KERNEL); if (!file->private_data) { pr_err("%s: alloc priv data faild.\n", __func__); return -ENOMEM; diff --git a/drivers/amvdec_ports/decoder/vdec_h264_if.c b/drivers/amvdec_ports/decoder/vdec_h264_if.c index 3fdac28..8a740c5 100644 --- a/drivers/amvdec_ports/decoder/vdec_h264_if.c +++ b/drivers/amvdec_ports/decoder/vdec_h264_if.c @@ -584,7 +584,7 @@ static int stream_parse(struct vdec_h264_inst *inst, u8 *buf, u32 size) inst->vsi->is_combine = is_combine; inst->vsi->nalu_pos = nal_idx; - ps = kzalloc(sizeof(struct h264_param_sets), GFP_KERNEL); + ps = vzalloc(sizeof(struct h264_param_sets)); if (ps == NULL) return -ENOMEM; @@ -599,7 +599,7 @@ static int stream_parse(struct vdec_h264_inst *inst, u8 *buf, u32 size) ret = ps->sps_parsed ? 0 : -1; out: - kfree(ps); + vfree(ps); return ret; } diff --git a/drivers/amvdec_ports/decoder/vdec_hevc_if.c b/drivers/amvdec_ports/decoder/vdec_hevc_if.c index 7c1e5eb..3d7e76e 100644 --- a/drivers/amvdec_ports/decoder/vdec_hevc_if.c +++ b/drivers/amvdec_ports/decoder/vdec_hevc_if.c @@ -424,7 +424,7 @@ static int stream_parse(struct vdec_hevc_inst *inst, u8 *buf, u32 size) int ret = 0; struct h265_param_sets *ps = NULL; - ps = kzalloc(sizeof(struct h265_param_sets), GFP_KERNEL); + ps = vzalloc(sizeof(struct h265_param_sets)); if (ps == NULL) return -ENOMEM; @@ -439,7 +439,7 @@ static int stream_parse(struct vdec_hevc_inst *inst, u8 *buf, u32 size) ret = ps->sps_parsed ? 0 : -1; out: - kfree(ps); + vfree(ps); return ret; } diff --git a/drivers/amvdec_ports/decoder/vdec_vp9_if.c b/drivers/amvdec_ports/decoder/vdec_vp9_if.c index 4091500..106dc5e 100644 --- a/drivers/amvdec_ports/decoder/vdec_vp9_if.c +++ b/drivers/amvdec_ports/decoder/vdec_vp9_if.c @@ -449,7 +449,7 @@ static int stream_parse(struct vdec_vp9_inst *inst, u8 *buf, u32 size) int ret = 0; struct vp9_param_sets *ps = NULL; - ps = kzalloc(sizeof(struct vp9_param_sets), GFP_KERNEL); + ps = vzalloc(sizeof(struct vp9_param_sets)); if (ps == NULL) return -ENOMEM; @@ -464,7 +464,7 @@ static int stream_parse(struct vdec_vp9_inst *inst, u8 *buf, u32 size) ret = ps->head_parsed ? 0 : -1; out: - kfree(ps); + vfree(ps); return ret; } -- cgit