summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2021-03-12 10:05:44 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-04-06 14:35:14 +0200
commit4ebddb7c17c4549f04741c7faf8e4ced62391d20 (patch)
tree928c1a767c599fc03e08e0b641877ca3e8ab1353
parent5bf2c8b66e4eb47f16ce41b936be699d07256b76 (diff)
downloadlinux-4ebddb7c17c4549f04741c7faf8e4ced62391d20.tar.gz
linux-4ebddb7c17c4549f04741c7faf8e4ced62391d20.tar.bz2
linux-4ebddb7c17c4549f04741c7faf8e4ced62391d20.zip
media: entity: Add lockdep check to media graph walk
It was always assumed that walking the media graph would require holding the media_device graph_mutex but this was not documented nor checked for. Add a lockdep check to graph walk init and iter, and document the need for acquiring the graph_mutex. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--drivers/media/mc/mc-entity.c1
-rw-r--r--include/media/media-entity.h5
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 12b45e669bcc..678b99771cfa 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -340,6 +340,7 @@ static void media_graph_walk_iter(struct media_graph *graph)
stack_push(graph, next);
dev_dbg(entity->graph_obj.mdev->dev, "walk: pushing '%s' on stack\n",
next->name);
+ lockdep_assert_held(&entity->graph_obj.mdev->graph_mutex);
}
struct media_entity *media_graph_walk_next(struct media_graph *graph)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index a90e2bf6baf7..09737b47881f 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -885,6 +885,11 @@ int media_entity_get_fwnode_pad(struct media_entity *entity,
*
* @graph: Media graph structure that will be used to walk the graph
* @mdev: Pointer to the &media_device that contains the object
+ *
+ * The caller is required to hold the media_device graph_mutex during the graph
+ * walk until the graph state is released.
+ *
+ * Returns zero on success or a negative error code otherwise.
*/
__must_check int media_graph_walk_init(
struct media_graph *graph, struct media_device *mdev);