Commit a553c901 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mauro Carvalho Chehab

media: ipu3-cio2: Replace infinite loop by one with clear exit condition

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9a262c7a
...@@ -540,7 +540,7 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) ...@@ -540,7 +540,7 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
{ {
struct device *dev = &cio2->pci_dev->dev; struct device *dev = &cio2->pci_dev->dev;
struct cio2_queue *q = cio2->cur_queue; struct cio2_queue *q = cio2->cur_queue;
int buffers_found = 0; struct cio2_fbpt_entry *entry;
u64 ns = ktime_get_ns(); u64 ns = ktime_get_ns();
if (dma_chan >= CIO2_QUEUES) { if (dma_chan >= CIO2_QUEUES) {
...@@ -548,15 +548,18 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) ...@@ -548,15 +548,18 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
return; 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 */ /* Find out which buffer(s) are ready */
do { do {
struct cio2_fbpt_entry *const entry =
&q->fbpt[q->bufs_first * CIO2_MAX_LOPS];
struct cio2_buffer *b; struct cio2_buffer *b;
if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID)
break;
b = q->bufs[q->bufs_first]; b = q->bufs[q->bufs_first];
if (b) { if (b) {
unsigned int bytes = entry[1].second_entry.num_of_bytes; unsigned int bytes = entry[1].second_entry.num_of_bytes;
...@@ -578,13 +581,8 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) ...@@ -578,13 +581,8 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
atomic_inc(&q->frame_sequence); atomic_inc(&q->frame_sequence);
cio2_fbpt_entry_init_dummy(cio2, entry); cio2_fbpt_entry_init_dummy(cio2, entry);
q->bufs_first = (q->bufs_first + 1) % CIO2_MAX_BUFFERS; q->bufs_first = (q->bufs_first + 1) % CIO2_MAX_BUFFERS;
buffers_found++; entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS];
} while (1); } while (!(entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID));
if (buffers_found == 0)
dev_warn(&cio2->pci_dev->dev,
"no ready buffers found on DMA channel %u\n",
dma_chan);
} }
static void cio2_queue_event_sof(struct cio2_device *cio2, struct cio2_queue *q) static void cio2_queue_event_sof(struct cio2_device *cio2, struct cio2_queue *q)
......
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