From: Nas Chung <nas.chung@chipsnmedia.com>
To: Detlev Casanova <detlev.casanova@collabora.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Benjamin Gaignard <benjamin.gaignard@collabora.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Heiko Stuebner <heiko@sntech.de>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rockchip@lists.infradead.org"
<linux-rockchip@lists.infradead.org>,
"kernel@collabora.com" <kernel@collabora.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH v4 3/5] media: v4l2-core: Add v4l2-metrics interface
Date: Fri, 27 Nov 2026 03:32:51 +0000 [thread overview]
Message-ID: <SL2P216MB2441C07DE4CD2D1B41341ED4FB412@SL2P216MB2441.KORP216.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20261125-v4l2-add-fdinfo-v4-3-2dc73fad9932@collabora.com>
Hi Detlev,
>-----Original Message-----
>From: Detlev Casanova <detlev.casanova@collabora.com>
>Sent: Thursday, November 26, 2026 12:12 AM
>To: Mauro Carvalho Chehab <mchehab@kernel.org>; Nicolas Dufresne
><nicolas.dufresne@collabora.com>; Benjamin Gaignard
><benjamin.gaignard@collabora.com>; Philipp Zabel <p.zabel@pengutronix.de>;
>Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>; Heiko Stuebner
><heiko@sntech.de>
>Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>rockchip@lists.infradead.org; kernel@collabora.com; Detlev Casanova
><detlev.casanova@collabora.com>; linux-arm-kernel@lists.infradead.org
>Subject: [PATCH v4 3/5] media: v4l2-core: Add v4l2-metrics interface
>
...
>+
>+void v4l2_metrics_show(struct v4l2_metrics *metrics, struct seq_file *m,
>unsigned int core_id)
>+{
>+ seq_printf(m, "v4l2-driver-type:\t%s\n", driver_type_name[metrics-
>>driver_type]);
>+ seq_printf(m, "v4l2-core-usage-time-%u:\t%llu ns\n", core_id,
>metrics->hw_usage_time);
>+
>+ if (metrics->has_hw_usage_cycles)
>+ seq_printf(m, "v4l2-core-usage-cycles-%u:\t%llu\n",
>+ core_id, metrics->hw_usage_cycles);
>+}
>+EXPORT_SYMBOL_GPL(v4l2_metrics_show);
>+
>+void v4l2_metrics_show_clock(struct seq_file *m, struct clk *clk, unsigned
>int core_id)
To allow maxfreq and curfreq to differ, how about passing both values
instead of the clock?
void v4l2_metrics_show_freq(struct seq_file *m, unsigned int core_id,
unsigned long cur_freq, unsigned long max_freq)
Thanks,
Nas
>+{
>+ seq_printf(m, "v4l2-maxfreq-%u:\t%lu Hz\n",
>+ core_id, clk_get_rate(clk));
>+ seq_printf(m, "v4l2-curfreq-%u:\t%lu Hz\n",
>+ core_id, clk_get_rate(clk));
>+}
>+EXPORT_SYMBOL_GPL(v4l2_metrics_show_clock);
>diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
>index aad4b3689d7e..4f1ca1bbc61f 100644
>--- a/include/media/v4l2-fh.h
>+++ b/include/media/v4l2-fh.h
>@@ -17,6 +17,7 @@
> #include <linux/kconfig.h>
> #include <linux/list.h>
> #include <linux/videodev2.h>
>+#include <media/v4l2-metrics.h>
>
> struct video_device;
> struct v4l2_ctrl_handler;
>@@ -27,6 +28,7 @@ struct v4l2_ctrl_handler;
> * @list: list of file handlers
> * @vdev: pointer to &struct video_device
> * @ctrl_handler: pointer to &struct v4l2_ctrl_handler
>+ * @metrics: metrics information for this handle
> * @prio: priority of the file handler, as defined by &enum v4l2_priority
> *
> * @wait: event' s wait queue
>@@ -43,6 +45,7 @@ struct v4l2_fh {
> struct list_head list;
> struct video_device *vdev;
> struct v4l2_ctrl_handler *ctrl_handler;
>+ struct v4l2_metrics metrics;
> enum v4l2_priority prio;
>
> /* Events */
>diff --git a/include/media/v4l2-metrics.h b/include/media/v4l2-metrics.h
>new file mode 100644
>index 000000000000..fc493b65f117
>--- /dev/null
>+++ b/include/media/v4l2-metrics.h
>@@ -0,0 +1,47 @@
>+/* SPDX-License-Identifier: GPL-2.0-only */
>+/*
>+ * v4l2-metrics.h
>+ *
>+ * V4L2 metrics management.
>+ *
>+ * Maintain a per-file handle list of statistics about the hardware and
>handle
>+ * exposing it in the fdinfo.
>+ *
>+ * Copyright (C) 2026 Collabora.
>+ *
>+ * Contact: Detlev Casanova <detlev.casanova@collabora.com>
>+ */
>+#ifndef V4L2_METRICS_H
>+#define V4L2_METRICS_H
>+
>+#include <linux/types.h>
>+
>+struct clk;
>+struct seq_file;
>+
>+enum v4l2_driver_type {
>+ V4L2_DRIVER_TYPE_UNKNOWN = 0,
>+ V4L2_DRIVER_TYPE_STATELESS_ENCODER,
>+ V4L2_DRIVER_TYPE_STATELESS_DECODER,
>+
>+ V4L2_DRIVER_TYPE_COUNT,
>+};
>+
>+struct v4l2_metrics {
>+ u64 hw_usage_time;
>+ u64 hw_usage_cycles;
>+ bool has_hw_usage_cycles;
>+ enum v4l2_driver_type driver_type;
>+};
>+
>+void v4l2_metrics_init(struct v4l2_metrics *metrics);
>+void v4l2_metrics_exit(struct v4l2_metrics *metrics);
>+
>+void v4l2_metrics_update_hw_time(struct v4l2_metrics *metrics, u64
>time_ns);
>+void v4l2_metrics_update_hw_cycles(struct v4l2_metrics *metrics, u64
>cycles);
>+void v4l2_metrics_set_driver_type(struct v4l2_metrics *metrics, enum
>v4l2_driver_type type);
>+
>+void v4l2_metrics_show(struct v4l2_metrics *metrics, struct seq_file *m,
>unsigned int core_id);
>+void v4l2_metrics_show_clock(struct seq_file *m, struct clk *clk, unsigned
>int core_id);
>+
>+#endif /* V4L2_METRICS_H */
>
>--
>2.56.1
>
next prev parent reply other threads:[~2026-11-27 3:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 15:11 [PATCH v4 0/5] media: Add fdinfo support for v4l2 drivers Detlev Casanova
2026-11-25 15:11 ` [PATCH v4 1/5] media: v4l2: Add callback for show_fdinfo Detlev Casanova
2026-11-25 15:11 ` [PATCH v4 2/5] docs: media: add documentation for V4L2 driver usage metrics Detlev Casanova
2026-11-25 15:12 ` [PATCH v4 3/5] media: v4l2-core: Add v4l2-metrics interface Detlev Casanova
2026-11-27 3:32 ` Nas Chung [this message]
2026-11-25 15:12 ` [PATCH v4 4/5] media: hantro: Add per-context fdinfo usage metrics Detlev Casanova
2026-11-25 15:12 ` [PATCH v4 5/5] media: rkvdec: " Detlev Casanova
2026-11-27 3:29 ` [PATCH v4 0/5] media: Add fdinfo support for v4l2 drivers Nicolas Dufresne
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=SL2P216MB2441C07DE4CD2D1B41341ED4FB412@SL2P216MB2441.KORP216.PROD.OUTLOOK.COM \
--to=nas.chung@chipsnmedia.com \
--cc=benjamin.gaignard@collabora.com \
--cc=detlev.casanova@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=kernel@collabora.com \
--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=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
/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
all inboxes | Powered by JetHome®