lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250802-media-private-data-v1-0-eb140ddd6a9d@ideasonboard.com>
Date: Sat, 02 Aug 2025 11:22:22 +0200
From: Jacopo Mondi <jacopo.mondi@...asonboard.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>, 
 Devarsh Thakkar <devarsht@...com>, Benoit Parrot <bparrot@...com>, 
 Hans Verkuil <hverkuil@...nel.org>, Mike Isely <isely@...ox.com>, 
 Laurent Pinchart <laurent.pinchart@...asonboard.com>, 
 Hans de Goede <hansg@...nel.org>, 
 Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>, 
 Christian Gromm <christian.gromm@...rochip.com>, 
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 Alex Shi <alexs@...nel.org>, Yanteng Si <si.yanteng@...ux.dev>, 
 Dongliang Mu <dzm91@...t.edu.cn>, Jonathan Corbet <corbet@....net>, 
 Tomasz Figa <tfiga@...omium.org>, 
 Marek Szyprowski <m.szyprowski@...sung.com>, 
 Andy Walls <awalls@...metrocast.net>, 
 Michael Tretter <m.tretter@...gutronix.de>, 
 Pengutronix Kernel Team <kernel@...gutronix.de>, 
 Bin Liu <bin.liu@...iatek.com>, Matthias Brugger <matthias.bgg@...il.com>, 
 AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, 
 Dmitry Osipenko <digetx@...il.com>, 
 Thierry Reding <thierry.reding@...il.com>, 
 Jonathan Hunter <jonathanh@...dia.com>, 
 Mirela Rabulea <mirela.rabulea@....com>, Shawn Guo <shawnguo@...nel.org>, 
 Sascha Hauer <s.hauer@...gutronix.de>, Fabio Estevam <festevam@...il.com>, 
 Kieran Bingham <kieran.bingham+renesas@...asonboard.com>, 
 Michal Simek <michal.simek@....com>, Ming Qian <ming.qian@....com>, 
 Zhou Peng <eagle.zhou@....com>, 
 Xavier Roumegue <xavier.roumegue@....nxp.com>, 
 Philipp Zabel <p.zabel@...gutronix.de>, 
 Vikash Garodia <quic_vgarodia@...cinc.com>, 
 Dikshita Agarwal <quic_dikshita@...cinc.com>, 
 Abhinav Kumar <abhinav.kumar@...ux.dev>, 
 Bryan O'Donoghue <bryan.odonoghue@...aro.org>, 
 Sylwester Nawrocki <sylvester.nawrocki@...il.com>, 
 Jernej Skrabec <jernej.skrabec@...il.com>, Chen-Yu Tsai <wens@...e.org>, 
 Samuel Holland <samuel@...lland.org>, 
 Daniel Almeida <daniel.almeida@...labora.com>, 
 Neil Armstrong <neil.armstrong@...aro.org>, 
 Kevin Hilman <khilman@...libre.com>, Jerome Brunet <jbrunet@...libre.com>, 
 Martin Blumenstingl <martin.blumenstingl@...glemail.com>, 
 Nas Chung <nas.chung@...psnmedia.com>, 
 Jackson Lee <jackson.lee@...psnmedia.com>, 
 Minghsiu Tsai <minghsiu.tsai@...iatek.com>, 
 Houlong Wei <houlong.wei@...iatek.com>, 
 Andrew-CT Chen <andrew-ct.chen@...iatek.com>, 
 Tiffany Lin <tiffany.lin@...iatek.com>, 
 Yunfei Dong <yunfei.dong@...iatek.com>, 
 Geert Uytterhoeven <geert+renesas@...der.be>, 
 Magnus Damm <magnus.damm@...il.com>, 
 Mikhail Ulyanov <mikhail.ulyanov@...entembedded.com>, 
 Jacob Chen <jacob-chen@...wrt.com>, 
 Ezequiel Garcia <ezequiel@...guardiasur.com.ar>, 
 Heiko Stuebner <heiko@...ech.de>, 
 Detlev Casanova <detlev.casanova@...labora.com>, 
 Krzysztof Kozlowski <krzk@...nel.org>, 
 Alim Akhtar <alim.akhtar@...sung.com>, 
 Sylwester Nawrocki <s.nawrocki@...sung.com>, 
 Łukasz Stelmach <l.stelmach@...sung.com>, 
 Andrzej Pietrasiewicz <andrzejtp2010@...il.com>, 
 Jacek Anaszewski <jacek.anaszewski@...il.com>, 
 Andrzej Hajda <andrzej.hajda@...el.com>, 
 Fabien Dessenne <fabien.dessenne@...s.st.com>, 
 Hugues Fruchet <hugues.fruchet@...s.st.com>, 
 Jean-Christophe Trotin <jean-christophe.trotin@...s.st.com>, 
 Maxime Coquelin <mcoquelin.stm32@...il.com>, 
 Alexandre Torgue <alexandre.torgue@...s.st.com>, 
 Nicolas Dufresne <nicolas.dufresne@...labora.com>, 
 Benjamin Gaignard <benjamin.gaignard@...labora.com>, 
 Steve Longerbeam <slongerbeam@...il.com>, 
 Maxime Ripard <mripard@...nel.org>, Paul Kocialkowski <paulk@...-base.io>, 
 Niklas Söderlund <niklas.soderlund@...natech.se>, 
 Robert Foss <rfoss@...nel.org>, Todor Tomov <todor.too@...il.com>, 
 Vladimir Zapolskiy <vladimir.zapolskiy@...aro.org>, 
 Corentin Labbe <clabbe@...libre.com>, 
 Sakari Ailus <sakari.ailus@...ux.intel.com>, 
 Bingbu Cao <bingbu.cao@...el.com>, Tianshu Qiu <tian.shu.qiu@...el.com>, 
 Stanislaw Gruszka <stanislaw.gruszka@...ux.intel.com>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-staging@...ts.linux.dev, linux-doc@...r.kernel.org, 
 linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org, 
 linux-tegra@...r.kernel.org, imx@...ts.linux.dev, 
 linux-renesas-soc@...r.kernel.org, linux-arm-msm@...r.kernel.org, 
 linux-samsung-soc@...r.kernel.org, linux-sunxi@...ts.linux.dev, 
 linux-usb@...r.kernel.org, linux-amlogic@...ts.infradead.org, 
 linux-rockchip@...ts.infradead.org, 
 linux-stm32@...md-mailman.stormreply.com, mjpeg-users@...ts.sourceforge.net, 
 Jacopo Mondi <jacopo.mondi@...asonboard.com>
Subject: [PATCH 00/65] media: Rationalise usage of v4l2_fh

The v4l2_fh abstraction layer provides to drivers support to represent
per-open file handle context and associate driver-specific data to them.

Currently drivers that do not require custom per-file handle data can
use the v4l2_fh_open() and v4l2_fh_release() helpers as handlers
v4l2_file_operations open() and close() functions. The two helpers
set the file->private_data pointer to the newly allocated v4l2_fh.

Drivers that instead store per-file handle data and represent them with
driver-specific types that embed an instance of struct v4l2_fh have
instead to use different helpers: v4l2_fh_init() and v4l2_fh_add() it's
their responsibility to initialize file->private_data with what they
consider more opportune.

Unfortunately this leads to inconsistencies and slightly different
implementations in drivers, which increase the maintenance burden.

The series starts with patches from Laurent to address some of
these inconsistencies. Some drivers in-facts set the file->private_data
pointer to their own driver-specific types that embed the v4l2_fh.
As the driver-specific type can be accessed with a simple container_of
we can make all drivers set file->private_data to point to the v4l2_fh
to make all the code base use the same pattern.

Once all drivers have been made consistent we can modify the framework
to automate the file->private_data initialisation by modifying
v4l2_fh_add() to set file->private_data to the v4l2_fh allocated by
drivers as part of their private structures. Once that's done we can now
remove all direct accesses to file->private_data by providing the
file_to_v4l2_fh helper.

Now that all drivers that use v4l2_fh are guaranteed to have
file->private_data initialised we can remove accesses to the 'void
*priv' filed provided by v4l2-ioctl to drivers to make sure they always
go through the file * and retrieve the driver specific type from the
v4l2_fh there embedded. This guarantees a more robust data type layout
and make usage of v4l2_fh more consistent and clear across the code
base.

Once that's done, the v4l2-ioctl layer can be modified to stop passing
file->private_data as the second argument to all ioctl handlers, as it
is not ideal to have access to the same data through two different entry
point.

