mirror of https://gitee.com/openkylin/linux.git
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
9a262c7a7f
commit
a553c90136
|
@ -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)
|
||||||
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)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue