From 2b84f5edda9e2c08c4e2c37dc2b0d7692c341a99 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2024 10:34:23 +0000 Subject: [PATCH] Revert "media: mc: Expand MUST_CONNECT flag to always require an enabled link" This reverts commit e2c545b841a7ae2c1796c9968fcf47166075cfb1 which is commit b3decc5ce7d778224d266423b542326ad469cb5f upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I94f10b3fe86210799b5697259e32114f00f080f0 Signed-off-by: Greg Kroah-Hartman --- .../media/mediactl/media-types.rst | 11 ++-- drivers/media/mc/mc-entity.c | 53 ++++--------------- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst b/Documentation/userspace-api/media/mediactl/media-types.rst index 6332e8395263..0ffeece1e0c8 100644 --- a/Documentation/userspace-api/media/mediactl/media-types.rst +++ b/Documentation/userspace-api/media/mediactl/media-types.rst @@ -375,11 +375,12 @@ Types and flags used to represent the media graph elements are origins of links. * - ``MEDIA_PAD_FL_MUST_CONNECT`` - - If this flag is set, then for this pad to be able to stream, it must - be connected by at least one enabled link. There could be temporary - reasons (e.g. device configuration dependent) for the pad to need - enabled links even when this flag isn't set; the absence of the flag - doesn't imply there is none. + - If this flag is set and the pad is linked to any other pad, then + at least one of those links must be enabled for the entity to be + able to stream. There could be temporary reasons (e.g. device + configuration dependent) for the pad to need enabled links even + when this flag isn't set; the absence of the flag doesn't imply + there is none. One and only one of ``MEDIA_PAD_FL_SINK`` and ``MEDIA_PAD_FL_SOURCE`` diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 8919df09e3e8..50b68b4dde5d 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -509,15 +509,14 @@ static int media_pipeline_walk_push(struct media_pipeline_walk *walk, /* * Move the top entry link cursor to the next link. If all links of the entry - * have been visited, pop the entry itself. Return true if the entry has been - * popped. + * have been visited, pop the entry itself. */ -static bool media_pipeline_walk_pop(struct media_pipeline_walk *walk) +static void media_pipeline_walk_pop(struct media_pipeline_walk *walk) { struct media_pipeline_walk_entry *entry; if (WARN_ON(walk->stack.top < 0)) - return false; + return; entry = media_pipeline_walk_top(walk); @@ -527,7 +526,7 @@ static bool media_pipeline_walk_pop(struct media_pipeline_walk *walk) walk->stack.top); walk->stack.top--; - return true; + return; } entry->links = entry->links->next; @@ -535,8 +534,6 @@ static bool media_pipeline_walk_pop(struct media_pipeline_walk *walk) dev_dbg(walk->mdev->dev, "media pipeline: moved entry %u to next link\n", walk->stack.top); - - return false; } /* Free all memory allocated while walking the pipeline. */ @@ -586,12 +583,11 @@ static int media_pipeline_explore_next_link(struct media_pipeline *pipe, struct media_link *link; struct media_pad *local; struct media_pad *remote; - bool last_link; int ret; origin = entry->pad; link = list_entry(entry->links, typeof(*link), list); - last_link = media_pipeline_walk_pop(walk); + media_pipeline_walk_pop(walk); dev_dbg(walk->mdev->dev, "media pipeline: exploring link '%s':%u -> '%s':%u\n", @@ -616,7 +612,7 @@ static int media_pipeline_explore_next_link(struct media_pipeline *pipe, local->index)) { dev_dbg(walk->mdev->dev, "media pipeline: skipping link (no route)\n"); - goto done; + return 0; } /* @@ -631,44 +627,13 @@ static int media_pipeline_explore_next_link(struct media_pipeline *pipe, if (!(link->flags & MEDIA_LNK_FL_ENABLED)) { dev_dbg(walk->mdev->dev, "media pipeline: skipping link (disabled)\n"); - goto done; + return 0; } ret = media_pipeline_add_pad(pipe, walk, remote); if (ret) return ret; -done: - /* - * If we're done iterating over links, iterate over pads of the entity. - * This is necessary to discover pads that are not connected with any - * link. Those are dead ends from a pipeline exploration point of view, - * but are still part of the pipeline and need to be added to enable - * proper validation. - */ - if (!last_link) - return 0; - - dev_dbg(walk->mdev->dev, - "media pipeline: adding unconnected pads of '%s'\n", - local->entity->name); - - media_entity_for_each_pad(origin->entity, local) { - /* - * Skip the origin pad (already handled), pad that have links - * (already discovered through iterating over links) and pads - * not internally connected. - */ - if (origin == local || !local->num_links || - !media_entity_has_pad_interdep(origin->entity, origin->index, - local->index)) - continue; - - ret = media_pipeline_add_pad(pipe, walk, local); - if (ret) - return ret; - } - return 0; } @@ -780,6 +745,7 @@ __must_check int __media_pipeline_start(struct media_pad *pad, struct media_pad *pad = ppad->pad; struct media_entity *entity = pad->entity; bool has_enabled_link = false; + bool has_link = false; struct media_link *link; dev_dbg(mdev->dev, "Validating pad '%s':%u\n", pad->entity->name, @@ -809,6 +775,7 @@ __must_check int __media_pipeline_start(struct media_pad *pad, /* Record if the pad has links and enabled links. */ if (link->flags & MEDIA_LNK_FL_ENABLED) has_enabled_link = true; + has_link = true; /* * Validate the link if it's enabled and has the @@ -846,7 +813,7 @@ __must_check int __media_pipeline_start(struct media_pad *pad, * 3. If the pad has the MEDIA_PAD_FL_MUST_CONNECT flag set, * ensure that it has either no link or an enabled link. */ - if ((pad->flags & MEDIA_PAD_FL_MUST_CONNECT) && + if ((pad->flags & MEDIA_PAD_FL_MUST_CONNECT) && has_link && !has_enabled_link) { dev_dbg(mdev->dev, "Pad '%s':%u must be connected by an enabled link\n",