As mentioned in the commit message of the last patch, there are plans to
re-use the second ioctl argument to provide drivers a
video_device_state. This patch series paves the way for that by making
sure the argument can be re-used safely.

Signed-off-by: Jacopo Mondi <jacopo.mondi@...asonboard.com>
---
Jacopo Mondi (36):
      media: rcar-vin: Do not set file->private_data
      media: rzg2l-cru: Do not set file->private_data
      media: camss: Remove custom .release fop()
      media: v4l2-ioctl: Access v4l2_fh from private_data
      media: allegro: Access v4l2_fh from file
      media: meson-ge2d: Access v4l2_fh from file
      media: coda: Access v4l2_fh from file
      media: wave5: Access v4l2_fh from file
      media: m2m-deinterlace: Access v4l2_fh from file
      media: mtk: jpeg: Access v4l2_fh from file->private_data
      media: mtk_mdp_m2m: Access v4l2_fh from file
      media: mtk: mdp3: Access v4l2_fh from file
      media: mtk: vcodec: Access v4l2_fh from file
      media: tegra-vde: Access v4l2_fh from file
      media: imx-jpeg: Access v4l2_fh from file
      media: imx-isi: Access v4l2_fh from file
      media: nxp: mx2: Access v4l2_fh from file
      media: renesas: Access v4l2_fh from file
      media: rockhip: rga: Access v4l2_fh from file
      media: rockchip: rkvdec: Access v4l2_fh from file
      media: exynos-gsc: Access v4l2_fh from file
      media: exynos4-is: Access v4l2_fh from file
      media: s3c-camif: Set queue owner using file
      media: s5p-g2d: Access v4l2_fh from file
      media: s5p-jpeg: Access v4l2_fh from file
      media: s5p-mfc: Access v4l2_fh from file
      media: bdisp: Access v4l2_fh from file
      media: st: delta: Access v4l2_fh from file
      media: stm32: dma2d: Access v4l2_fh from file
      media: omap3isp: Access v4l2_fh from file
      media: cx18:  Access v4l2_fh from file
      media: ivtv: Access v4l2_fh from file
      media: zoran: Remove access to __fh
      media: usb: hdpvr: Access v4l2_fh from file
      media: usb: uvc: Access v4l2_fh from file
      media: staging: imx: Access v4l2_fh from file

