diff mbox series

[RFC,v2] media: rcar-vin: Allow independent VIN link enablement

Message ID 20190106212018.16519-1-slongerbeam@gmail.com (mailing list archive)
State New, archived
Headers show
Series [RFC,v2] media: rcar-vin: Allow independent VIN link enablement | expand

Commit Message

Steve Longerbeam Jan. 6, 2019, 9:20 p.m. UTC
There is a block of code in rvin_group_link_notify() that loops through
all entities in the media graph, and prevents enabling a link to a VIN
node if any entity is in use. This prevents enabling a VIN link even if
there is an in-use entity somewhere in the graph that is independent of
the link's pipeline.

For example, the code will prevent enabling a link from the first
rcar-csi2 receiver to a VIN node even if there is an enabled link
somewhere far upstream on the second independent rcar-csi2 receiver
pipeline.

If this code is meant to prevent modifying a link if any entity in the
graph is actively involved in streaming (because modifying the CHSEL
register fields can disrupt any/all running streams), then the entities
stream counts should be checked rather than the use counts.

(There is already such a check in __media_entity_setup_link() that verifies
the stream_count of the link's source and sink entities are both zero,
but that is insufficient, since there should be no running streams in
the entire graph).

Modify the media_device_for_each_entity() loop to check the entity
stream_count instead of the use_count, and elaborate on the comment.
VIN node links can now be enabled even if there are other independent
in-use entities that are not streaming.

Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3")

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
---
Changes in v2:
- bring back the media_device_for_each_entity() loop but check the
  stream_count not the use_count.
---
 drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Niklas Söderlund Jan. 9, 2019, 10:40 p.m. UTC | #1
Hi Steve,

Thanks for your patch, I think it looks good.

On 2019-01-06 13:20:18 -0800, Steve Longerbeam wrote:
> There is a block of code in rvin_group_link_notify() that loops through
> all entities in the media graph, and prevents enabling a link to a VIN
> node if any entity is in use. This prevents enabling a VIN link even if
> there is an in-use entity somewhere in the graph that is independent of
> the link's pipeline.
> 
> For example, the code will prevent enabling a link from the first
> rcar-csi2 receiver to a VIN node even if there is an enabled link
> somewhere far upstream on the second independent rcar-csi2 receiver
> pipeline.
> 
> If this code is meant to prevent modifying a link if any entity in the
> graph is actively involved in streaming (because modifying the CHSEL
> register fields can disrupt any/all running streams), then the entities
> stream counts should be checked rather than the use counts.
> 
> (There is already such a check in __media_entity_setup_link() that verifies
> the stream_count of the link's source and sink entities are both zero,
> but that is insufficient, since there should be no running streams in
> the entire graph).
> 
> Modify the media_device_for_each_entity() loop to check the entity
> stream_count instead of the use_count, and elaborate on the comment.
> VIN node links can now be enabled even if there are other independent
> in-use entities that are not streaming.
> 
> Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3")
> 
> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
> Changes in v2:
> - bring back the media_device_for_each_entity() loop but check the
>   stream_count not the use_count.
> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index f0719ce24b97..6dd6b11c1b2b 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags,
>  	    !is_media_entity_v4l2_video_device(link->sink->entity))
>  		return 0;
>  
> -	/* If any entity is in use don't allow link changes. */
> +	/*
> +	 * Don't allow link changes if any entity in the graph is
> +	 * streaming, because modifying the CHSEL register fields
> +	 * can disrupt running streams.
> +	 */
>  	media_device_for_each_entity(entity, &group->mdev)
> -		if (entity->use_count)
> +		if (entity->stream_count)
>  			return -EBUSY;
>  
>  	mutex_lock(&group->lock);
> -- 
> 2.17.1
>
Steve Longerbeam Jan. 10, 2019, 1:19 a.m. UTC | #2
On 1/9/19 2:40 PM, Niklas Söderlund wrote:
> Hi Steve,
>
> Thanks for your patch, I think it looks good.

Thanks for the Ack! I'm not real familiar with the RFC patch process. 
Should this be submitted again with RFC stripped from the subject line?

Steve

