diff mbox series

media: staging: ipu3-imgu: Set fields before media_entity_pads_init()

Message ID 20231228093926.748001-1-hidenorik@chromium.org
State Accepted
Commit 87318b7092670d4086bfec115a0280a60c51c2dd
Headers show
Series media: staging: ipu3-imgu: Set fields before media_entity_pads_init() | expand

Commit Message

Hidenori Kobayashi Dec. 28, 2023, 9:39 a.m. UTC
The pad's flags is checked in media_entity_pads_init(), so it has to be
initialized beforehand. The ops initialization is also moved together
for readability.

Signed-off-by: Hidenori Kobayashi <hidenorik@chromium.org>
---
 drivers/staging/media/ipu3/ipu3-v4l2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Dan Carpenter Jan. 4, 2024, 10:04 a.m. UTC | #1
On Thu, Dec 28, 2023 at 06:39:25PM +0900, Hidenori Kobayashi wrote:
> The pad's flags is checked in media_entity_pads_init(), so it has to be
> initialized beforehand. The ops initialization is also moved together
> for readability.
> 

How does this bug look like to a user?  What is the Fixes tag?  Does
this need to be backported to stable?

regards,
dan carpenter
Hidenori Kobayashi Jan. 5, 2024, 2:19 a.m. UTC | #2
On Thu, Jan 04, 2024 at 01:04:27PM +0300, Dan Carpenter wrote:
> On Thu, Dec 28, 2023 at 06:39:25PM +0900, Hidenori Kobayashi wrote:
> > The pad's flags is checked in media_entity_pads_init(), so it has to be
> > initialized beforehand. The ops initialization is also moved together
> > for readability.
> > 
> 
> How does this bug look like to a user?  What is the Fixes tag?  Does
> this need to be backported to stable?

I suppose I should have included those in the commit message.

1) To a user, the imgu driver fails to probe with the following message:

[   14.596315] ipu3-imgu 0000:00:05.0: failed initialize subdev media entity (-22)
[   14.596322] ipu3-imgu 0000:00:05.0: failed to register subdev0 ret (-22)
[   14.596327] ipu3-imgu 0000:00:05.0: failed to register pipes (-22)
[   14.596331] ipu3-imgu 0000:00:05.0: failed to create V4L2 devices (-22)

2) Re Fixes tag, I see that the first commit of imgu driver already
initializes the flags after media_entity_pads_init(). The documentation
of this API ( "Drivers must set the direction of every pad ... before
calling media_entity_pads_init") predates the first commit. So, I guess

Fixes: a0ca1627b450 ("media: staging/intel-ipu3: Add v4l2 driver based on media framework")

3) Re stable, I was not sure. The probe failure only appears after a
check was added by Commit deb866f9e3a45ae058b21765feeffae6aea6a193. That
check is not in linux-6.6.y branch. So I was not sure if this counts as
"a real bug that bothers people" mentioned in the document.


With the above, how does the following sounds to you?

The imgu driver fails to probe because it does not set the pad's flags
before calling media_entity_pads_init(). Fix the initialization order so
that the driver probe succeeds. The ops initialization is also moved
together for readability.

Fixes: a0ca1627b450 ("media: staging/intel-ipu3: Add v4l2 driver based on media framework")

Thanks for the guidance,
Hidenori
Dan Carpenter Jan. 5, 2024, 7:34 a.m. UTC | #3
On Fri, Jan 05, 2024 at 11:19:23AM +0900, Hidenori Kobayashi wrote:
> On Thu, Jan 04, 2024 at 01:04:27PM +0300, Dan Carpenter wrote:
> > On Thu, Dec 28, 2023 at 06:39:25PM +0900, Hidenori Kobayashi wrote:
> > > The pad's flags is checked in media_entity_pads_init(), so it has to be
> > > initialized beforehand. The ops initialization is also moved together
> > > for readability.
> > > 
> > 
> > How does this bug look like to a user?  What is the Fixes tag?  Does
> > this need to be backported to stable?
> 
> I suppose I should have included those in the commit message.
> 
> 1) To a user, the imgu driver fails to probe with the following message:
> 
> [   14.596315] ipu3-imgu 0000:00:05.0: failed initialize subdev media entity (-22)
> [   14.596322] ipu3-imgu 0000:00:05.0: failed to register subdev0 ret (-22)
> [   14.596327] ipu3-imgu 0000:00:05.0: failed to register pipes (-22)
> [   14.596331] ipu3-imgu 0000:00:05.0: failed to create V4L2 devices (-22)
> 

Yeah.  This is super useful information.

> 2) Re Fixes tag, I see that the first commit of imgu driver already
> initializes the flags after media_entity_pads_init(). The documentation
> of this API ( "Drivers must set the direction of every pad ... before
> calling media_entity_pads_init") predates the first commit. So, I guess
> 
> Fixes: a0ca1627b450 ("media: staging/intel-ipu3: Add v4l2 driver based on media framework")
> 
> 3) Re stable, I was not sure. The probe failure only appears after a
> check was added by Commit deb866f9e3a45ae058b21765feeffae6aea6a193. That
> check is not in linux-6.6.y branch. So I was not sure if this counts as
> "a real bug that bothers people" mentioned in the document.

Hm...  I don't know either.  Wait for a day and see if anyone else has
an opinion then listen to your gut and resend with whatever your gut
says?

regards,
dan carpenter
Sakari Ailus Jan. 8, 2024, 8:59 a.m. UTC | #4
Hi Dan, Hidenori,

