]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/media-rcar-vin-allow-independent-vin-link-enablement.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / queue-4.19 / media-rcar-vin-allow-independent-vin-link-enablement.patch
1 From ce5a41d12dd7b451edbfc0345f7cb7932558d615 Mon Sep 17 00:00:00 2001
2 From: Steve Longerbeam <slongerbeam@gmail.com>
3 Date: Mon, 14 Jan 2019 20:10:19 -0500
4 Subject: media: rcar-vin: Allow independent VIN link enablement
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ Upstream commit c5ff0edb8e2270a75935c73217fb0de1abd2d910 ]
10
11 There is a block of code in rvin_group_link_notify() that prevents
12 enabling a link to a VIN node if any entity in the media graph is
13 in use. This prevents enabling a VIN link even if there is an in-use
14 entity somewhere in the graph that is independent of the link's
15 pipeline.
16
17 For example, the code block will prevent enabling a link from
18 the first rcar-csi2 receiver to a VIN node even if there is an
19 enabled link somewhere far upstream on the second independent
20 rcar-csi2 receiver pipeline.
21
22 If this code block is meant to prevent modifying a link if any entity
23 in the graph is actively involved in streaming (because modifying
24 the CHSEL register fields can disrupt any/all running streams), then
25 the entities stream counts should be checked rather than the use counts.
26
27 (There is already such a check in __media_entity_setup_link() that verifies
28 the stream_count of the link's source and sink entities are both zero,
29 but that is insufficient, since there should be no running streams in
30 the entire graph).
31
32 Modify the code block to check the entity stream_count instead of the
33 use_count (and elaborate on the comment). VIN node links can now be
34 enabled even if there are other independent in-use entities that are
35 not streaming.
36
37 Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3")
38
39 Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
40 Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
41 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
42 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
43 Signed-off-by: Sasha Levin <sashal@kernel.org>
44 ---
45 drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++--
46 1 file changed, 6 insertions(+), 2 deletions(-)
47
48 diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
49 index ce09799976ef..e1085e3ab3cc 100644
50 --- a/drivers/media/platform/rcar-vin/rcar-core.c
51 +++ b/drivers/media/platform/rcar-vin/rcar-core.c
52 @@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags,
53 !is_media_entity_v4l2_video_device(link->sink->entity))
54 return 0;
55
56 - /* If any entity is in use don't allow link changes. */
57 + /*
58 + * Don't allow link changes if any entity in the graph is
59 + * streaming, modifying the CHSEL register fields can disrupt
60 + * running streams.
61 + */
62 media_device_for_each_entity(entity, &group->mdev)
63 - if (entity->use_count)
64 + if (entity->stream_count)
65 return -EBUSY;
66
67 mutex_lock(&group->lock);
68 --
69 2.19.1
70