From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 B384C352F88 for ; Wed, 11 Feb 2026 09:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770800979; cv=none; b=hn+pIexPq3pvforVW3anj2FWqFc8R2o5anv09u1UT23aT2v+jPISqy0GU0vLqDosFw52r+w8cPWBHz5pxJyRxNLj/iIUYjzUQrc9EXfwBpOtCvQkQDc4w8vnhp35WTiJ6tgnxnZffveM0QfBeD519x115kxQSYjiyOKiBUAsNAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770800979; c=relaxed/simple; bh=D2Y0Wyl7Zmidn5S05hOMSpy6zWgZ26n1xgPifjSYBvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LCFHztIOByOMu+iZcSwjYhy5XrPeg5QmC3girKcxIuaD+UiWKGju9+LSaQC2PMELdP6TBWveamABVlYjMIFwFM+fHqi7SvDI57j7ETcYOiqp+R5Sw1GVL79LVoBuxGbCaIAs2hIEkk63YvIArvr+JduL+AFKm8Mzv3ps1d7M/78= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=oBaAO6vl; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oBaAO6vl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770800977; x=1802336977; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D2Y0Wyl7Zmidn5S05hOMSpy6zWgZ26n1xgPifjSYBvw=; b=oBaAO6vlHaLteANvMLJj5d/WoKBtLHpGrMX3sLGBsmZd/QW12Yp55YGA axqwEEf8KohrtBHF0BDHqWi+M2Set3e577VEbD5HKBrMkDIcVmmLwZbEO dAODwC8tBw/NSTYnindbe5d96Ltoox+aj88QQRcNwmLSLi0Bn9+3d9Zn9 eO1IeIVuo9JzJccf5YiEuUMBjCHGHxFr5njzIdHGFx4Yn+kj1M/dTt9/I CFNlnxkRPDMwTSXrk8nGxqe7n1Ib3GsvnMyWoiQFvidbw116K4L0+R/oV IyAl8yRGazgJHWAb192lQyyv7OJeyACRQcypjgMV0Avu1QIFsDuXtYQhG w==; X-CSE-ConnectionGUID: UlDE059DQseVltH4/7XLig== X-CSE-MsgGUID: DoIMItbMQzuDMM2+tPk5Cg== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="72019072" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="72019072" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2026 01:09:33 -0800 X-CSE-ConnectionGUID: d6xg8KnsQsKl1qGYqrB3Tg== X-CSE-MsgGUID: c/4gGihVRPiBa1Ka2MZpMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212222869" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.244.208]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2026 01:09:24 -0800 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id BC9EF121D4C; Wed, 11 Feb 2026 11:09:31 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1vq6Do-00000007laC-2Zfk; Wed, 11 Feb 2026 11:09:20 +0200 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hans@jjverkuil.nl, laurent.pinchart@ideasonboard.com, Prabhakar , Kate Hsuan , Alexander Shiyan , Dave Stevenson , Tommaso Merciai , Benjamin Mugnier , Sylvain Petinot , Christophe JAILLET , Julien Massot , Naushir Patuck , "Yan, Dongcheng" , "Cao, Bingbu" , "Qiu, Tian Shu" , Stefan Klug , Mirela Rabulea , =?UTF-8?q?Andr=C3=A9=20Apitzsch?= , Heimir Thor Sverrisson , Kieran Bingham , Mehdi Djait , Ricardo Ribalda Delgado , Hans de Goede , Jacopo Mondi , Tomi Valkeinen , David Plowman , "Yu, Ong Hock" , "Ng, Khai Wen" Subject: [PATCH v2 07/14] media: mc: Add MEDIA_LNK_FL_VALIDATE_LATE Date: Wed, 11 Feb 2026 11:09:13 +0200 Message-ID: <20260211090920.1851141-8-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260211090920.1851141-1-sakari.ailus@linux.intel.com> References: <20260211090920.1851141-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add MEDIA_LNK_FL_VALIDATE_LATE flag to support late validation of links. This is serving the use case where video devices are configured and started streaming indepenently of each other but this sequence may be run in series, in such a way that a video device in a pipeline starts streaming before another one is configured. Before this flag, drivers have resorted to implementing the link validation separately for the video nodes as part of streaming start sequence. media_pipeline_start() shall be called on each leaf entity connected to the graph with a link where MEDIA_LNK_FL_VALIDATE_LATE is set before uphardware operation. Signed-off-by: Sakari Ailus --- .../media/mediactl/media-ioc-setup-link.rst | 4 ++ .../media/mediactl/media-types.rst | 5 ++ drivers/media/mc/mc-entity.c | 58 ++++++++++++++++++- include/uapi/linux/media.h | 1 + 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/Documentation/userspace-api/media/mediactl/media-ioc-setup-link.rst b/Documentation/userspace-api/media/mediactl/media-ioc-setup-link.rst index 23208300cb61..7a9a43c71cde 100644 --- a/Documentation/userspace-api/media/mediactl/media-ioc-setup-link.rst +++ b/Documentation/userspace-api/media/mediactl/media-ioc-setup-link.rst @@ -49,6 +49,10 @@ Only links marked with the ``DYNAMIC`` link flag can be enabled/disabled while streaming media data. Attempting to enable or disable a streaming non-dynamic link will return an ``EBUSY`` error code. +The ``VALIDATE_LATE`` flag is used to signal that the validation of the link may +be delayed until actual hardware operation even if the rest of the pipeline +would be validated at an earlier point of time. + If the specified link can't be found the driver returns with an ``EINVAL`` error code. diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst b/Documentation/userspace-api/media/mediactl/media-types.rst index 6332e8395263..d6a690655a01 100644 --- a/Documentation/userspace-api/media/mediactl/media-types.rst +++ b/Documentation/userspace-api/media/mediactl/media-types.rst @@ -391,6 +391,7 @@ must be set for every pad. .. _MEDIA-LNK-FL-ENABLED: .. _MEDIA-LNK-FL-IMMUTABLE: .. _MEDIA-LNK-FL-DYNAMIC: +.. _MEDIA-LNK-FL-VALIDATE-LATE: .. _MEDIA-LNK-FL-LINK-TYPE: .. flat-table:: Media link flags @@ -410,6 +411,10 @@ must be set for every pad. - The link enabled state can be modified during streaming. This flag is set by drivers and is read-only for applications. + * - ``MEDIA_LNK_FL_VALIDATE_LATE`` + - The validation of the link may be delayed up to until the start of + hardware operation. + * - ``MEDIA_LNK_FL_LINK_TYPE`` - This is a bitmask that defines the type of the link. The following link types are currently supported: diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index ef959e9bb313..b29b519237d6 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -772,7 +772,7 @@ static int __media_pipeline_validate_one(struct media_pad *origin, struct media_pipeline *pipe, struct media_pad *pad, struct media_link *link, - bool *has_enabled_link) + bool *has_enabled_link, bool skip_validation) { struct media_device *mdev = origin->graph_obj.mdev; struct media_entity *entity = pad->entity; @@ -782,6 +782,9 @@ __media_pipeline_validate_one(struct media_pad *origin, if (link->flags & MEDIA_LNK_FL_ENABLED && has_enabled_link) *has_enabled_link = true; + if (skip_validation) + return 0; + /* * Validate the link if it's enabled and has the * current pad as its sink. @@ -833,7 +836,24 @@ __must_check int __media_pipeline_start(struct media_pad *origin, * valid, so just increase the start count. */ if (pipe->start_count) { + struct media_link *link; + + link = __media_entity_next_link(origin->entity, NULL, + MEDIA_LNK_FL_DATA_LINK); + if (link && link->flags & MEDIA_LNK_FL_VALIDATE_LATE) { + dev_dbg(mdev->dev, + "Validating pad '%s':%u late\n", + origin->entity->name, origin->index); + + ret = __media_pipeline_validate_one(link->sink, pipe, + link->sink, link, + NULL, false); + if (ret) + return ret; + } + pipe->start_count++; + return 0; } @@ -881,9 +901,16 @@ __must_check int __media_pipeline_start(struct media_pad *origin, if (link->sink != pad && link->source != pad) continue; + /* Skip late-validated links not connected to origin. */ + bool skip_validation = + link->flags & MEDIA_LNK_FL_VALIDATE_LATE && + (link->sink == origin || + link->source == origin); + ret = __media_pipeline_validate_one(origin, pipe, origin, link, - &has_enabled_link); + &has_enabled_link, + skip_validation); if (ret) goto error; } @@ -1163,6 +1190,33 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, if (WARN_ON(!(sink->pads[sink_pad].flags & MEDIA_PAD_FL_SINK))) return -EINVAL; + /* + * With the late validate flag, either source or sink shall have exactly + * one pad and no links before this one. Similarly, no links may be + * added to entities with a single pad and an existing late-validated + * link. + */ + if (flags & MEDIA_LNK_FL_VALIDATE_LATE) { + if (!(source->num_pads == 1 && !source->num_links) && + !(sink->num_pads == 1 && !sink->num_links)) + return -EINVAL; + } else { + struct media_entity *entities[] = { source, sink }; + + for (unsigned int i = 0; i < ARRAY_SIZE(entities); i++) { + if (entities[i]->num_pads != 1) + continue; + + struct media_link *__link = + __media_entity_next_link(entities[i], NULL, + MEDIA_LNK_FL_DATA_LINK); + + if (__link && + __link->flags & MEDIA_LNK_FL_VALIDATE_LATE) + return -EINVAL; + } + } + link = media_add_link(&source->links); if (link == NULL) return -ENOMEM; diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 1c80b1d6bbaf..c96e2118ea99 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -219,6 +219,7 @@ struct media_pad_desc { #define MEDIA_LNK_FL_ENABLED (1U << 0) #define MEDIA_LNK_FL_IMMUTABLE (1U << 1) #define MEDIA_LNK_FL_DYNAMIC (1U << 2) +#define MEDIA_LNK_FL_VALIDATE_LATE (1U << 3) #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28) # define MEDIA_LNK_FL_DATA_LINK (0U << 28) -- 2.47.3