media: ti: j721e-csi2rx: Fix races while restarting DMA
After the frame is submitted to DMA, it may happen that the submitted
list is not updated soon enough, and the DMA callback is triggered
before that.
This can lead to kernel crashes, so move everything in a single
lock/unlock section to prevent such races.
Fixes: b4a3d877dc
("media: ti: Add CSI2RX support for J721E")
Signed-off-by: Jai Luthra <j-luthra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
fd64dda48f
commit
ad79c9ecea
@ -786,15 +786,14 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb)
|
|||||||
dev_warn(csi->dev,
|
dev_warn(csi->dev,
|
||||||
"Failed to drain DMA. Next frame might be bogus\n");
|
"Failed to drain DMA. Next frame might be bogus\n");
|
||||||
|
|
||||||
|
spin_lock_irqsave(&dma->lock, flags);
|
||||||
ret = ti_csi2rx_start_dma(csi, buf);
|
ret = ti_csi2rx_start_dma(csi, buf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(csi->dev, "Failed to start DMA: %d\n", ret);
|
|
||||||
spin_lock_irqsave(&dma->lock, flags);
|
|
||||||
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||||
dma->state = TI_CSI2RX_DMA_IDLE;
|
dma->state = TI_CSI2RX_DMA_IDLE;
|
||||||
spin_unlock_irqrestore(&dma->lock, flags);
|
spin_unlock_irqrestore(&dma->lock, flags);
|
||||||
|
dev_err(csi->dev, "Failed to start DMA: %d\n", ret);
|
||||||
} else {
|
} else {
|
||||||
spin_lock_irqsave(&dma->lock, flags);
|
|
||||||
list_add_tail(&buf->list, &dma->submitted);
|
list_add_tail(&buf->list, &dma->submitted);
|
||||||
spin_unlock_irqrestore(&dma->lock, flags);
|
spin_unlock_irqrestore(&dma->lock, flags);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user