v4l: fixed the issue of parser. [1/1]
authorNanxin Qin <nanxin.qin@amlogic.com>
Mon, 2 Dec 2019 03:05:46 +0000 (11:05 +0800)
committerNanxin Qin <nanxin.qin@amlogic.com>
Tue, 3 Dec 2019 06:26:12 +0000 (14:26 +0800)
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 <nanxin.qin@amlogic.com>
drivers/amvdec_ports/aml_vcodec_dec.c
drivers/amvdec_ports/aml_vcodec_dec.h
drivers/amvdec_ports/aml_vcodec_dec_drv.c
drivers/amvdec_ports/decoder/vdec_h264_if.c
drivers/amvdec_ports/decoder/vdec_hevc_if.c
drivers/amvdec_ports/decoder/vdec_vp9_if.c

index 570203990c2f756db505e5196bfc5ff0dcd17dbe..6989153b2fd3858a14b93e52b47822a769f1cff4 100644 (file)
@@ -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);
index 7ca3337654329628ba458eee5798cbf872e60bc4..765b788bc386ca80b850a209cc067e477398b022 100644 (file)
@@ -23,6 +23,7 @@
 #include <media/videobuf2-core.h>
 #include <media/videobuf2-v4l2.h>
 #include <linux/amlogic/media/codec_mm/codec_mm.h>
+#include <linux/amlogic/media/video_sink/v4lvideo_ext.h>
 #include "aml_vcodec_util.h"
 
 #define VCODEC_CAPABILITY_4K_DISABLED  0x10
 
 #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;
index 6307e5bf895e98c4700b758bd4f8084f1cab778c..d35d738454b8237ea996b442407aaf0eda05f287 100644 (file)
@@ -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;
index 3fdac28f6c5f80c8dab534e3454493c900f12dc7..8a740c5e5ec71ecd6cd3508ffab7f3a3677bf18f 100644 (file)
@@ -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;
 }
index 7c1e5eba93b9f29102dda030671ff201e57932ac..3d7e76ec5de028aa4a7c69853ed75575c45e10bb 100644 (file)
@@ -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;
 }
index 4091500de7f5deb6e4842f22b441701141e7f347..106dc5ebe4f3b64407c0d99db2f3873259ecde13 100644 (file)
@@ -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;
 }