Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	Prabhakar <prabhakar.csengg@gmail.com>,
	"Kate Hsuan" <hpa@redhat.com>,
	"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
	"Tommaso Merciai" <tomm.merciai@gmail.com>,
	"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
	"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
	"Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
	"Julien Massot" <julien.massot@collabora.com>,
	"Naushir Patuck" <naush@raspberrypi.com>,
	"Yan, Dongcheng" <dongcheng.yan@intel.com>,
	"Stefan Klug" <stefan.klug@ideasonboard.com>,
	"Mirela Rabulea" <mirela.rabulea@nxp.com>,
	"André Apitzsch" <git@apitzsch.eu>,
	"Heimir Thor Sverrisson" <heimir.sverrisson@gmail.com>,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Mehdi Djait" <mehdi.djait@linux.intel.com>,
	"Ricardo Ribalda Delgado" <ribalda@kernel.org>,
	"Hans de Goede" <hansg@kernel.org>,
	"Jacopo Mondi" <jacopo.mondi@ideasonboard.com>,
	"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>,
	"David Plowman" <david.plowman@raspberrypi.com>,
	"Yu, Ong Hock" <ong.hock.yu@intel.com>,
	"Ng, Khai Wen" <khai.wen.ng@intel.com>,
	"Jai Luthra" <jai.luthra@ideasonboard.com>,
	"Rishikesh Donadkar" <r-donadkar@ti.com>,
	"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
	"Antti Laakso" <antti.laakso@linux.intel.com>
Subject: Re: [PATCH 1/1] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error
Date: Thu, 8 Oct 2026 15:26:42 +0300	[thread overview]
Message-ID: <aseMAtCqoVBz7ggH@kekkonen.localdomain> (raw)
In-Reply-To: <07ce46a4-a8f7-49fc-8ceb-7276abc0d4ad@kernel.org>

Hi Hans,

