From: Steve Longerbeam <slongerbeam@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: mark.rutland@arm.com, andrew-ct.chen@mediatek.com,
minghsiu.tsai@mediatek.com, nick@shmanahar.org,
songjun.wu@microchip.com, hverkuil@xs4all.nl,
Steve Longerbeam <steve_longerbeam@mentor.com>,
robert.jarzmik@free.fr, devel@driverdev.osuosl.org,
markus.heiser@darmarIT.de,
laurent.pinchart+renesas@ideasonboard.com, geert@linux-m68k.org,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
kernel@pengutronix.de, arnd@arndb.de, mchehab@kernel.org,
bparrot@ti.com, robh+dt@kernel.org, horms+renesas@verge.net.au,
tiffany.lin@mediatek.com, linux-arm-kernel@lists.infradead.org,
niklas.soderlund+renesas@ragnatech.se,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
jean-christophe.trotin@st.com, p.zabel@pengutronix.de,
fabio.estevam@nxp.com, shawnguo@kernel.org,
sudipm.mukherjee@gmail.com
Subject: Re: [PATCH v3 00/24] i.MX Media Driver
Date: Thu, 2 Feb 2017 11:12:41 -0800 [thread overview]
Message-ID: <2e1cf096-ecb8-ba3d-a554-f4cc6999ed4e@gmail.com> (raw)
In-Reply-To: <20170202185826.GV27312@n2100.armlinux.org.uk>
On 02/02/2017 10:58 AM, Russell King - ARM Linux wrote:
> On Thu, Feb 02, 2017 at 10:26:55AM -0800, Steve Longerbeam wrote:
>> On 02/02/2017 09:56 AM, Russell King - ARM Linux wrote:
>>> and for whatever reason we end up falling out through free_ring. This
>>> is VERY bad news, because it means that the ring which SMFC took a copy
>>> of is now freed beneath its feet.
>> Yes, that is bad. That was a bug, if imx_media_dma_buf_queue_from_vb()
>> returned error, the ring should not have been freed, it should have only
>> returned the error. And further bad stuff happens from that point on.
>>
>> But all of this is gone in version 4.
> I think there's an error in how you think the queue_setup() works.
>
> camif_queue_setup() always returns the number of buffers between
> IMX_MEDIA_MIN_RING_BUFS and IMX_MEDIA_MAX_RING_BUFS. However, it seems
> that, looking through the videobuf2-core.c code, that the value is
> passed to __vb2_queue_alloc() to allocate the specified number of
> _additional_ buffers over and on-top of the existing q->num_buffers:
>
> static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
> unsigned int num_buffers, unsigned int num_planes,
> const unsigned plane_sizes[VB2_MAX_PLANES])
> {
> for (buffer = 0; buffer < num_buffers; ++buffer) {
> ...
> vb->index = q->num_buffers + buffer;
>
> and
>
> int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
> unsigned int *count)
> {
> unsigned int num_buffers, allocated_buffers, num_planes = 0;
> ...
> num_buffers = min_t(unsigned int, *count, VB2_MAX_FRAME);
> num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed);
> ...
> /*
> * Ask the driver how many buffers and planes per buffer it requires.
> * Driver also sets the size and allocator context for each plane.
> */
> ret = call_qop(q, queue_setup, q, &num_buffers, &num_planes,
> plane_sizes, q->alloc_devs);
> if (ret)
> return ret;
>
> /* Finally, allocate buffers and video memory */
> allocated_buffers =
> __vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes);
>
> or:
>
> int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
> unsigned int *count, unsigned requested_planes,
> const unsigned requested_sizes[])
> {
> unsigned int num_planes = 0, num_buffers, allocated_buffers;
> ...
> num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers);
> if (requested_planes && requested_sizes) {
> num_planes = requested_planes;
> ...
> /*
> * Ask the driver, whether the requested number of buffers, planes per
> * buffer and their sizes are acceptable
> */
> ret = call_qop(q, queue_setup, q, &num_buffers,
> &num_planes, plane_sizes, q->alloc_devs);
> if (ret)
> return ret;
>
> /* Finally, allocate buffers and video memory */
> allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers,
> num_planes, plane_sizes);
>
>
> It seems to me that if you don't take account of the existing queue
> size, your camif_queue_setup() has the side effect that each time
> either of these are called. Hence, the vb2 queue increases by the
> same amount each time, which is probably what you don't want.
>
> The documentation on queue_setup() leaves much to be desired:
>
> * @queue_setup: called from VIDIOC_REQBUFS() and VIDIOC_CREATE_BUFS()
> * handlers before memory allocation. It can be called
> * twice: if the original number of requested buffers
> * could not be allocated, then it will be called a
> * second time with the actually allocated number of
> * buffers to verify if that is OK.
> * The driver should return the required number of buffers
> * in \*num_buffers, the required number of planes per
> * buffer in \*num_planes, the size of each plane should be
> * set in the sizes\[\] array and optional per-plane
> * allocator specific device in the alloc_devs\[\] array.
> * When called from VIDIOC_REQBUFS,() \*num_planes == 0,
> * the driver has to use the currently configured format to
> * determine the plane sizes and \*num_buffers is the total
> * number of buffers that are being allocated. When called
> * from VIDIOC_CREATE_BUFS,() \*num_planes != 0 and it
> * describes the requested number of planes and sizes\[\]
> * contains the requested plane sizes. If either
> * \*num_planes or the requested sizes are invalid callback
> * must return %-EINVAL. In this case \*num_buffers are
> * being allocated additionally to q->num_buffers.
>
> That's really really ambiguous, because the "In this case" part doesn't
> really tell you which case it's talking about - but it seems to me looking
> at the code that it's referring to the VIDIOC_CREATE_BUFS case.
Yes, I caught this when adding fixes from v4l2-compliance testing, which
is not part of the version 3 driver. I agree it is a confusing API. When
called from VIDIOC_CREATE_BUFS (indicated by *num_planes != 0),
*num_buffers is supposed to be requested buffers _in addition_ to
already requested q->num_buffers, which is important info and
should be emphasized a little more than the "oh by the way" fashion
in the prototype description, IMHO.
>
> As you support both .vidioc_create_bufs and .vidioc_reqbufs, it seems
> to me that you're not handling the VIDIOC_CREATE_BUFS case correctly.
>
> Can you please make sure that your next version resolves that?
Here is the current .queue_setup() op in imx-media-capture.c:
static int capture_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers,
unsigned int *nplanes,
unsigned int sizes[],
struct device *alloc_devs[])
{
struct capture_priv *priv = vb2_get_drv_priv(vq);
struct v4l2_pix_format *pix = &priv->vdev.fmt.fmt.pix;
unsigned int count = *nbuffers;
if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
if (*nplanes) {
if (*nplanes != 1 || sizes[0] < pix->sizeimage)
return -EINVAL;
count += vq->num_buffers;
}
while (pix->sizeimage * count > VID_MEM_LIMIT)
count--;
if (*nplanes)
*nbuffers = (count < vq->num_buffers) ? 0 :
count - vq->num_buffers;
else
*nbuffers = count;
*nplanes = 1;
sizes[0] = pix->sizeimage;
return 0;
}
>
next prev parent reply other threads:[~2017-02-02 19:12 UTC|newest]
Thread overview: 185+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-07 2:11 [PATCH v3 00/24] i.MX Media Driver Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 01/24] [media] dt-bindings: Add bindings for i.MX media driver Steve Longerbeam
2017-01-13 11:55 ` Philipp Zabel
2017-01-13 19:03 ` Steve Longerbeam
2017-01-16 12:09 ` Philipp Zabel
2017-01-16 17:13 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 02/24] ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node Steve Longerbeam
2017-01-13 11:57 ` Philipp Zabel
2017-01-13 22:40 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 03/24] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 04/24] ARM: dts: imx6qdl: add media device Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 05/24] ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround Steve Longerbeam
2017-01-13 11:59 ` Philipp Zabel
2017-01-07 2:11 ` [PATCH v3 06/24] ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors Steve Longerbeam
2017-01-13 12:03 ` Philipp Zabel
2017-01-13 23:04 ` Steve Longerbeam
2017-01-16 12:55 ` Philipp Zabel
2017-01-16 17:15 ` Steve Longerbeam
2017-02-05 15:17 ` Laurent Pinchart
2017-01-30 22:28 ` Russell King - ARM Linux
2017-01-30 22:51 ` Russell King - ARM Linux
2017-02-05 15:24 ` Laurent Pinchart
2017-02-05 15:37 ` Russell King - ARM Linux
2017-01-07 2:11 ` [PATCH v3 07/24] ARM: dts: imx6-sabresd: " Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 08/24] ARM: dts: imx6-sabreauto: create i2cmux for i2c3 Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 09/24] ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 10/24] ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture Steve Longerbeam
2017-01-12 19:37 ` Tim Harvey
2017-01-12 23:40 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 11/24] ARM: dts: imx6-sabreauto: add the ADV7180 video decoder Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 12/24] add mux and video interface bridge entity functions Steve Longerbeam
2017-01-20 13:56 ` Hans Verkuil
2017-02-05 15:36 ` Laurent Pinchart
2017-02-06 10:27 ` Philipp Zabel
2017-01-07 2:11 ` [PATCH v3 13/24] platform: add video-multiplexer subdevice driver Steve Longerbeam
2017-01-10 5:35 ` Rob Herring
2017-01-20 14:03 ` Hans Verkuil
2017-01-24 12:02 ` Philipp Zabel
2017-01-25 2:07 ` Steve Longerbeam
2017-02-05 15:48 ` Laurent Pinchart
2017-02-06 9:50 ` Hans Verkuil
2017-02-06 22:33 ` Laurent Pinchart
2017-02-06 23:10 ` Steve Longerbeam
2017-02-07 10:26 ` Laurent Pinchart
2017-02-07 10:41 ` Philipp Zabel
2017-02-07 14:11 ` Laurent Pinchart
2017-02-07 13:36 ` Benoit Parrot
2017-02-07 20:50 ` Sakari Ailus
2017-02-07 23:04 ` Laurent Pinchart
2017-01-24 12:44 ` Javier Martinez Canillas
2017-01-26 1:22 ` Steve Longerbeam
2017-02-07 20:46 ` Sakari Ailus
2017-02-08 9:47 ` Philipp Zabel
2017-02-08 10:05 ` Laurent Pinchart
2017-01-07 2:11 ` [PATCH v3 14/24] UAPI: Add media UAPI Kbuild file Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 15/24] media: Add userspace header file for i.MX Steve Longerbeam
2017-01-13 12:05 ` Philipp Zabel
2017-01-13 23:13 ` Steve Longerbeam
2017-02-05 15:50 ` Laurent Pinchart
2017-01-07 2:11 ` [PATCH v3 16/24] media: Add i.MX media core driver Steve Longerbeam
2017-01-13 15:20 ` Philipp Zabel
2017-01-14 22:46 ` Steve Longerbeam
2017-01-16 13:47 ` Philipp Zabel
2017-01-23 2:31 ` Steve Longerbeam
2017-01-23 11:13 ` Philipp Zabel
2017-01-24 1:38 ` Steve Longerbeam
2017-01-24 1:45 ` Steve Longerbeam
2017-01-24 11:37 ` Philipp Zabel
2017-01-30 15:28 ` Russell King - ARM Linux
[not found] ` <2b1d2418-1ad4-6373-cb07-c3aeab48187f@gmail.com>
2017-01-19 1:44 ` Steve Longerbeam
2017-01-24 11:39 ` Philipp Zabel
2017-01-30 22:29 ` Russell King - ARM Linux
2017-02-02 22:44 ` Russell King - ARM Linux
2017-02-02 22:50 ` Russell King - ARM Linux
2017-02-07 1:54 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 17/24] media: imx: Add CSI subdev driver Steve Longerbeam
2017-01-16 15:03 ` Philipp Zabel
2017-01-16 21:15 ` Steve Longerbeam
2017-01-30 22:29 ` Russell King - ARM Linux
2017-01-31 10:30 ` Russell King - ARM Linux
2017-01-31 11:20 ` Russell King - ARM Linux
2017-02-01 0:31 ` Steve Longerbeam
2017-02-01 0:58 ` Russell King - ARM Linux
2017-01-31 15:51 ` Philipp Zabel
2017-01-31 16:48 ` Philipp Zabel
2017-02-01 1:40 ` Steve Longerbeam
2017-02-07 16:18 ` [PATCH] media: imx: csi: fix crop rectangle reset in sink set_fmt Philipp Zabel
2017-01-07 2:11 ` [PATCH v3 18/24] media: imx: Add SMFC subdev driver Steve Longerbeam
2017-02-01 18:39 ` Russell King - ARM Linux
2017-02-01 18:52 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 19/24] media: imx: Add IC subdev drivers Steve Longerbeam
2017-01-20 14:29 ` Hans Verkuil
2017-01-25 2:39 ` Steve Longerbeam
2017-01-30 22:29 ` Russell King - ARM Linux
2017-01-07 2:11 ` [PATCH v3 20/24] media: imx: Add Camera Interface subdev driver Steve Longerbeam
2017-01-20 14:38 ` Hans Verkuil
2017-01-24 2:15 ` Steve Longerbeam
2017-01-31 13:42 ` Russell King - ARM Linux
2017-01-31 18:21 ` Steve Longerbeam
2017-01-31 20:33 ` Russell King - ARM Linux
2017-01-31 21:55 ` Ian Arkver
2017-01-31 22:04 ` Russell King - ARM Linux
2017-01-31 22:33 ` Ian Arkver
2017-01-31 22:36 ` Steve Longerbeam
2017-01-31 23:30 ` Russell King - ARM Linux
2017-01-31 23:41 ` Steve Longerbeam
2017-02-02 22:35 ` Russell King - ARM Linux
2017-02-07 1:52 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 21/24] media: imx: Add MIPI CSI-2 Receiver " Steve Longerbeam
2017-01-30 22:30 ` Russell King - ARM Linux
2017-01-31 0:01 ` Russell King - ARM Linux
2017-01-31 9:49 ` Philipp Zabel
2017-02-01 1:02 ` Steve Longerbeam
2017-02-01 1:13 ` Russell King - ARM Linux
2017-01-31 0:31 ` Russell King - ARM Linux
2017-01-31 2:11 ` Steve Longerbeam
2017-02-01 23:44 ` Russell King - ARM Linux
2017-02-02 0:04 ` Steve Longerbeam
2017-02-02 11:50 ` Philipp Zabel
2017-02-08 23:23 ` Steve Longerbeam
2017-02-08 23:42 ` Russell King - ARM Linux
2017-02-09 23:49 ` Steve Longerbeam
2017-02-09 23:51 ` Steve Longerbeam
2017-02-13 9:20 ` Philipp Zabel
2017-02-13 23:20 ` Steve Longerbeam
2017-02-14 16:59 ` Philipp Zabel
2017-02-09 9:43 ` Philipp Zabel
2017-01-07 2:11 ` [PATCH v3 22/24] media: imx: Add MIPI CSI-2 OV5640 sensor " Steve Longerbeam
2017-01-20 14:48 ` Hans Verkuil
2017-01-25 19:10 ` Steve Longerbeam
2017-01-30 23:29 ` Russell King - ARM Linux
2017-01-31 3:31 ` Steve Longerbeam
2017-02-02 10:36 ` Laurent Pinchart
2017-02-12 22:53 ` Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 23/24] media: imx: Add Parallel OV5642 " Steve Longerbeam
2017-01-07 2:11 ` [PATCH v3 24/24] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers Steve Longerbeam
2017-01-11 23:14 ` [PATCH v3 00/24] i.MX Media Driver Tim Harvey
2017-01-12 3:22 ` Steve Longerbeam
2017-01-20 13:52 ` Hans Verkuil
2017-01-20 16:31 ` Philipp Zabel
2017-01-20 18:40 ` Steve Longerbeam
2017-01-20 20:39 ` Hans Verkuil
2017-01-23 11:00 ` Philipp Zabel
2017-01-23 11:08 ` Hans Verkuil
2017-01-24 11:28 ` Philipp Zabel
2017-01-23 23:08 ` Steve Longerbeam
2017-01-24 11:27 ` Philipp Zabel
2017-01-28 19:27 ` Steve Longerbeam
2017-01-30 13:06 ` Russell King - ARM Linux
2017-01-31 10:09 ` Philipp Zabel
2017-01-31 13:14 ` Russell King - ARM Linux
2017-01-31 13:35 ` Philipp Zabel
2017-01-31 14:04 ` Russell King - ARM Linux
2017-01-31 0:45 ` Russell King - ARM Linux
2017-01-31 1:06 ` Russell King - ARM Linux
2017-01-31 2:06 ` Steve Longerbeam
2017-01-31 1:22 ` Steve Longerbeam
2017-01-31 9:49 ` Philipp Zabel
2017-01-31 10:21 ` Russell King - ARM Linux
2017-01-31 11:00 ` Russell King - ARM Linux
2017-01-31 23:43 ` Steve Longerbeam
2017-02-01 0:23 ` Russell King - ARM Linux
2017-02-01 1:54 ` Steve Longerbeam
2017-02-01 9:20 ` Russell King - ARM Linux
2017-01-31 13:54 ` Philipp Zabel
2017-01-31 14:25 ` Philipp Zabel
2017-01-31 15:03 ` Russell King - ARM Linux
2017-02-01 1:26 ` Steve Longerbeam
2017-02-01 9:30 ` Philipp Zabel
2017-02-01 10:11 ` Russell King - ARM Linux
2017-02-01 10:42 ` Philipp Zabel
2017-02-01 10:53 ` Russell King - ARM Linux
2017-02-02 0:19 ` Steve Longerbeam
2017-02-03 14:41 ` Laurent Pinchart
2017-02-03 17:56 ` Steve Longerbeam
2017-02-15 2:27 ` Steve Longerbeam
2017-02-15 9:33 ` Philipp Zabel
2017-02-02 17:22 ` Russell King - ARM Linux
2017-02-02 17:31 ` Steve Longerbeam
2017-02-02 17:56 ` Russell King - ARM Linux
2017-02-02 18:26 ` Steve Longerbeam
2017-02-02 18:58 ` Russell King - ARM Linux
2017-02-02 19:12 ` Steve Longerbeam [this message]
2017-02-02 22:29 ` Russell King - ARM Linux
2017-02-03 18:49 ` Steve Longerbeam
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=2e1cf096-ecb8-ba3d-a554-f4cc6999ed4e@gmail.com \
--to=slongerbeam@gmail.com \
--cc=andrew-ct.chen@mediatek.com \
--cc=arnd@arndb.de \
--cc=bparrot@ti.com \
--cc=devel@driverdev.osuosl.org \
--cc=devicetree@vger.kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=horms+renesas@verge.net.au \
--cc=hverkuil@xs4all.nl \
--cc=jean-christophe.trotin@st.com \
--cc=kernel@pengutronix.de \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=markus.heiser@darmarIT.de \
--cc=mchehab@kernel.org \
--cc=minghsiu.tsai@mediatek.com \
--cc=nick@shmanahar.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=p.zabel@pengutronix.de \
--cc=robert.jarzmik@free.fr \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=songjun.wu@microchip.com \
--cc=steve_longerbeam@mentor.com \
--cc=sudipm.mukherjee@gmail.com \
--cc=tiffany.lin@mediatek.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;
as well as URLs for NNTP newsgroup(s).