Linux Media Controller development
 help / color / mirror / Atom feed
From: Bingbu Cao <bingbu.cao@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Yong Zhi <yong.zhi@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>,
	Tian Shu Qiu <tian.shu.qiu@intel.com>,
	linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [PATCH v1 5/7] media: ipu3-cio2: Replace infinite loop by one with clear exit condition
Date: Mon, 17 Aug 2020 18:21:23 +0800	[thread overview]
Message-ID: <aa68f5ec-359c-70ce-ecf6-ee013497230a@linux.intel.com> (raw)
In-Reply-To: <20200814163017.35001-5-andriy.shevchenko@linux.intel.com>



On 8/15/20 12:30 AM, Andy Shevchenko wrote:
> Refactor cio2_buffer_done() to get rid of infinite loop by replacing it by one
> with clear exit condition. This change also allows to check for an error ahead.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index eee7f841050d..f4175dc1501a 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -541,7 +541,7 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
>  {
>  	struct device *dev = &cio2->pci_dev->dev;
>  	struct cio2_queue *q = cio2->cur_queue;
> -	int buffers_found = 0;
> +	struct cio2_fbpt_entry *const entry;
No 'const' here.

>  	u64 ns = ktime_get_ns();
>  
>  	if (dma_chan >= CIO2_QUEUES) {
> @@ -549,15 +549,18 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
>  		return;
>  	}
>  
> +	entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS];
> +	if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID) {
> +		dev_warn(&cio2->pci_dev->dev,
> +			 "no ready buffers found on DMA channel %u\n",
> +			 dma_chan);
> +		return;
> +	}
> +
>  	/* Find out which buffer(s) are ready */
>  	do {
> -		struct cio2_fbpt_entry *const entry =
> -			&q->fbpt[q->bufs_first * CIO2_MAX_LOPS];
>  		struct cio2_buffer *b;
>  
> -		if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID)
> -			break;
> -
>  		b = q->bufs[q->bufs_first];
>  		if (b) {
>  			unsigned int bytes = entry[1].second_entry.num_of_bytes;
> @@ -579,13 +582,8 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
>  		atomic_inc(&q->frame_sequence);
>  		cio2_fbpt_entry_init_dummy(cio2, entry);
>  		q->bufs_first = (q->bufs_first + 1) % CIO2_MAX_BUFFERS;
> -		buffers_found++;
> -	} while (1);
> -
> -	if (buffers_found == 0)
> -		dev_warn(&cio2->pci_dev->dev,
> -			 "no ready buffers found on DMA channel %u\n",
> -			 dma_chan);
> +		entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS];
> +	} while (!(entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID));
>  }
>  
>  static void cio2_queue_event_sof(struct cio2_device *cio2, struct cio2_queue *q)
> 

-- 
Best regards,
Bingbu Cao

  reply	other threads:[~2020-08-17 10:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14 16:30 [PATCH v1 1/7] media: ipu3-cio2: Simplify cleanup code Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 2/7] media: ipu3-cio2: Introduce CIO2_MAX_ENTRIES constant Andy Shevchenko
2020-08-14 20:18   ` Sakari Ailus
2020-08-17 11:46     ` Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 3/7] media: ipu2-cio2: Replace custom definition with PAGE_SIZE Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 4/7] media: ipu3-cio2: Use macros from pfn.h Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 5/7] media: ipu3-cio2: Replace infinite loop by one with clear exit condition Andy Shevchenko
2020-08-17 10:21   ` Bingbu Cao [this message]
2020-08-17 11:47     ` Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 6/7] media: ipu3-cio2: Use readl_poll_timeout() helper Andy Shevchenko
2020-08-17  9:27   ` Bingbu Cao
2020-08-17  9:44     ` Andy Shevchenko
2020-08-17 11:13       ` Sakari Ailus
2020-08-17 11:20         ` Andy Shevchenko
2020-08-17 11:27           ` Sakari Ailus
2020-08-17 11:33             ` Andy Shevchenko
2020-08-17 11:55               ` Sakari Ailus
2020-08-17 12:29                 ` Andy Shevchenko
2020-08-17 12:44                   ` Sakari Ailus
2020-08-14 16:30 ` [PATCH v1 7/7] media: ipu3-cio2: Update Copyright year and fix indentation issues Andy Shevchenko
2020-08-14 20:16 ` [PATCH v1 1/7] media: ipu3-cio2: Simplify cleanup code Sakari Ailus
2020-08-17 14:37   ` Andy Shevchenko

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=aa68f5ec-359c-70ce-ecf6-ee013497230a@linux.intel.com \
    --to=bingbu.cao@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.com \
    /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