public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier@osg.samsung.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [media-workshop] [PATCH v8.4 81/83] [media] media-entity: init pads on entity init if was registered before
Date: Mon, 23 Nov 2015 17:21:22 -0300	[thread overview]
Message-ID: <56537542.6060204@osg.samsung.com> (raw)
In-Reply-To: <2341331.P6c9pT8HFp@avalon>

Hello Laurent,

On 11/23/2015 01:20 PM, Laurent Pinchart wrote:
> Hi Javier,
> 
> (Replying to linux-media instead of media-workshop, I can't find this patch in 
> my linux-media folder)
>
> Thank you for the patch.
>

Thanks for your feedback.
 
> On Monday 12 October 2015 13:44:10 Mauro Carvalho Chehab wrote:
>> From: Javier Martinez Canillas <javier@osg.samsung.com>
>>
>> If an entity is registered with a media device before is initialized
>> with media_device_register_entity(), the number of pads won't be set
>> so media_device_register_entity() won't create pad objects and add
>> it to the media device pads list.
>>
>> Do this at entity initialization time if the entity was registered
>> before so the graph is complete and correct regardless of the order
>> in which the entities are initialized and registered.
> 
> We now have two places where the pads graph objects are initialized and that 
> looks like a bug to me as media_gobj_init() allocates IDs and, even worse, 
> adds the entity to the media device entities list.
>

Yes but the idea of this patch was in fact to make it less error prone and
more robust since entities could either be initialized and later registered
or first be registered and then later initialized.
 
> We need to standardize on where graph objects are initialized across the 
> different kind of objects and document this clearly otherwise drivers will get 
> it wrong.
>

I'm OK with having more strict rules of the order in which objects should
be initialized and registered and force all drivers to follow these docs.

>> Suggested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

This patch was suggested by Mauro so I'll also let him to comment what he
prefers or if he has another opinion on this.

>> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
>> ---
>>  drivers/media/media-entity.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
>> index f28265864b76..2c984fb7d497 100644
>> --- a/drivers/media/media-entity.c
>> +++ b/drivers/media/media-entity.c
>> @@ -238,6 +238,7 @@ int
>>  media_entity_init(struct media_entity *entity, u16 num_pads,
>>  		  struct media_pad *pads)
>>  {
>> +	struct media_device *mdev = entity->graph_obj.mdev;
>>  	unsigned int i;
>>
>>  	entity->group_id = 0;
>> @@ -246,11 +247,20 @@ media_entity_init(struct media_entity *entity, u16
>> num_pads, entity->num_pads = num_pads;
>>  	entity->pads = pads;
>>
>> +	if (mdev)
>> +		spin_lock(&mdev->lock);
>> +
>>  	for (i = 0; i < num_pads; i++) {
>>  		pads[i].entity = entity;
>>  		pads[i].index = i;
>> +		if (mdev)
>> +			media_gobj_init(mdev, MEDIA_GRAPH_PAD,
>> +					&entity->pads[i].graph_obj);
>>  	}
>>
>> +	if (mdev)
>> +		spin_unlock(&mdev->lock);
>> +
>>  	return 0;
>>  }
>>  EXPORT_SYMBOL_GPL(media_entity_init);
> 

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

  reply	other threads:[~2015-11-23 20:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1444668252-2303-1-git-send-email-mchehab@osg.samsung.com>
     [not found] ` <1444668252-2303-82-git-send-email-mchehab@osg.samsung.com>
2015-11-23 16:20   ` [media-workshop] [PATCH v8.4 81/83] [media] media-entity: init pads on entity init if was registered before Laurent Pinchart
2015-11-23 20:21     ` Javier Martinez Canillas [this message]
2015-11-24 10:22       ` Mauro Carvalho Chehab
2015-11-26 23:36         ` Sakari Ailus
     [not found] ` <20151014183548.7180618e@concha.lan>
     [not found]   ` <20151107220255.GT17128@valkosipuli.retiisi.org.uk>
2015-12-06  1:36     ` [media-workshop] [PATCH v8.4 43/83] [media] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56537542.6060204@osg.samsung.com \
    --to=javier@osg.samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox