[media] s5p-mfc: use spinlock to protect MFC context
[deliverable/linux.git] / drivers / media / platform / s5p-mfc / s5p_mfc_opr_v5.c
index 8754b7e039e88db3854f24552b3cd0b454b0e141..81e1e4ce6c2452dd76a24d4490a60257f4059e26 100644 (file)
@@ -1166,7 +1166,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
        struct s5p_mfc_buf *temp_vb;
-       unsigned long flags;
 
        if (ctx->state == MFCINST_FINISHING) {
                last_frame = MFC_DEC_LAST_FRAME;
@@ -1176,11 +1175,9 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
                return 0;
        }
 
-       spin_lock_irqsave(&dev->irqlock, flags);
        /* Frames are being decoded */
        if (list_empty(&ctx->src_queue)) {
                mfc_debug(2, "No src buffers\n");
-               spin_unlock_irqrestore(&dev->irqlock, flags);
                return -EAGAIN;
        }
        /* Get the next source buffer */
@@ -1189,7 +1186,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
                vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
                ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused);
-       spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) {
                last_frame = MFC_DEC_LAST_FRAME;
@@ -1203,21 +1199,17 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
 static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       unsigned long flags;
        struct s5p_mfc_buf *dst_mb;
        struct s5p_mfc_buf *src_mb;
        unsigned long src_y_addr, src_c_addr, dst_addr;
        unsigned int dst_size;
 
-       spin_lock_irqsave(&dev->irqlock, flags);
        if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) {
                mfc_debug(2, "no src buffers\n");
-               spin_unlock_irqrestore(&dev->irqlock, flags);
                return -EAGAIN;
        }
        if (list_empty(&ctx->dst_queue)) {
                mfc_debug(2, "no dst buffers\n");
-               spin_unlock_irqrestore(&dev->irqlock, flags);
                return -EAGAIN;
        }
        if (list_empty(&ctx->src_queue)) {
@@ -1249,7 +1241,6 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
        dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
        dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
        s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
-       spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        mfc_debug(2, "encoding buffer with index=%d state=%d\n",
                  src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state);
@@ -1260,11 +1251,9 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
 static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       unsigned long flags;
        struct s5p_mfc_buf *temp_vb;
 
        /* Initializing decoding - parsing header */
-       spin_lock_irqsave(&dev->irqlock, flags);
        mfc_debug(2, "Preparing to init decoding\n");
        temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
        s5p_mfc_set_dec_desc_buffer(ctx);
@@ -1273,7 +1262,6 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
                        vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
                        0, temp_vb->b->vb2_buf.planes[0].bytesused);
-       spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        s5p_mfc_init_decode_v5(ctx);
 }
@@ -1281,18 +1269,15 @@ static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
 static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       unsigned long flags;
        struct s5p_mfc_buf *dst_mb;
        unsigned long dst_addr;
        unsigned int dst_size;
 
        s5p_mfc_set_enc_ref_buffer_v5(ctx);
-       spin_lock_irqsave(&dev->irqlock, flags);
        dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
        dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
        dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
        s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
-       spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        s5p_mfc_init_encode_v5(ctx);
 }
@@ -1300,7 +1285,6 @@ static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
 static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       unsigned long flags;
        struct s5p_mfc_buf *temp_vb;
        int ret;
 
@@ -1314,11 +1298,9 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
                        "before starting processing\n");
                return -EAGAIN;
        }
-       spin_lock_irqsave(&dev->irqlock, flags);
        if (list_empty(&ctx->src_queue)) {
                mfc_err("Header has been deallocated in the middle of"
                        " initialization\n");
-               spin_unlock_irqrestore(&dev->irqlock, flags);
                return -EIO;
        }
        temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
@@ -1327,7 +1309,6 @@ static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
        s5p_mfc_set_dec_stream_buffer_v5(ctx,
                        vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
                        0, temp_vb->b->vb2_buf.planes[0].bytesused);
-       spin_unlock_irqrestore(&dev->irqlock, flags);
        dev->curr_ctx = ctx->num;
        ret = s5p_mfc_set_dec_frame_buffer_v5(ctx);
        if (ret) {
This page took 0.039998 seconds and 5 git commands to generate.