Commit 2dd54a54 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

V4L/DVB (12424): soc-camera: fix recursive locking in .buf_queue()

The .buf_queue() V4L2 driver method is called under
spinlock_irqsave(q->irqlock,...), don't take the lock again inside the
function.
Reported-by: default avatarAntonio Ospite <ospite@studenti.unina.it>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7d2e2e35
...@@ -234,6 +234,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) ...@@ -234,6 +234,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
return ret; return ret;
} }
/* Called under spinlock_irqsave(&pcdev->lock, ...) */
static void mx1_videobuf_queue(struct videobuf_queue *vq, static void mx1_videobuf_queue(struct videobuf_queue *vq,
struct videobuf_buffer *vb) struct videobuf_buffer *vb)
{ {
...@@ -241,13 +242,10 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq, ...@@ -241,13 +242,10 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx1_camera_dev *pcdev = ici->priv; struct mx1_camera_dev *pcdev = ici->priv;
struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb); struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
unsigned long flags;
dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize); vb, vb->baddr, vb->bsize);
spin_lock_irqsave(&pcdev->lock, flags);
list_add_tail(&vb->queue, &pcdev->capture); list_add_tail(&vb->queue, &pcdev->capture);
vb->state = VIDEOBUF_ACTIVE; vb->state = VIDEOBUF_ACTIVE;
...@@ -264,8 +262,6 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq, ...@@ -264,8 +262,6 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq,
__raw_writel(temp, pcdev->base + CSICR1); __raw_writel(temp, pcdev->base + CSICR1);
} }
} }
spin_unlock_irqrestore(&pcdev->lock, flags);
} }
static void mx1_videobuf_release(struct videobuf_queue *vq, static void mx1_videobuf_release(struct videobuf_queue *vq,
......
...@@ -332,7 +332,10 @@ static enum pixel_fmt fourcc_to_ipu_pix(__u32 fourcc) ...@@ -332,7 +332,10 @@ static enum pixel_fmt fourcc_to_ipu_pix(__u32 fourcc)
} }
} }
/* Called with .vb_lock held */ /*
* Called with .vb_lock mutex held and
* under spinlock_irqsave(&mx3_cam->lock, ...)
*/
static void mx3_videobuf_queue(struct videobuf_queue *vq, static void mx3_videobuf_queue(struct videobuf_queue *vq,
struct videobuf_buffer *vb) struct videobuf_buffer *vb)
{ {
...@@ -346,7 +349,8 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq, ...@@ -346,7 +349,8 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
struct idmac_video_param *video = &ichan->params.video; struct idmac_video_param *video = &ichan->params.video;
const struct soc_camera_data_format *data_fmt = icd->current_fmt; const struct soc_camera_data_format *data_fmt = icd->current_fmt;
dma_cookie_t cookie; dma_cookie_t cookie;
unsigned long flags;
BUG_ON(!irqs_disabled());
/* This is the configuration of one sg-element */ /* This is the configuration of one sg-element */
video->out_pixel_fmt = fourcc_to_ipu_pix(data_fmt->fourcc); video->out_pixel_fmt = fourcc_to_ipu_pix(data_fmt->fourcc);
...@@ -359,8 +363,6 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq, ...@@ -359,8 +363,6 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
memset((void *)vb->baddr, 0xaa, vb->bsize); memset((void *)vb->baddr, 0xaa, vb->bsize);
#endif #endif
spin_lock_irqsave(&mx3_cam->lock, flags);
list_add_tail(&vb->queue, &mx3_cam->capture); list_add_tail(&vb->queue, &mx3_cam->capture);
if (!mx3_cam->active) { if (!mx3_cam->active) {
...@@ -370,24 +372,23 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq, ...@@ -370,24 +372,23 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
vb->state = VIDEOBUF_QUEUED; vb->state = VIDEOBUF_QUEUED;
} }
spin_unlock_irqrestore(&mx3_cam->lock, flags); spin_unlock_irq(&mx3_cam->lock);
cookie = txd->tx_submit(txd); cookie = txd->tx_submit(txd);
dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg)); dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg));
spin_lock_irq(&mx3_cam->lock);
if (cookie >= 0) if (cookie >= 0)
return; return;
/* Submit error */ /* Submit error */
vb->state = VIDEOBUF_PREPARED; vb->state = VIDEOBUF_PREPARED;
spin_lock_irqsave(&mx3_cam->lock, flags);
list_del_init(&vb->queue); list_del_init(&vb->queue);
if (mx3_cam->active == buf) if (mx3_cam->active == buf)
mx3_cam->active = NULL; mx3_cam->active = NULL;
spin_unlock_irqrestore(&mx3_cam->lock, flags);
} }
/* Called with .vb_lock held */ /* Called with .vb_lock held */
......
...@@ -612,6 +612,7 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev) ...@@ -612,6 +612,7 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
dev_dbg(pcdev->soc_host.dev, "%s\n", __func__); dev_dbg(pcdev->soc_host.dev, "%s\n", __func__);
} }
/* Called under spinlock_irqsave(&pcdev->lock, ...) */
static void pxa_videobuf_queue(struct videobuf_queue *vq, static void pxa_videobuf_queue(struct videobuf_queue *vq,
struct videobuf_buffer *vb) struct videobuf_buffer *vb)
{ {
...@@ -619,13 +620,10 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq, ...@@ -619,13 +620,10 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv; struct pxa_camera_dev *pcdev = ici->priv;
struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
unsigned long flags;
dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d active=%p\n", __func__, dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d active=%p\n", __func__,
vb, vb->baddr, vb->bsize, pcdev->active); vb, vb->baddr, vb->bsize, pcdev->active);
spin_lock_irqsave(&pcdev->lock, flags);
list_add_tail(&vb->queue, &pcdev->capture); list_add_tail(&vb->queue, &pcdev->capture);
vb->state = VIDEOBUF_ACTIVE; vb->state = VIDEOBUF_ACTIVE;
...@@ -633,8 +631,6 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq, ...@@ -633,8 +631,6 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq,
if (!pcdev->active) if (!pcdev->active)
pxa_camera_start_capture(pcdev); pxa_camera_start_capture(pcdev);
spin_unlock_irqrestore(&pcdev->lock, flags);
} }
static void pxa_videobuf_release(struct videobuf_queue *vq, static void pxa_videobuf_release(struct videobuf_queue *vq,
......
...@@ -282,27 +282,24 @@ out: ...@@ -282,27 +282,24 @@ out:
return ret; return ret;
} }
/* Called under spinlock_irqsave(&pcdev->lock, ...) */
static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue *vq, static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue *vq,
struct videobuf_buffer *vb) struct videobuf_buffer *vb)
{ {
struct soc_camera_device *icd = vq->priv_data; struct soc_camera_device *icd = vq->priv_data;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv; struct sh_mobile_ceu_dev *pcdev = ici->priv;
unsigned long flags;
dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
vb, vb->baddr, vb->bsize); vb, vb->baddr, vb->bsize);
vb->state = VIDEOBUF_QUEUED; vb->state = VIDEOBUF_QUEUED;
spin_lock_irqsave(&pcdev->lock, flags);
list_add_tail(&vb->queue, &pcdev->capture); list_add_tail(&vb->queue, &pcdev->capture);
if (!pcdev->active) { if (!pcdev->active) {
pcdev->active = vb; pcdev->active = vb;
sh_mobile_ceu_capture(pcdev); sh_mobile_ceu_capture(pcdev);
} }
spin_unlock_irqrestore(&pcdev->lock, flags);
} }
static void sh_mobile_ceu_videobuf_release(struct videobuf_queue *vq, static void sh_mobile_ceu_videobuf_release(struct videobuf_queue *vq,
......
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