> On 2019-01-06 13:20:18 -0800, Steve Longerbeam wrote:
>> There is a block of code in rvin_group_link_notify() that loops through
>> all entities in the media graph, and prevents enabling a link to a VIN
>> node if any entity is in use. This prevents enabling a VIN link even if
>> there is an in-use entity somewhere in the graph that is independent of
>> the link's pipeline.
>>
>> For example, the code will prevent enabling a link from the first
>> rcar-csi2 receiver to a VIN node even if there is an enabled link
>> somewhere far upstream on the second independent rcar-csi2 receiver
>> pipeline.
>>
>> If this code is meant to prevent modifying a link if any entity in the
>> graph is actively involved in streaming (because modifying the CHSEL
>> register fields can disrupt any/all running streams), then the entities
>> stream counts should be checked rather than the use counts.
>>
>> (There is already such a check in __media_entity_setup_link() that verifies
>> the stream_count of the link's source and sink entities are both zero,
>> but that is insufficient, since there should be no running streams in
>> the entire graph).
>>
>> Modify the media_device_for_each_entity() loop to check the entity
>> stream_count instead of the use_count, and elaborate on the comment.
>> VIN node links can now be enabled even if there are other independent
>> in-use entities that are not streaming.
>>
>> Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3")
>>
>> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
>> ---
>> Changes in v2:
>> - bring back the media_device_for_each_entity() loop but check the
>>    stream_count not the use_count.
>> ---
>>   drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
>> index f0719ce24b97..6dd6b11c1b2b 100644
>> --- a/drivers/media/platform/rcar-vin/rcar-core.c
>> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
>> @@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags,
>>   	    !is_media_entity_v4l2_video_device(link->sink->entity))
>>   		return 0;
>>   
>> -	/* If any entity is in use don't allow link changes. */
>> +	/*
>> +	 * Don't allow link changes if any entity in the graph is
>> +	 * streaming, because modifying the CHSEL register fields
>> +	 * can disrupt running streams.
>> +	 */
>>   	media_device_for_each_entity(entity, &group->mdev)
>> -		if (entity->use_count)
>> +		if (entity->stream_count)
>>   			return -EBUSY;
>>   
>>   	mutex_lock(&group->lock);
>> -- 
>> 2.17.1
>>
Steve Longerbeam Jan. 15, 2019, 1:03 a.m. UTC | #3
On 1/9/19 5:19 PM, Steve Longerbeam wrote:
>
>
> On 1/9/19 2:40 PM, Niklas Söderlund wrote:
>> Hi Steve,
>>
>> Thanks for your patch, I think it looks good.
>
> Thanks for the Ack! I'm not real familiar with the RFC patch process. 
> Should this be submitted again with RFC stripped from the subject line?

I've been told there isn't really a process for RFC patch submission. I 
will re-submit and strip off the RFC and add your Reviewed-by.

Steve

>
>
>> On 2019-01-06 13:20:18 -0800, Steve Longerbeam wrote:
>>> There is a block of code in rvin_group_link_notify() that loops through
>>> all entities in the media graph, and prevents enabling a link to a VIN
>>> node if any entity is in use. This prevents enabling a VIN link even if
>>> there is an in-use entity somewhere in the graph that is independent of
>>> the link's pipeline.
>>>
>>> For example, the code will prevent enabling a link from the first
>>> rcar-csi2 receiver to a VIN node even if there is an enabled link
>>> somewhere far upstream on the second independent rcar-csi2 receiver
>>> pipeline.
>>>
>>> If this code is meant to prevent modifying a link if any entity in the
>>> graph is actively involved in streaming (because modifying the CHSEL
>>> register fields can disrupt any/all running streams), then the entities
>>> stream counts should be checked rather than the use counts.
>>>
>>> (There is already such a check in __media_entity_setup_link() that 
>>> verifies
>>> the stream_count of the link's source and sink entities are both zero,
>>> but that is insufficient, since there should be no running streams in
>>> the entire graph).
>>>
>>> Modify the media_device_for_each_entity() loop to check the entity
>>> stream_count instead of the use_count, and elaborate on the comment.
>>> VIN node links can now be enabled even if there are other independent
>>> in-use entities that are not streaming.
>>>
>>> Fixes: c0cc5aef31 ("media: rcar-vin: add link notify for Gen3")
>>>
>>> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
>> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>>
>>> ---
>>> Changes in v2:
>>> - bring back the media_device_for_each_entity() loop but check the
>>>    stream_count not the use_count.
>>> ---
>>>   drivers/media/platform/rcar-vin/rcar-core.c | 8 ++++++--
>>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
>>> b/drivers/media/platform/rcar-vin/rcar-core.c
>>> index f0719ce24b97..6dd6b11c1b2b 100644
>>> --- a/drivers/media/platform/rcar-vin/rcar-core.c
>>> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
>>> @@ -131,9 +131,13 @@ static int rvin_group_link_notify(struct 
>>> media_link *link, u32 flags,
>>> !is_media_entity_v4l2_video_device(link->sink->entity))
>>>           return 0;
>>>   -    /* If any entity is in use don't allow link changes. */
>>> +    /*
>>> +     * Don't allow link changes if any entity in the graph is
>>> +     * streaming, because modifying the CHSEL register fields
>>> +     * can disrupt running streams.
>>> +     */
>>>       media_device_for_each_entity(entity, &group->mdev)
>>> -        if (entity->use_count)
>>> +        if (entity->stream_count)
>>>               return -EBUSY;
>>>         mutex_lock(&group->lock);
>>> -- 
>>> 2.17.1
>>>
>
diff mbox series

Patch

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index f0719ce24b97..6dd6b11c1b2b 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -131,9 +131,13 @@  static int rvin_group_link_notify(struct media_link *link, u32 flags,
 	    !is_media_entity_v4l2_video_device(link->sink->entity))
 		return 0;
 
-	/* If any entity is in use don't allow link changes. */
+	/*
+	 * Don't allow link changes if any entity in the graph is
+	 * streaming, because modifying the CHSEL register fields
+	 * can disrupt running streams.
+	 */
 	media_device_for_each_entity(entity, &group->mdev)
-		if (entity->use_count)
+		if (entity->stream_count)
 			return -EBUSY;
 
 	mutex_lock(&group->lock);