Commit efb13c3d authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] s5p-fimc: Simplify locking by removing the context data structure spinlock

Access to the memory-to-memory video node is serialized through a
mutex so now there is no point in having per device context structure
spinlock.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent aa333122
...@@ -147,10 +147,12 @@ int fimc_capture_config_update(struct fimc_ctx *ctx) ...@@ -147,10 +147,12 @@ int fimc_capture_config_update(struct fimc_ctx *ctx)
if (!test_bit(ST_CAPT_APPLY_CFG, &fimc->state)) if (!test_bit(ST_CAPT_APPLY_CFG, &fimc->state))
return 0; return 0;
spin_lock(&ctx->slock);
fimc_hw_set_camera_offset(fimc, &ctx->s_frame); fimc_hw_set_camera_offset(fimc, &ctx->s_frame);
ret = fimc_set_scaler_info(ctx); ret = fimc_set_scaler_info(ctx);
if (ret == 0) { if (ret)
return ret;
fimc_hw_set_prescaler(ctx); fimc_hw_set_prescaler(ctx);
fimc_hw_set_mainscaler(ctx); fimc_hw_set_mainscaler(ctx);
fimc_hw_set_target_format(ctx); fimc_hw_set_target_format(ctx);
...@@ -159,9 +161,8 @@ int fimc_capture_config_update(struct fimc_ctx *ctx) ...@@ -159,9 +161,8 @@ int fimc_capture_config_update(struct fimc_ctx *ctx)
fimc_hw_set_out_dma(ctx); fimc_hw_set_out_dma(ctx);
if (fimc->variant->has_alpha) if (fimc->variant->has_alpha)
fimc_hw_set_rgb_alpha(ctx); fimc_hw_set_rgb_alpha(ctx);
clear_bit(ST_CAPT_APPLY_CFG, &fimc->state); clear_bit(ST_CAPT_APPLY_CFG, &fimc->state);
}
spin_unlock(&ctx->slock);
return ret; return ret;
} }
...@@ -1525,7 +1526,6 @@ int fimc_register_capture_device(struct fimc_dev *fimc, ...@@ -1525,7 +1526,6 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
INIT_LIST_HEAD(&vid_cap->pending_buf_q); INIT_LIST_HEAD(&vid_cap->pending_buf_q);
INIT_LIST_HEAD(&vid_cap->active_buf_q); INIT_LIST_HEAD(&vid_cap->active_buf_q);
spin_lock_init(&ctx->slock);
vid_cap->ctx = ctx; vid_cap->ctx = ctx;
q = &fimc->vid_cap.vbq; q = &fimc->vid_cap.vbq;
......
...@@ -320,7 +320,7 @@ static int fimc_m2m_shutdown(struct fimc_ctx *ctx) ...@@ -320,7 +320,7 @@ static int fimc_m2m_shutdown(struct fimc_ctx *ctx)
if (!fimc_m2m_pending(fimc)) if (!fimc_m2m_pending(fimc))
return 0; return 0;
fimc_ctx_state_lock_set(FIMC_CTX_SHUT, ctx); fimc_ctx_state_set(FIMC_CTX_SHUT, ctx);
ret = wait_event_timeout(fimc->irq_queue, ret = wait_event_timeout(fimc->irq_queue,
!fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx), !fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx),
...@@ -430,14 +430,12 @@ static irqreturn_t fimc_irq_handler(int irq, void *priv) ...@@ -430,14 +430,12 @@ static irqreturn_t fimc_irq_handler(int irq, void *priv)
spin_unlock(&fimc->slock); spin_unlock(&fimc->slock);
fimc_m2m_job_finish(ctx, VB2_BUF_STATE_DONE); fimc_m2m_job_finish(ctx, VB2_BUF_STATE_DONE);
spin_lock(&ctx->slock);
if (ctx->state & FIMC_CTX_SHUT) { if (ctx->state & FIMC_CTX_SHUT) {
ctx->state &= ~FIMC_CTX_SHUT; ctx->state &= ~FIMC_CTX_SHUT;
wake_up(&fimc->irq_queue); wake_up(&fimc->irq_queue);
} }
spin_unlock(&ctx->slock);
}
return IRQ_HANDLED; return IRQ_HANDLED;
}
} else if (test_bit(ST_CAPT_PEND, &fimc->state)) { } else if (test_bit(ST_CAPT_PEND, &fimc->state)) {
fimc_capture_irq_handler(fimc, fimc_capture_irq_handler(fimc,
!test_bit(ST_CAPT_JPEG, &fimc->state)); !test_bit(ST_CAPT_JPEG, &fimc->state));
...@@ -644,7 +642,6 @@ static void fimc_dma_run(void *priv) ...@@ -644,7 +642,6 @@ static void fimc_dma_run(void *priv)
spin_lock_irqsave(&fimc->slock, flags); spin_lock_irqsave(&fimc->slock, flags);
set_bit(ST_M2M_PEND, &fimc->state); set_bit(ST_M2M_PEND, &fimc->state);
spin_lock(&ctx->slock);
ctx->state |= (FIMC_SRC_ADDR | FIMC_DST_ADDR); ctx->state |= (FIMC_SRC_ADDR | FIMC_DST_ADDR);
ret = fimc_prepare_config(ctx, ctx->state); ret = fimc_prepare_config(ctx, ctx->state);
if (ret) if (ret)
...@@ -661,10 +658,8 @@ static void fimc_dma_run(void *priv) ...@@ -661,10 +658,8 @@ static void fimc_dma_run(void *priv)
fimc_hw_set_input_path(ctx); fimc_hw_set_input_path(ctx);
fimc_hw_set_in_dma(ctx); fimc_hw_set_in_dma(ctx);
ret = fimc_set_scaler_info(ctx); ret = fimc_set_scaler_info(ctx);
if (ret) { if (ret)
spin_unlock(&fimc->slock);
goto dma_unlock; goto dma_unlock;
}
fimc_hw_set_prescaler(ctx); fimc_hw_set_prescaler(ctx);
fimc_hw_set_mainscaler(ctx); fimc_hw_set_mainscaler(ctx);
fimc_hw_set_target_format(ctx); fimc_hw_set_target_format(ctx);
...@@ -688,7 +683,6 @@ static void fimc_dma_run(void *priv) ...@@ -688,7 +683,6 @@ static void fimc_dma_run(void *priv)
FIMC_SRC_FMT | FIMC_DST_FMT); FIMC_SRC_FMT | FIMC_DST_FMT);
fimc_hw_activate_input_dma(fimc, true); fimc_hw_activate_input_dma(fimc, true);
dma_unlock: dma_unlock:
spin_unlock(&ctx->slock);
spin_unlock_irqrestore(&fimc->slock, flags); spin_unlock_irqrestore(&fimc->slock, flags);
} }
...@@ -827,9 +821,9 @@ static int fimc_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -827,9 +821,9 @@ static int fimc_s_ctrl(struct v4l2_ctrl *ctrl)
unsigned long flags; unsigned long flags;
int ret; int ret;
spin_lock_irqsave(&ctx->slock, flags); spin_lock_irqsave(&ctx->fimc_dev->slock, flags);
ret = __fimc_s_ctrl(ctx, ctrl); ret = __fimc_s_ctrl(ctx, ctrl);
spin_unlock_irqrestore(&ctx->slock, flags); spin_unlock_irqrestore(&ctx->fimc_dev->slock, flags);
return ret; return ret;
} }
...@@ -1174,9 +1168,9 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh, ...@@ -1174,9 +1168,9 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
ctx->scaler.enabled = 1; ctx->scaler.enabled = 1;
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
fimc_ctx_state_lock_set(FIMC_PARAMS | FIMC_DST_FMT, ctx); fimc_ctx_state_set(FIMC_PARAMS | FIMC_DST_FMT, ctx);
else else
fimc_ctx_state_lock_set(FIMC_PARAMS | FIMC_SRC_FMT, ctx); fimc_ctx_state_set(FIMC_PARAMS | FIMC_SRC_FMT, ctx);
dbg("f_w: %d, f_h: %d", frame->f_width, frame->f_height); dbg("f_w: %d, f_h: %d", frame->f_width, frame->f_height);
...@@ -1363,7 +1357,7 @@ static int fimc_m2m_s_crop(struct file *file, void *fh, struct v4l2_crop *cr) ...@@ -1363,7 +1357,7 @@ static int fimc_m2m_s_crop(struct file *file, void *fh, struct v4l2_crop *cr)
f->width = cr->c.width; f->width = cr->c.width;
f->height = cr->c.height; f->height = cr->c.height;
fimc_ctx_state_lock_set(FIMC_PARAMS, ctx); fimc_ctx_state_set(FIMC_PARAMS, ctx);
return 0; return 0;
} }
...@@ -1467,7 +1461,6 @@ static int fimc_m2m_open(struct file *file) ...@@ -1467,7 +1461,6 @@ static int fimc_m2m_open(struct file *file)
ctx->flags = 0; ctx->flags = 0;
ctx->in_path = FIMC_DMA; ctx->in_path = FIMC_DMA;
ctx->out_path = FIMC_DMA; ctx->out_path = FIMC_DMA;
spin_lock_init(&ctx->slock);
ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init); ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init);
if (IS_ERR(ctx->m2m_ctx)) { if (IS_ERR(ctx->m2m_ctx)) {
......
...@@ -465,7 +465,6 @@ struct fimc_dev { ...@@ -465,7 +465,6 @@ struct fimc_dev {
/** /**
* fimc_ctx - the device context data * fimc_ctx - the device context data
* @slock: spinlock protecting this data structure
* @s_frame: source frame properties * @s_frame: source frame properties
* @d_frame: destination frame properties * @d_frame: destination frame properties
* @out_order_1p: output 1-plane YCBCR order * @out_order_1p: output 1-plane YCBCR order
...@@ -492,7 +491,6 @@ struct fimc_dev { ...@@ -492,7 +491,6 @@ struct fimc_dev {
* @ctrls_rdy: true if the control handler is initialized * @ctrls_rdy: true if the control handler is initialized
*/ */
struct fimc_ctx { struct fimc_ctx {
spinlock_t slock;
struct fimc_frame s_frame; struct fimc_frame s_frame;
struct fimc_frame d_frame; struct fimc_frame d_frame;
u32 out_order_1p; u32 out_order_1p;
...@@ -560,13 +558,13 @@ static inline bool fimc_capture_active(struct fimc_dev *fimc) ...@@ -560,13 +558,13 @@ static inline bool fimc_capture_active(struct fimc_dev *fimc)
return ret; return ret;
} }
static inline void fimc_ctx_state_lock_set(u32 state, struct fimc_ctx *ctx) static inline void fimc_ctx_state_set(u32 state, struct fimc_ctx *ctx)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ctx->slock, flags); spin_lock_irqsave(&ctx->fimc_dev->slock, flags);
ctx->state |= state; ctx->state |= state;
spin_unlock_irqrestore(&ctx->slock, flags); spin_unlock_irqrestore(&ctx->fimc_dev->slock, flags);
} }
static inline bool fimc_ctx_state_is_set(u32 mask, struct fimc_ctx *ctx) static inline bool fimc_ctx_state_is_set(u32 mask, struct fimc_ctx *ctx)
...@@ -574,9 +572,9 @@ static inline bool fimc_ctx_state_is_set(u32 mask, struct fimc_ctx *ctx) ...@@ -574,9 +572,9 @@ static inline bool fimc_ctx_state_is_set(u32 mask, struct fimc_ctx *ctx)
unsigned long flags; unsigned long flags;
bool ret; bool ret;
spin_lock_irqsave(&ctx->slock, flags); spin_lock_irqsave(&ctx->fimc_dev->slock, flags);
ret = (ctx->state & mask) == mask; ret = (ctx->state & mask) == mask;
spin_unlock_irqrestore(&ctx->slock, flags); spin_unlock_irqrestore(&ctx->fimc_dev->slock, flags);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment