From nobody Thu Apr 2 20:14:35 2026 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 99E3B35FF69; Thu, 12 Feb 2026 16:24:15 +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=1770913457; cv=none; b=VNBs9QEsGIB2Kk4Ff2bjHAfYprKMYaXVvC89KL3RC2J0rDvKsEZ8uDNlVZrzaVdU4kPlToZX2ljyk2hwlApIpOtvMmHQbGpD+iKs3mwXPmThd8lkMSdZonAZ7RRz0E04HJTvgeXubPK5fAgxvpcCBAX+Da0VCNfUak4eMpZdlX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770913457; c=relaxed/simple; bh=EgY6rRozA0nftZszqOZUvhTiePvvlTkScGicAmL6ngk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nB4ZVN8tRvR1s4pU53BrY+qihpcexWQV2uk4Y+L8Sf7tIFfGLlNmIHFJnp+jA7dyojuXF3GhEB8WFh/oDTpLKfcsaFhcDaBo/93RFT35tTeuelxelfKOK1OWKHDdfoWgocBZIxoFQTnRrZV4Lj91OEFyC87bAw+wjT2abOQ53s8= 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=I/El3T4P; 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="I/El3T4P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1770913453; bh=EgY6rRozA0nftZszqOZUvhTiePvvlTkScGicAmL6ngk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/El3T4P0xovkgMTWcwcUXRdgkb5x/Jtnuc437sudcJIWdnjlnXYE41volTkySBfe g7jQRcLsGl/6alBEVCexl9s9fNPtON5QVNL73QcPbYHGdDtI2xmR/0NTAl9fXhJD97 qFgkabxP+3rZGcrSj/VLHSKhIhAq7nLVYZzkjHJ1vCw1IqG+/MV1hueucPtyb6z0Ib 6JJCp4vP4H9d182O5pN+LiOzLutxAzCRJr2Iv2W1tiEb3dXrCcmuYPMCgXKDOukGs9 CiNst9RRZQqTFC8aF46h8zMFj8HeWJ7xWZO/9c9oit/M9SXY9Hz5RaDDX0zYuBPuZD 0q/HX4jCb7KJw== Received: from trenzalore (modemcable014.2-22-96.mc.videotron.ca [96.22.2.14]) (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 A672017E0A49; Thu, 12 Feb 2026 17:24:10 +0100 (CET) From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Nicolas Dufresne , Benjamin Gaignard , Philipp Zabel , Mauro Carvalho Chehab , Heiko Stuebner , Daniel Almeida , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Hans Verkuil , Laurent Pinchart , Ricardo Ribalda , Yunke Cao , Detlev Casanova , Sakari Ailus , Pavan Bobba , James Cowgill , Ma Ke , Jacopo Mondi , Daniel Scally , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-trace-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 11/11] media: hantro: Add fdinfo callback Date: Thu, 12 Feb 2026 11:23:28 -0500 Message-ID: <20260212162328.192217-12-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260212162328.192217-1-detlev.casanova@collabora.com> References: <20260212162328.192217-1-detlev.casanova@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The fdinfo shows the number of buffers in each queue and the total amount of video buffer memory. Signed-off-by: Detlev Casanova --- drivers/media/platform/verisilicon/hantro.h | 1 + drivers/media/platform/verisilicon/hantro_drv.c | 15 +++++++++++++++ drivers/media/platform/verisilicon/hantro_v4l2.c | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/pl= atform/verisilicon/hantro.h index d5cddc783688..9e9fc0658586 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -268,6 +268,7 @@ struct hantro_ctx { const struct hantro_codec_ops *codec_ops; struct hantro_postproc_ctx postproc; bool need_postproc; + u64 stats_buf_memory; =20 /* Specific for particular codec modes. */ union { diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/medi= a/platform/verisilicon/hantro_drv.c index 8dd26ca32459..86d316a8a3e8 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -711,6 +712,19 @@ static int hantro_release(struct file *filp) return 0; } =20 +static void hantro_show_fdinfo(struct seq_file *m, struct file *filp) +{ + struct hantro_ctx *ctx =3D + container_of(filp->private_data, struct hantro_ctx, fh); + + struct vb2_queue *src_q =3D v4l2_m2m_get_src_vq(ctx->fh.m2m_ctx); + struct vb2_queue *dst_q =3D v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx); + + seq_printf(m, "src-queued-count: %04u\n", src_q->queued_count); + seq_printf(m, "dst-queued-count: %04u\n", dst_q->queued_count); + seq_printf(m, "buf-size: %llu\n", ctx->stats_buf_memory); +} + static const struct v4l2_file_operations hantro_fops =3D { .owner =3D THIS_MODULE, .open =3D hantro_open, @@ -718,6 +732,7 @@ static const struct v4l2_file_operations hantro_fops = =3D { .poll =3D v4l2_m2m_fop_poll, .unlocked_ioctl =3D video_ioctl2, .mmap =3D v4l2_m2m_fop_mmap, + .show_fdinfo =3D hantro_show_fdinfo, }; =20 static const struct of_device_id of_hantro_match[] =3D { diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index fcf3bd9bcda2..6d129613ea3d 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -820,18 +820,26 @@ hantro_queue_setup(struct vb2_queue *vq, unsigned int= *num_buffers, return -EINVAL; } =20 + ctx->stats_buf_memory =3D 0; + if (*num_planes) { if (*num_planes !=3D pixfmt->num_planes) return -EINVAL; - for (i =3D 0; i < pixfmt->num_planes; ++i) + for (i =3D 0; i < pixfmt->num_planes; ++i) { if (sizes[i] < pixfmt->plane_fmt[i].sizeimage) return -EINVAL; + ctx->stats_buf_memory +=3D pixfmt->plane_fmt[i].sizeimage; + } + + ctx->stats_buf_memory *=3D *num_buffers; + return 0; } =20 *num_planes =3D pixfmt->num_planes; for (i =3D 0; i < pixfmt->num_planes; ++i) sizes[i] =3D pixfmt->plane_fmt[i].sizeimage; + return 0; } =20 --=20 2.53.0