Laurent Pinchart (29):
      media: pci: saa7164: Store v4l2_fh pointer in file->private_data
      media: imagination: Store v4l2_fh pointer in file->private_data
      media: ti: vpe: Store v4l2_fh pointer in file->private_data
      media: usb: hdpvr: Store v4l2_fh pointer in file->private_data
      media: usb: pvrusb2: Store v4l2_fh pointer in file->private_data
      media: usb: uvcvideo: Store v4l2_fh pointer in file->private_data
      media: staging: most: Store v4l2_fh pointer in file->private_data
      media: Wrap file->private_data access with a helper function
      media: Replace file->private_data access with file_to_v4l2_fh()
      media: nvidia: tegra-vde: Replace file->private_data access
      media: Replace file->private_data access with custom functions
      media: pci: ivtv: Don't create fake v4l2_fh
      media: amphion: Make some vpu_v4l2 functions static
      media: amphion: Delete v4l2_fh synchronously in .release()
      media: visl: Drop visl_v4l2fh_to_ctx() function
      media: v4l2-fh: Move piece of documentation to correct function
      media: camss: Replace .open() file operation with v4l2_fh_open()
      media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance()
      media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init()
      media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init()
      media: qcom: iris: Drop unused argument to iris_get_inst()
      media: qcom: venus: Pass file pointer to venus_close_common()
      media: Set file->private_data in v4l2_fh_add()
      media: Reset file->private_data to NULL in v4l2_fh_del()
      media: hantro: Access v4l2_fh from file->private_data
      media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check
      media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually
      media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
      media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers

 Documentation/driver-api/media/v4l2-fh.rst         |  56 ++---
 .../zh_CN/video4linux/v4l2-framework.txt           |  11 +-
 drivers/media/common/videobuf2/videobuf2-v4l2.c    |   2 +-
 drivers/media/pci/cx18/cx18-driver.h               |   2 +-
 drivers/media/pci/cx18/cx18-fileops.c              |  11 +-
 drivers/media/pci/cx18/cx18-ioctl.c                |  64 +++---
 drivers/media/pci/intel/ipu6/ipu6-isys-video.c     |   1 -
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c             |   2 -
 drivers/media/pci/ivtv/ivtv-driver.h               |   7 +-
 drivers/media/pci/ivtv/ivtv-fileops.c              |  40 ++--
 drivers/media/pci/ivtv/ivtv-ioctl.c                | 124 +++++------
 drivers/media/pci/ivtv/ivtv-irq.c                  |   4 +-
 drivers/media/pci/saa7164/saa7164-encoder.c        |  30 ++-
 drivers/media/pci/saa7164/saa7164-vbi.c            |  25 ++-
 drivers/media/pci/saa7164/saa7164.h                |  10 +
 drivers/media/pci/zoran/zoran.h                    |   6 -
 drivers/media/pci/zoran/zoran_driver.c             |   3 +-
 drivers/media/platform/allegro-dvt/allegro-core.c  |  32 +--
 drivers/media/platform/amlogic/meson-ge2d/ge2d.c   |  25 ++-
 drivers/media/platform/amphion/vpu.h               |   2 +-
 drivers/media/platform/amphion/vpu_v4l2.c          |  22 +-
 drivers/media/platform/amphion/vpu_v4l2.h          |   8 -
 .../media/platform/chips-media/coda/coda-common.c  |  50 +++--
 .../platform/chips-media/wave5/wave5-helper.c      |  10 +-
 .../platform/chips-media/wave5/wave5-helper.h      |   2 +-
 .../platform/chips-media/wave5/wave5-vpu-dec.c     |  23 +-
 .../platform/chips-media/wave5/wave5-vpu-enc.c     |  29 ++-
 .../media/platform/chips-media/wave5/wave5-vpu.h   |   5 +
 .../media/platform/imagination/e5010-jpeg-enc.c    |  23 +-
 .../media/platform/imagination/e5010-jpeg-enc.h    |   5 +
 drivers/media/platform/m2m-deinterlace.c           |  26 ++-
 .../media/platform/mediatek/jpeg/mtk_jpeg_core.c   |  37 ++--
 drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c  |  29 ++-
 .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c    |  25 ++-
 .../mediatek/vcodec/decoder/mtk_vcodec_dec.c       |  36 ++--
 .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c   |   9 +-
 .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h   |   5 +
 .../mediatek/vcodec/encoder/mtk_vcodec_enc.c       |  37 ++--
 .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c   |   9 +-
 .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h   |   4 +-
 drivers/media/platform/nvidia/tegra-vde/v4l2.c     |  35 ++-
 drivers/media/platform/nxp/dw100/dw100.c           |   7 +-
 drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c     |  45 ++--
 drivers/media/platform/nxp/imx-pxp.c               |   7 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c |  21 +-
 drivers/media/platform/nxp/mx2_emmaprp.c           |  24 ++-
 drivers/media/platform/qcom/camss/camss-video.c    |  43 +---
 drivers/media/platform/qcom/iris/iris_vidc.c       |  36 ++--
 drivers/media/platform/qcom/venus/core.c           |   4 +-
 drivers/media/platform/qcom/venus/core.h           |   4 +-
 drivers/media/platform/qcom/venus/vdec.c           |   5 +-
 drivers/media/platform/qcom/venus/venc.c           |   5 +-
 .../media/platform/renesas/rcar-vin/rcar-v4l2.c    |   2 -
 drivers/media/platform/renesas/rcar_fdp1.c         |  17 +-
 drivers/media/platform/renesas/rcar_jpu.c          |  27 ++-
 .../media/platform/renesas/rzg2l-cru/rzg2l-video.c |   1 -
 drivers/media/platform/renesas/vsp1/vsp1_histo.c   |   6 +-
 drivers/media/platform/renesas/vsp1/vsp1_video.c   |  18 +-
 drivers/media/platform/rockchip/rga/rga.c          |  16 +-
 drivers/media/platform/rockchip/rga/rga.h          |   5 +
 drivers/media/platform/rockchip/rkvdec/rkvdec.c    |  21 +-
 drivers/media/platform/rockchip/rkvdec/rkvdec.h    |   4 +-
 .../media/platform/samsung/exynos-gsc/gsc-core.h   |   6 +-
 .../media/platform/samsung/exynos-gsc/gsc-m2m.c    |  37 ++--
 .../media/platform/samsung/exynos4-is/fimc-core.h  |   5 +-
 .../media/platform/samsung/exynos4-is/fimc-m2m.c   |  19 +-
 .../platform/samsung/s3c-camif/camif-capture.c     |  26 +--
 drivers/media/platform/samsung/s5p-g2d/g2d.c       |  22 +-
 .../media/platform/samsung/s5p-jpeg/jpeg-core.c    |  33 ++-
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c   |  13 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_common.h      |   6 +
 .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c   |  22 +-
 .../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c   |  24 +--
 drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c   |  30 +--
 drivers/media/platform/st/sti/delta/delta-v4l2.c   |  41 ++--
 drivers/media/platform/st/sti/hva/hva-v4l2.c       |  38 ++--
 drivers/media/platform/st/sti/hva/hva.h            |   2 -
 drivers/media/platform/st/stm32/dma2d/dma2d.c      |  18 +-
 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c   |  10 +-
 .../platform/sunxi/sun8i-rotate/sun8i_rotate.c     |  10 +-
 drivers/media/platform/ti/omap3isp/ispvideo.c      |  36 ++--
 drivers/media/platform/ti/omap3isp/ispvideo.h      |   6 +-
 drivers/media/platform/ti/vpe/vpe.c                |  21 +-
 drivers/media/platform/verisilicon/hantro.h        |   4 +-
 drivers/media/platform/verisilicon/hantro_drv.c    |  10 +-
 drivers/media/platform/verisilicon/hantro_v4l2.c   |  22 +-
 drivers/media/platform/xilinx/xilinx-dma.c         |  10 +-
 drivers/media/test-drivers/vicodec/vicodec-core.c  |   7 +-
 drivers/media/test-drivers/vim2m.c                 |   7 +-
 drivers/media/test-drivers/visl/visl-core.c        |   5 +-
 drivers/media/test-drivers/visl/visl.h             |   7 +-
 drivers/media/test-drivers/vivid/vivid-core.c      |   4 +-
 drivers/media/test-drivers/vivid/vivid-radio-rx.c  |   4 +-
 drivers/media/test-drivers/vivid/vivid-radio-tx.c  |   4 +-
 drivers/media/usb/hdpvr/hdpvr-video.c              |  39 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c           |  69 +++---
 drivers/media/usb/uvc/uvc_metadata.c               |  10 +-
 drivers/media/usb/uvc/uvc_v4l2.c                   |  47 ++--
 drivers/media/usb/uvc/uvcvideo.h                   |   5 +
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c      |   2 +-
 drivers/media/v4l2-core/v4l2-ctrls-api.c           |   9 +-
 drivers/media/v4l2-core/v4l2-fh.c                  |  16 +-
 drivers/media/v4l2-core/v4l2-ioctl.c               |  53 ++---
 drivers/media/v4l2-core/v4l2-mem2mem.c             |  34 +--
 drivers/media/v4l2-core/v4l2-subdev.c              |  16 +-
 drivers/staging/media/imx/imx-media-csc-scaler.c   |  26 +--
 drivers/staging/media/ipu7/ipu7-isys-video.c       |   1 -
 drivers/staging/media/meson/vdec/vdec.c            |  29 +--
 drivers/staging/media/meson/vdec/vdec.h            |   5 +
 drivers/staging/media/sunxi/cedrus/cedrus.c        |   8 +-
 drivers/staging/media/sunxi/cedrus/cedrus.h        |   5 +
 drivers/staging/media/sunxi/cedrus/cedrus_video.c  |   5 -
 drivers/staging/most/video/video.c                 |  19 +-
 drivers/usb/gadget/function/uvc.h                  |   5 +
 drivers/usb/gadget/function/uvc_v4l2.c             |   8 +-
 include/media/v4l2-fh.h                            |  28 ++-
 include/media/v4l2-ioctl.h                         | 236 ++++++++++-----------
 117 files changed, 1203 insertions(+), 1185 deletions(-)
---
base-commit: d968e50b5c26642754492dea23cbd3592bde62d8
change-id: 20250801-media-private-data-4515851e7e1d

Best regards,
-- 
Jacopo Mondi <jacopo.mondi@...asonboard.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