linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock
@ 2013-02-07  0:03 John Sheu
  2013-02-07  0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: John Sheu @ 2013-02-07  0:03 UTC (permalink / raw)
  To: linux-media; +Cc: John Sheu, John Sheu

From: John Sheu <sheu@chromium.org>

In v4l2_m2m_try_schedule(), use the CAPTURE queue lock when accessing
the CAPTURE queue, instead of relying on just holding the OUTPUT queue
lock.

Signed-off-by: John Sheu <sheu@google.com>
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 438ea45..c52a2c5 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -230,12 +230,15 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
 		dprintk("No input buffers available\n");
 		return;
 	}
+	spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
 	if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)) {
+		spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
 		spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags);
 		spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
 		dprintk("No output buffers available\n");
 		return;
 	}
+	spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
 	spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags);
 
 	if (m2m_dev->m2m_ops->job_ready
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF
  2013-02-07  0:03 [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock John Sheu
@ 2013-02-07  0:03 ` John Sheu
  2013-02-28 15:45   ` Pawel Osciak
  2013-02-07  0:03 ` [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap John Sheu
  2013-02-28 15:44 ` [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock Pawel Osciak
  2 siblings, 1 reply; 8+ messages in thread
From: John Sheu @ 2013-02-07  0:03 UTC (permalink / raw)
  To: linux-media; +Cc: John Sheu, John Sheu

From: John Sheu <sheu@chromium.org>

When a v4l2-mem2mem context gets a STREAMOFF call on either its CAPTURE
or OUTPUT queues, we should:
* Drop the corresponding rdy_queue, since a subsequent STREAMON expects
  an empty queue.
* Deschedule the context, as it now has at least one empty queue and
  cannot run.

Signed-off-by: John Sheu <sheu@google.com>
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index c52a2c5..c5c9d24 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -408,10 +408,35 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_streamon);
 int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 		       enum v4l2_buf_type type)
 {
-	struct vb2_queue *vq;
+	struct v4l2_m2m_dev *m2m_dev;
+	struct v4l2_m2m_queue_ctx *q_ctx;
+	unsigned long flags_job, flags;
+	int ret;
 
-	vq = v4l2_m2m_get_vq(m2m_ctx, type);
-	return vb2_streamoff(vq, type);
+	q_ctx = get_queue_ctx(m2m_ctx, type);
+	ret = vb2_streamoff(&q_ctx->q, type);
+	if (ret)
+		return ret;
+
+	m2m_dev = m2m_ctx->m2m_dev;
+	spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job);
+	/* We should not be scheduled anymore, since we're dropping a queue. */
+	INIT_LIST_HEAD(&m2m_ctx->queue);
+	m2m_ctx->job_flags = 0;
+
+	spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
+	/* Drop queue, since streamoff returns device to the same state as after
+	 * calling reqbufs. */
+	INIT_LIST_HEAD(&q_ctx->rdy_queue);
+	spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
+
+	if (m2m_dev->curr_ctx == m2m_ctx) {
+		m2m_dev->curr_ctx = NULL;
+		wake_up(&m2m_ctx->finished);
+	}
+	spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);
 
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap
  2013-02-07  0:03 [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock John Sheu
  2013-02-07  0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
@ 2013-02-07  0:03 ` John Sheu
  2013-02-07 10:24   ` Sumit Semwal
  2013-02-28 15:44 ` [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock Pawel Osciak
  2 siblings, 1 reply; 8+ messages in thread
From: John Sheu @ 2013-02-07  0:03 UTC (permalink / raw)
  To: linux-media; +Cc: John Sheu, John Sheu

From: John Sheu <sheu@chromium.org>

Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
themselves on failure.  Not restoring the struct's data on failure
causes a double-decrement of the vm_file's refcount.

Signed-off-by: John Sheu <sheu@google.com>
---
 drivers/base/dma-buf.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index a3f79c4..01daf9c 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
 int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
 		 unsigned long pgoff)
 {
+	struct file *oldfile;
+	int ret;
+
 	if (WARN_ON(!dmabuf || !vma))
 		return -EINVAL;
 
@@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
 		return -EINVAL;
 
 	/* readjust the vma */
-	if (vma->vm_file)
-		fput(vma->vm_file);
-
+	oldfile = vma->vm_file;
 	vma->vm_file = get_file(dmabuf->file);
 
 	vma->vm_pgoff = pgoff;
 
-	return dmabuf->ops->mmap(dmabuf, vma);
+	ret = dmabuf->ops->mmap(dmabuf, vma);
+	if (ret) {
+		/* restore old parameters on failure */
+		vma->vm_file = oldfile;
+		fput(dmabuf->file);
+	} else {
+		if (oldfile)
+			fput(oldfile);
+	}
+	return ret;
 }
 EXPORT_SYMBOL_GPL(dma_buf_mmap);
 
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap
  2013-02-07  0:03 ` [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap John Sheu
@ 2013-02-07 10:24   ` Sumit Semwal
  2013-03-18 23:49     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 8+ messages in thread
From: Sumit Semwal @ 2013-02-07 10:24 UTC (permalink / raw)
  To: John Sheu; +Cc: linux-media, John Sheu

Hi John,

On Thursday 07 February 2013 05:33 AM, John Sheu wrote:
> From: John Sheu <sheu@chromium.org>
>
> Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
> themselves on failure.  Not restoring the struct's data on failure
> causes a double-decrement of the vm_file's refcount.
Thanks for your patch; could you please re-send it to the correct, 
relevant lists and me (as the maintainer of dma-buf) rather than just to 
linux-media ml?

I just chanced to see this patch, otherwise it could easily have slipped 
past me (and other interested parties).

You could run scripts/get_maintainer.pl on your patch to find out the 
right lists / email IDs to CC.

Thanks and best regards,
~Sumit.
>
> Signed-off-by: John Sheu <sheu@google.com>
> ---
>   drivers/base/dma-buf.c | 18 ++++++++++++++----
>   1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
> index a3f79c4..01daf9c 100644
> --- a/drivers/base/dma-buf.c
> +++ b/drivers/base/dma-buf.c
> @@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
>   int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>   		 unsigned long pgoff)
>   {
> +	struct file *oldfile;
> +	int ret;
> +
>   	if (WARN_ON(!dmabuf || !vma))
>   		return -EINVAL;
>
> @@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>   		return -EINVAL;
>
>   	/* readjust the vma */
> -	if (vma->vm_file)
> -		fput(vma->vm_file);
> -
> +	oldfile = vma->vm_file;
>   	vma->vm_file = get_file(dmabuf->file);
>
>   	vma->vm_pgoff = pgoff;
>
> -	return dmabuf->ops->mmap(dmabuf, vma);
> +	ret = dmabuf->ops->mmap(dmabuf, vma);
> +	if (ret) {
> +		/* restore old parameters on failure */
> +		vma->vm_file = oldfile;
> +		fput(dmabuf->file);
> +	} else {
> +		if (oldfile)
> +			fput(oldfile);
> +	}
> +	return ret;
>   }
>   EXPORT_SYMBOL_GPL(dma_buf_mmap);
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock
  2013-02-07  0:03 [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock John Sheu
  2013-02-07  0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
  2013-02-07  0:03 ` [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap John Sheu
@ 2013-02-28 15:44 ` Pawel Osciak
  2 siblings, 0 replies; 8+ messages in thread
From: Pawel Osciak @ 2013-02-28 15:44 UTC (permalink / raw)
  To: John Sheu; +Cc: LMML, John Sheu

On Wed, Feb 6, 2013 at 4:03 PM, John Sheu <sheu@google.com> wrote:
> From: John Sheu <sheu@chromium.org>
>
> In v4l2_m2m_try_schedule(), use the CAPTURE queue lock when accessing
> the CAPTURE queue, instead of relying on just holding the OUTPUT queue
> lock.
>
> Signed-off-by: John Sheu <sheu@google.com>

Acked-by: Pawel Osciak <pawel@osciak.com>

> ---
>  drivers/media/v4l2-core/v4l2-mem2mem.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index 438ea45..c52a2c5 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -230,12 +230,15 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
>                 dprintk("No input buffers available\n");
>                 return;
>         }
> +       spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
>         if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)) {
> +               spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
>                 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags);
>                 spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
>                 dprintk("No output buffers available\n");
>                 return;
>         }
> +       spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags);
>         spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags);
>
>         if (m2m_dev->m2m_ops->job_ready
> --
> 1.8.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best regards,
Pawel Osciak

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF
  2013-02-07  0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
@ 2013-02-28 15:45   ` Pawel Osciak
  0 siblings, 0 replies; 8+ messages in thread
From: Pawel Osciak @ 2013-02-28 15:45 UTC (permalink / raw)
  To: John Sheu; +Cc: LMML, John Sheu

On Wed, Feb 6, 2013 at 4:03 PM, John Sheu <sheu@google.com> wrote:
> From: John Sheu <sheu@chromium.org>
>
> When a v4l2-mem2mem context gets a STREAMOFF call on either its CAPTURE
> or OUTPUT queues, we should:
> * Drop the corresponding rdy_queue, since a subsequent STREAMON expects
>   an empty queue.
> * Deschedule the context, as it now has at least one empty queue and
>   cannot run.
>
> Signed-off-by: John Sheu <sheu@google.com>

Acked-by: Pawel Osciak <pawel@osciak.com>

> ---
>  drivers/media/v4l2-core/v4l2-mem2mem.c | 31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index c52a2c5..c5c9d24 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -408,10 +408,35 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_streamon);
>  int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
>                        enum v4l2_buf_type type)
>  {
> -       struct vb2_queue *vq;
> +       struct v4l2_m2m_dev *m2m_dev;
> +       struct v4l2_m2m_queue_ctx *q_ctx;
> +       unsigned long flags_job, flags;
> +       int ret;
>
> -       vq = v4l2_m2m_get_vq(m2m_ctx, type);
> -       return vb2_streamoff(vq, type);
> +       q_ctx = get_queue_ctx(m2m_ctx, type);
> +       ret = vb2_streamoff(&q_ctx->q, type);
> +       if (ret)
> +               return ret;
> +
> +       m2m_dev = m2m_ctx->m2m_dev;
> +       spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job);
> +       /* We should not be scheduled anymore, since we're dropping a queue. */
> +       INIT_LIST_HEAD(&m2m_ctx->queue);
> +       m2m_ctx->job_flags = 0;
> +
> +       spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
> +       /* Drop queue, since streamoff returns device to the same state as after
> +        * calling reqbufs. */
> +       INIT_LIST_HEAD(&q_ctx->rdy_queue);
> +       spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
> +
> +       if (m2m_dev->curr_ctx == m2m_ctx) {
> +               m2m_dev->curr_ctx = NULL;
> +               wake_up(&m2m_ctx->finished);
> +       }
> +       spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
> +
> +       return 0;
>  }
>  EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);
>
> --
> 1.8.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
Best regards,
Pawel Osciak

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap
  2013-02-07 10:24   ` Sumit Semwal
@ 2013-03-18 23:49     ` Mauro Carvalho Chehab
  2013-03-25 11:24       ` Sumit Semwal
  0 siblings, 1 reply; 8+ messages in thread
From: Mauro Carvalho Chehab @ 2013-03-18 23:49 UTC (permalink / raw)
  To: Sumit Semwal; +Cc: John Sheu, linux-media, John Sheu

Em Thu, 07 Feb 2013 15:54:52 +0530
Sumit Semwal <sumit.semwal@linaro.org> escreveu:

> Hi John,
> 
> On Thursday 07 February 2013 05:33 AM, John Sheu wrote:
> > From: John Sheu <sheu@chromium.org>
> >
> > Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
> > themselves on failure.  Not restoring the struct's data on failure
> > causes a double-decrement of the vm_file's refcount.
> Thanks for your patch; could you please re-send it to the correct, 
> relevant lists and me (as the maintainer of dma-buf) rather than just to 
> linux-media ml?

Yes, it doesn't make sense to apply this one via the media tree ;)

I'm applying patches 1 and 2, as they should go through the media tree.

Thanks!
Mauro
> 
> I just chanced to see this patch, otherwise it could easily have slipped 
> past me (and other interested parties).
> 
> You could run scripts/get_maintainer.pl on your patch to find out the 
> right lists / email IDs to CC.
> 
> Thanks and best regards,
> ~Sumit.
> >
> > Signed-off-by: John Sheu <sheu@google.com>
> > ---
> >   drivers/base/dma-buf.c | 18 ++++++++++++++----
> >   1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
> > index a3f79c4..01daf9c 100644
> > --- a/drivers/base/dma-buf.c
> > +++ b/drivers/base/dma-buf.c
> > @@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
> >   int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
> >   		 unsigned long pgoff)
> >   {
> > +	struct file *oldfile;
> > +	int ret;
> > +
> >   	if (WARN_ON(!dmabuf || !vma))
> >   		return -EINVAL;
> >
> > @@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
> >   		return -EINVAL;
> >
> >   	/* readjust the vma */
> > -	if (vma->vm_file)
> > -		fput(vma->vm_file);
> > -
> > +	oldfile = vma->vm_file;
> >   	vma->vm_file = get_file(dmabuf->file);
> >
> >   	vma->vm_pgoff = pgoff;
> >
> > -	return dmabuf->ops->mmap(dmabuf, vma);
> > +	ret = dmabuf->ops->mmap(dmabuf, vma);
> > +	if (ret) {
> > +		/* restore old parameters on failure */
> > +		vma->vm_file = oldfile;
> > +		fput(dmabuf->file);
> > +	} else {
> > +		if (oldfile)
> > +			fput(oldfile);
> > +	}
> > +	return ret;
> >   }
> >   EXPORT_SYMBOL_GPL(dma_buf_mmap);
> >
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap
  2013-03-18 23:49     ` Mauro Carvalho Chehab
