All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org, Sakari Ailus <sakari.ailus@iki.fi>,
	Michal Simek <michal.simek@xilinx.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [PATCH v1 5/5] media: xilinx: dma: Use media_pipeline_for_each_pad()
Date: Fri, 16 Dec 2022 02:36:43 +0200	[thread overview]
Message-ID: <Y5u9m7SUmg0oKV+q@pendragon.ideasonboard.com> (raw)
In-Reply-To: <e71c1729-a052-bda8-f277-ea0c94e64073@ideasonboard.com>

Hi Tomi,

On Thu, Dec 15, 2022 at 03:29:13PM +0200, Tomi Valkeinen wrote:
> On 12/12/2022 16:16, Laurent Pinchart wrote:
> > Replace usage of the deprecated media graph walk API with the new
> > media_pipeline_for_each_pad() macro.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >   drivers/media/platform/xilinx/xilinx-dma.c | 28 +++++-----------------
> >   1 file changed, 6 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
> > index 0a7fd8642a65..fee02c8c85fd 100644
> > --- a/drivers/media/platform/xilinx/xilinx-dma.c
> > +++ b/drivers/media/platform/xilinx/xilinx-dma.c
> > @@ -173,31 +173,19 @@ static int xvip_pipeline_set_stream(struct xvip_pipeline *pipe, bool on)
> >   static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
> >   				  struct xvip_dma *start)
> >   {
> > -	struct media_graph graph;
> > -	struct media_entity *entity = &start->video.entity;
> > -	struct media_device *mdev = entity->graph_obj.mdev;
> > +	struct media_pipeline_pad_iter iter;
> >   	unsigned int num_inputs = 0;
> >   	unsigned int num_outputs = 0;
> > -	int ret;
> > +	struct media_pad *pad;
> >   
> > -	mutex_lock(&mdev->graph_mutex);
> > -
> > -	/* Walk the graph to locate the video nodes. */
> > -	ret = media_graph_walk_init(&graph, mdev);
> > -	if (ret) {
> > -		mutex_unlock(&mdev->graph_mutex);
> > -		return ret;
> > -	}
> > -
> > -	media_graph_walk_start(&graph, entity);
> > -
> > -	while ((entity = media_graph_walk_next(&graph))) {
> > +	/* Locate the video nodes in the pipeline. */
> > +	media_pipeline_for_each_pad(&pipe->pipe, &iter, pad) {
> >   		struct xvip_dma *dma;
> >   
> > -		if (entity->function != MEDIA_ENT_F_IO_V4L)
> > +		if (pad->entity->function != MEDIA_ENT_F_IO_V4L)
> >   			continue;
> 
> Why do you iterate the pads here, instead of using 
> media_pipeline_for_each_entity()?

The entity iterator still iterates over all pads internally, so it's not
more efficient. It also requires explicit initialization and cleanup, so
is more complicated to use. In this specific case, the driver ignores
all pads belonging to entities that are not V4L2 video nodes
(MEDIA_ENT_F_IO_V4L). As such entities have a single pad, there's a
guarantee they will not be visited twice.

If you think this is too fragile due to the assumption that
MEDIA_ENT_F_IO_V4L entities have a single pad, I can use the entity
iterator, it's not a big deal.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-12-16  0:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 14:16 [PATCH v1 0/5] media: Replace media graph walk in several drivers Laurent Pinchart
2022-12-12 14:16 ` [PATCH v1 1/5] media: mc: entity: Add pad iterator for media_pipeline Laurent Pinchart
2022-12-15 12:33   ` Tomi Valkeinen
2022-12-15 12:48     ` Laurent Pinchart
2022-12-15 12:55       ` Tomi Valkeinen
2022-12-12 14:16 ` [PATCH v1 2/5] media: mc: entity: Add entity " Laurent Pinchart
2022-12-15 12:48   ` Tomi Valkeinen
2022-12-15 12:51     ` Laurent Pinchart
2022-12-12 14:16 ` [PATCH v1 3/5] media: ti: omap3isp: Use media_pipeline_for_each_entity() Laurent Pinchart
2022-12-15 13:16   ` Tomi Valkeinen
2022-12-12 14:16 ` [PATCH v1 4/5] media: ti: omap4iss: " Laurent Pinchart
2022-12-12 14:16 ` [PATCH v1 5/5] media: xilinx: dma: Use media_pipeline_for_each_pad() Laurent Pinchart
2022-12-15 13:29   ` Tomi Valkeinen
2022-12-16  0:36     ` Laurent Pinchart [this message]
2022-12-16  6:47       ` Tomi Valkeinen
2022-12-19 22:22         ` 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=Y5u9m7SUmg0oKV+q@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sakari.ailus@iki.fi \
    --cc=tomi.valkeinen@ideasonboard.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 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.