All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	niklas.soderlund+renesas@ragnatech.se,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Kishon Vijay Abraham <kishon@ti.com>,
	satish.nagireddy@getcruise.com, Tomasz Figa <tfiga@chromium.org>
Subject: Re: [PATCH v14 19/34] media: Documentation: Add GS_ROUTING documentation
Date: Fri, 30 Sep 2022 12:33:58 +0000	[thread overview]
Message-ID: <YzbiNmtE8MLRjikr@paasikivi.fi.intel.com> (raw)
In-Reply-To: <afb7a387-62ea-c252-d440-d5f8a0bb0d17@ideasonboard.com>

Moi,

On Fri, Sep 30, 2022 at 03:10:16PM +0300, Tomi Valkeinen wrote:
> Hei,
> 
> On 30/09/2022 14:21, Sakari Ailus wrote:
> > Moi,
> > 
> > On Wed, Sep 28, 2022 at 10:54:44AM +0300, Tomi Valkeinen wrote:
> > > Hi,
> > > 
> > > On 28/09/2022 00:13, Sakari Ailus wrote:
> > > > Moi,
> > > > 
> > > > On Tue, Sep 27, 2022 at 03:33:15PM +0300, Tomi Valkeinen wrote:
> > > > > On 27/09/2022 13:23, Sakari Ailus wrote:
> > > > > 
> > > > > <snip>
> > > > > 
> > > > > > > > > +All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called. This
> > > > > > > > > +means that the userspace mut reconfigure all streams after calling the ioctl
> > > > > > > > > +with e.g. ``VIDIOC_SUBDEV_S_FMT``.
> > > > > > > > 
> > > > > > > > How about this:
> > > > > > > > 
> > > > > > > > Calling ``VIDIOC_SUBDEV_S_ROUTING`` will cause the selections and subdev
> > > > > > > > formats being propagated from the sink pads towards the sources.
> > > > > > > 
> > > > > > > Hmm, but that's not true. The selections and formats will be zeroed, unless
> > > > > > > the driver initializes them to a value. There's no propagation done.
> > > > > > 
> > > > > > They need to be propagated. The driver is responsible for maintaining a
> > > > > > valid configuration for the processing steps in a sub-device, and with
> > > > > > routes that must apply to routes as well.
> > > > > 
> > > > > Hmm, no, they don't need to be propagated. The driver needs to initialize
> > > > > the formats and selections to valid configuration, that is true, but it
> > > > > doesn't mean the driver propagates settings from the sink pads to the source
> > > > > pads. In theory the formats on sink and source sides could be different.
> > > > 
> > > > After propagation, the user may set the format (or selection) later on in
> > > > the processing steps. The propagation is required by the spec and I don't
> > > > see why it would be different for drivers with support for streams. Of
> > > > course this needs to take place taking hardware limitations into account.
> > > 
> > > I don't disagree with the above, but I still don't see why it matters here.
> > 
> > It does. The user needs to be able to rely on the ability of the driver to
> > maintain valid internal configuration. That user generally has less
> > information on this than the driver.
> 
> I had a short chat with Sakari, and it seems there's no real issue here,
> mostly just a misunderstanding.
> 
> The action point is to clarify what "reset" means (it means resetting to
> driver default values, keeping the subdev configuration valid). And perhaps
> also highlighting somewhere that when e.g. setting the formats, propagation
> happens with subdevices using routes too.

Thanks. Sometimes e-mail just isn't enough. :-)

...

> > > If we have a CSI-2 receiver that has a hardcoded handling of the VC & DT,
> > > how does the userspace configure the routes? The userspace doesn't see the
> > > VCs or DTs. We could have static routes defined in the receiver subdevice,
> > > but does that help?
> > 
> > Good point. I think not.
> > 
> > I guess we would then leave the routes for the user to create and driver to
> > try to configure the hardware accordingly or fail in link validation?
> > 
> > Perhaps we won't need a static route flag then after all.
> > 
> > > 
> > > The HW I use, TI's CAL, has the means to configure VC/DT freely. But it has
> > > 8 DMA engines, and, of course, each stream has to go to a single DMA engine.
> > > So I think we could say that it has 8 static streams, and the user can only
> > > enable or disable them. But I'm not sure how much adding a new flag for this
> > > helps.
> > 
> > Could this be limited by only allowing to create eight routes?
> 
> Yes, and the driver should do that. But the driver should also verify the
> routing, so that each DMA engine only gets one route.
> 
> So here it might be possible to use a STATIC flag for the routes. Afaics,
> the only benefit of that would be to give a hint to the userspace about the
> possible routes. It's difficult to say if it's worth the trouble.

I'm fine with leaving out the flag. It seems it wouldn't have been as
useful in practice as I originally thought.

> 
> > > > Using one flag for two different purposes may thus prove problematic over
> > > > time. I'd thus define another for the other purpose. In the worst case it
> > > > won't be needed and we can make it obsolete later on.
> > > 
> > > I'd like to have a clear example of a setup where we need this flag and
> > > benefit from it before adding it.
> > > 
> > > In the CAL case I don't see much benefit. I think the only thing it gives us
> > > is a minimal discovery mechanism for the userspace to understand how CAL
> > > routes can be configured. I say minimal, as it still won't cover it fully as
> > > the validity of the routing depends on the actual VCs and DTs too (which
> > > will be found out only at the stream start time).
> > > 
> > > And this would only give us discovery for the receiver and wouldn't help
> > > with the bridges.
> > > 
> > > > > > > 
> > > > > > > But as I said above, I haven't figured out a use for this.
> > > > > > > 
> > > > > > > > > +      - 1
> > > > > > > > > +      - The route is immutable. Set by the driver.
> > > > > > > > > +    * - V4L2_SUBDEV_ROUTE_FL_SOURCE
> > > > > > > > > +      - 2
> > > > > > > > > +      - The route is a source route, and the ``sink_pad`` and ``sink_stream``
> > > > > > > > > +        fields are unused. Set by the driver.
> > > > > > > > > +
> > > > > > > > > +Return Value
> > > > > > > > > +============
> > > > > > > > > +
> > > > > > > > > +On success 0 is returned, on error -1 and the ``errno`` variable is set
> > > > > > > > > +appropriately. The generic error codes are described at the
> > > > > > > > > +:ref:`Generic Error Codes <gen-errors>` chapter.
> > > > > > > > > +
> > > > > > > > > +ENOSPC
> > > > > > > > > +   The number of provided route entries is less than the available ones.
> > > > > > > > 
> > > > > > > > What does "available ones" mean in this context? More than is supported?
> > > > > > > > Wouldn't E2BIG be the appropriate code in that case?
> > > > > > > 
> > > > > > > Good question. I don't think I wrote this part =). ENOSPC refers to the case
> > > > > > > where VIDIOC_SUBDEV_G_ROUTING is called without enough space for the routing
> > > > > > > table. So "available ones" mean the routes in the subdev's routing table,
> > > > > > > and "provided route entries" refers to the userspace target routing table.
> > > > > > > 
> > > > > > > It sounds pretty odd, and obviously needs a clarification.
> > > > > > 
> > > > > > I think I actually can think what this did mean. It means that the
> > > > > > num_routes is smaller than the number of routes in a routing table when
> > > > > > G_ROUTING is called. For that I think ENOSPC is the right code actually.
> > > > > > 
> > > > > > But also I think we need to document what happens when there are too many
> > > > > > routes. For that E2BIG would be appropriate.
> > > > > 
> > > > > v4l2-ioctl.c returns EINVAL if there are over 256 routes. The drivers
> > > > > should, of course, do additional check if needed. In v4l2-ioctl.c it seems
> > > > > common to return EINVAL if there's too much data, but we can of course
> > > > > define E2BIG for routing ioctls.
> > > > 
> > > > The number (256) is just the current limit. I don't expect more though.
> > > > 
> > > > But the user space could know the number is too large if we have a proper
> > > > error code for it. Up to you. However at least documentation needs to be
> > > > amended since this case remains undocumented.
> > > 
> > > I can change the returned error from EINVAL to E2BIG and document it. But
> > > everything else in check_array_args return EINVAL, so it would be going into
> > > different direction.
> > 
> > Could this be beneficial in telling the user too many routes have been
> > configured (as I wrote above)?
> 
> Yes, I think the driver should return E2BIG if there are too many routes.
> 
> But my question is, should v4l2-ioctl.c return E2BIG for > 256 routes?
> That's not how it works for all the other ioctls there, they return EINVAL.
> I don't mind changing that to E2BIG, but usually it's nice if the code is
> consistent.

From the user's point of view the "too many routes" condition is the same
independently of whether the information comes from the framework or the
driver. So I think using -E2BIG in the framework is the right thing to do.