@ 2013-03-25 11:24       ` Sumit Semwal
  0 siblings, 0 replies; 8+ messages in thread
From: Sumit Semwal @ 2013-03-25 11:24 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: John Sheu, linux-media, John Sheu

On 19 March 2013 05:19, Mauro Carvalho Chehab <mchehab@redhat.com> wrote:
> Em Thu, 07 Feb 2013 15:54:52 +0530
> Sumit Semwal <sumit.semwal@linaro.org> escreveu:
>
>> Hi John,
>>
>> On Thursday 07 February 2013 05:33 AM, John Sheu wrote:
>> > From: John Sheu <sheu@chromium.org>
>> >
>> > Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
>> > themselves on failure.  Not restoring the struct's data on failure
>> > causes a double-decrement of the vm_file's refcount.
>> Thanks for your patch; could you please re-send it to the correct,
>> relevant lists and me (as the maintainer of dma-buf) rather than just to
>> linux-media ml?
>
> Yes, it doesn't make sense to apply this one via the media tree ;)
>
> I'm applying patches 1 and 2, as they should go through the media tree.
Sure, this patch is already in mainline as of 3.9-rc1 :)
>
> Thanks!
> Mauro
>>
>> I just chanced to see this patch, otherwise it could easily have slipped
>> past me (and other interested parties).
>>
>> You could run scripts/get_maintainer.pl on your patch to find out the
>> right lists / email IDs to CC.
>>
>> Thanks and best regards,
>> ~Sumit.
>> >
>> > Signed-off-by: John Sheu <sheu@google.com>
>> > ---
>> >   drivers/base/dma-buf.c | 18 ++++++++++++++----
>> >   1 file changed, 14 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
>> > index a3f79c4..01daf9c 100644
>> > --- a/drivers/base/dma-buf.c
>> > +++ b/drivers/base/dma-buf.c
>> > @@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
>> >   int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>> >              unsigned long pgoff)
>> >   {
>> > +   struct file *oldfile;
>> > +   int ret;
>> > +
>> >     if (WARN_ON(!dmabuf || !vma))
>> >             return -EINVAL;
>> >
>> > @@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>> >             return -EINVAL;
>> >
>> >     /* readjust the vma */
>> > -   if (vma->vm_file)
>> > -           fput(vma->vm_file);
>> > -
>> > +   oldfile = vma->vm_file;
>> >     vma->vm_file = get_file(dmabuf->file);
>> >
>> >     vma->vm_pgoff = pgoff;
>> >
>> > -   return dmabuf->ops->mmap(dmabuf, vma);
>> > +   ret = dmabuf->ops->mmap(dmabuf, vma);
>> > +   if (ret) {
>> > +           /* restore old parameters on failure */
>> > +           vma->vm_file = oldfile;
>> > +           fput(dmabuf->file);
>> > +   } else {
>> > +           if (oldfile)
>> > +                   fput(oldfile);
>> > +   }
>> > +   return ret;
>> >   }
>> >   EXPORT_SYMBOL_GPL(dma_buf_mmap);
>> >
>> >
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-media" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> --
>
> Cheers,
> Mauro



--
Thanks and regards,

Sumit Semwal

Linaro Kernel Engineer - Graphics working group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-03-25 11:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-07  0:03 [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock John Sheu
2013-02-07  0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
2013-02-28 15:45   ` Pawel Osciak
2013-02-07  0:03 ` [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap John Sheu
2013-02-07 10:24   ` Sumit Semwal
2013-03-18 23:49     ` Mauro Carvalho Chehab
2013-03-25 11:24       ` Sumit Semwal
2013-02-28 15:44 ` [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock Pawel Osciak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).