linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helen Koike <helen.koike@collabora.com>
To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, ezequiel@collabora.com,
	hverkuil@xs4all.nl, kernel@collabora.com, dafna3@gmail.com,
	sakari.ailus@linux.intel.com, linux-rockchip@lists.infradead.org,
	mchehab@kernel.org, tfiga@chromium.org
Subject: Re: [PATCH v2 09/14] media: staging: rkisp1: remove atomic operations for frame sequence
Date: Mon, 17 Aug 2020 18:48:09 -0300	[thread overview]
Message-ID: <c93cab1c-747c-250d-eb6b-1ed748cc909d@collabora.com> (raw)
In-Reply-To: <20200815103734.31153-10-dafna.hirschfeld@collabora.com>

Hi Dafna,

On 8/15/20 7:37 AM, Dafna Hirschfeld wrote:
> 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.
> 
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> ---
>  drivers/staging/media/rkisp1/rkisp1-capture.c |  2 +-
>  drivers/staging/media/rkisp1/rkisp1-common.h  |  2 +-
>  drivers/staging/media/rkisp1/rkisp1-isp.c     | 20 +++++++++----------
>  drivers/staging/media/rkisp1/rkisp1-params.c  |  2 +-
>  drivers/staging/media/rkisp1/rkisp1-stats.c   |  3 +--
>  5 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
> index c05280950ea0..d7017afc5405 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-capture.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
> @@ -632,7 +632,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);
> diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h
> index 9b41935c6597..79edece6ee77 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-common.h
> +++ b/drivers/staging/media/rkisp1/rkisp1-common.h
> @@ -112,7 +112,7 @@ struct rkisp1_isp {
>  	const struct rkisp1_isp_mbus_info *src_fmt;
>  	struct mutex ops_lock;
>  	bool is_dphy_errctrl_disabled;
> -	atomic_t frame_sequence;
> +	__u32 frame_sequence;
>  };
>  
>  struct rkisp1_vdev_node {
> diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c
> index ad2ece78abbf..1ffe7cc7bb12 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-isp.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c
> @@ -940,7 +940,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)
> @@ -1093,15 +1093,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);
>  }
>  
> @@ -1116,7 +1109,14 @@ 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) {
> +		/*
> +		 * Increment the frame sequence on the vsync signal.
> +		 * This will allow applications to detect dropped.

I know just moved the comment, but I would like to take this opportunity
to fix this text:

s/to detect dropped/to detect dropped frames.

> +		 * Note that there is a debugfs counter for dropped
> +		 * frames, but using this event is more accurate.

I'm not sure if this phrase is accurate :P
Since the debugfs counter should be reliable to verify we dropped frames.

I mean, usage is different.

maybe just:

s/, but using this event is more accurate././


With or without these changes:

Acked-by: Helen Koike <helen.koike@collabora.com>

Regards,
Helen

> +		 */
> +		rkisp1->isp.frame_sequence++;
>  		rkisp1_isp_queue_event_sof(&rkisp1->isp);
>  
>  	if (status & RKISP1_CIF_ISP_PIC_SIZE_ERROR) {
> diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c
> index 4b4391c0a2a0..cc242ad5106e 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-params.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-params.c
> @@ -1227,7 +1227,7 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1)
>  	 * We want the vb.sequence to be the frame that the params are applied to.
>  	 * So we set vb.sequence to be the isp's frame_sequence + 1
>  	 */
> -	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);
> diff --git a/drivers/staging/media/rkisp1/rkisp1-stats.c b/drivers/staging/media/rkisp1/rkisp1-stats.c
> index 87e4104d20dd..52417b388854 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-stats.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-stats.c
> @@ -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 */
> 

  reply	other threads:[~2020-08-17 21:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15 10:37 [PATCH v2 00/14] media: staging: rkisp1: various bug fixes Dafna Hirschfeld
2020-08-15 10:37 ` [PATCH v2 01/14] media: staging: rkisp1: call params isr only upon frame out Dafna Hirschfeld
2020-08-17 21:46   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 02/14] media: staging: rkisp1: params: use rkisp1_param_set_bits to set reg in isr Dafna Hirschfeld
2020-08-17 21:46   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 03/14] media: staging: rkisp1: params: use the new effect value in cproc config Dafna Hirschfeld
2020-08-17 21:46   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 04/14] media: staging: rkisp1: params: don't release lock in isr before buffer is done Dafna Hirschfeld
2020-08-17 21:47   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 05/14] media: staging: rkisp1: params: upon stream stop, iterate a local list to return the buffers Dafna Hirschfeld
2020-08-17 21:47   ` Helen Koike
2020-08-20  9:27     ` Hans Verkuil
2020-08-20 12:16       ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 06/14] media: staging: rkisp1: params: in the isr, return if buffer list is empty Dafna Hirschfeld
2020-08-17 21:47   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 07/14] media: staging: rkisp1: params: avoid using buffer if params is not streaming Dafna Hirschfeld
2020-08-16  4:28   ` kernel test robot
2020-08-17 21:47   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 08/14] media: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1 Dafna Hirschfeld
2020-08-17 21:47   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 09/14] media: staging: rkisp1: remove atomic operations for frame sequence Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike [this message]
2020-09-17 16:41     ` Dafna Hirschfeld
2020-08-15 10:37 ` [PATCH v2 10/14] media: staging: rkisp1: isp: add a warning and debugfs var for irq delay Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike
2020-08-18  6:46     ` Dafna Hirschfeld
2020-08-15 10:37 ` [PATCH v2 11/14] media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike
2020-08-18  6:37     ` Dafna Hirschfeld
2020-08-15 10:37 ` [PATCH v2 12/14] media: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 13/14] media: staging: rkisp1: call media_pipeline_start/stop from stats and params Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike
2020-08-15 10:37 ` [PATCH v2 14/14] media: staging: rkisp1: params: no need to lock default config Dafna Hirschfeld
2020-08-17 21:48   ` Helen Koike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c93cab1c-747c-250d-eb6b-1ed748cc909d@collabora.com \
    --to=helen.koike@collabora.com \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=ezequiel@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).