Skip to contentSkip to conversation

videobuf2-core: modify the num of users

PATCH New panpan liu 3 participants 3 messages Aug 14, 2014 Media (V4L/DVB)

lore
Share & tools
lore

panpan liu

author
#0 lore raw

PATCH 1/1 videobuf2-core: modify the num of users

If num_users returns 1 or more than 1, that means we are not the only user of the plane's memory.

---
 drivers/media/v4l2-core/videobuf2-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf2-core.c +1 -1
index c359006..d3a4b8f 100644
@@ -625,7 +625,7 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
 		 * case anyway. If num_users() returns more than 1,
 		 * we are not the only user of the plane's memory.
 		 */
-		if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
+		if (mem_priv && call_memop(vb, num_users, mem_priv) >= 1)
 			return true;
 	}
 	return false;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 videobuf2-core: modify the num of users

Quoted 4 lines · panpan liu

If num_users returns 1 or more than 1, that means we are not the only user of the plane's memory.

NACK.

Please read the function documentation and how it is used. If the number of users is 1, we are the only user and should be able to free the queue. This will make us unable to do so.

Quoted 19 lines
---
 drivers/media/v4l2-core/videobuf2-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf2-core.c +1 -2
index c359006..d3a4b8f 100644
@@ -625,7 +625,7 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
                 * case anyway. If num_users() returns more than 1,
                 * we are not the only user of the plane's memory.
                 */
-               if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
+               if (mem_priv && call_memop(vb, num_users, mem_priv) >= 1)
                        return true;
        }
        return false;
--

1.7.9.5

Signature · 2 lines
Thanks,
Pawel Osciak
#2 lore raw

PATCH 1/1 videobuf2-core: modify the num of users

In reply to panpan liu

Hi,

I've got a few questions:

Quoted 2 lines · panpan liu

If num_users returns 1 or more than 1, that means we are not the only user of the plane's memory.

Why do think this is wrong? When the buffer is allocated the refcount is set to 1, so anyone mapping that buffer will increase the refcount making it 'in use'.

Seems perfectly OK to me.

So if your patch solves a problem for you, then I'd like to know what that problem is. You might be solving it in the wrong place.

drivers/media/v4l2-core/videobuf2-core.c static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) · line 626

Quoted 13 lines
---
  drivers/media/v4l2-core/videobuf2-core.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf2-core.c +0 -0
index c359006..d3a4b8f 100644
@@ -625,7 +625,7 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
  		 * case anyway. If num_users() returns more than 1,
  		 * we are not the only user of the plane's memory.

And even if there was a bug, then your patch is incomplete because you didn't update the comment.

drivers/media/v4l2-core/videobuf2-core.c static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) · line 631

Quoted 7 lines
drivers/media/v4l2-core/videobuf2-core.c +1 -1
  		 */
-		if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
+		if (mem_priv && call_memop(vb, num_users, mem_priv) >= 1)
  			return true;
  	}
  	return false;

Regards,

Hans