From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ming Qian <ming.qian@nxp.com>
Cc: mchehab@kernel.org, shawnguo@kernel.org, robh+dt@kernel.org,
s.hauer@pengutronix.de, hverkuil-cisco@xs4all.nl,
kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
aisheng.dong@nxp.com, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v18 05/15] media: amphion: implement vpu core communication based on mailbox
Date: Wed, 9 Mar 2022 15:23:56 +0300 [thread overview]
Message-ID: <20220309122356.GD2592@kili> (raw)
In-Reply-To: <58d4fef9a9b9295459dd15747c2630eea839a5fb.1645670589.git.ming.qian@nxp.com>
On Thu, Feb 24, 2022 at 11:10:03AM +0800, Ming Qian wrote:
> +static bool vpu_inst_receive_msg(struct vpu_inst *inst, struct vpu_rpc_event *pkt)
> +{
> + u32 bytes = sizeof(struct vpu_rpc_event_header);
> + u32 ret;
> +
> + memset(pkt, 0, sizeof(*pkt));
> + if (kfifo_len(&inst->msg_fifo) < bytes)
> + return false;
> +
> + ret = kfifo_out(&inst->msg_fifo, pkt, bytes);
> + if (ret != bytes)
> + return false;
> +
> + if (pkt->hdr.num > 0) {
> + bytes = pkt->hdr.num * sizeof(u32);
Imagine if we had declared "bytes" as unsigned long, then on 64 bit
systems we wouldn't have to worry about integer overflows here. The u32
type has a lot of negatives and none of the positives that unsigned long
has.
> + ret = kfifo_out(&inst->msg_fifo, pkt->data, bytes);
> + if (ret != bytes)
> + return false;
> + }
> +
> + return true;
> +}
[ Snip ]
> +void vpu_msg_delayed_work(struct work_struct *work)
> +{
> + struct vpu_core *core;
> + struct delayed_work *dwork;
> + u32 bytes = sizeof(bytes);
LOL... You got jokes.
> + u32 i;
> +
> + if (!work)
> + return;
> +
> + dwork = to_delayed_work(work);
> + core = container_of(dwork, struct vpu_core, msg_delayed_work);
> + if (kfifo_len(&core->msg_fifo) >= bytes)
> + vpu_core_run_msg_work(core);
> +
> + bytes = sizeof(struct vpu_rpc_event_header);
> + for (i = 0; i < core->supported_instance_count; i++) {
> + struct vpu_inst *inst = vpu_core_find_instance(core, i);
> +
> + if (!inst)
> + continue;
> +
> + if (inst->workqueue && kfifo_len(&inst->msg_fifo) >= bytes)
> + queue_work(inst->workqueue, &inst->msg_work);
> +
> + vpu_inst_put(inst);
> + }
> +}
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-03-09 12:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 3:09 [PATCH v18 00/15] amphion video decoder/encoder driver Ming Qian
2022-02-24 3:09 ` [PATCH v18 01/15] dt-bindings: media: amphion: add amphion video codec bindings Ming Qian
2022-02-24 3:10 ` [PATCH v18 02/15] media: add nv12m_8l128 and nv12m_10be_8l128 video format Ming Qian
2022-02-24 3:10 ` [PATCH v18 03/15] media: amphion: add amphion vpu device driver Ming Qian
2022-02-24 3:10 ` [PATCH v18 04/15] media: amphion: add vpu core driver Ming Qian
2022-03-09 12:06 ` Dan Carpenter
2022-02-24 3:10 ` [PATCH v18 05/15] media: amphion: implement vpu core communication based on mailbox Ming Qian
2022-03-09 12:23 ` Dan Carpenter [this message]
2022-02-24 3:10 ` [PATCH v18 06/15] media: amphion: add vpu v4l2 m2m support Ming Qian
2022-03-09 11:34 ` Dan Carpenter
2022-03-10 1:55 ` [EXT] " Ming Qian
2022-02-24 3:10 ` [PATCH v18 07/15] media: amphion: add v4l2 m2m vpu encoder stateful driver Ming Qian
2022-02-24 3:10 ` [PATCH v18 08/15] media: amphion: add v4l2 m2m vpu decoder " Ming Qian
2022-02-24 3:10 ` [PATCH v18 09/15] media: amphion: implement windsor encoder rpc interface Ming Qian
2022-02-24 3:10 ` [PATCH v18 10/15] media: amphion: implement malone decoder " Ming Qian
2022-03-09 11:44 ` Dan Carpenter
2022-02-24 3:10 ` [PATCH v18 11/15] arm64: dts: freescale: imx8q: add imx vpu codec entries Ming Qian
2022-02-24 3:10 ` [PATCH v18 12/15] firmware: imx: scu-pd: imx8q: add vpu mu resources Ming Qian
2022-02-24 3:10 ` [PATCH v18 13/15] MAINTAINERS: add AMPHION VPU CODEC V4L2 driver entry Ming Qian
2022-02-24 3:10 ` [PATCH v18 14/15] arm64: defconfig: amphion: enable vpu driver Ming Qian
2022-02-24 3:10 ` [PATCH v18 15/15] media: amphion: add amphion vpu entry in Kconfig and Makefile Ming Qian
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=20220309122356.GD2592@kili \
--to=dan.carpenter@oracle.com \
--cc=aisheng.dong@nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ming.qian@nxp.com \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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).