All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl
Date: Tue, 24 Nov 2015 08:57:23 -0200	[thread overview]
Message-ID: <20151124085723.79af4e69@recife.lan> (raw)
In-Reply-To: <2796992.BmKOJN8UBM@avalon>

Em Mon, 23 Nov 2015 21:56:50 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:47 Mauro Carvalho Chehab wrote:
> > Due to the graph traversal algorithm currently in usage, we
> > need a copy of all data links. Those backlinks should not be
> > send to userspace, as otherwise, all links there will be
> > duplicated.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> > index 0238885fcc74..97eb97d9b662 100644
> > --- a/drivers/media/media-device.c
> > +++ b/drivers/media/media-device.c
> > @@ -333,6 +333,9 @@ static long __media_device_get_topology(struct
> > media_device *mdev, /* Get links and number of links */
> >  	i = 0;
> >  	media_device_for_each_link(link, mdev) {
> > +		if (link->is_backlink)
> > +			continue;
> > +
> >  		i++;
> > 
> >  		if (ret || !topo->links)
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index cd4d767644df..4868b8269204 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -648,6 +648,7 @@ media_create_pad_link(struct media_entity *source, u16
> > source_pad, backlink->source = &source->pads[source_pad];
> >  	backlink->sink = &sink->pads[sink_pad];
> >  	backlink->flags = flags;
> > +	backlink->is_backlink = true;
> > 
> >  	/* Initialize graph object embedded at the new link */
> >  	media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index e1a89899deef..3d389f142a1d 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -96,6 +96,7 @@ struct media_pipeline {
> >   * @reverse:	Pointer to the link for the reverse direction of a pad to 
> pad
> >   *		link.
> >   * @flags:	Link flags, as defined at uapi/media.h (MEDIA_LNK_FL_*)
> > + * @is_backlink: Indicate if the link is a backlink.
> >   */
> >  struct media_link {
> >  	struct media_gobj graph_obj;
> > @@ -112,6 +113,7 @@ struct media_link {
> >  	};
> >  	struct media_link *reverse;
> >  	unsigned long flags;
> > +	bool is_backlink;
> 
> I agree with the purpose of this patch (and as stated for other patches in the 
> series I believe you should squash it with the patch that introduces the 
> G_TOPOLOGY ioctl) but I won't whether you couldn't do with the additional 
> variable by adding a flag for backlinks (flag that wouldn't be shown to 
> userspace).
> 
> Now that I think about it an even better implementation could be to avoid 
> creating backlinks at all. As links are now dynamically allocated you could 
> have two struct list_head in the link structure, one for the source and one 
> for the sink. It sounds too easy to be true, I wonder if I'm overlooking 
> something.

I tried that. This was actually one of my pans. However, it is not as
trivial as it seems. I explored several different alternatives:

1) we could have two lists at struct media_entity, one for links and another
one for backlinks:

struct media_link {
	...
	struct list_head list;
	...
};

struct media_entity {
	...
	struct list_head links;
	struct list_head backlinks;
	...
};

And add the link to either one of the list. However, in such case,
container_of() would not work, because the offset of the data at the 
struct media_entity will be different, if the link is at the links
or backlinks list.

2) to have 2 lists also at struct media_link, one for the links and
another one for the backlinks, but this will require non trivial
changes at the graph traversal logic.

I can foresee some other alternatives that I didn't try yet:

- to use a separate data struct for the backlinks, like:
	struct media_obj_group {
		struct *media_object;
		struct list_head list;
	}
  and use this to store backlinks. Again, would require nontrivial
  changes at the graph traversal logic and would end by spending
  some extra memory for the backlinks;

- using the same structs as already defined, patching all routines
  that use links to add the capability for them to identify if the
  link is actually a backlink. This would be non-trivial and may
  be messy.

So, while I would love to get rid of backlinks, fixing it is not
trivial at all.

Regards,
Mauro

  reply	other threads:[~2015-11-24 10:57 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
2015-09-11 14:48   ` Hans Verkuil
2015-11-23 20:01   ` Laurent Pinchart
2015-11-24 11:00     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
2015-09-11 14:57   ` Hans Verkuil
2015-12-10 18:24     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 03/18] [media] au0828: Create connector links Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
2015-09-11 14:58   ` Hans Verkuil
2015-11-23 19:56   ` Laurent Pinchart
2015-11-24 10:57     ` Mauro Carvalho Chehab [this message]
2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
2015-09-11 15:18   ` Hans Verkuil
2015-11-23 19:46   ` Laurent Pinchart
2015-12-10 11:37     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices Mauro Carvalho Chehab
     [not found]   ` <9af2bbe9e63004f843e8478bc3d31cd03ea75d64.1441559233.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-09-11 15:19     ` Hans Verkuil
2015-09-11 15:19       ` Hans Verkuil
2015-11-23 18:09     ` Laurent Pinchart
2015-11-23 18:09       ` Laurent Pinchart
2015-12-10 18:43       ` Mauro Carvalho Chehab
2015-12-10 18:43         ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails Mauro Carvalho Chehab
2015-09-11 15:20   ` Hans Verkuil
2015-12-10 17:33     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph() Mauro Carvalho Chehab
2015-09-11 15:22   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 09/18] [media] media-entity: enforce check of interface and links creation Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 10/18] [media] cx231xx: enforce check for graph creation Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 11/18] [media] au0828:: " Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 12/18] [media] media-entity: must check media_create_pad_link() Mauro Carvalho Chehab
2015-09-11 15:24   ` Hans Verkuil
2015-11-23 17:54   ` Laurent Pinchart
2015-12-10 19:13     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function Mauro Carvalho Chehab
2015-09-06 17:30   ` Mauro Carvalho Chehab
2015-09-11 15:25   ` Hans Verkuil
2015-09-11 15:25     ` Hans Verkuil
2015-11-23 17:51   ` Laurent Pinchart
2015-11-23 17:51     ` Laurent Pinchart
2015-11-24 10:32     ` Mauro Carvalho Chehab
2015-11-24 10:32       ` Mauro Carvalho Chehab
     [not found] ` <cover.1441559233.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-09-06 17:30   ` [PATCH 14/18] [media] media-device: export the entity function via new ioctl Mauro Carvalho Chehab
2015-09-06 17:30     ` Mauro Carvalho Chehab
2015-09-11 15:26     ` Hans Verkuil
     [not found]     ` <13a08789f63775c6f014c08969bc8ed3f0550c82.1441559233.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-11-23 17:46       ` Laurent Pinchart
2015-11-23 17:46         ` Laurent Pinchart
2015-11-24 10:27         ` Mauro Carvalho Chehab
2015-11-24 10:27           ` Mauro Carvalho Chehab
2015-09-06 17:30   ` [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions Mauro Carvalho Chehab
2015-09-06 17:30     ` Mauro Carvalho Chehab
2015-09-06 17:30     ` Mauro Carvalho Chehab
     [not found]     ` <0545064c26ab320b6019adf1ff24e8d69339d682.1441559233.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-09-11 15:36       ` Hans Verkuil
2015-09-11 15:36         ` Hans Verkuil
2015-09-11 15:36         ` Hans Verkuil
2015-12-10 19:54         ` Mauro Carvalho Chehab
2015-12-10 19:54           ` Mauro Carvalho Chehab
2015-12-10 19:54           ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 16/18] [media] DocBook: update entities documentation Mauro Carvalho Chehab
2015-09-06 17:31 ` [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Mauro Carvalho Chehab
2015-09-11 15:38   ` Hans Verkuil
2015-09-06 17:31 ` [PATCH 18/18] [media] dvbdev: Don't create indirect links Mauro Carvalho Chehab
2015-09-11 15:48   ` Hans Verkuil
2015-12-10 20:20     ` Mauro Carvalho Chehab

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=20151124085723.79af4e69@recife.lan \
    --to=mchehab@osg.samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.