From: Detlev Casanova <detlev.casanova@collabora.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-kernel@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Dragan Simic <dsimic@manjaro.org>,
Alexey Charkov <alchark@gmail.com>,
Cristian Ciocaltea <cristian.ciocaltea@collabora.com>,
Diederik de Haas <didi.debian@cknow.org>,
Andy Yan <andy.yan@rock-chips.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-staging@lists.linux.dev
Subject: Re: [PATCH 1/3] media: rockchip: Introduce the rkvdec2 driver
Date: Mon, 17 Jun 2024 10:23:02 -0400 [thread overview]
Message-ID: <5810431.QJadu78ljV@arisu> (raw)
In-Reply-To: <94b9e0fd-2f4f-4d75-ae39-7d780a4e6374@moroto.mountain>
[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]
On Monday, June 17, 2024 8:02:56 A.M. EDT Dan Carpenter wrote:
> On Fri, Jun 14, 2024 at 09:56:27PM -0400, Detlev Casanova wrote:
> > +static int rkvdec2_start_streaming(struct vb2_queue *q, unsigned int
> > count) +{
> > + struct rkvdec2_ctx *ctx = vb2_get_drv_priv(q);
> > + const struct rkvdec2_coded_fmt_desc *desc;
> > + int ret, i;
> > + u32 width, height;
> > +
> > + if (V4L2_TYPE_IS_CAPTURE(q->type))
> > + return 0;
> > +
> > + desc = ctx->coded_fmt_desc;
> > + if (WARN_ON(!desc))
> > + return -EINVAL;
> > +
> > + width = ctx->decoded_fmt.fmt.pix_mp.width;
> > + height = ctx->decoded_fmt.fmt.pix_mp.height;
> > + for (i = 0; i < RKVDEC2_RCB_COUNT; i++) {
> > + ctx->rcb_bufs[i].cpu =
> > + dma_alloc_coherent(ctx->dev->dev,
> > + RCB_SIZE(i),
> > + &ctx-
>rcb_bufs[i].dma,
> > + GFP_KERNEL);
> > + if (!ctx->rcb_bufs[i].cpu) {
> > + ret = -ENOMEM;
> > + goto err_rcb;
> > + }
> > + }
> > +
> > + if (desc->ops->start) {
> > + ret = desc->ops->start(ctx);
> > + if (ret)
> > + goto err_ops_start;
> > + }
> > +
> > + return 0;
> > +
> > +err_ops_start:
> > +err_rcb:
> > + i--;
> > + while (i) {
> > + dma_free_coherent(ctx->dev->dev,
> > + RCB_SIZE(i),
> > + ctx->rcb_bufs[i].cpu,
> > + ctx->rcb_bufs[i].dma);
> > + i--;
> > + }
>
> This will leak the first element of the ctx->rcb_bufs[i] array. The
> traditional way to write this is either while (--i >= 0) or for unsigned
> int i iterators it would be while (i--).
Yes, I was thinking that an even better solution would be to allocate 1 dma
buffer and use offsets in it when configuring the hw. But this is only one
allocation per streamon, not per frame, so this might just be good enough as
is.
I'll fix the freeing code part
> > +
> > + return ret;
> > +}
>
> regards,
> dan carpenter
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2024-06-17 14:23 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-15 1:56 [PATCH 0/3] media: rockchip: Add rkvdec2 driver Detlev Casanova
2024-06-15 1:56 ` [PATCH 1/3] media: rockchip: Introduce the " Detlev Casanova
2024-06-15 8:51 ` Diederik de Haas
2024-06-15 19:44 ` Detlev Casanova
2024-06-16 8:40 ` Diederik de Haas
2024-06-17 13:52 ` Nicolas Dufresne
2025-01-29 14:48 ` Piotr Oniszczuk
2025-01-29 16:20 ` Nicolas Dufresne
2025-01-30 10:22 ` Piotr Oniszczuk
2025-01-29 16:50 ` Detlev Casanova
2025-01-30 10:46 ` Piotr Oniszczuk
2025-01-30 14:54 ` Piotr Oniszczuk
2024-06-15 13:55 ` kernel test robot
2024-06-15 17:21 ` kernel test robot
2024-06-15 22:24 ` Dmitry Osipenko
2024-06-15 22:32 ` Dmitry Osipenko
2024-06-16 6:58 ` Andy Yan
2024-06-17 13:40 ` [PATCH " Detlev Casanova
2024-06-17 13:59 ` Nicolas Dufresne
2024-06-16 21:40 ` Jonas Karlman
2024-06-17 13:56 ` Detlev Casanova
2024-06-17 4:49 ` Alex Bee
2024-06-17 14:17 ` Detlev Casanova
2024-06-17 15:10 ` Nicolas Dufresne
2024-06-17 9:47 ` Jianfeng Liu
2024-06-17 14:04 ` Nicolas Dufresne
2024-06-17 14:20 ` Detlev Casanova
2024-06-17 15:22 ` Nicolas Dufresne
2024-06-18 12:13 ` Jianfeng Liu
2024-06-18 12:39 ` Detlev Casanova
2024-06-18 16:34 ` Nicolas Dufresne
2024-06-19 7:41 ` Jianfeng Liu
2024-06-17 15:21 ` Jianfeng Liu
2024-06-17 12:02 ` Dan Carpenter
2024-06-17 14:23 ` Detlev Casanova [this message]
2024-06-15 1:56 ` [PATCH 2/3] media: dt-bindings: rockchip: Document RK3588 Video Decoder 2 bindings Detlev Casanova
2024-06-15 3:15 ` Rob Herring (Arm)
2024-06-15 8:11 ` Jonas Karlman
2024-06-15 19:49 ` Detlev Casanova
2024-06-15 22:58 ` Heiko Stuebner
2024-06-15 1:56 ` [PATCH 3/3] arm64: dts: rockchip: Add rkvdec2 Video Decoder on rk3588(s) Detlev Casanova
2024-06-15 8:25 ` Jonas Karlman
2024-06-15 19:55 ` Detlev Casanova
2024-06-16 7:28 ` Heiko Stuebner
2024-06-17 14:31 ` Detlev Casanova
2024-06-16 9:17 ` Jonas Karlman
2024-06-16 11:55 ` Dragan Simic
2024-06-17 14:36 ` Detlev Casanova
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=5810431.QJadu78ljV@arisu \
--to=detlev.casanova@collabora.com \
--cc=alchark@gmail.com \
--cc=andy.yan@rock-chips.com \
--cc=conor+dt@kernel.org \
--cc=cristian.ciocaltea@collabora.com \
--cc=dan.carpenter@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=didi.debian@cknow.org \
--cc=dsimic@manjaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=heiko@sntech.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.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).