From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 645B938AC87; Fri, 12 Jun 2026 14:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781274412; cv=none; b=qRthtyxVjuYorjJ5nkHqEjx6pOgdLPXppFYhnyDVgBKe5J9affCRJIyMuKqyAj0KFsO5fAj0tSciy5XaoalG/hdtaJMnieJ33U9vVGsyHthTYP5TE07AFkrZ2OX7R0QzlFuhwuaeSwJK+D3WHwzeESXAtDHki3ml8QjF/iBVnVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781274412; c=relaxed/simple; bh=oQwOxS3Hw6I/7xWUOiCUqQ18gZdrBmQAvomq/6T/pdw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MUcS3F5wv6CgF+CXCzVCO7HuzBT7g+GdqsVF+33SNf2KOhIHjZ9D32QJ8581ZTzo0mVthzzGLky9fj2P4XviMrRs5y5GXvZD2VsJyxxSGT6rSDJVvhqkZZF0EvXJZ02QAYZZ4UXwTsehKBWgQqKhpmFYkE6QE5+HXEyYTETZJ5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Hi3PL2bB; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Hi3PL2bB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1781274401; bh=oQwOxS3Hw6I/7xWUOiCUqQ18gZdrBmQAvomq/6T/pdw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Hi3PL2bBZup5h9ce9t2P3NvZeCVEttzzXUCYHZwADZ3ZTN6OeZsKITBju9ZuMgBEu tx2jbxYVCvYHshXAqHc/3wVOBNT9yOQ/QB/UJJ1evq/WatRnTirI/kfDLtJSvshIcO /0kMRISwFxqw9n358i/N4IcAbUqtccnmdnqZiRyIU4xd6Zch270UMJ8uHuqBrKcpcn iVSj1mGTtaejZFPirlgcsE6Y35xAgRghMT6vQCOHZcZKazonpTQ6WXDVyrU8EW8g3n dNLCuI+VMvM/nqODcwWga7+kvFK2zctBtAolJk4MiOFsyBNITMakcq81hvC9sdxZkX 7BjBR/gdyvwnQ== Received: from [192.168.0.15] (unknown [100.64.0.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by bali.collaboradmins.com (Postfix) with ESMTPSA id 6C5BE17E0A49; Fri, 12 Jun 2026 16:26:40 +0200 (CEST) From: Detlev Casanova Date: Fri, 12 Jun 2026 10:26:23 -0400 Subject: [PATCH 2/3] docs: media: add documentation for media client usage stats Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260612-v4l2-add-fdinfo-v1-2-723211abc861@collabora.com> References: <20260612-v4l2-add-fdinfo-v1-0-723211abc861@collabora.com> In-Reply-To: <20260612-v4l2-add-fdinfo-v1-0-723211abc861@collabora.com> To: Mauro Carvalho Chehab , Nicolas Dufresne , Benjamin Gaignard , Philipp Zabel Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Detlev Casanova , Christopher Healy X-Mailer: b4 0.15.2 From: Christopher Healy Document the media fdinfo interface for per-file-descriptor usage statistics exposed by stateless V4L2 codec drivers via /proc//fdinfo/. This interface is specific to stateless (request API based) codec devices where the kernel driver has per-job visibility into hardware execution. Stateful codecs cannot support this because their firmware manages job scheduling opaquely. The specification defines media- prefixed keys for engine utilization time, hardware cycle counts, and operating frequency, following the same conventions as the DRM fdinfo mechanism documented in drm-usage-stats.rst. Signed-off-by: Christopher Healy --- .../userspace-api/media/drivers/index.rst | 1 + .../media/drivers/media-usage-stats.rst | 84 ++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/Documentation/userspace-api/media/drivers/index.rst b/Documentation/userspace-api/media/drivers/index.rst index 02967c9b18d6..61879738836c 100644 --- a/Documentation/userspace-api/media/drivers/index.rst +++ b/Documentation/userspace-api/media/drivers/index.rst @@ -34,6 +34,7 @@ For more details see the file COPYING in the source distribution of Linux. imx-uapi mali-c55 max2175 + media-usage-stats npcm-video omap3isp-uapi thp7312 diff --git a/Documentation/userspace-api/media/drivers/media-usage-stats.rst b/Documentation/userspace-api/media/drivers/media-usage-stats.rst new file mode 100644 index 000000000000..835a74902e6e --- /dev/null +++ b/Documentation/userspace-api/media/drivers/media-usage-stats.rst @@ -0,0 +1,84 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _media-usage-stats: + +========================== +Media client usage stats +========================== + +Stateless V4L2 codec drivers can optionally expose per-file-descriptor usage +statistics via ``/proc//fdinfo/``. This is analogous to the DRM fdinfo +mechanism documented in :ref:`drm-client-usage-stats`, but uses the ``media-`` +key prefix for V4L2 media devices. + +This interface is specific to stateless (request API based) codec devices, +including both decoders and encoders. With stateless codecs, the kernel driver +explicitly submits each frame to the hardware and receives a completion +interrupt, providing a clean per-job boundary that can be attributed to the +submitting file descriptor. + +Stateful codec devices cannot support this interface because their firmware +manages job scheduling internally. The kernel driver submits bitstream data +but has no visibility into per-frame hardware execution timing. + +Implementation +============== + +The V4L2 core provides the plumbing: drivers implement the ``show_fdinfo`` +callback in ``struct v4l2_file_operations``, and the core wires it into the +kernel ``struct file_operations`` so that ``/proc//fdinfo/`` output +includes the driver-provided keys. + +File format specification +========================= + +- File shall contain one key value pair per one line of text. +- Colon character (``:``) must be used to delimit keys and values. +- All standardised keys shall be prefixed with ``media-``. +- Driver-specific keys shall be prefixed with ``driver_name-``. + +Mandatory keys +-------------- + +- media-driver: + + String shall contain the name of the media driver. + +Utilization keys +---------------- + +- media-engine-: ns + + Time in nanoseconds that the hardware engine spent busy processing work + belonging to this file descriptor. The ```` identifies the engine + (e.g. ``decoder``, ``encoder``). + + Values are not required to be constantly monotonic if it makes the driver + implementation easier, but are required to catch up with the previously + reported larger value within a reasonable period. + +Frequency keys +-------------- + +- media-maxfreq-: Hz + + Maximum operating frequency of the engine identified by ````. + +- media-curfreq-: Hz + + Current operating frequency of the engine identified by ````. + +Example output +============== + +:: + + media-driver: hantro-vpu + media-engine-decoder: 123456789 ns + media-maxfreq-decoder: 600000000 Hz + media-curfreq-decoder: 600000000 Hz + +Driver specific implementations +=============================== + +* Hantro VPU (``drivers/media/platform/verisilicon/``) -- 2.54.0