On Wed, Oct 07, 2026 at 12:14:46PM +0200, Hans Verkuil wrote:
> On 07/10/2026 11:48, Sakari Ailus wrote:
> > Hi Hans,
> > 
> > On Wed, Oct 07, 2026 at 11:43:35AM +0200, Hans Verkuil wrote:
> >> On 06/10/2026 11:29, Sakari Ailus wrote:
> >>> Internal pads should only be accessible to file handles with
> >>> V4L2_SUBDEV_CLIENT_CAP_STREAMS flag set. Return an error otherwise.
> >>>
> >>> Fixes: 49cdf56876d3 ("media: mc: Add INTERNAL pad flag")
> >>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> >>> ---
> >>>  drivers/media/v4l2-core/v4l2-subdev.c | 7 ++++++-
> >>>  1 file changed, 6 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> >>> index a07d77e584c3..7cb5a40f0f8c 100644
> >>> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> >>> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> >>> @@ -854,8 +854,13 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
> >>>  	case VIDIOC_SUBDEV_G_FMT: {
> >>>  		struct v4l2_subdev_format *format = arg;
> >>>  
> >>> -		if (!client_supports_streams)
> >>> +		if (!client_supports_streams) {
> >>> +			if (format->pad < sd->entity.num_pads &&
> >>> +			    sd->entity.pads[format->pad].flags & MEDIA_PAD_FL_INTERNAL)
> >>> +				return -EINVAL;
> >>> +
> >>>  			format->stream = 0;
> >>> +		}
> >>>  
> >>>  		memset(format->reserved, 0, sizeof(format->reserved));
> >>>  		memset(format->format.reserved, 0, sizeof(format->format.reserved));
> >>>
> >>
> >> There is no documentation that I can find that says that MEDIA_PAD_FL_INTERNAL is only available
> >> if V4L2_SUBDEV_CLIENT_CAP_STREAMS is set.
> >>
> >> I think this needs some more thought: if internal pads are only available if that cap is set,
> >> then I expect that a lot more ioctls will need this check. In that case the check should become
> >> a helper function.
> >>
> >> But how does this affect e.g. G_TOPOLOGY or ENUM_LINKS? If the cap is not set, should internal
> >> pads still be reported?
> > 
> > We don't have client capabilities on MC side, at least not right now. The
> > INTERNAL pads are intended to be used in very special circumstances and for
> > that we do have sub-device capability flags. They were introduced in this
> > cycle and if we allow wider access to them now, there could be issues
> > blocking that as the interface they expose isn't intended to be used
> > without these capability flags.
> 
> So are the internal pads exposed or not through these MC ioctls? That's not clear
> to me. It's not documented either.

The pads naturally are exposed via MC, like any other pads. Neither the
sink nor source pad documentation discusses whether the pads are
user-visible so I don't thin this explicitly needs to be specified for
internal pads either.

> 
> > 
> > I'll rework this to apply to the rest of the pad-related IOCTLs.
> > 
> >>
> >> And you need checks in v4l2-compliance, ensuring that trying to access internal pads without
> >> that cap will indeed fail.
> > 
> > I can add that.
> > 
> >>
> >> Ideally you would like to have this emulated in vimc as well.
> >>
> >> In other words, I think this needs more work, both in the core and w.r.t. documentation.
> > 
> > The INTERNAL pad flag was introduced as the Maxim serdes driver needed it
> > and we thought it's fine to merge it early; the bulk of the documentation
> > resides in the depths of my metadata series.
> > 
> 
> Ah, that's not something I was aware of (or may have been aware of, but forgotten). Adding
> a new uAPI requires a lot more care: proper documentation, v4l2-compliance tests, if at all
> possible emulation support in one of the test drivers.

Note that the maxim-serdes driver does not expose any functionality that
would depend on the internal pads solely; it requires streams API
enablement that is behind another kernel change. It is thus very, very
unlikely to cause any issues. On the other hand, no functionality is
disabled by the other two patches I posted to hide the INTERNAL flag from
the userspace.

An example of the contrary, though, is fairly recently merged STREAMS
capability flag, which in its current state cannot be taken into use --
we'll have to use another bit, as enabling this flag now will break
libcamera. The problem here is that the flag is changing the behaviour of
existing interfaces but at the time of the introduction of the flag it
wasn't exactly specified how the existing interfaces would be affected.

> 
> Neither was it reviewed by the media maintainers (me or Mauro). I'm really not happy about
> that. uAPI changes have to be reviewed by the media maintainers.
> 
> Before rc1 is released you must have a patch series ready (and reviewed by me) adding proper
> documentation, fixing issues like the one addressed in this patch, and a patch for
> v4l2-compliance.
> 
> Ideally also a patch to emulate this in the test driver (probably vimc), but that will
> likely take more time.
> 
> If it is not properly documented etc., then I might decide to revert this driver + uAPI
> change in 7.4-rcX.
> 
> As media committer it is your responsibility to ensure that the media maintainers have
> reviewed uAPI changes and are OK with it. That clearly didn't happen here.

In retrospect, I agree I should have explictly asked you before merging the
patch. My apologies for that. Still, versions of the patch have been out
for review for more than three years and while the previous version you've
commented is v6 (in 2023), there have been six more versions for review
where you've been cc'd and additional 15 versions of the maxim-serdes
driver patchset containing the same patch (where you haven't been cc'd
though).

My hope is that we'd get the metadata series, which contains multi-stream
support on which work has been done for more than a decade now, merged in
7.5 (or at least not much later than that), with userspace support in
libcamera which Jai has been working on. I'll post a new version of that
once we have rc1.

-- 
Kind regards,

Sakari Ailus

      reply	other threads:[~2026-10-08 12:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  9:29 [PATCH 1/1] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error Sakari Ailus
2026-10-07  9:43 ` Hans Verkuil
2026-10-07  9:48   ` Sakari Ailus
2026-10-07 10:14     ` Hans Verkuil
2026-10-08 12:26       ` Sakari Ailus [this message]

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=aseMAtCqoVBz7ggH@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=antti.laakso@linux.intel.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=david.plowman@raspberrypi.com \
    --cc=dongcheng.yan@intel.com \
    --cc=git@apitzsch.eu \
    --cc=hansg@kernel.org \
    --cc=heimir.sverrisson@gmail.com \
    --cc=hpa@redhat.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jai.luthra@ideasonboard.com \
    --cc=julien.massot@collabora.com \
    --cc=khai.wen.ng@intel.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mehdi.djait@linux.intel.com \
    --cc=mirela.rabulea@nxp.com \
    --cc=mkorpershoek@kernel.org \
    --cc=naush@raspberrypi.com \
    --cc=ong.hock.yu@intel.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=r-donadkar@ti.com \
    --cc=ribalda@kernel.org \
    --cc=stefan.klug@ideasonboard.com \
    --cc=sylvain.petinot@foss.st.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=tomm.merciai@gmail.com \
    /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