On Fri, Jan 05, 2024 at 10:34:20AM +0300, Dan Carpenter wrote:
> On Fri, Jan 05, 2024 at 11:19:23AM +0900, Hidenori Kobayashi wrote:
> > On Thu, Jan 04, 2024 at 01:04:27PM +0300, Dan Carpenter wrote:
> > > On Thu, Dec 28, 2023 at 06:39:25PM +0900, Hidenori Kobayashi wrote:
> > > > The pad's flags is checked in media_entity_pads_init(), so it has to be
> > > > initialized beforehand. The ops initialization is also moved together
> > > > for readability.
> > > > 
> > > 
> > > How does this bug look like to a user?  What is the Fixes tag?  Does
> > > this need to be backported to stable?
> > 
> > I suppose I should have included those in the commit message.
> > 
> > 1) To a user, the imgu driver fails to probe with the following message:
> > 
> > [   14.596315] ipu3-imgu 0000:00:05.0: failed initialize subdev media entity (-22)
> > [   14.596322] ipu3-imgu 0000:00:05.0: failed to register subdev0 ret (-22)
> > [   14.596327] ipu3-imgu 0000:00:05.0: failed to register pipes (-22)
> > [   14.596331] ipu3-imgu 0000:00:05.0: failed to create V4L2 devices (-22)
> > 
> 
> Yeah.  This is super useful information.
> 
> > 2) Re Fixes tag, I see that the first commit of imgu driver already
> > initializes the flags after media_entity_pads_init(). The documentation
> > of this API ( "Drivers must set the direction of every pad ... before
> > calling media_entity_pads_init") predates the first commit. So, I guess
> > 
> > Fixes: a0ca1627b450 ("media: staging/intel-ipu3: Add v4l2 driver based on media framework")
> > 
> > 3) Re stable, I was not sure. The probe failure only appears after a
> > check was added by Commit deb866f9e3a45ae058b21765feeffae6aea6a193. That
> > check is not in linux-6.6.y branch. So I was not sure if this counts as
> > "a real bug that bothers people" mentioned in the document.
> 
> Hm...  I don't know either.  Wait for a day and see if anyone else has
> an opinion then listen to your gut and resend with whatever your gut
> says?

The suggested commit message seems good to me, the Fixes: line is
important. Thanks for digging this up! The patch should go to v6.7, too, so
please add Cc: stable (for v6.7).
Hidenori Kobayashi Jan. 9, 2024, 3:27 a.m. UTC | #5
Hi Dan, Sakari,

On Mon, Jan 08, 2024 at 08:59:37AM +0000, Sakari Ailus wrote:
> Hi Dan, Hidenori,
> 
> On Fri, Jan 05, 2024 at 10:34:20AM +0300, Dan Carpenter wrote:
> > Hm...  I don't know either.  Wait for a day and see if anyone else has
> > an opinion then listen to your gut and resend with whatever your gut
> > says?
> 
> The suggested commit message seems good to me, the Fixes: line is
> important. Thanks for digging this up! The patch should go to v6.7, too, so
> please add Cc: stable (for v6.7).

Thanks for the comments! I'll send v2 with the revised commit message,
with Cc: stable.

Hidenori
diff mbox series

Patch

diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index a66f034380c0..3df58eb3e882 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -1069,6 +1069,11 @@  static int imgu_v4l2_subdev_register(struct imgu_device *imgu,
 	struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
 
 	/* Initialize subdev media entity */
+	imgu_sd->subdev.entity.ops = &imgu_media_ops;
+	for (i = 0; i < IMGU_NODE_NUM; i++) {
+		imgu_sd->subdev_pads[i].flags = imgu_pipe->nodes[i].output ?
+			MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE;
+	}
 	r = media_entity_pads_init(&imgu_sd->subdev.entity, IMGU_NODE_NUM,
 				   imgu_sd->subdev_pads);
 	if (r) {
@@ -1076,11 +1081,6 @@  static int imgu_v4l2_subdev_register(struct imgu_device *imgu,
 			"failed initialize subdev media entity (%d)\n", r);
 		return r;
 	}
-	imgu_sd->subdev.entity.ops = &imgu_media_ops;
-	for (i = 0; i < IMGU_NODE_NUM; i++) {
-		imgu_sd->subdev_pads[i].flags = imgu_pipe->nodes[i].output ?
-			MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE;
-	}
 
 	/* Initialize subdev */
 	v4l2_subdev_init(&imgu_sd->subdev, &imgu_subdev_ops);
@@ -1177,15 +1177,15 @@  static int imgu_v4l2_node_setup(struct imgu_device *imgu, unsigned int pipe,
 	}
 
 	/* Initialize media entities */
+	node->vdev_pad.flags = node->output ?
+		MEDIA_PAD_FL_SOURCE : MEDIA_PAD_FL_SINK;
+	vdev->entity.ops = NULL;
 	r = media_entity_pads_init(&vdev->entity, 1, &node->vdev_pad);
 	if (r) {
 		dev_err(dev, "failed initialize media entity (%d)\n", r);
 		mutex_destroy(&node->lock);
 		return r;
 	}
-	node->vdev_pad.flags = node->output ?
-		MEDIA_PAD_FL_SOURCE : MEDIA_PAD_FL_SINK;
-	vdev->entity.ops = NULL;
 
 	/* Initialize vbq */
 	vbq->type = node->vdev_fmt.type;