media: staging: rkisp1: remove atomic operations for frame sequence
authorDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Tue, 22 Sep 2020 11:33:56 +0000 (13:33 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sun, 27 Sep 2020 09:34:05 +0000 (11:34 +0200)
The isp.frame_sequence is now read only from the irq handlers
that are all fired from the same interrupt, so there is not need
for atomic operation.
In addition, the frame seq incrementation is moved from
rkisp1_isp_queue_event_sof to rkisp1_isp_isr to make the code
clearer and the incorrect inline comment is removed.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/rkisp1/rkisp1-capture.c
drivers/staging/media/rkisp1/rkisp1-common.h
drivers/staging/media/rkisp1/rkisp1-isp.c
drivers/staging/media/rkisp1/rkisp1-params.c
drivers/staging/media/rkisp1/rkisp1-stats.c

index a0889e9548a3c5b2ce448f5442d3a8bb8b25775a..84a173204b86ca82799fb5c54d2ab6e6b7b91a10 100644 (file)
@@ -674,7 +674,7 @@ static void rkisp1_handle_buffer(struct rkisp1_capture *cap)
        curr_buf = cap->buf.curr;
 
        if (curr_buf) {
-               curr_buf->vb.sequence = atomic_read(&isp->frame_sequence);
+               curr_buf->vb.sequence = isp->frame_sequence;
                curr_buf->vb.vb2_buf.timestamp = ktime_get_boottime_ns();
                curr_buf->vb.field = V4L2_FIELD_NONE;
                vb2_buffer_done(&curr_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
index 874186a6dabb87271da0460ca175389d3aee6ad5..01a4d9bae9823fb049a68ba25e41a55353458de5 100644 (file)
@@ -131,7 +131,7 @@ struct rkisp1_isp {
        const struct rkisp1_isp_mbus_info *src_fmt;
        struct mutex ops_lock; /* serialize the subdevice ops */
        bool is_dphy_errctrl_disabled;
-       atomic_t frame_sequence;
+       __u32 frame_sequence;
 };
 
 /*
index 704dd08c6ee55188a279a772f6d288df02de447c..49efcb589d5c793e26ecc6d59d6b0661a0e11144 100644 (file)
@@ -952,7 +952,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
        if (rkisp1->active_sensor->mbus_type != V4L2_MBUS_CSI2_DPHY)
                return -EINVAL;
 
-       atomic_set(&rkisp1->isp.frame_sequence, -1);
+       rkisp1->isp.frame_sequence = -1;
        mutex_lock(&isp->ops_lock);
        ret = rkisp1_config_cif(rkisp1);
        if (ret)
@@ -1104,15 +1104,8 @@ static void rkisp1_isp_queue_event_sof(struct rkisp1_isp *isp)
        struct v4l2_event event = {
                .type = V4L2_EVENT_FRAME_SYNC,
        };
+       event.u.frame_sync.frame_sequence = isp->frame_sequence;
 
-       /*
-        * Increment the frame sequence on the vsync signal.
-        * This will allow applications to detect dropped.
-        * Note that there is a debugfs counter for dropped
-        * frames, but using this event is more accurate.
-        */
-       event.u.frame_sync.frame_sequence =
-               atomic_inc_return(&isp->frame_sequence);
        v4l2_event_queue(isp->sd.devnode, &event);
 }
 
@@ -1127,9 +1120,10 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1)
        rkisp1_write(rkisp1, status, RKISP1_CIF_ISP_ICR);
 
        /* Vertical sync signal, starting generating new frame */
-       if (status & RKISP1_CIF_ISP_V_START)
+       if (status & RKISP1_CIF_ISP_V_START) {
+               rkisp1->isp.frame_sequence++;
                rkisp1_isp_queue_event_sof(&rkisp1->isp);
-
+       }
        if (status & RKISP1_CIF_ISP_PIC_SIZE_ERROR) {
                /* Clear pic_size_error */
                isp_err = rkisp1_read(rkisp1, RKISP1_CIF_ISP_ERR);
index 24a49368df222d018ae6532ebdc94c3179e6f508..7aa76f03272879adf3fe7297a22c28f1475bf4b4 100644 (file)
@@ -1220,7 +1220,7 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1)
         * frame_sequence + 1 here to indicate to userspace on which frame these parameters
         * are being applied.
         */
-       unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence) + 1;
+       unsigned int frame_sequence = rkisp1->isp.frame_sequence + 1;
        struct rkisp1_params *params = &rkisp1->params;
 
        spin_lock(&params->config_lock);
index 1daab7a318dcb8d8ebb026cf53be40be238f3529..6aa18d970f2bc34d27f6e62bbceeea8bee44740c 100644 (file)
@@ -307,8 +307,7 @@ rkisp1_stats_send_measurement(struct rkisp1_stats *stats, u32 isp_ris)
 {
        struct rkisp1_stat_buffer *cur_stat_buf;
        struct rkisp1_buffer *cur_buf = NULL;
-       unsigned int frame_sequence =
-               atomic_read(&stats->rkisp1->isp.frame_sequence);
+       unsigned int frame_sequence = stats->rkisp1->isp.frame_sequence;
        u64 timestamp = ktime_get_ns();
 
        /* get one empty buffer */