From: jacopo mondi <jacopo@jmondi.org>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
tomoharu.fukawa.eb@renesas.com
Subject: Re: [PATCH 2/3] rcar-vin: allocate a scratch buffer at stream start
Date: Mon, 12 Mar 2018 14:55:13 +0100 [thread overview]
Message-ID: <20180312135513.GB12967@w540> (raw)
In-Reply-To: <20180310000953.25366-3-niklas.soderlund+renesas@ragnatech.se>
[-- Attachment #1: Type: text/plain, Size: 3159 bytes --]
Hi Niklas,
On Sat, Mar 10, 2018 at 01:09:52AM +0100, Niklas Söderlund wrote:
> Before starting capturing allocate a scratch buffer which can be used by
> the driver to give to the hardware if no buffers are available from
> userspace. The buffer is not used in this patch but prepares for future
> refactoring where the scratch buffer can be used to avoid the need to
> fallback on single capture mode if userspace don't queue buffers as fast
> as the VIN driver consumes them.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/rcar-vin/rcar-dma.c | 19 +++++++++++++++++++
> drivers/media/platform/rcar-vin/rcar-vin.h | 4 ++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> index b4be75d5009080f7..8ea73cdc9a720abe 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -1070,6 +1070,17 @@ static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
> unsigned long flags;
> int ret;
>
> + /* Allocate scratch buffer. */
> + vin->scratch = dma_alloc_coherent(vin->dev, vin->format.sizeimage,
> + &vin->scratch_phys, GFP_KERNEL);
> + if (!vin->scratch) {
> + spin_lock_irqsave(&vin->qlock, flags);
> + return_all_buffers(vin, VB2_BUF_STATE_QUEUED);
> + spin_unlock_irqrestore(&vin->qlock, flags);
> + vin_err(vin, "Failed to allocate scratch buffer\n");
> + return -ENOMEM;
> + }
> +
> sd = vin_to_source(vin);
> v4l2_subdev_call(sd, video, s_stream, 1);
>
> @@ -1085,6 +1096,10 @@ static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
>
> spin_unlock_irqrestore(&vin->qlock, flags);
>
> + if (ret)
> + dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> + vin->scratch_phys);
> +
> return ret;
> }
>
> @@ -1135,6 +1150,10 @@ static void rvin_stop_streaming(struct vb2_queue *vq)
>
> /* disable interrupts */
> rvin_disable_interrupts(vin);
> +
> + /* Free scratch buffer. */
> + dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> + vin->scratch_phys);
> }
>
> static const struct vb2_ops rvin_qops = {
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 5382078143fb3869..11a981d707c7ca47 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -102,6 +102,8 @@ struct rvin_graph_entity {
> *
> * @lock: protects @queue
> * @queue: vb2 buffers queue
> + * @scratch: cpu address for scratch buffer
> + * @scratch_phys: pysical address of the scratch buffer
Nitpicking: physical
Thanks
j
> *
> * @qlock: protects @queue_buf, @buf_list, @continuous, @sequence
> * @state
> @@ -130,6 +132,8 @@ struct rvin_dev {
>
> struct mutex lock;
> struct vb2_queue queue;
> + void *scratch;
> + dma_addr_t scratch_phys;
>
> spinlock_t qlock;
> struct vb2_v4l2_buffer *queue_buf[HW_BUFFER_NUM];
> --
> 2.16.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2018-03-13 19:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-10 0:09 [PATCH 0/3] rcar-vin: always run in continues mode Niklas Söderlund
2018-03-10 0:09 ` [PATCH 1/3] rcar-vin: remove duplicated check of state in irq handler Niklas Söderlund
2018-03-13 16:42 ` Kieran Bingham
2018-03-13 17:56 ` Niklas Söderlund
2018-03-14 15:17 ` jacopo mondi
2018-03-14 16:36 ` Niklas Söderlund
2018-03-13 18:43 ` Hans Verkuil
2018-03-10 0:09 ` [PATCH 2/3] rcar-vin: allocate a scratch buffer at stream start Niklas Söderlund
2018-03-12 13:55 ` jacopo mondi [this message]
2018-03-13 16:49 ` Kieran Bingham
2018-03-10 0:09 ` [PATCH 3/3] rcar-vin: use scratch buffer and always run in continuous mode Niklas Söderlund
2018-03-12 14:38 ` jacopo mondi
2018-03-12 16:33 ` Niklas Söderlund
2018-03-13 18:47 ` Hans Verkuil
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=20180312135513.GB12967@w540 \
--to=jacopo@jmondi.org \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=tomoharu.fukawa.eb@renesas.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox