Re: [PATCH v4 21/29] media: mc: Don't care about unsettable flags in MEDIA_IOC_LINK_SETUP

Sakari Ailus
2026-04-21T10:44:46Z

Hi Laurent,

On Thu, Apr 16, 2026 at 06:59:17PM +0300, Laurent Pinchart wrote:
> Hi Sakari,
>
> Thank you for the patch.
>
> On Wed, Apr 08, 2026 at 06:39:30PM +0300, Sakari Ailus wrote:
> > The implementation of MEDIA_IOC_LINK_SETUP currently requires that all
> > flags that are set by the driver are correctly set as the driver expects.
> > This poses a problem for adding new flags as programs could not work with
> > links that have unknown flags even when the use of these flags wouldn't
> > affect the program.
>
> I suppose applications could be instructed to preserve the flags they
> don't know about, but some existing applications probably don't do that.
>
> > Ignore the non-settable link flags.
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> > drivers/media/mc/mc-entity.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> > index 717569bd1a8c..287eded356bb 100644
> > --- a/drivers/media/mc/mc-entity.c
> > +++ b/drivers/media/mc/mc-entity.c
> > @@ -1319,7 +1319,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
> >
> > int __media_entity_setup_link(struct media_link *link, u32 flags)
> > {
> > - const u32 mask = MEDIA_LNK_FL_ENABLED;
> > + const u32 settable_flags = MEDIA_LNK_FL_ENABLED;
> > struct media_device *mdev;
> > struct media_pad *source, *sink;
> > int ret = -EBUSY;
> > @@ -1327,9 +1327,9 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
> > if (link == NULL)
> > return -EINVAL;
> >
> > - /* The non-modifiable link flags must not be modified. */
> > - if ((link->flags & ~mask) != (flags & ~mask))
> > - return -EINVAL;
> > + /* Only allow changing user-settable flags. */
> > + flags &= settable_flags;
> > + flags |= link->flags & ~settable_flags;
>
> Now that the link can be configured with different flags than the ones
> set by userspace, I think the ioctl should return the actual link flags.

I'll do that for v5.

>
> >
> > if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
> > return link->flags == flags ? 0 : -EINVAL;
>

--
Regards,

Sakari Ailus