-- 
Terveisin,

Sakari Ailus

  reply	other threads:[~2022-09-30 12:34 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 14:13 [PATCH v14 00/34] Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 01/34] media: Documentation: mc: add definitions for stream and pipeline Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 02/34] media: media-entity.h: add include for min() Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 03/34] media: subdev: increase V4L2_FRAME_DESC_ENTRY_MAX to 8 Tomi Valkeinen
2022-09-29  6:48   ` Bingbu Cao
2022-10-03 11:32     ` Tomi Valkeinen
2022-10-13  7:31       ` Bingbu Cao
2022-08-31 14:13 ` [PATCH v14 04/34] media: mc: entity: Rename streaming_count -> start_count Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 05/34] media: mc: entity: Add iterator helper for entity pads Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 06/34] media: mc: entity: Merge media_entity_enum_init and __media_entity_enum_init Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 07/34] media: mc: entity: Move media_entity_get_fwnode_pad() out of graph walk section Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 08/34] media: mc: entity: Add media_entity_pipeline() to access the media pipeline Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 09/34] media: v4l2-dev: Add videodev wrappers for media pipelines Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 10/34] media: drivers: use video device pipeline start/stop Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 11/34] media: drivers: use video_device_pipeline() Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 12/34] media: mc: entity: add alloc variant of pipeline_start Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 13/34] media: drivers: use video_device_pipeline_alloc_start() Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 14/34] media: mc: entity: Rewrite media_pipeline_start() Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 15/34] media: mc: entity: Add has_pad_interdep entity operation Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 16/34] media: mc: convert pipeline funcs to take media_pad Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 17/34] media: add V4L2_SUBDEV_FL_STREAMS Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 18/34] media: add V4L2_SUBDEV_CAP_STREAMS Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 19/34] media: Documentation: Add GS_ROUTING documentation Tomi Valkeinen
2022-09-27  5:59   ` Sakari Ailus
2022-09-27  9:32     ` Tomi Valkeinen
2022-09-27 10:23       ` Sakari Ailus
2022-09-27 12:33         ` Tomi Valkeinen
2022-09-27 21:13           ` Sakari Ailus
2022-09-28  7:54             ` Tomi Valkeinen
2022-09-30 11:21               ` Sakari Ailus
2022-09-30 12:10                 ` Tomi Valkeinen
2022-09-30 12:33                   ` Sakari Ailus [this message]
2022-08-31 14:13 ` [PATCH v14 20/34] media: subdev: Add [GS]_ROUTING subdev ioctls and operations Tomi Valkeinen
2022-09-30 11:05   ` Sakari Ailus
2022-09-30 11:22     ` Tomi Valkeinen
2022-09-30 12:34       ` Sakari Ailus
2022-08-31 14:13 ` [PATCH v14 21/34] media: subdev: add v4l2_subdev_has_pad_interdep() Tomi Valkeinen
2022-09-23  9:50   ` Sakari Ailus
2022-08-31 14:13 ` [PATCH v14 22/34] media: subdev: add v4l2_subdev_set_routing helper() Tomi Valkeinen
2022-09-25 11:26   ` Sakari Ailus
2022-09-26  5:56     ` Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 23/34] media: subdev: Add for_each_active_route() macro Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 24/34] media: Documentation: add multiplexed streams documentation Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 25/34] media: subdev: add stream based configuration Tomi Valkeinen
2022-08-31 18:04   ` Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 26/34] media: subdev: use streams in v4l2_subdev_link_validate() Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 27/34] media: subdev: add "opposite" stream helper funcs Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 28/34] media: subdev: add streams to v4l2_subdev_get_fmt() helper function Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 29/34] media: subdev: add v4l2_subdev_set_routing_with_fmt() helper Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 30/34] media: subdev: add v4l2_subdev_routing_validate() helper Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 31/34] media: v4l2-subdev: Add v4l2_subdev_state_xlate_streams() helper Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 32/34] media: v4l2-subdev: Add subdev .(enable|disable)_streams() operations Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 33/34] media: v4l2-subdev: Add v4l2_subdev_s_stream_helper() function Tomi Valkeinen
2022-08-31 14:13 ` [PATCH v14 34/34] media: Add stream to frame descriptor Tomi Valkeinen

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=YzbiNmtE8MLRjikr@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kishon@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=satish.nagireddy@getcruise.com \
    --cc=tfiga@chromium.org \
    --cc=tomi.valkeinen@ideasonboard.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.