From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Pawel Osciak <p.osciak@samsung.com>
Cc: linux-media@vger.kernel.org, m.szyprowski@samsung.com,
kyungmin.park@samsung.com
Subject: Re: [PATCH v1 1/1] V4L: Add sync before a hardware operation to videobuf.
Date: Wed, 05 May 2010 17:57:38 -0300 [thread overview]
Message-ID: <4BE1DBC2.3000300@redhat.com> (raw)
In-Reply-To: <1263914929-28211-2-git-send-email-p.osciak@samsung.com>
Pawel Osciak wrote:
> Architectures with non-coherent CPU cache (e.g. ARM) may require a cache
> flush or invalidation before starting a hardware operation if the data in
> a video buffer being queued has been touched by the CPU.
>
> This patch adds calls to sync before a hardware operation that are expected
> to be interpreted and handled by each memory type-specific module.
>
> Whether it is a sync before or after the operation can be determined from
> the current buffer state: VIDEOBUF_DONE and VIDEOBUF_ERROR indicate a sync
> called after an operation.
Hi Pawel,
After analyzing this patch, maybe the better is to add a check for dma
coherency. So, instead of directly calling sync,the better is to check
if !dma_is_consistent(), to avoid adding a penalty on architectures
where the cache is coherent.
>
> diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
> index bb0a1c8..e56c67a 100644
> --- a/drivers/media/video/videobuf-core.c
> +++ b/drivers/media/video/videobuf-core.c
> @@ -561,6 +561,8 @@ int videobuf_qbuf(struct videobuf_queue *q,
> goto done;
> }
>
> + CALL(q, sync, q, buf);
> +
> list_add_tail(&buf->stream, &q->stream);
> if (q->streaming) {
> spin_lock_irqsave(q->irqlock, flags);
> @@ -761,6 +763,8 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
> if (0 != retval)
> goto done;
>
> + CALL(q, sync, q, q->read_buf);
> +
> /* start capture & wait */
> spin_lock_irqsave(q->irqlock, flags);
> q->ops->buf_queue(q, q->read_buf);
> @@ -826,6 +830,8 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
> goto done;
> }
>
> + CALL(q, sync, q, q->read_buf);
> +
> spin_lock_irqsave(q->irqlock, flags);
> q->ops->buf_queue(q, q->read_buf);
> spin_unlock_irqrestore(q->irqlock, flags);
> @@ -893,6 +899,9 @@ static int __videobuf_read_start(struct videobuf_queue *q)
> err = q->ops->buf_prepare(q, q->bufs[i], field);
> if (err)
> return err;
> +
> + CALL(q, sync, q, q->read_buf);
> +
> list_add_tail(&q->bufs[i]->stream, &q->stream);
> }
> spin_lock_irqsave(q->irqlock, flags);
> diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
> index fa78555..2b153f8 100644
> --- a/drivers/media/video/videobuf-dma-sg.c
> +++ b/drivers/media/video/videobuf-dma-sg.c
> @@ -50,6 +50,9 @@ MODULE_LICENSE("GPL");
> #define dprintk(level, fmt, arg...) if (debug >= level) \
> printk(KERN_DEBUG "vbuf-sg: " fmt , ## arg)
>
> +#define is_sync_after(vb) \
> + (vb->state == VIDEOBUF_DONE || vb->state == VIDEOBUF_ERROR)
> +
> /* --------------------------------------------------------------------- */
>
> struct scatterlist*
> @@ -516,6 +519,9 @@ static int __videobuf_sync(struct videobuf_queue *q,
> BUG_ON(!mem);
> MAGIC_CHECK(mem->magic,MAGIC_SG_MEM);
>
> + if (!is_sync_after(buf))
> + return 0;
> +
> return videobuf_dma_sync(q,&mem->dma);
> }
>
--
Cheers,
Mauro
prev parent reply other threads:[~2010-05-05 20:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-19 15:28 [PATCH/RFC v1 0/1] Buffer sync for non cache-coherent architectures Pawel Osciak
2010-01-19 15:28 ` [PATCH v1 1/1] V4L: Add sync before a hardware operation to videobuf Pawel Osciak
2010-05-05 20:57 ` Mauro Carvalho Chehab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BE1DBC2.3000300@redhat.com \
--to=mchehab@redhat.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=p.osciak@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.