linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: vb2: Print the queue pointer in debug messages
@ 2018-04-26 20:06 Laurent Pinchart
  2018-04-28 11:10 ` kbuild test robot
  2018-04-28 11:33 ` kbuild test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Laurent Pinchart @ 2018-04-26 20:06 UTC (permalink / raw)
  To: linux-media; +Cc: paul.elder, Sakari Ailus, Hans Verkuil

When debugging issues that involve more than one video queue, messages
related to multiple queues get interleaved without any easy way to tell
which queue they relate to. Fix this by printing the queue pointer for
all debug messages in the vb2 core and V4L2 layers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/common/videobuf2/videobuf2-core.c | 193 ++++++++++++------------
 drivers/media/common/videobuf2/videobuf2-v4l2.c |  39 ++---
 2 files changed, 118 insertions(+), 114 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index d3f7bb33a54d..e35e79c32550 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -34,10 +34,10 @@
 static int debug;
 module_param(debug, int, 0644);
 
-#define dprintk(level, fmt, arg...)				\
-	do {							\
-		if (debug >= level)				\
-			pr_info("%s: " fmt, __func__, ## arg);	\
+#define dprintk(q, level, fmt, arg...)					\
+	do {								\
+		if (debug >= level)					\
+			pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
 	} while (0)
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -51,8 +51,8 @@ module_param(debug, int, 0644);
  */
 
 #define log_memop(vb, op)						\
-	dprintk(2, "call_memop(%p, %d, %s)%s\n",			\
-		(vb)->vb2_queue, (vb)->index, #op,			\
+	dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n",	\
+		(vb)->index, #op,					\
 		(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
 
 #define call_memop(vb, op, args...)					\
@@ -90,7 +90,7 @@ module_param(debug, int, 0644);
 })
 
 #define log_qop(q, op)							\
-	dprintk(2, "call_qop(%p, %s)%s\n", q, #op,			\
+	dprintk(q, 2, "call_qop(%p, %s)%s\n", q, #op,			\
 		(q)->ops->op ? "" : " (nop)")
 
 #define call_qop(q, op, args...)					\
@@ -113,8 +113,8 @@ module_param(debug, int, 0644);
 })
 
 #define log_vb_qop(vb, op, args...)					\
-	dprintk(2, "call_vb_qop(%p, %d, %s)%s\n",			\
-		(vb)->vb2_queue, (vb)->index, #op,			\
+	dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n",	\
+		(vb)->index, #op,					\
 		(vb)->vb2_queue->ops->op ? "" : " (nop)")
 
 #define call_vb_qop(vb, op, args...)					\
@@ -241,7 +241,8 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
 	for (plane = 0; plane < vb->num_planes; ++plane) {
 		call_void_memop(vb, put, vb->planes[plane].mem_priv);
 		vb->planes[plane].mem_priv = NULL;
-		dprintk(3, "freed plane %d of buffer %d\n", plane, vb->index);
+		dprintk(vb->vb2_queue, 3, "freed plane %d of buffer %d\n",
+			plane, vb->index);
 	}
 }
 
@@ -311,7 +312,7 @@ static void __setup_offsets(struct vb2_buffer *vb)
 	for (plane = 0; plane < vb->num_planes; ++plane) {
 		vb->planes[plane].m.offset = off;
 
-		dprintk(3, "buffer %d, plane %d offset 0x%08lx\n",
+		dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n",
 				vb->index, plane, off);
 
 		off += vb->planes[plane].length;
@@ -342,7 +343,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		/* Allocate videobuf buffer structures */
 		vb = kzalloc(q->buf_struct_size, GFP_KERNEL);
 		if (!vb) {
-			dprintk(1, "memory alloc for buffer struct failed\n");
+			dprintk(q, 1, "memory alloc for buffer struct failed\n");
 			break;
 		}
 
@@ -362,7 +363,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		if (memory == VB2_MEMORY_MMAP) {
 			ret = __vb2_buf_mem_alloc(vb);
 			if (ret) {
-				dprintk(1, "failed allocating memory for buffer %d\n",
+				dprintk(q, 1, "failed allocating memory for buffer %d\n",
 					buffer);
 				q->bufs[vb->index] = NULL;
 				kfree(vb);
@@ -376,7 +377,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 			 */
 			ret = call_vb_qop(vb, buf_init, vb);
 			if (ret) {
-				dprintk(1, "buffer %d %p initialization failed\n",
+				dprintk(q, 1, "buffer %d %p initialization failed\n",
 					buffer, vb);
 				__vb2_buf_mem_free(vb);
 				q->bufs[vb->index] = NULL;
@@ -386,7 +387,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		}
 	}
 
-	dprintk(1, "allocated %d buffers, %d plane(s) each\n",
+	dprintk(q, 1, "allocated %d buffers, %d plane(s) each\n",
 			buffer, num_planes);
 
 	return buffer;
@@ -438,7 +439,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
 		if (q->bufs[buffer] == NULL)
 			continue;
 		if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) {
-			dprintk(1, "preparing buffers, cannot free\n");
+			dprintk(q, 1, "preparing buffers, cannot free\n");
 			return -EAGAIN;
 		}
 	}
@@ -615,12 +616,12 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 {
 	if (memory != VB2_MEMORY_MMAP && memory != VB2_MEMORY_USERPTR &&
 	    memory != VB2_MEMORY_DMABUF) {
-		dprintk(1, "unsupported memory type\n");
+		dprintk(q, 1, "unsupported memory type\n");
 		return -EINVAL;
 	}
 
 	if (type != q->type) {
-		dprintk(1, "requested type is incorrect\n");
+		dprintk(q, 1, "requested type is incorrect\n");
 		return -EINVAL;
 	}
 
@@ -629,17 +630,17 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 	 * are available.
 	 */
 	if (memory == VB2_MEMORY_MMAP && __verify_mmap_ops(q)) {
-		dprintk(1, "MMAP for current setup unsupported\n");
+		dprintk(q, 1, "MMAP for current setup unsupported\n");
 		return -EINVAL;
 	}
 
 	if (memory == VB2_MEMORY_USERPTR && __verify_userptr_ops(q)) {
-		dprintk(1, "USERPTR for current setup unsupported\n");
+		dprintk(q, 1, "USERPTR for current setup unsupported\n");
 		return -EINVAL;
 	}
 
 	if (memory == VB2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
-		dprintk(1, "DMABUF for current setup unsupported\n");
+		dprintk(q, 1, "DMABUF for current setup unsupported\n");
 		return -EINVAL;
 	}
 
@@ -649,7 +650,7 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 	 * do the memory and type validation.
 	 */
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return 0;
@@ -664,7 +665,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 	int ret;
 
 	if (q->streaming) {
-		dprintk(1, "streaming active\n");
+		dprintk(q, 1, "streaming active\n");
 		return -EBUSY;
 	}
 
@@ -677,7 +678,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 		mutex_lock(&q->mmap_lock);
 		if (q->memory == VB2_MEMORY_MMAP && __buffers_in_use(q)) {
 			mutex_unlock(&q->mmap_lock);
-			dprintk(1, "memory in use, cannot free\n");
+			dprintk(q, 1, "memory in use, cannot free\n");
 			return -EBUSY;
 		}
 
@@ -722,7 +723,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 	allocated_buffers =
 		__vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes);
 	if (allocated_buffers == 0) {
-		dprintk(1, "memory allocation failed\n");
+		dprintk(q, 1, "memory allocation failed\n");
 		return -ENOMEM;
 	}
 
@@ -792,7 +793,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 	int ret;
 
 	if (q->num_buffers == VB2_MAX_FRAME) {
-		dprintk(1, "maximum number of buffers already allocated\n");
+		dprintk(q, 1, "maximum number of buffers already allocated\n");
 		return -ENOBUFS;
 	}
 
@@ -822,7 +823,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 	allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers,
 				num_planes, plane_sizes);
 	if (allocated_buffers == 0) {
-		dprintk(1, "memory allocation failed\n");
+		dprintk(q, 1, "memory allocation failed\n");
 		return -ENOMEM;
 	}
 
@@ -913,7 +914,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 	 */
 	vb->cnt_buf_done++;
 #endif
-	dprintk(4, "done processing on buffer %d, state: %d\n",
+	dprintk(q, 4, "done processing on buffer %d, state: %d\n",
 			vb->index, state);
 
 	/* sync buffers */
@@ -1002,12 +1003,12 @@ static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
 			&& vb->planes[plane].length == planes[plane].length)
 			continue;
 
-		dprintk(3, "userspace address for plane %d changed, reacquiring memory\n",
+		dprintk(q, 3, "userspace address for plane %d changed, reacquiring memory\n",
 			plane);
 
 		/* Check if the provided plane buffer is large enough */
 		if (planes[plane].length < vb->planes[plane].min_length) {
-			dprintk(1, "provided buffer size %u is less than setup size %u for plane %d\n",
+			dprintk(q, 1, "provided buffer size %u is less than setup size %u for plane %d\n",
 						planes[plane].length,
 						vb->planes[plane].min_length,
 						plane);
@@ -1036,7 +1037,7 @@ static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
 				planes[plane].m.userptr,
 				planes[plane].length, q->dma_dir);
 		if (IS_ERR(mem_priv)) {
-			dprintk(1, "failed acquiring userspace memory for plane %d\n",
+			dprintk(q, 1, "failed acquiring userspace memory for plane %d\n",
 				plane);
 			ret = PTR_ERR(mem_priv);
 			goto err;
@@ -1063,14 +1064,14 @@ static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
 		 */
 		ret = call_vb_qop(vb, buf_init, vb);
 		if (ret) {
-			dprintk(1, "buffer initialization failed\n");
+			dprintk(q, 1, "buffer initialization failed\n");
 			goto err;
 		}
 	}
 
 	ret = call_vb_qop(vb, buf_prepare, vb);
 	if (ret) {
-		dprintk(1, "buffer preparation failed\n");
+		dprintk(q, 1, "buffer preparation failed\n");
 		call_void_vb_qop(vb, buf_cleanup, vb);
 		goto err;
 	}
@@ -1115,7 +1116,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 		struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd);
 
 		if (IS_ERR_OR_NULL(dbuf)) {
-			dprintk(1, "invalid dmabuf fd for plane %d\n",
+			dprintk(q, 1, "invalid dmabuf fd for plane %d\n",
 				plane);
 			ret = -EINVAL;
 			goto err;
@@ -1126,7 +1127,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 			planes[plane].length = dbuf->size;
 
 		if (planes[plane].length < vb->planes[plane].min_length) {
-			dprintk(1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
+			dprintk(q, 1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
 				planes[plane].length, plane,
 				vb->planes[plane].min_length);
 			dma_buf_put(dbuf);
@@ -1141,7 +1142,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 			continue;
 		}
 
-		dprintk(3, "buffer for plane %d changed\n", plane);
+		dprintk(q, 3, "buffer for plane %d changed\n", plane);
 
 		if (!reacquired) {
 			reacquired = true;
@@ -1160,7 +1161,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 				q->alloc_devs[plane] ? : q->dev,
 				dbuf, planes[plane].length, q->dma_dir);
 		if (IS_ERR(mem_priv)) {
-			dprintk(1, "failed to attach dmabuf\n");
+			dprintk(q, 1, "failed to attach dmabuf\n");
 			ret = PTR_ERR(mem_priv);
 			dma_buf_put(dbuf);
 			goto err;
@@ -1178,7 +1179,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 	for (plane = 0; plane < vb->num_planes; ++plane) {
 		ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
 		if (ret) {
-			dprintk(1, "failed to map dmabuf for plane %d\n",
+			dprintk(q, 1, "failed to map dmabuf for plane %d\n",
 				plane);
 			goto err;
 		}
@@ -1203,14 +1204,14 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
 		 */
 		ret = call_vb_qop(vb, buf_init, vb);
 		if (ret) {
-			dprintk(1, "buffer initialization failed\n");
+			dprintk(q, 1, "buffer initialization failed\n");
 			goto err;
 		}
 	}
 
 	ret = call_vb_qop(vb, buf_prepare, vb);
 	if (ret) {
-		dprintk(1, "buffer preparation failed\n");
+		dprintk(q, 1, "buffer preparation failed\n");
 		call_void_vb_qop(vb, buf_cleanup, vb);
 		goto err;
 	}
@@ -1245,7 +1246,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const void *pb)
 	int ret;
 
 	if (q->error) {
-		dprintk(1, "fatal error occurred on queue\n");
+		dprintk(q, 1, "fatal error occurred on queue\n");
 		return -EIO;
 	}
 
@@ -1267,7 +1268,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const void *pb)
 	}
 
 	if (ret) {
-		dprintk(1, "buffer preparation failed: %d\n", ret);
+		dprintk(q, 1, "buffer preparation failed: %d\n", ret);
 		vb->state = VB2_BUF_STATE_DEQUEUED;
 		return ret;
 	}
@@ -1288,7 +1289,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
 
 	vb = q->bufs[index];
 	if (vb->state != VB2_BUF_STATE_DEQUEUED) {
-		dprintk(1, "invalid buffer state %d\n",
+		dprintk(q, 1, "invalid buffer state %d\n",
 			vb->state);
 		return -EINVAL;
 	}
@@ -1300,7 +1301,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
 	/* Fill buffer information for the userspace */
 	call_void_bufop(q, fill_user_buffer, vb, pb);
 
-	dprintk(2, "prepare of buffer %d succeeded\n", vb->index);
+	dprintk(q, 2, "prepare of buffer %d succeeded\n", vb->index);
 
 	return ret;
 }
@@ -1338,7 +1339,7 @@ static int vb2_start_streaming(struct vb2_queue *q)
 
 	q->start_streaming_called = 0;
 
-	dprintk(1, "driver refused to start streaming\n");
+	dprintk(q, 1, "driver refused to start streaming\n");
 	/*
 	 * If you see this warning, then the driver isn't cleaning up properly
 	 * after a failed start_streaming(). See the start_streaming()
@@ -1385,10 +1386,10 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
 	case VB2_BUF_STATE_PREPARED:
 		break;
 	case VB2_BUF_STATE_PREPARING:
-		dprintk(1, "buffer still being prepared\n");
+		dprintk(q, 1, "buffer still being prepared\n");
 		return -EINVAL;
 	default:
-		dprintk(1, "invalid buffer state %d\n", vb->state);
+		dprintk(q, 1, "invalid buffer state %d\n", vb->state);
 		return -EINVAL;
 	}
 
@@ -1430,7 +1431,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
 			return ret;
 	}
 
-	dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
+	dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_qbuf);
@@ -1456,17 +1457,17 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		int ret;
 
 		if (!q->streaming) {
-			dprintk(1, "streaming off, will not wait for buffers\n");
+			dprintk(q, 1, "streaming off, will not wait for buffers\n");
 			return -EINVAL;
 		}
 
 		if (q->error) {
-			dprintk(1, "Queue in error state, will not wait for buffers\n");
+			dprintk(q, 1, "Queue in error state, will not wait for buffers\n");
 			return -EIO;
 		}
 
 		if (q->last_buffer_dequeued) {
-			dprintk(3, "last buffer dequeued already, will not wait for buffers\n");
+			dprintk(q, 3, "last buffer dequeued already, will not wait for buffers\n");
 			return -EPIPE;
 		}
 
@@ -1478,7 +1479,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		}
 
 		if (nonblocking) {
-			dprintk(3, "nonblocking and no buffers to dequeue, will not wait\n");
+			dprintk(q, 3, "nonblocking and no buffers to dequeue, will not wait\n");
 			return -EAGAIN;
 		}
 
@@ -1492,7 +1493,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		/*
 		 * All locks have been released, it is safe to sleep now.
 		 */
-		dprintk(3, "will sleep waiting for buffers\n");
+		dprintk(q, 3, "will sleep waiting for buffers\n");
 		ret = wait_event_interruptible(q->done_wq,
 				!list_empty(&q->done_list) || !q->streaming ||
 				q->error);
@@ -1503,7 +1504,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		 */
 		call_void_qop(q, wait_finish, q);
 		if (ret) {
-			dprintk(1, "sleep was interrupted\n");
+			dprintk(q, 1, "sleep was interrupted\n");
 			return ret;
 		}
 	}
@@ -1551,7 +1552,7 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb,
 int vb2_wait_for_all_buffers(struct vb2_queue *q)
 {
 	if (!q->streaming) {
-		dprintk(1, "streaming off, will not wait for buffers\n");
+		dprintk(q, 1, "streaming off, will not wait for buffers\n");
 		return -EINVAL;
 	}
 
@@ -1597,13 +1598,13 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
 
 	switch (vb->state) {
 	case VB2_BUF_STATE_DONE:
-		dprintk(3, "returning done buffer\n");
+		dprintk(q, 3, "returning done buffer\n");
 		break;
 	case VB2_BUF_STATE_ERROR:
-		dprintk(3, "returning done buffer with errors\n");
+		dprintk(q, 3, "returning done buffer with errors\n");
 		break;
 	default:
-		dprintk(1, "invalid buffer state\n");
+		dprintk(q, 1, "invalid buffer state\n");
 		return -EINVAL;
 	}
 
@@ -1625,7 +1626,7 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
 	/* go back to dequeued state */
 	__vb2_dqbuf(vb);
 
-	dprintk(2, "dqbuf of buffer %d, with state %d\n",
+	dprintk(q, 2, "dqbuf of buffer %d, with state %d\n",
 			vb->index, vb->state);
 
 	return 0;
@@ -1718,22 +1719,22 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 	int ret;
 
 	if (type != q->type) {
-		dprintk(1, "invalid stream type\n");
+		dprintk(q, 1, "invalid stream type\n");
 		return -EINVAL;
 	}
 
 	if (q->streaming) {
-		dprintk(3, "already streaming\n");
+		dprintk(q, 3, "already streaming\n");
 		return 0;
 	}
 
 	if (!q->num_buffers) {
-		dprintk(1, "no buffers have been allocated\n");
+		dprintk(q, 1, "no buffers have been allocated\n");
 		return -EINVAL;
 	}
 
 	if (q->num_buffers < q->min_buffers_needed) {
-		dprintk(1, "need at least %u allocated buffers\n",
+		dprintk(q, 1, "need at least %u allocated buffers\n",
 				q->min_buffers_needed);
 		return -EINVAL;
 	}
@@ -1755,7 +1756,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 
 	q->streaming = 1;
 
-	dprintk(3, "successful\n");
+	dprintk(q, 3, "successful\n");
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_streamon);
@@ -1771,7 +1772,7 @@ EXPORT_SYMBOL_GPL(vb2_queue_error);
 int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
 {
 	if (type != q->type) {
-		dprintk(1, "invalid stream type\n");
+		dprintk(q, 1, "invalid stream type\n");
 		return -EINVAL;
 	}
 
@@ -1788,7 +1789,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
 	q->waiting_for_buffers = !q->is_output;
 	q->last_buffer_dequeued = false;
 
-	dprintk(3, "successful\n");
+	dprintk(q, 3, "successful\n");
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_streamoff);
@@ -1831,39 +1832,39 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
 	struct dma_buf *dbuf;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
 	if (!q->mem_ops->get_dmabuf) {
-		dprintk(1, "queue does not support DMA buffer exporting\n");
+		dprintk(q, 1, "queue does not support DMA buffer exporting\n");
 		return -EINVAL;
 	}
 
 	if (flags & ~(O_CLOEXEC | O_ACCMODE)) {
-		dprintk(1, "queue does support only O_CLOEXEC and access mode flags\n");
+		dprintk(q, 1, "queue does support only O_CLOEXEC and access mode flags\n");
 		return -EINVAL;
 	}
 
 	if (type != q->type) {
-		dprintk(1, "invalid buffer type\n");
+		dprintk(q, 1, "invalid buffer type\n");
 		return -EINVAL;
 	}
 
 	if (index >= q->num_buffers) {
-		dprintk(1, "buffer index out of range\n");
+		dprintk(q, 1, "buffer index out of range\n");
 		return -EINVAL;
 	}
 
 	vb = q->bufs[index];
 
 	if (plane >= vb->num_planes) {
-		dprintk(1, "buffer plane out of range\n");
+		dprintk(q, 1, "buffer plane out of range\n");
 		return -EINVAL;
 	}
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "expbuf: file io in progress\n");
+		dprintk(q, 1, "expbuf: file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -1872,20 +1873,20 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
 	dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
 				flags & O_ACCMODE);
 	if (IS_ERR_OR_NULL(dbuf)) {
-		dprintk(1, "failed to export buffer %d, plane %d\n",
+		dprintk(q, 1, "failed to export buffer %d, plane %d\n",
 			index, plane);
 		return -EINVAL;
 	}
 
 	ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE);
 	if (ret < 0) {
-		dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
+		dprintk(q, 3, "buffer %d, plane %d failed to export (%d)\n",
 			index, plane, ret);
 		dma_buf_put(dbuf);
 		return ret;
 	}
 
-	dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
+	dprintk(q, 3, "buffer %d, plane %d exported as %d descriptor\n",
 		index, plane, ret);
 	*fd = ret;
 
@@ -1902,7 +1903,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	unsigned long length;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
@@ -1910,22 +1911,22 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	 * Check memory area access mode.
 	 */
 	if (!(vma->vm_flags & VM_SHARED)) {
-		dprintk(1, "invalid vma flags, VM_SHARED needed\n");
+		dprintk(q, 1, "invalid vma flags, VM_SHARED needed\n");
 		return -EINVAL;
 	}
 	if (q->is_output) {
 		if (!(vma->vm_flags & VM_WRITE)) {
-			dprintk(1, "invalid vma flags, VM_WRITE needed\n");
+			dprintk(q, 1, "invalid vma flags, VM_WRITE needed\n");
 			return -EINVAL;
 		}
 	} else {
 		if (!(vma->vm_flags & VM_READ)) {
-			dprintk(1, "invalid vma flags, VM_READ needed\n");
+			dprintk(q, 1, "invalid vma flags, VM_READ needed\n");
 			return -EINVAL;
 		}
 	}
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "mmap: file io in progress\n");
+		dprintk(q, 1, "mmap: file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -1945,7 +1946,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	 */
 	length = PAGE_ALIGN(vb->planes[plane].length);
 	if (length < (vma->vm_end - vma->vm_start)) {
-		dprintk(1,
+		dprintk(q, 1,
 			"MMAP invalid, as it would overflow buffer length\n");
 		return -EINVAL;
 	}
@@ -1956,7 +1957,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	if (ret)
 		return ret;
 
-	dprintk(3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
+	dprintk(q, 3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_mmap);
@@ -1975,7 +1976,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
 	int ret;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
@@ -2212,7 +2213,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
 	 */
 	count = 1;
 
-	dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
+	dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
 		(read) ? "read" : "write", count, q->fileio_read_once,
 		q->fileio_write_immediately);
 
@@ -2310,7 +2311,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q)
 		fileio->count = 0;
 		vb2_core_reqbufs(q, fileio->memory, &fileio->count);
 		kfree(fileio);
-		dprintk(3, "file io emulator closed\n");
+		dprintk(q, 3, "file io emulator closed\n");
 	}
 	return 0;
 }
@@ -2339,7 +2340,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	unsigned index;
 	int ret;
 
-	dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n",
+	dprintk(q, 3, "mode %s, offset %ld, count %zd, %sblocking\n",
 		read ? "read" : "write", (long)*ppos, count,
 		nonblock ? "non" : "");
 
@@ -2351,7 +2352,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	 */
 	if (!vb2_fileio_is_active(q)) {
 		ret = __vb2_init_fileio(q, read);
-		dprintk(3, "vb2_init_fileio result: %d\n", ret);
+		dprintk(q, 3, "vb2_init_fileio result: %d\n", ret);
 		if (ret)
 			return ret;
 	}
@@ -2368,7 +2369,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		 * Call vb2_dqbuf to get buffer back.
 		 */
 		ret = vb2_core_dqbuf(q, &index, NULL, nonblock);
-		dprintk(5, "vb2_dqbuf result: %d\n", ret);
+		dprintk(q, 5, "vb2_dqbuf result: %d\n", ret);
 		if (ret)
 			return ret;
 		fileio->dq_count += 1;
@@ -2399,20 +2400,20 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	 */
 	if (buf->pos + count > buf->size) {
 		count = buf->size - buf->pos;
-		dprintk(5, "reducing read count: %zd\n", count);
+		dprintk(q, 5, "reducing read count: %zd\n", count);
 	}
 
 	/*
 	 * Transfer data to userspace.
 	 */
-	dprintk(3, "copying %zd bytes - buffer %d, offset %u\n",
+	dprintk(q, 3, "copying %zd bytes - buffer %d, offset %u\n",
 		count, index, buf->pos);
 	if (read)
 		ret = copy_to_user(data, buf->vaddr + buf->pos, count);
 	else
 		ret = copy_from_user(buf->vaddr + buf->pos, data, count);
 	if (ret) {
-		dprintk(3, "error copying data\n");
+		dprintk(q, 3, "error copying data\n");
 		return -EFAULT;
 	}
 
@@ -2432,7 +2433,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		 * Check if this is the last buffer to read.
 		 */
 		if (read && fileio->read_once && fileio->dq_count == 1) {
-			dprintk(3, "read limit reached\n");
+			dprintk(q, 3, "read limit reached\n");
 			return __vb2_cleanup_fileio(q);
 		}
 
@@ -2444,7 +2445,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		if (copy_timestamp)
 			b->timestamp = ktime_get_ns();
 		ret = vb2_core_qbuf(q, index, NULL);
-		dprintk(5, "vb2_dbuf result: %d\n", ret);
+		dprintk(q, 5, "vb2_dbuf result: %d\n", ret);
 		if (ret)
 			return ret;
 
@@ -2531,7 +2532,7 @@ static int vb2_thread(void *data)
 			if (!threadio->stop)
 				ret = vb2_core_dqbuf(q, &index, NULL, 0);
 			call_void_qop(q, wait_prepare, q);
-			dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
+			dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret);
 			if (!ret)
 				vb = q->bufs[index];
 		}
@@ -2585,7 +2586,7 @@ int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
 	threadio->priv = priv;
 
 	ret = __vb2_init_fileio(q, !q->is_output);
-	dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
+	dprintk(q, 3, "file io: vb2_init_fileio result: %d\n", ret);
 	if (ret)
 		goto nomem;
 	q->threadio = threadio;
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 886a2d8d5c6c..9e97bc347b38 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -34,10 +34,11 @@
 static int debug;
 module_param(debug, int, 0644);
 
-#define dprintk(level, fmt, arg...)					      \
+#define dprintk(q, level, fmt, arg...)					      \
 	do {								      \
 		if (debug >= level)					      \
-			pr_info("vb2-v4l2: %s: " fmt, __func__, ## arg); \
+			pr_info("vb2-v4l2: (q=%p) %s: " fmt,		      \
+				q, __func__, ## arg);			      \
 	} while (0)
 
 /* Flags that are set by the vb2 core */
@@ -60,12 +61,14 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
 
 	/* Is memory for copying plane information present? */
 	if (b->m.planes == NULL) {
-		dprintk(1, "multi-planar buffer passed but planes array not provided\n");
+		dprintk(vb->vb2_queue, 1,
+			"multi-planar buffer passed but planes array not provided\n");
 		return -EINVAL;
 	}
 
 	if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
-		dprintk(1, "incorrect planes array length, expected %d, got %d\n",
+		dprintk(vb->vb2_queue, 1,
+			"incorrect planes array length, expected %d, got %d\n",
 			vb->num_planes, b->length);
 		return -EINVAL;
 	}
@@ -158,23 +161,23 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
 				    const char *opname)
 {
 	if (b->type != q->type) {
-		dprintk(1, "%s: invalid buffer type\n", opname);
+		dprintk(q, 1, "%s: invalid buffer type\n", opname);
 		return -EINVAL;
 	}
 
 	if (b->index >= q->num_buffers) {
-		dprintk(1, "%s: buffer index out of range\n", opname);
+		dprintk(q, 1, "%s: buffer index out of range\n", opname);
 		return -EINVAL;
 	}
 
 	if (q->bufs[b->index] == NULL) {
 		/* Should never happen */
-		dprintk(1, "%s: buffer is NULL\n", opname);
+		dprintk(q, 1, "%s: buffer is NULL\n", opname);
 		return -EINVAL;
 	}
 
 	if (b->memory != q->memory) {
-		dprintk(1, "%s: invalid memory type\n", opname);
+		dprintk(q, 1, "%s: invalid memory type\n", opname);
 		return -EINVAL;
 	}
 
@@ -302,7 +305,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
 
 	ret = __verify_length(vb, b);
 	if (ret < 0) {
-		dprintk(1, "plane parameters verification failed: %d\n", ret);
+		dprintk(q, 1, "plane parameters verification failed: %d\n", ret);
 		return ret;
 	}
 	if (b->field == V4L2_FIELD_ALTERNATE && q->is_output) {
@@ -315,7 +318,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
 		 * that just says that it is either a top or a bottom field,
 		 * but not which of the two it is.
 		 */
-		dprintk(1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
+		dprintk(q, 1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
 		return -EINVAL;
 	}
 	vb->timestamp = 0;
@@ -467,12 +470,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
 	int ret;
 
 	if (b->type != q->type) {
-		dprintk(1, "wrong buffer type\n");
+		dprintk(q, 1, "wrong buffer type\n");
 		return -EINVAL;
 	}
 
 	if (b->index >= q->num_buffers) {
-		dprintk(1, "buffer index out of range\n");
+		dprintk(q, 1, "buffer index out of range\n");
 		return -EINVAL;
 	}
 	vb = q->bufs[b->index];
@@ -496,7 +499,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b)
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -565,7 +568,7 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -579,12 +582,12 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
 	if (b->type != q->type) {
-		dprintk(1, "invalid buffer type\n");
+		dprintk(q, 1, "invalid buffer type\n");
 		return -EINVAL;
 	}
 
@@ -603,7 +606,7 @@ EXPORT_SYMBOL_GPL(vb2_dqbuf);
 int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return vb2_core_streamon(q, type);
@@ -613,7 +616,7 @@ EXPORT_SYMBOL_GPL(vb2_streamon);
 int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
 {
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return vb2_core_streamoff(q, type);
-- 
Regards,

Laurent Pinchart

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: vb2: Print the queue pointer in debug messages
  2018-04-26 20:06 [PATCH] media: vb2: Print the queue pointer in debug messages Laurent Pinchart
@ 2018-04-28 11:10 ` kbuild test robot
  2018-04-28 11:33 ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-04-28 11:10 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: kbuild-all, linux-media, paul.elder, Sakari Ailus, Hans Verkuil

[-- Attachment #1: Type: text/plain, Size: 49441 bytes --]

Hi Laurent,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Laurent-Pinchart/media-vb2-Print-the-queue-pointer-in-debug-messages/20180428-184113
base:   git://linuxtv.org/media_tree.git master
config: i386-randconfig-x014-201816 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from drivers/media//common/videobuf2/videobuf2-core.c:20:
   drivers/media//common/videobuf2/videobuf2-core.c: In function '__vb2_buf_mem_alloc':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media//common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
>> drivers/media//common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
--
   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from drivers/media/common/videobuf2/videobuf2-core.c:20:
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_mem_alloc':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^~~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_mem_free':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^~~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_userptr_put':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^~~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_plane_dmabuf_put':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:86:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^~~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_alloc':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:124:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:378:10: note: in expansion of macro 'call_vb_qop'
       ret = call_vb_qop(vb, buf_init, vb);
             ^~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:124:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:378:10: note: in expansion of macro 'call_vb_qop'
       ret = call_vb_qop(vb, buf_init, vb);
             ^~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:124:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:378:10: note: in expansion of macro 'call_vb_qop'
       ret = call_vb_qop(vb, buf_init, vb);
             ^~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_free':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:134:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: note: in expansion of macro 'call_void_vb_qop'
       call_void_vb_qop(vb, buf_cleanup, vb);
       ^~~~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:134:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: note: in expansion of macro 'call_void_vb_qop'
       call_void_vb_qop(vb, buf_cleanup, vb);
       ^~~~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:116:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:134:2: note: in expansion of macro 'log_vb_qop'
     log_vb_qop(vb, op);      \
     ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: note: in expansion of macro 'call_void_vb_qop'
       call_void_vb_qop(vb, buf_cleanup, vb);
       ^~~~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_buffer_in_use':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:63:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:63:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:63:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_plane_vaddr':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^~~~~~~~~~~~~~
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^~~~~~~~~~~~~~
   include/linux/kern_levels.h:5:18: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
    #define KERN_INFO KERN_SOH "6" /* informational */
                      ^~~~~~~~
   include/linux/printk.h:311:9: note: in expansion of macro 'KERN_INFO'
     printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
            ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:40:4: note: in expansion of macro 'pr_info'
       pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
       ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:54:2: note: in expansion of macro 'dprintk'
     dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n", \
     ^~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:75:2: note: in expansion of macro 'log_memop'
     log_memop(vb, op);      \
     ^~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^~~~~~~~~~~~~~
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_plane_cookie':

vim +/pr_info +40 drivers/media//common/videobuf2/videobuf2-core.c

    36	
    37	#define dprintk(q, level, fmt, arg...)					\
    38		do {								\
    39			if (debug >= level)					\
  > 40				pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
    41		} while (0)
    42	
    43	#ifdef CONFIG_VIDEO_ADV_DEBUG
    44	
    45	/*
    46	 * If advanced debugging is on, then count how often each op is called
    47	 * successfully, which can either be per-buffer or per-queue.
    48	 *
    49	 * This makes it easy to check that the 'init' and 'cleanup'
    50	 * (and variations thereof) stay balanced.
    51	 */
    52	
    53	#define log_memop(vb, op)						\
  > 54		dprintk((vb)->vb2_queue, 2, "call_memop(%p, %d, %s)%s\n",	\
    55			(vb)->index, #op,					\
    56			(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
    57	
    58	#define call_memop(vb, op, args...)					\
    59	({									\
    60		struct vb2_queue *_q = (vb)->vb2_queue;				\
    61		int err;							\
    62										\
    63		log_memop(vb, op);						\
    64		err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0;		\
    65		if (!err)							\
    66			(vb)->cnt_mem_ ## op++;					\
    67		err;								\
    68	})
    69	
    70	#define call_ptr_memop(vb, op, args...)					\
    71	({									\
    72		struct vb2_queue *_q = (vb)->vb2_queue;				\
    73		void *ptr;							\
    74										\
  > 75		log_memop(vb, op);						\
    76		ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL;		\
    77		if (!IS_ERR_OR_NULL(ptr))					\
    78			(vb)->cnt_mem_ ## op++;					\
    79		ptr;								\
    80	})
    81	
    82	#define call_void_memop(vb, op, args...)				\
    83	({									\
    84		struct vb2_queue *_q = (vb)->vb2_queue;				\
    85										\
    86		log_memop(vb, op);						\
    87		if (_q->mem_ops->op)						\
    88			_q->mem_ops->op(args);					\
    89		(vb)->cnt_mem_ ## op++;						\
    90	})
    91	
    92	#define log_qop(q, op)							\
    93		dprintk(q, 2, "call_qop(%p, %s)%s\n", q, #op,			\
    94			(q)->ops->op ? "" : " (nop)")
    95	
    96	#define call_qop(q, op, args...)					\
    97	({									\
    98		int err;							\
    99										\
   100		log_qop(q, op);							\
   101		err = (q)->ops->op ? (q)->ops->op(args) : 0;			\
   102		if (!err)							\
   103			(q)->cnt_ ## op++;					\
   104		err;								\
   105	})
   106	
   107	#define call_void_qop(q, op, args...)					\
   108	({									\
   109		log_qop(q, op);							\
   110		if ((q)->ops->op)						\
   111			(q)->ops->op(args);					\
   112		(q)->cnt_ ## op++;						\
   113	})
   114	
   115	#define log_vb_qop(vb, op, args...)					\
   116		dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n",	\
   117			(vb)->index, #op,					\
   118			(vb)->vb2_queue->ops->op ? "" : " (nop)")
   119	
   120	#define call_vb_qop(vb, op, args...)					\
   121	({									\
   122		int err;							\
   123										\
 > 124		log_vb_qop(vb, op);						\
   125		err = (vb)->vb2_queue->ops->op ?				\
   126			(vb)->vb2_queue->ops->op(args) : 0;			\
   127		if (!err)							\
   128			(vb)->cnt_ ## op++;					\
   129		err;								\
   130	})
   131	
   132	#define call_void_vb_qop(vb, op, args...)				\
   133	({									\
   134		log_vb_qop(vb, op);						\
   135		if ((vb)->vb2_queue->ops->op)					\
   136			(vb)->vb2_queue->ops->op(args);				\
   137		(vb)->cnt_ ## op++;						\
   138	})
   139	
   140	#else
   141	
   142	#define call_memop(vb, op, args...)					\
   143		((vb)->vb2_queue->mem_ops->op ?					\
   144			(vb)->vb2_queue->mem_ops->op(args) : 0)
   145	
   146	#define call_ptr_memop(vb, op, args...)					\
   147		((vb)->vb2_queue->mem_ops->op ?					\
   148			(vb)->vb2_queue->mem_ops->op(args) : NULL)
   149	
   150	#define call_void_memop(vb, op, args...)				\
   151		do {								\
   152			if ((vb)->vb2_queue->mem_ops->op)			\
   153				(vb)->vb2_queue->mem_ops->op(args);		\
   154		} while (0)
   155	
   156	#define call_qop(q, op, args...)					\
   157		((q)->ops->op ? (q)->ops->op(args) : 0)
   158	
   159	#define call_void_qop(q, op, args...)					\
   160		do {								\
   161			if ((q)->ops->op)					\
   162				(q)->ops->op(args);				\
   163		} while (0)
   164	
   165	#define call_vb_qop(vb, op, args...)					\
   166		((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
   167	
   168	#define call_void_vb_qop(vb, op, args...)				\
   169		do {								\
   170			if ((vb)->vb2_queue->ops->op)				\
   171				(vb)->vb2_queue->ops->op(args);			\
   172		} while (0)
   173	
   174	#endif
   175	
   176	#define call_bufop(q, op, args...)					\
   177	({									\
   178		int ret = 0;							\
   179		if (q && q->buf_ops && q->buf_ops->op)				\
   180			ret = q->buf_ops->op(args);				\
   181		ret;								\
   182	})
   183	
   184	#define call_void_bufop(q, op, args...)					\
   185	({									\
   186		if (q && q->buf_ops && q->buf_ops->op)				\
   187			q->buf_ops->op(args);					\
   188	})
   189	
   190	static void __vb2_queue_cancel(struct vb2_queue *q);
   191	static void __enqueue_in_driver(struct vb2_buffer *vb);
   192	
   193	/*
   194	 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
   195	 */
   196	static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
   197	{
   198		struct vb2_queue *q = vb->vb2_queue;
   199		void *mem_priv;
   200		int plane;
   201		int ret = -ENOMEM;
   202	
   203		/*
   204		 * Allocate memory for all planes in this buffer
   205		 * NOTE: mmapped areas should be page aligned
   206		 */
   207		for (plane = 0; plane < vb->num_planes; ++plane) {
   208			unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
   209	
 > 210			mem_priv = call_ptr_memop(vb, alloc,
   211					q->alloc_devs[plane] ? : q->dev,
   212					q->dma_attrs, size, q->dma_dir, q->gfp_flags);
   213			if (IS_ERR_OR_NULL(mem_priv)) {
   214				if (mem_priv)
   215					ret = PTR_ERR(mem_priv);
   216				goto free;
   217			}
   218	
   219			/* Associate allocator private data with this plane */
   220			vb->planes[plane].mem_priv = mem_priv;
   221		}
   222	
   223		return 0;
   224	free:
   225		/* Free already allocated memory if one of the allocations failed */
   226		for (; plane > 0; --plane) {
 > 227			call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
   228			vb->planes[plane - 1].mem_priv = NULL;
   229		}
   230	
   231		return ret;
   232	}
   233	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26036 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: vb2: Print the queue pointer in debug messages
  2018-04-26 20:06 [PATCH] media: vb2: Print the queue pointer in debug messages Laurent Pinchart
  2018-04-28 11:10 ` kbuild test robot
@ 2018-04-28 11:33 ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-04-28 11:33 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: kbuild-all, linux-media, paul.elder, Sakari Ailus, Hans Verkuil

[-- Attachment #1: Type: text/plain, Size: 53371 bytes --]

Hi Laurent,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Laurent-Pinchart/media-vb2-Print-the-queue-pointer-in-debug-messages/20180428-184113
base:   git://linuxtv.org/media_tree.git master
config: i386-randconfig-a1-201816 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_mem_alloc':
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:210:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, alloc,
                 ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:227:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_mem_free':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:242:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, put, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_buf_userptr_put':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:259:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_plane_dmabuf_put':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:274:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, unmap_dmabuf, p->mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:276:2: note: in expansion of macro 'call_void_memop'
     call_void_memop(vb, detach_dmabuf, p->mem_priv);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_alloc':
   drivers/media/common/videobuf2/videobuf2-core.c:378:4: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
       ret = call_vb_qop(vb, buf_init, vb);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:378:4: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:378:4: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_free':
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
       call_void_vb_qop(vb, buf_cleanup, vb);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:453:4: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_buffer_in_use':
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:547:19: note: in expansion of macro 'call_memop'
      if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
                      ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_plane_vaddr':
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:881:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
            ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_plane_cookie':
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:891:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv);
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:891:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv);
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:891:9: note: in expansion of macro 'call_ptr_memop'
     return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv);
            ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_buffer_done':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:922:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, finish, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:922:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, finish, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:922:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, finish, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__prepare_mmap':
   drivers/media/common/videobuf2/videobuf2-core.c:975:2: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     return ret ? ret : call_vb_qop(vb, buf_prepare, vb);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:975:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:975:2: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__prepare_userptr':
   drivers/media/common/videobuf2/videobuf2-core.c:1023:5: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
        call_void_vb_qop(vb, buf_cleanup, vb);
        ^
   drivers/media/common/videobuf2/videobuf2-core.c:1023:5: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1023:5: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1025:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1025:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1025:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
       ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1035:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, get_userptr,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1035:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, get_userptr,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1035:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, get_userptr,
                 ^
   drivers/media/common/videobuf2/videobuf2-core.c:1065:3: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
      ret = call_vb_qop(vb, buf_init, vb);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:1065:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1065:3: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1072:2: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     ret = call_vb_qop(vb, buf_prepare, vb);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:1072:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1072:2: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1075:3: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
      call_void_vb_qop(vb, buf_cleanup, vb);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:1075:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1075:3: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1084:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr,
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1084:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr,
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1084:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, put_userptr,
       ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__prepare_dmabuf':
   drivers/media/common/videobuf2/videobuf2-core.c:1149:4: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
       call_void_vb_qop(vb, buf_cleanup, vb);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:1149:4: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1149:4: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1160:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, attach_dmabuf,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1160:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, attach_dmabuf,
                 ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1160:14: note: in expansion of macro 'call_ptr_memop'
      mem_priv = call_ptr_memop(vb, attach_dmabuf,
                 ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1180:9: note: in expansion of macro 'call_memop'
      ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1180:9: note: in expansion of macro 'call_memop'
      ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1180:9: note: in expansion of macro 'call_memop'
      ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1205:3: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
      ret = call_vb_qop(vb, buf_init, vb);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:1205:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1205:3: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1212:2: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     ret = call_vb_qop(vb, buf_prepare, vb);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:1212:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1212:2: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1215:3: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
      call_void_vb_qop(vb, buf_cleanup, vb);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:1215:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1215:3: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__enqueue_in_driver':
   drivers/media/common/videobuf2/videobuf2-core.c:1239:2: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     call_void_vb_qop(vb, buf_queue, vb);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:1239:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1239:2: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__buf_prepare':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1278:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1278:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1278:3: note: in expansion of macro 'call_void_memop'
      call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
      ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_dqbuf':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1584:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1584:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1584:4: note: in expansion of macro 'call_void_memop'
       call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_core_dqbuf':
   drivers/media/common/videobuf2/videobuf2-core.c:1611:2: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     call_void_vb_qop(vb, buf_finish, vb);
     ^
   drivers/media/common/videobuf2/videobuf2-core.c:1611:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1611:2: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_cancel':
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1705:5: note: in expansion of macro 'call_void_memop'
        call_void_memop(vb, finish,
        ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1705:5: note: in expansion of macro 'call_void_memop'
        call_void_memop(vb, finish,
        ^
   drivers/media/common/videobuf2/videobuf2-core.c:84:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1705:5: note: in expansion of macro 'call_void_memop'
        call_void_memop(vb, finish,
        ^
   drivers/media/common/videobuf2/videobuf2-core.c:1711:4: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
       call_void_vb_qop(vb, buf_finish, vb);
       ^
   drivers/media/common/videobuf2/videobuf2-core.c:1711:4: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c:1711:4: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_core_expbuf':
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1873:9: note: in expansion of macro 'call_ptr_memop'
     dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1873:9: note: in expansion of macro 'call_ptr_memop'
     dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
            ^
>> drivers/media/common/videobuf2/videobuf2-core.c:72:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1873:9: note: in expansion of macro 'call_ptr_memop'
     dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
            ^
   drivers/media/common/videobuf2/videobuf2-core.c: In function 'vb2_mmap':
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'unsigned int' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1955:8: note: in expansion of macro 'call_memop'
     ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
           ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%d' expects argument of type 'int', but argument 5 has type 'char *' [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1955:8: note: in expansion of macro 'call_memop'
     ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
           ^
   drivers/media/common/videobuf2/videobuf2-core.c:60:9: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     struct vb2_queue *_q = (vb)->vb2_queue;    \
            ^
   drivers/media/common/videobuf2/videobuf2-core.c:1955:8: note: in expansion of macro 'call_memop'
     ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
           ^

vim +72 drivers/media/common/videobuf2/videobuf2-core.c

af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   69  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   70  #define call_ptr_memop(vb, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   71  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  @72  	struct vb2_queue *_q = (vb)->vb2_queue;				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   73  	void *ptr;							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   74  									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   75  	log_memop(vb, op);						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   76  	ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL;		\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   77  	if (!IS_ERR_OR_NULL(ptr))					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   78  		(vb)->cnt_mem_ ## op++;					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   79  	ptr;								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   80  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   81  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   82  #define call_void_memop(vb, op, args...)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   83  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   84  	struct vb2_queue *_q = (vb)->vb2_queue;				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   85  									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   86  	log_memop(vb, op);						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   87  	if (_q->mem_ops->op)						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   88  		_q->mem_ops->op(args);					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   89  	(vb)->cnt_mem_ ## op++;						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   90  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   91  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   92  #define log_qop(q, op)							\
5291e8a263 drivers/media/common/videobuf2/videobuf2-core.c Laurent Pinchart      2018-04-26   93  	dprintk(q, 2, "call_qop(%p, %s)%s\n", q, #op,			\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   94  		(q)->ops->op ? "" : " (nop)")
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   95  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   96  #define call_qop(q, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   97  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   98  	int err;							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03   99  									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  100  	log_qop(q, op);							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  101  	err = (q)->ops->op ? (q)->ops->op(args) : 0;			\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  102  	if (!err)							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  103  		(q)->cnt_ ## op++;					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  104  	err;								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  105  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  106  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  107  #define call_void_qop(q, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  108  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  109  	log_qop(q, op);							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  110  	if ((q)->ops->op)						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  111  		(q)->ops->op(args);					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  112  	(q)->cnt_ ## op++;						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  113  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  114  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  115  #define log_vb_qop(vb, op, args...)					\
5291e8a263 drivers/media/common/videobuf2/videobuf2-core.c Laurent Pinchart      2018-04-26  116  	dprintk((vb)->vb2_queue, 2, "call_vb_qop(%p, %d, %s)%s\n",	\
5291e8a263 drivers/media/common/videobuf2/videobuf2-core.c Laurent Pinchart      2018-04-26  117  		(vb)->index, #op,					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  118  		(vb)->vb2_queue->ops->op ? "" : " (nop)")
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  119  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  120  #define call_vb_qop(vb, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  121  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  122  	int err;							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  123  									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  124  	log_vb_qop(vb, op);						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  125  	err = (vb)->vb2_queue->ops->op ?				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  126  		(vb)->vb2_queue->ops->op(args) : 0;			\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  127  	if (!err)							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  128  		(vb)->cnt_ ## op++;					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  129  	err;								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  130  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  131  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  132  #define call_void_vb_qop(vb, op, args...)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  133  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  134  	log_vb_qop(vb, op);						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  135  	if ((vb)->vb2_queue->ops->op)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  136  		(vb)->vb2_queue->ops->op(args);				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  137  	(vb)->cnt_ ## op++;						\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  138  })
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  139  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  140  #else
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  141  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  142  #define call_memop(vb, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  143  	((vb)->vb2_queue->mem_ops->op ?					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  144  		(vb)->vb2_queue->mem_ops->op(args) : 0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  145  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  146  #define call_ptr_memop(vb, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  147  	((vb)->vb2_queue->mem_ops->op ?					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  148  		(vb)->vb2_queue->mem_ops->op(args) : NULL)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  149  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  150  #define call_void_memop(vb, op, args...)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  151  	do {								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  152  		if ((vb)->vb2_queue->mem_ops->op)			\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  153  			(vb)->vb2_queue->mem_ops->op(args);		\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  154  	} while (0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  155  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  156  #define call_qop(q, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  157  	((q)->ops->op ? (q)->ops->op(args) : 0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  158  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  159  #define call_void_qop(q, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  160  	do {								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  161  		if ((q)->ops->op)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  162  			(q)->ops->op(args);				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  163  	} while (0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  164  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  165  #define call_vb_qop(vb, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  166  	((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  167  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  168  #define call_void_vb_qop(vb, op, args...)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  169  	do {								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  170  		if ((vb)->vb2_queue->ops->op)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  171  			(vb)->vb2_queue->ops->op(args);			\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  172  	} while (0)
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  173  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  174  #endif
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  175  
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  176  #define call_bufop(q, op, args...)					\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  177  ({									\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  178  	int ret = 0;							\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  179  	if (q && q->buf_ops && q->buf_ops->op)				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  180  		ret = q->buf_ops->op(args);				\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  181  	ret;								\
af3bac1a7c drivers/media/v4l2-core/videobuf2-core.c        Junghak Sung          2015-11-03  182  })
ea42c8ecb2 drivers/media/video/videobuf2-core.c            Marek Szyprowski      2011-04-12  183  
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  184  #define call_void_bufop(q, op, args...)					\
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  185  ({									\
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  186  	if (q && q->buf_ops && q->buf_ops->op)				\
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  187  		q->buf_ops->op(args);					\
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  188  })
10cc3b1e12 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  189  
fb64dca805 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2014-02-28  190  static void __vb2_queue_cancel(struct vb2_queue *q);
ce0eff016f drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-01-20  191  static void __enqueue_in_driver(struct vb2_buffer *vb);
fb64dca805 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2014-02-28  192  
2a87af6ba1 drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2017-11-27  193  /*
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  194   * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  195   */
c1426bc727 drivers/media/video/videobuf2-core.c            Marek Szyprowski      2011-08-24  196  static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  197  {
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  198  	struct vb2_queue *q = vb->vb2_queue;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  199  	void *mem_priv;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  200  	int plane;
0ff657b0f6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-07-21  201  	int ret = -ENOMEM;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  202  
7f8414594e drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2013-04-19  203  	/*
7f8414594e drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2013-04-19  204  	 * Allocate memory for all planes in this buffer
7f8414594e drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2013-04-19  205  	 * NOTE: mmapped areas should be page aligned
7f8414594e drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2013-04-19  206  	 */
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  207  	for (plane = 0; plane < vb->num_planes; ++plane) {
58e1ba3ce6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-11-20  208  		unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
7f8414594e drivers/media/v4l2-core/videobuf2-core.c        Mauro Carvalho Chehab 2013-04-19  209  
20be7ab8db drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2015-12-16 @210  		mem_priv = call_ptr_memop(vb, alloc,
36c0f8b32c drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-04-15  211  				q->alloc_devs[plane] ? : q->dev,
5b6f9abe5a drivers/media/v4l2-core/videobuf2-core.c        Stanimir Varbanov     2017-08-21  212  				q->dma_attrs, size, q->dma_dir, q->gfp_flags);
72b7876c2e drivers/media/v4l2-core/videobuf2-core.c        Christophe JAILLET    2017-04-23  213  		if (IS_ERR_OR_NULL(mem_priv)) {
0ff657b0f6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-07-21  214  			if (mem_priv)
0ff657b0f6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-07-21  215  				ret = PTR_ERR(mem_priv);
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  216  			goto free;
0ff657b0f6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-07-21  217  		}
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  218  
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  219  		/* Associate allocator private data with this plane */
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  220  		vb->planes[plane].mem_priv = mem_priv;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  221  	}
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  222  
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  223  	return 0;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  224  free:
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  225  	/* Free already allocated memory if one of the allocations failed */
a00d026637 drivers/media/video/videobuf2-core.c            Marek Szyprowski      2011-12-15  226  	for (; plane > 0; --plane) {
a1d36d8c70 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2014-03-17  227  		call_void_memop(vb, put, vb->planes[plane - 1].mem_priv);
a00d026637 drivers/media/video/videobuf2-core.c            Marek Szyprowski      2011-12-15  228  		vb->planes[plane - 1].mem_priv = NULL;
a00d026637 drivers/media/video/videobuf2-core.c            Marek Szyprowski      2011-12-15  229  	}
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  230  
0ff657b0f6 drivers/media/v4l2-core/videobuf2-core.c        Hans Verkuil          2016-07-21  231  	return ret;
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  232  }
e23ccc0ad9 drivers/media/video/videobuf2-core.c            Pawel Osciak          2010-10-11  233  

:::::: The code at line 72 was first introduced by commit
:::::: af3bac1a7c8a21ff4f4edede397cba8e3f8ee503 [media] media: videobuf2: Move vb2_fileio_data and vb2_thread to core part

:::::: TO: Junghak Sung <jh1009.sung@samsung.com>
:::::: CC: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30914 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: vb2: Print the queue pointer in debug messages
  2019-06-08 12:38 Laurent Pinchart
@ 2019-06-11  9:46 ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2019-06-11  9:46 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media

Hi Laurent,

On 6/8/19 2:38 PM, Laurent Pinchart wrote:
> When debugging issues that involve more than one video queue, messages
> related to multiple queues get interleaved without any easy way to tell
> which queue they relate to. Fix this by printing the queue pointer for
> all debug messages in the vb2 core and V4L2 layers.

I like the idea, but I think it can be done better:

I'd suggest adding a name field to struct vb2_queue. In vb2_core_queue_init()
you check if name was set, and if not, then fill it with e.g.:

snprintf(q->name, sizeof(q->name), "%s-%p",
	 q->is_output ? "out" : "cap", q);

The out/cap prefix is very useful for debugging m2m devices.

Perhaps we should also introduce a vb2_queue_init_name() so drivers can
specify a name for the queue.

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> Changes since v1:
> 
> - Fix format specifiers in vb2 ops-related macros
> ---
>  .../media/common/videobuf2/videobuf2-core.c   | 219 +++++++++---------
>  .../media/common/videobuf2/videobuf2-v4l2.c   |  55 ++---
>  2 files changed, 139 insertions(+), 135 deletions(-)
> 
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index 4489744fbbd9..05677ebdb21f 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -34,10 +34,10 @@
>  static int debug;
>  module_param(debug, int, 0644);
>  
> -#define dprintk(level, fmt, arg...)				\
> -	do {							\
> -		if (debug >= level)				\
> -			pr_info("%s: " fmt, __func__, ## arg);	\
> +#define dprintk(q, level, fmt, arg...)					\
> +	do {								\
> +		if (debug >= level)					\
> +			pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\

And with the proposed change I'd change this to:

			pr_info("%s %s: " fmt, (q)->name, __func__, ## arg);\

Regards,

	Hans

>  	} while (0)
>  
>  #ifdef CONFIG_VIDEO_ADV_DEBUG
> @@ -51,8 +51,8 @@ module_param(debug, int, 0644);
>   */
>  
>  #define log_memop(vb, op)						\
> -	dprintk(2, "call_memop(%p, %d, %s)%s\n",			\
> -		(vb)->vb2_queue, (vb)->index, #op,			\
> +	dprintk((vb)->vb2_queue, 2, "call_memop(%d, %s)%s\n",		\
> +		(vb)->index, #op,					\
>  		(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
>  
>  #define call_memop(vb, op, args...)					\
> @@ -90,7 +90,7 @@ module_param(debug, int, 0644);
>  })
>  
>  #define log_qop(q, op)							\
> -	dprintk(2, "call_qop(%p, %s)%s\n", q, #op,			\
> +	dprintk(q, 2, "call_qop(%s)%s\n", #op,				\
>  		(q)->ops->op ? "" : " (nop)")
>  
>  #define call_qop(q, op, args...)					\
> @@ -113,8 +113,8 @@ module_param(debug, int, 0644);
>  })
>  
>  #define log_vb_qop(vb, op, args...)					\
> -	dprintk(2, "call_vb_qop(%p, %d, %s)%s\n",			\
> -		(vb)->vb2_queue, (vb)->index, #op,			\
> +	dprintk((vb)->vb2_queue, 2, "call_vb_qop(%d, %s)%s\n",		\
> +		(vb)->index, #op,					\
>  		(vb)->vb2_queue->ops->op ? "" : " (nop)")
>  
>  #define call_vb_qop(vb, op, args...)					\
> @@ -246,7 +246,8 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
>  	for (plane = 0; plane < vb->num_planes; ++plane) {
>  		call_void_memop(vb, put, vb->planes[plane].mem_priv);
>  		vb->planes[plane].mem_priv = NULL;
> -		dprintk(3, "freed plane %d of buffer %d\n", plane, vb->index);
> +		dprintk(vb->vb2_queue, 3, "freed plane %d of buffer %d\n",
> +			plane, vb->index);
>  	}
>  }
>  
> @@ -316,7 +317,7 @@ static void __setup_offsets(struct vb2_buffer *vb)
>  	for (plane = 0; plane < vb->num_planes; ++plane) {
>  		vb->planes[plane].m.offset = off;
>  
> -		dprintk(3, "buffer %d, plane %d offset 0x%08lx\n",
> +		dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n",
>  				vb->index, plane, off);
>  
>  		off += vb->planes[plane].length;
> @@ -347,7 +348,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
>  		/* Allocate videobuf buffer structures */
>  		vb = kzalloc(q->buf_struct_size, GFP_KERNEL);
>  		if (!vb) {
> -			dprintk(1, "memory alloc for buffer struct failed\n");
> +			dprintk(q, 1, "memory alloc for buffer struct failed\n");
>  			break;
>  		}
>  
> @@ -369,7 +370,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
>  		if (memory == VB2_MEMORY_MMAP) {
>  			ret = __vb2_buf_mem_alloc(vb);
>  			if (ret) {
> -				dprintk(1, "failed allocating memory for buffer %d\n",
> +				dprintk(q, 1, "failed allocating memory for buffer %d\n",
>  					buffer);
>  				q->bufs[vb->index] = NULL;
>  				kfree(vb);
> @@ -383,7 +384,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
>  			 */
>  			ret = call_vb_qop(vb, buf_init, vb);
>  			if (ret) {
> -				dprintk(1, "buffer %d %p initialization failed\n",
> +				dprintk(q, 1, "buffer %d %p initialization failed\n",
>  					buffer, vb);
>  				__vb2_buf_mem_free(vb);
>  				q->bufs[vb->index] = NULL;
> @@ -393,7 +394,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
>  		}
>  	}
>  
> -	dprintk(1, "allocated %d buffers, %d plane(s) each\n",
> +	dprintk(q, 1, "allocated %d buffers, %d plane(s) each\n",
>  			buffer, num_planes);
>  
>  	return buffer;
> @@ -445,7 +446,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
>  		if (q->bufs[buffer] == NULL)
>  			continue;
>  		if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) {
> -			dprintk(1, "preparing buffers, cannot free\n");
> +			dprintk(q, 1, "preparing buffers, cannot free\n");
>  			return -EAGAIN;
>  		}
>  	}
> @@ -623,12 +624,12 @@ int vb2_verify_memory_type(struct vb2_queue *q,
>  {
>  	if (memory != VB2_MEMORY_MMAP && memory != VB2_MEMORY_USERPTR &&
>  	    memory != VB2_MEMORY_DMABUF) {
> -		dprintk(1, "unsupported memory type\n");
> +		dprintk(q, 1, "unsupported memory type\n");
>  		return -EINVAL;
>  	}
>  
>  	if (type != q->type) {
> -		dprintk(1, "requested type is incorrect\n");
> +		dprintk(q, 1, "requested type is incorrect\n");
>  		return -EINVAL;
>  	}
>  
> @@ -637,17 +638,17 @@ int vb2_verify_memory_type(struct vb2_queue *q,
>  	 * are available.
>  	 */
>  	if (memory == VB2_MEMORY_MMAP && __verify_mmap_ops(q)) {
> -		dprintk(1, "MMAP for current setup unsupported\n");
> +		dprintk(q, 1, "MMAP for current setup unsupported\n");
>  		return -EINVAL;
>  	}
>  
>  	if (memory == VB2_MEMORY_USERPTR && __verify_userptr_ops(q)) {
> -		dprintk(1, "USERPTR for current setup unsupported\n");
> +		dprintk(q, 1, "USERPTR for current setup unsupported\n");
>  		return -EINVAL;
>  	}
>  
>  	if (memory == VB2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
> -		dprintk(1, "DMABUF for current setup unsupported\n");
> +		dprintk(q, 1, "DMABUF for current setup unsupported\n");
>  		return -EINVAL;
>  	}
>  
> @@ -657,7 +658,7 @@ int vb2_verify_memory_type(struct vb2_queue *q,
>  	 * do the memory and type validation.
>  	 */
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  	return 0;
> @@ -673,12 +674,12 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  	int ret;
>  
>  	if (q->streaming) {
> -		dprintk(1, "streaming active\n");
> +		dprintk(q, 1, "streaming active\n");
>  		return -EBUSY;
>  	}
>  
>  	if (q->waiting_in_dqbuf && *count) {
> -		dprintk(1, "another dup()ped fd is waiting for a buffer\n");
> +		dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
>  		return -EBUSY;
>  	}
>  
> @@ -691,7 +692,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  		mutex_lock(&q->mmap_lock);
>  		if (debug && q->memory == VB2_MEMORY_MMAP &&
>  		    __buffers_in_use(q))
> -			dprintk(1, "memory in use, orphaning buffers\n");
> +			dprintk(q, 1, "memory in use, orphaning buffers\n");
>  
>  		/*
>  		 * Call queue_cancel to clean up any buffers in the
> @@ -742,7 +743,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  	allocated_buffers =
>  		__vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes);
>  	if (allocated_buffers == 0) {
> -		dprintk(1, "memory allocation failed\n");
> +		dprintk(q, 1, "memory allocation failed\n");
>  		return -ENOMEM;
>  	}
>  
> @@ -812,20 +813,20 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
>  	int ret;
>  
>  	if (q->num_buffers == VB2_MAX_FRAME) {
> -		dprintk(1, "maximum number of buffers already allocated\n");
> +		dprintk(q, 1, "maximum number of buffers already allocated\n");
>  		return -ENOBUFS;
>  	}
>  
>  	if (!q->num_buffers) {
>  		if (q->waiting_in_dqbuf && *count) {
> -			dprintk(1, "another dup()ped fd is waiting for a buffer\n");
> +			dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
>  			return -EBUSY;
>  		}
>  		memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
>  		q->memory = memory;
>  		q->waiting_for_buffers = !q->is_output;
>  	} else if (q->memory != memory) {
> -		dprintk(1, "memory model mismatch\n");
> +		dprintk(q, 1, "memory model mismatch\n");
>  		return -EINVAL;
>  	}
>  
> @@ -849,7 +850,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
>  	allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers,
>  				num_planes, plane_sizes);
>  	if (allocated_buffers == 0) {
> -		dprintk(1, "memory allocation failed\n");
> +		dprintk(q, 1, "memory allocation failed\n");
>  		return -ENOMEM;
>  	}
>  
> @@ -939,7 +940,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
>  	 */
>  	vb->cnt_buf_done++;
>  #endif
> -	dprintk(4, "done processing on buffer %d, state: %d\n",
> +	dprintk(q, 4, "done processing on buffer %d, state: %d\n",
>  			vb->index, state);
>  
>  	if (state != VB2_BUF_STATE_QUEUED) {
> @@ -1029,12 +1030,12 @@ static int __prepare_userptr(struct vb2_buffer *vb)
>  			&& vb->planes[plane].length == planes[plane].length)
>  			continue;
>  
> -		dprintk(3, "userspace address for plane %d changed, reacquiring memory\n",
> +		dprintk(q, 3, "userspace address for plane %d changed, reacquiring memory\n",
>  			plane);
>  
>  		/* Check if the provided plane buffer is large enough */
>  		if (planes[plane].length < vb->planes[plane].min_length) {
> -			dprintk(1, "provided buffer size %u is less than setup size %u for plane %d\n",
> +			dprintk(q, 1, "provided buffer size %u is less than setup size %u for plane %d\n",
>  						planes[plane].length,
>  						vb->planes[plane].min_length,
>  						plane);
> @@ -1064,7 +1065,7 @@ static int __prepare_userptr(struct vb2_buffer *vb)
>  				planes[plane].m.userptr,
>  				planes[plane].length, q->dma_dir);
>  		if (IS_ERR(mem_priv)) {
> -			dprintk(1, "failed acquiring userspace memory for plane %d\n",
> +			dprintk(q, 1, "failed acquiring userspace memory for plane %d\n",
>  				plane);
>  			ret = PTR_ERR(mem_priv);
>  			goto err;
> @@ -1091,14 +1092,14 @@ static int __prepare_userptr(struct vb2_buffer *vb)
>  		 */
>  		ret = call_vb_qop(vb, buf_init, vb);
>  		if (ret) {
> -			dprintk(1, "buffer initialization failed\n");
> +			dprintk(q, 1, "buffer initialization failed\n");
>  			goto err;
>  		}
>  	}
>  
>  	ret = call_vb_qop(vb, buf_prepare, vb);
>  	if (ret) {
> -		dprintk(1, "buffer preparation failed\n");
> +		dprintk(q, 1, "buffer preparation failed\n");
>  		call_void_vb_qop(vb, buf_cleanup, vb);
>  		goto err;
>  	}
> @@ -1141,7 +1142,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  		struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd);
>  
>  		if (IS_ERR_OR_NULL(dbuf)) {
> -			dprintk(1, "invalid dmabuf fd for plane %d\n",
> +			dprintk(q, 1, "invalid dmabuf fd for plane %d\n",
>  				plane);
>  			ret = -EINVAL;
>  			goto err;
> @@ -1152,7 +1153,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  			planes[plane].length = dbuf->size;
>  
>  		if (planes[plane].length < vb->planes[plane].min_length) {
> -			dprintk(1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
> +			dprintk(q, 1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
>  				planes[plane].length, plane,
>  				vb->planes[plane].min_length);
>  			dma_buf_put(dbuf);
> @@ -1167,7 +1168,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  			continue;
>  		}
>  
> -		dprintk(3, "buffer for plane %d changed\n", plane);
> +		dprintk(q, 3, "buffer for plane %d changed\n", plane);
>  
>  		if (!reacquired) {
>  			reacquired = true;
> @@ -1187,7 +1188,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  				q->alloc_devs[plane] ? : q->dev,
>  				dbuf, planes[plane].length, q->dma_dir);
>  		if (IS_ERR(mem_priv)) {
> -			dprintk(1, "failed to attach dmabuf\n");
> +			dprintk(q, 1, "failed to attach dmabuf\n");
>  			ret = PTR_ERR(mem_priv);
>  			dma_buf_put(dbuf);
>  			goto err;
> @@ -1208,7 +1209,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  
>  		ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
>  		if (ret) {
> -			dprintk(1, "failed to map dmabuf for plane %d\n",
> +			dprintk(q, 1, "failed to map dmabuf for plane %d\n",
>  				plane);
>  			goto err;
>  		}
> @@ -1233,14 +1234,14 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
>  		 */
>  		ret = call_vb_qop(vb, buf_init, vb);
>  		if (ret) {
> -			dprintk(1, "buffer initialization failed\n");
> +			dprintk(q, 1, "buffer initialization failed\n");
>  			goto err;
>  		}
>  	}
>  
>  	ret = call_vb_qop(vb, buf_prepare, vb);
>  	if (ret) {
> -		dprintk(1, "buffer preparation failed\n");
> +		dprintk(q, 1, "buffer preparation failed\n");
>  		call_void_vb_qop(vb, buf_cleanup, vb);
>  		goto err;
>  	}
> @@ -1276,7 +1277,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
>  	int ret;
>  
>  	if (q->error) {
> -		dprintk(1, "fatal error occurred on queue\n");
> +		dprintk(q, 1, "fatal error occurred on queue\n");
>  		return -EIO;
>  	}
>  
> @@ -1287,7 +1288,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
>  	if (q->is_output) {
>  		ret = call_vb_qop(vb, buf_out_validate, vb);
>  		if (ret) {
> -			dprintk(1, "buffer validation failed\n");
> +			dprintk(q, 1, "buffer validation failed\n");
>  			return ret;
>  		}
>  	}
> @@ -1311,7 +1312,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
>  	}
>  
>  	if (ret) {
> -		dprintk(1, "buffer preparation failed: %d\n", ret);
> +		dprintk(q, 1, "buffer preparation failed: %d\n", ret);
>  		vb->state = orig_state;
>  		return ret;
>  	}
> @@ -1423,12 +1424,12 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
>  
>  	vb = q->bufs[index];
>  	if (vb->state != VB2_BUF_STATE_DEQUEUED) {
> -		dprintk(1, "invalid buffer state %d\n",
> +		dprintk(q, 1, "invalid buffer state %d\n",
>  			vb->state);
>  		return -EINVAL;
>  	}
>  	if (vb->prepared) {
> -		dprintk(1, "buffer already prepared\n");
> +		dprintk(q, 1, "buffer already prepared\n");
>  		return -EINVAL;
>  	}
>  
> @@ -1439,7 +1440,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
>  	/* Fill buffer information for the userspace */
>  	call_void_bufop(q, fill_user_buffer, vb, pb);
>  
> -	dprintk(2, "prepare of buffer %d succeeded\n", vb->index);
> +	dprintk(q, 2, "prepare of buffer %d succeeded\n", vb->index);
>  
>  	return 0;
>  }
> @@ -1477,7 +1478,7 @@ static int vb2_start_streaming(struct vb2_queue *q)
>  
>  	q->start_streaming_called = 0;
>  
> -	dprintk(1, "driver refused to start streaming\n");
> +	dprintk(q, 1, "driver refused to start streaming\n");
>  	/*
>  	 * If you see this warning, then the driver isn't cleaning up properly
>  	 * after a failed start_streaming(). See the start_streaming()
> @@ -1515,7 +1516,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  	int ret;
>  
>  	if (q->error) {
> -		dprintk(1, "fatal error occurred on queue\n");
> +		dprintk(q, 1, "fatal error occurred on queue\n");
>  		return -EIO;
>  	}
>  
> @@ -1523,14 +1524,14 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  
>  	if (!req && vb->state != VB2_BUF_STATE_IN_REQUEST &&
>  	    q->requires_requests) {
> -		dprintk(1, "qbuf requires a request\n");
> +		dprintk(q, 1, "qbuf requires a request\n");
>  		return -EBADR;
>  	}
>  
>  	if ((req && q->uses_qbuf) ||
>  	    (!req && vb->state != VB2_BUF_STATE_IN_REQUEST &&
>  	     q->uses_requests)) {
> -		dprintk(1, "queue in wrong mode (qbuf vs requests)\n");
> +		dprintk(q, 1, "queue in wrong mode (qbuf vs requests)\n");
>  		return -EBUSY;
>  	}
>  
> @@ -1539,7 +1540,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  
>  		q->uses_requests = 1;
>  		if (vb->state != VB2_BUF_STATE_DEQUEUED) {
> -			dprintk(1, "buffer %d not in dequeued state\n",
> +			dprintk(q, 1, "buffer %d not in dequeued state\n",
>  				vb->index);
>  			return -EINVAL;
>  		}
> @@ -1547,7 +1548,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  		if (q->is_output && !vb->prepared) {
>  			ret = call_vb_qop(vb, buf_out_validate, vb);
>  			if (ret) {
> -				dprintk(1, "buffer validation failed\n");
> +				dprintk(q, 1, "buffer validation failed\n");
>  				return ret;
>  			}
>  		}
> @@ -1583,7 +1584,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  			call_void_bufop(q, fill_user_buffer, vb, pb);
>  		}
>  
> -		dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
> +		dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index);
>  		return 0;
>  	}
>  
> @@ -1600,10 +1601,10 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  		}
>  		break;
>  	case VB2_BUF_STATE_PREPARING:
> -		dprintk(1, "buffer still being prepared\n");
> +		dprintk(q, 1, "buffer still being prepared\n");
>  		return -EINVAL;
>  	default:
> -		dprintk(1, "invalid buffer state %d\n", vb->state);
> +		dprintk(q, 1, "invalid buffer state %d\n", vb->state);
>  		return -EINVAL;
>  	}
>  
> @@ -1645,7 +1646,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
>  			return ret;
>  	}
>  
> -	dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
> +	dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_qbuf);
> @@ -1671,22 +1672,22 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
>  		int ret;
>  
>  		if (q->waiting_in_dqbuf) {
> -			dprintk(1, "another dup()ped fd is waiting for a buffer\n");
> +			dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
>  			return -EBUSY;
>  		}
>  
>  		if (!q->streaming) {
> -			dprintk(1, "streaming off, will not wait for buffers\n");
> +			dprintk(q, 1, "streaming off, will not wait for buffers\n");
>  			return -EINVAL;
>  		}
>  
>  		if (q->error) {
> -			dprintk(1, "Queue in error state, will not wait for buffers\n");
> +			dprintk(q, 1, "Queue in error state, will not wait for buffers\n");
>  			return -EIO;
>  		}
>  
>  		if (q->last_buffer_dequeued) {
> -			dprintk(3, "last buffer dequeued already, will not wait for buffers\n");
> +			dprintk(q, 3, "last buffer dequeued already, will not wait for buffers\n");
>  			return -EPIPE;
>  		}
>  
> @@ -1698,7 +1699,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
>  		}
>  
>  		if (nonblocking) {
> -			dprintk(3, "nonblocking and no buffers to dequeue, will not wait\n");
> +			dprintk(q, 3, "nonblocking and no buffers to dequeue, will not wait\n");
>  			return -EAGAIN;
>  		}
>  
> @@ -1713,7 +1714,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
>  		/*
>  		 * All locks have been released, it is safe to sleep now.
>  		 */
> -		dprintk(3, "will sleep waiting for buffers\n");
> +		dprintk(q, 3, "will sleep waiting for buffers\n");
>  		ret = wait_event_interruptible(q->done_wq,
>  				!list_empty(&q->done_list) || !q->streaming ||
>  				q->error);
> @@ -1725,7 +1726,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
>  		call_void_qop(q, wait_finish, q);
>  		q->waiting_in_dqbuf = 0;
>  		if (ret) {
> -			dprintk(1, "sleep was interrupted\n");
> +			dprintk(q, 1, "sleep was interrupted\n");
>  			return ret;
>  		}
>  	}
> @@ -1773,7 +1774,7 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb,
>  int vb2_wait_for_all_buffers(struct vb2_queue *q)
>  {
>  	if (!q->streaming) {
> -		dprintk(1, "streaming off, will not wait for buffers\n");
> +		dprintk(q, 1, "streaming off, will not wait for buffers\n");
>  		return -EINVAL;
>  	}
>  
> @@ -1811,13 +1812,13 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
>  
>  	switch (vb->state) {
>  	case VB2_BUF_STATE_DONE:
> -		dprintk(3, "returning done buffer\n");
> +		dprintk(q, 3, "returning done buffer\n");
>  		break;
>  	case VB2_BUF_STATE_ERROR:
> -		dprintk(3, "returning done buffer with errors\n");
> +		dprintk(q, 3, "returning done buffer with errors\n");
>  		break;
>  	default:
> -		dprintk(1, "invalid buffer state\n");
> +		dprintk(q, 1, "invalid buffer state\n");
>  		return -EINVAL;
>  	}
>  
> @@ -1848,7 +1849,7 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
>  		media_request_put(vb->request);
>  	vb->request = NULL;
>  
> -	dprintk(2, "dqbuf of buffer %d, with state %d\n",
> +	dprintk(q, 2, "dqbuf of buffer %d, with state %d\n",
>  			vb->index, vb->state);
>  
>  	return 0;
> @@ -1971,22 +1972,22 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
>  	int ret;
>  
>  	if (type != q->type) {
> -		dprintk(1, "invalid stream type\n");
> +		dprintk(q, 1, "invalid stream type\n");
>  		return -EINVAL;
>  	}
>  
>  	if (q->streaming) {
> -		dprintk(3, "already streaming\n");
> +		dprintk(q, 3, "already streaming\n");
>  		return 0;
>  	}
>  
>  	if (!q->num_buffers) {
> -		dprintk(1, "no buffers have been allocated\n");
> +		dprintk(q, 1, "no buffers have been allocated\n");
>  		return -EINVAL;
>  	}
>  
>  	if (q->num_buffers < q->min_buffers_needed) {
> -		dprintk(1, "need at least %u allocated buffers\n",
> +		dprintk(q, 1, "need at least %u allocated buffers\n",
>  				q->min_buffers_needed);
>  		return -EINVAL;
>  	}
> @@ -2006,7 +2007,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
>  
>  	q->streaming = 1;
>  
> -	dprintk(3, "successful\n");
> +	dprintk(q, 3, "successful\n");
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_streamon);
> @@ -2022,7 +2023,7 @@ EXPORT_SYMBOL_GPL(vb2_queue_error);
>  int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
>  {
>  	if (type != q->type) {
> -		dprintk(1, "invalid stream type\n");
> +		dprintk(q, 1, "invalid stream type\n");
>  		return -EINVAL;
>  	}
>  
> @@ -2039,7 +2040,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
>  	q->waiting_for_buffers = !q->is_output;
>  	q->last_buffer_dequeued = false;
>  
> -	dprintk(3, "successful\n");
> +	dprintk(q, 3, "successful\n");
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_streamoff);
> @@ -2082,39 +2083,39 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
>  	struct dma_buf *dbuf;
>  
>  	if (q->memory != VB2_MEMORY_MMAP) {
> -		dprintk(1, "queue is not currently set up for mmap\n");
> +		dprintk(q, 1, "queue is not currently set up for mmap\n");
>  		return -EINVAL;
>  	}
>  
>  	if (!q->mem_ops->get_dmabuf) {
> -		dprintk(1, "queue does not support DMA buffer exporting\n");
> +		dprintk(q, 1, "queue does not support DMA buffer exporting\n");
>  		return -EINVAL;
>  	}
>  
>  	if (flags & ~(O_CLOEXEC | O_ACCMODE)) {
> -		dprintk(1, "queue does support only O_CLOEXEC and access mode flags\n");
> +		dprintk(q, 1, "queue does support only O_CLOEXEC and access mode flags\n");
>  		return -EINVAL;
>  	}
>  
>  	if (type != q->type) {
> -		dprintk(1, "invalid buffer type\n");
> +		dprintk(q, 1, "invalid buffer type\n");
>  		return -EINVAL;
>  	}
>  
>  	if (index >= q->num_buffers) {
> -		dprintk(1, "buffer index out of range\n");
> +		dprintk(q, 1, "buffer index out of range\n");
>  		return -EINVAL;
>  	}
>  
>  	vb = q->bufs[index];
>  
>  	if (plane >= vb->num_planes) {
> -		dprintk(1, "buffer plane out of range\n");
> +		dprintk(q, 1, "buffer plane out of range\n");
>  		return -EINVAL;
>  	}
>  
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "expbuf: file io in progress\n");
> +		dprintk(q, 1, "expbuf: file io in progress\n");
>  		return -EBUSY;
>  	}
>  
> @@ -2123,20 +2124,20 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
>  	dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
>  				flags & O_ACCMODE);
>  	if (IS_ERR_OR_NULL(dbuf)) {
> -		dprintk(1, "failed to export buffer %d, plane %d\n",
> +		dprintk(q, 1, "failed to export buffer %d, plane %d\n",
>  			index, plane);
>  		return -EINVAL;
>  	}
>  
>  	ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE);
>  	if (ret < 0) {
> -		dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
> +		dprintk(q, 3, "buffer %d, plane %d failed to export (%d)\n",
>  			index, plane, ret);
>  		dma_buf_put(dbuf);
>  		return ret;
>  	}
>  
> -	dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
> +	dprintk(q, 3, "buffer %d, plane %d exported as %d descriptor\n",
>  		index, plane, ret);
>  	*fd = ret;
>  
> @@ -2153,7 +2154,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
>  	unsigned long length;
>  
>  	if (q->memory != VB2_MEMORY_MMAP) {
> -		dprintk(1, "queue is not currently set up for mmap\n");
> +		dprintk(q, 1, "queue is not currently set up for mmap\n");
>  		return -EINVAL;
>  	}
>  
> @@ -2161,17 +2162,17 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
>  	 * Check memory area access mode.
>  	 */
>  	if (!(vma->vm_flags & VM_SHARED)) {
> -		dprintk(1, "invalid vma flags, VM_SHARED needed\n");
> +		dprintk(q, 1, "invalid vma flags, VM_SHARED needed\n");
>  		return -EINVAL;
>  	}
>  	if (q->is_output) {
>  		if (!(vma->vm_flags & VM_WRITE)) {
> -			dprintk(1, "invalid vma flags, VM_WRITE needed\n");
> +			dprintk(q, 1, "invalid vma flags, VM_WRITE needed\n");
>  			return -EINVAL;
>  		}
>  	} else {
>  		if (!(vma->vm_flags & VM_READ)) {
> -			dprintk(1, "invalid vma flags, VM_READ needed\n");
> +			dprintk(q, 1, "invalid vma flags, VM_READ needed\n");
>  			return -EINVAL;
>  		}
>  	}
> @@ -2179,7 +2180,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
>  	mutex_lock(&q->mmap_lock);
>  
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "mmap: file io in progress\n");
> +		dprintk(q, 1, "mmap: file io in progress\n");
>  		ret = -EBUSY;
>  		goto unlock;
>  	}
> @@ -2200,7 +2201,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
>  	 */
>  	length = PAGE_ALIGN(vb->planes[plane].length);
>  	if (length < (vma->vm_end - vma->vm_start)) {
> -		dprintk(1,
> +		dprintk(q, 1,
>  			"MMAP invalid, as it would overflow buffer length\n");
>  		ret = -EINVAL;
>  		goto unlock;
> @@ -2220,7 +2221,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
>  	if (ret)
>  		return ret;
>  
> -	dprintk(3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
> +	dprintk(q, 3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(vb2_mmap);
> @@ -2239,7 +2240,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
>  	int ret;
>  
>  	if (q->memory != VB2_MEMORY_MMAP) {
> -		dprintk(1, "queue is not currently set up for mmap\n");
> +		dprintk(q, 1, "queue is not currently set up for mmap\n");
>  		return -EINVAL;
>  	}
>  
> @@ -2479,7 +2480,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
>  	 */
>  	count = 1;
>  
> -	dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
> +	dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
>  		(read) ? "read" : "write", count, q->fileio_read_once,
>  		q->fileio_write_immediately);
>  
> @@ -2577,7 +2578,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q)
>  		fileio->count = 0;
>  		vb2_core_reqbufs(q, fileio->memory, &fileio->count);
>  		kfree(fileio);
> -		dprintk(3, "file io emulator closed\n");
> +		dprintk(q, 3, "file io emulator closed\n");
>  	}
>  	return 0;
>  }
> @@ -2606,7 +2607,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  	unsigned index;
>  	int ret;
>  
> -	dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n",
> +	dprintk(q, 3, "mode %s, offset %ld, count %zd, %sblocking\n",
>  		read ? "read" : "write", (long)*ppos, count,
>  		nonblock ? "non" : "");
>  
> @@ -2614,7 +2615,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  		return -EINVAL;
>  
>  	if (q->waiting_in_dqbuf) {
> -		dprintk(3, "another dup()ped fd is %s\n",
> +		dprintk(q, 3, "another dup()ped fd is %s\n",
>  			read ? "reading" : "writing");
>  		return -EBUSY;
>  	}
> @@ -2624,7 +2625,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  	 */
>  	if (!vb2_fileio_is_active(q)) {
>  		ret = __vb2_init_fileio(q, read);
> -		dprintk(3, "vb2_init_fileio result: %d\n", ret);
> +		dprintk(q, 3, "vb2_init_fileio result: %d\n", ret);
>  		if (ret)
>  			return ret;
>  	}
> @@ -2641,7 +2642,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  		 * Call vb2_dqbuf to get buffer back.
>  		 */
>  		ret = vb2_core_dqbuf(q, &index, NULL, nonblock);
> -		dprintk(5, "vb2_dqbuf result: %d\n", ret);
> +		dprintk(q, 5, "vb2_dqbuf result: %d\n", ret);
>  		if (ret)
>  			return ret;
>  		fileio->dq_count += 1;
> @@ -2672,20 +2673,20 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  	 */
>  	if (buf->pos + count > buf->size) {
>  		count = buf->size - buf->pos;
> -		dprintk(5, "reducing read count: %zd\n", count);
> +		dprintk(q, 5, "reducing read count: %zd\n", count);
>  	}
>  
>  	/*
>  	 * Transfer data to userspace.
>  	 */
> -	dprintk(3, "copying %zd bytes - buffer %d, offset %u\n",
> +	dprintk(q, 3, "copying %zd bytes - buffer %d, offset %u\n",
>  		count, index, buf->pos);
>  	if (read)
>  		ret = copy_to_user(data, buf->vaddr + buf->pos, count);
>  	else
>  		ret = copy_from_user(buf->vaddr + buf->pos, data, count);
>  	if (ret) {
> -		dprintk(3, "error copying data\n");
> +		dprintk(q, 3, "error copying data\n");
>  		return -EFAULT;
>  	}
>  
> @@ -2705,7 +2706,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  		 * Check if this is the last buffer to read.
>  		 */
>  		if (read && fileio->read_once && fileio->dq_count == 1) {
> -			dprintk(3, "read limit reached\n");
> +			dprintk(q, 3, "read limit reached\n");
>  			return __vb2_cleanup_fileio(q);
>  		}
>  
> @@ -2717,7 +2718,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
>  		if (copy_timestamp)
>  			b->timestamp = ktime_get_ns();
>  		ret = vb2_core_qbuf(q, index, NULL, NULL);
> -		dprintk(5, "vb2_dbuf result: %d\n", ret);
> +		dprintk(q, 5, "vb2_dbuf result: %d\n", ret);
>  		if (ret)
>  			return ret;
>  
> @@ -2804,7 +2805,7 @@ static int vb2_thread(void *data)
>  			if (!threadio->stop)
>  				ret = vb2_core_dqbuf(q, &index, NULL, 0);
>  			call_void_qop(q, wait_prepare, q);
> -			dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
> +			dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret);
>  			if (!ret)
>  				vb = q->bufs[index];
>  		}
> @@ -2858,7 +2859,7 @@ int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
>  	threadio->priv = priv;
>  
>  	ret = __vb2_init_fileio(q, !q->is_output);
> -	dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
> +	dprintk(q, 3, "file io: vb2_init_fileio result: %d\n", ret);
>  	if (ret)
>  		goto nomem;
>  	q->threadio = threadio;
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 40d76eb4c2fe..0f034cabcd21 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -35,10 +35,11 @@
>  static int debug;
>  module_param(debug, int, 0644);
>  
> -#define dprintk(level, fmt, arg...)					      \
> +#define dprintk(q, level, fmt, arg...)					      \
>  	do {								      \
>  		if (debug >= level)					      \
> -			pr_info("vb2-v4l2: %s: " fmt, __func__, ## arg); \
> +			pr_info("vb2-v4l2: (q=%p) %s: " fmt,		      \
> +				q, __func__, ## arg);			      \
>  	} while (0)
>  
>  /* Flags that are set by us */
> @@ -63,12 +64,14 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
>  
>  	/* Is memory for copying plane information present? */
>  	if (b->m.planes == NULL) {
> -		dprintk(1, "multi-planar buffer passed but planes array not provided\n");
> +		dprintk(vb->vb2_queue, 1,
> +			"multi-planar buffer passed but planes array not provided\n");
>  		return -EINVAL;
>  	}
>  
>  	if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
> -		dprintk(1, "incorrect planes array length, expected %d, got %d\n",
> +		dprintk(vb->vb2_queue, 1,
> +			"incorrect planes array length, expected %d, got %d\n",
>  			vb->num_planes, b->length);
>  		return -EINVAL;
>  	}
> @@ -176,7 +179,7 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b
>  
>  	ret = __verify_length(vb, b);
>  	if (ret < 0) {
> -		dprintk(1, "plane parameters verification failed: %d\n", ret);
> +		dprintk(q, 1, "plane parameters verification failed: %d\n", ret);
>  		return ret;
>  	}
>  	if (b->field == V4L2_FIELD_ALTERNATE && q->is_output) {
> @@ -189,7 +192,7 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b
>  		 * that just says that it is either a top or a bottom field,
>  		 * but not which of the two it is.
>  		 */
> -		dprintk(1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
> +		dprintk(q, 1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
>  		return -EINVAL;
>  	}
>  	vbuf->sequence = 0;
> @@ -342,23 +345,23 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
>  	int ret;
>  
>  	if (b->type != q->type) {
> -		dprintk(1, "%s: invalid buffer type\n", opname);
> +		dprintk(q, 1, "%s: invalid buffer type\n", opname);
>  		return -EINVAL;
>  	}
>  
>  	if (b->index >= q->num_buffers) {
> -		dprintk(1, "%s: buffer index out of range\n", opname);
> +		dprintk(q, 1, "%s: buffer index out of range\n", opname);
>  		return -EINVAL;
>  	}
>  
>  	if (q->bufs[b->index] == NULL) {
>  		/* Should never happen */
> -		dprintk(1, "%s: buffer is NULL\n", opname);
> +		dprintk(q, 1, "%s: buffer is NULL\n", opname);
>  		return -EINVAL;
>  	}
>  
>  	if (b->memory != q->memory) {
> -		dprintk(1, "%s: invalid memory type\n", opname);
> +		dprintk(q, 1, "%s: invalid memory type\n", opname);
>  		return -EINVAL;
>  	}
>  
> @@ -370,7 +373,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
>  
>  	if (!is_prepare && (b->flags & V4L2_BUF_FLAG_REQUEST_FD) &&
>  	    vb->state != VB2_BUF_STATE_DEQUEUED) {
> -		dprintk(1, "%s: buffer is not in dequeued state\n", opname);
> +		dprintk(q, 1, "%s: buffer is not in dequeued state\n", opname);
>  		return -EINVAL;
>  	}
>  
> @@ -388,19 +391,19 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
>  
>  	if (!(b->flags & V4L2_BUF_FLAG_REQUEST_FD)) {
>  		if (q->requires_requests) {
> -			dprintk(1, "%s: queue requires requests\n", opname);
> +			dprintk(q, 1, "%s: queue requires requests\n", opname);
>  			return -EBADR;
>  		}
>  		if (q->uses_requests) {
> -			dprintk(1, "%s: queue uses requests\n", opname);
> +			dprintk(q, 1, "%s: queue uses requests\n", opname);
>  			return -EBUSY;
>  		}
>  		return 0;
>  	} else if (!q->supports_requests) {
> -		dprintk(1, "%s: queue does not support requests\n", opname);
> +		dprintk(q, 1, "%s: queue does not support requests\n", opname);
>  		return -EBADR;
>  	} else if (q->uses_qbuf) {
> -		dprintk(1, "%s: queue does not use requests\n", opname);
> +		dprintk(q, 1, "%s: queue does not use requests\n", opname);
>  		return -EBUSY;
>  	}
>  
> @@ -430,13 +433,13 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
>  		return -EINVAL;
>  
>  	if (b->request_fd < 0) {
> -		dprintk(1, "%s: request_fd < 0\n", opname);
> +		dprintk(q, 1, "%s: request_fd < 0\n", opname);
>  		return -EINVAL;
>  	}
>  
>  	req = media_request_get_by_fd(mdev, b->request_fd);
>  	if (IS_ERR(req)) {
> -		dprintk(1, "%s: invalid request_fd\n", opname);
> +		dprintk(q, 1, "%s: invalid request_fd\n", opname);
>  		return PTR_ERR(req);
>  	}
>  
> @@ -446,7 +449,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
>  	 */
>  	if (req->state != MEDIA_REQUEST_STATE_IDLE &&
>  	    req->state != MEDIA_REQUEST_STATE_UPDATING) {
> -		dprintk(1, "%s: request is not idle\n", opname);
> +		dprintk(q, 1, "%s: request is not idle\n", opname);
>  		media_request_put(req);
>  		return -EBUSY;
>  	}
> @@ -629,12 +632,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
>  	int ret;
>  
>  	if (b->type != q->type) {
> -		dprintk(1, "wrong buffer type\n");
> +		dprintk(q, 1, "wrong buffer type\n");
>  		return -EINVAL;
>  	}
>  
>  	if (b->index >= q->num_buffers) {
> -		dprintk(1, "buffer index out of range\n");
> +		dprintk(q, 1, "buffer index out of range\n");
>  		return -EINVAL;
>  	}
>  	vb = q->bufs[b->index];
> @@ -675,7 +678,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
>  	int ret;
>  
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  
> @@ -751,7 +754,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
>  	int ret;
>  
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  
> @@ -770,12 +773,12 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
>  	int ret;
>  
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  
>  	if (b->type != q->type) {
> -		dprintk(1, "invalid buffer type\n");
> +		dprintk(q, 1, "invalid buffer type\n");
>  		return -EINVAL;
>  	}
>  
> @@ -799,7 +802,7 @@ EXPORT_SYMBOL_GPL(vb2_dqbuf);
>  int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
>  {
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  	return vb2_core_streamon(q, type);
> @@ -809,7 +812,7 @@ EXPORT_SYMBOL_GPL(vb2_streamon);
>  int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
>  {
>  	if (vb2_fileio_is_active(q)) {
> -		dprintk(1, "file io in progress\n");
> +		dprintk(q, 1, "file io in progress\n");
>  		return -EBUSY;
>  	}
>  	return vb2_core_streamoff(q, type);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] media: vb2: Print the queue pointer in debug messages
@ 2019-06-08 12:38 Laurent Pinchart
  2019-06-11  9:46 ` Hans Verkuil
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2019-06-08 12:38 UTC (permalink / raw)
  To: linux-media

When debugging issues that involve more than one video queue, messages
related to multiple queues get interleaved without any easy way to tell
which queue they relate to. Fix this by printing the queue pointer for
all debug messages in the vb2 core and V4L2 layers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Fix format specifiers in vb2 ops-related macros
---
 .../media/common/videobuf2/videobuf2-core.c   | 219 +++++++++---------
 .../media/common/videobuf2/videobuf2-v4l2.c   |  55 ++---
 2 files changed, 139 insertions(+), 135 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 4489744fbbd9..05677ebdb21f 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -34,10 +34,10 @@
 static int debug;
 module_param(debug, int, 0644);
 
-#define dprintk(level, fmt, arg...)				\
-	do {							\
-		if (debug >= level)				\
-			pr_info("%s: " fmt, __func__, ## arg);	\
+#define dprintk(q, level, fmt, arg...)					\
+	do {								\
+		if (debug >= level)					\
+			pr_info("(q=%p) %s: " fmt, q, __func__, ## arg);\
 	} while (0)
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -51,8 +51,8 @@ module_param(debug, int, 0644);
  */
 
 #define log_memop(vb, op)						\
-	dprintk(2, "call_memop(%p, %d, %s)%s\n",			\
-		(vb)->vb2_queue, (vb)->index, #op,			\
+	dprintk((vb)->vb2_queue, 2, "call_memop(%d, %s)%s\n",		\
+		(vb)->index, #op,					\
 		(vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
 
 #define call_memop(vb, op, args...)					\
@@ -90,7 +90,7 @@ module_param(debug, int, 0644);
 })
 
 #define log_qop(q, op)							\
-	dprintk(2, "call_qop(%p, %s)%s\n", q, #op,			\
+	dprintk(q, 2, "call_qop(%s)%s\n", #op,				\
 		(q)->ops->op ? "" : " (nop)")
 
 #define call_qop(q, op, args...)					\
@@ -113,8 +113,8 @@ module_param(debug, int, 0644);
 })
 
 #define log_vb_qop(vb, op, args...)					\
-	dprintk(2, "call_vb_qop(%p, %d, %s)%s\n",			\
-		(vb)->vb2_queue, (vb)->index, #op,			\
+	dprintk((vb)->vb2_queue, 2, "call_vb_qop(%d, %s)%s\n",		\
+		(vb)->index, #op,					\
 		(vb)->vb2_queue->ops->op ? "" : " (nop)")
 
 #define call_vb_qop(vb, op, args...)					\
@@ -246,7 +246,8 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
 	for (plane = 0; plane < vb->num_planes; ++plane) {
 		call_void_memop(vb, put, vb->planes[plane].mem_priv);
 		vb->planes[plane].mem_priv = NULL;
-		dprintk(3, "freed plane %d of buffer %d\n", plane, vb->index);
+		dprintk(vb->vb2_queue, 3, "freed plane %d of buffer %d\n",
+			plane, vb->index);
 	}
 }
 
@@ -316,7 +317,7 @@ static void __setup_offsets(struct vb2_buffer *vb)
 	for (plane = 0; plane < vb->num_planes; ++plane) {
 		vb->planes[plane].m.offset = off;
 
-		dprintk(3, "buffer %d, plane %d offset 0x%08lx\n",
+		dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n",
 				vb->index, plane, off);
 
 		off += vb->planes[plane].length;
@@ -347,7 +348,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		/* Allocate videobuf buffer structures */
 		vb = kzalloc(q->buf_struct_size, GFP_KERNEL);
 		if (!vb) {
-			dprintk(1, "memory alloc for buffer struct failed\n");
+			dprintk(q, 1, "memory alloc for buffer struct failed\n");
 			break;
 		}
 
@@ -369,7 +370,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		if (memory == VB2_MEMORY_MMAP) {
 			ret = __vb2_buf_mem_alloc(vb);
 			if (ret) {
-				dprintk(1, "failed allocating memory for buffer %d\n",
+				dprintk(q, 1, "failed allocating memory for buffer %d\n",
 					buffer);
 				q->bufs[vb->index] = NULL;
 				kfree(vb);
@@ -383,7 +384,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 			 */
 			ret = call_vb_qop(vb, buf_init, vb);
 			if (ret) {
-				dprintk(1, "buffer %d %p initialization failed\n",
+				dprintk(q, 1, "buffer %d %p initialization failed\n",
 					buffer, vb);
 				__vb2_buf_mem_free(vb);
 				q->bufs[vb->index] = NULL;
@@ -393,7 +394,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
 		}
 	}
 
-	dprintk(1, "allocated %d buffers, %d plane(s) each\n",
+	dprintk(q, 1, "allocated %d buffers, %d plane(s) each\n",
 			buffer, num_planes);
 
 	return buffer;
@@ -445,7 +446,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
 		if (q->bufs[buffer] == NULL)
 			continue;
 		if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) {
-			dprintk(1, "preparing buffers, cannot free\n");
+			dprintk(q, 1, "preparing buffers, cannot free\n");
 			return -EAGAIN;
 		}
 	}
@@ -623,12 +624,12 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 {
 	if (memory != VB2_MEMORY_MMAP && memory != VB2_MEMORY_USERPTR &&
 	    memory != VB2_MEMORY_DMABUF) {
-		dprintk(1, "unsupported memory type\n");
+		dprintk(q, 1, "unsupported memory type\n");
 		return -EINVAL;
 	}
 
 	if (type != q->type) {
-		dprintk(1, "requested type is incorrect\n");
+		dprintk(q, 1, "requested type is incorrect\n");
 		return -EINVAL;
 	}
 
@@ -637,17 +638,17 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 	 * are available.
 	 */
 	if (memory == VB2_MEMORY_MMAP && __verify_mmap_ops(q)) {
-		dprintk(1, "MMAP for current setup unsupported\n");
+		dprintk(q, 1, "MMAP for current setup unsupported\n");
 		return -EINVAL;
 	}
 
 	if (memory == VB2_MEMORY_USERPTR && __verify_userptr_ops(q)) {
-		dprintk(1, "USERPTR for current setup unsupported\n");
+		dprintk(q, 1, "USERPTR for current setup unsupported\n");
 		return -EINVAL;
 	}
 
 	if (memory == VB2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
-		dprintk(1, "DMABUF for current setup unsupported\n");
+		dprintk(q, 1, "DMABUF for current setup unsupported\n");
 		return -EINVAL;
 	}
 
@@ -657,7 +658,7 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 	 * do the memory and type validation.
 	 */
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return 0;
@@ -673,12 +674,12 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 	int ret;
 
 	if (q->streaming) {
-		dprintk(1, "streaming active\n");
+		dprintk(q, 1, "streaming active\n");
 		return -EBUSY;
 	}
 
 	if (q->waiting_in_dqbuf && *count) {
-		dprintk(1, "another dup()ped fd is waiting for a buffer\n");
+		dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
 		return -EBUSY;
 	}
 
@@ -691,7 +692,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 		mutex_lock(&q->mmap_lock);
 		if (debug && q->memory == VB2_MEMORY_MMAP &&
 		    __buffers_in_use(q))
-			dprintk(1, "memory in use, orphaning buffers\n");
+			dprintk(q, 1, "memory in use, orphaning buffers\n");
 
 		/*
 		 * Call queue_cancel to clean up any buffers in the
@@ -742,7 +743,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
 	allocated_buffers =
 		__vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes);
 	if (allocated_buffers == 0) {
-		dprintk(1, "memory allocation failed\n");
+		dprintk(q, 1, "memory allocation failed\n");
 		return -ENOMEM;
 	}
 
@@ -812,20 +813,20 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 	int ret;
 
 	if (q->num_buffers == VB2_MAX_FRAME) {
-		dprintk(1, "maximum number of buffers already allocated\n");
+		dprintk(q, 1, "maximum number of buffers already allocated\n");
 		return -ENOBUFS;
 	}
 
 	if (!q->num_buffers) {
 		if (q->waiting_in_dqbuf && *count) {
-			dprintk(1, "another dup()ped fd is waiting for a buffer\n");
+			dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
 			return -EBUSY;
 		}
 		memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
 		q->memory = memory;
 		q->waiting_for_buffers = !q->is_output;
 	} else if (q->memory != memory) {
-		dprintk(1, "memory model mismatch\n");
+		dprintk(q, 1, "memory model mismatch\n");
 		return -EINVAL;
 	}
 
@@ -849,7 +850,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 	allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers,
 				num_planes, plane_sizes);
 	if (allocated_buffers == 0) {
-		dprintk(1, "memory allocation failed\n");
+		dprintk(q, 1, "memory allocation failed\n");
 		return -ENOMEM;
 	}
 
@@ -939,7 +940,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 	 */
 	vb->cnt_buf_done++;
 #endif
-	dprintk(4, "done processing on buffer %d, state: %d\n",
+	dprintk(q, 4, "done processing on buffer %d, state: %d\n",
 			vb->index, state);
 
 	if (state != VB2_BUF_STATE_QUEUED) {
@@ -1029,12 +1030,12 @@ static int __prepare_userptr(struct vb2_buffer *vb)
 			&& vb->planes[plane].length == planes[plane].length)
 			continue;
 
-		dprintk(3, "userspace address for plane %d changed, reacquiring memory\n",
+		dprintk(q, 3, "userspace address for plane %d changed, reacquiring memory\n",
 			plane);
 
 		/* Check if the provided plane buffer is large enough */
 		if (planes[plane].length < vb->planes[plane].min_length) {
-			dprintk(1, "provided buffer size %u is less than setup size %u for plane %d\n",
+			dprintk(q, 1, "provided buffer size %u is less than setup size %u for plane %d\n",
 						planes[plane].length,
 						vb->planes[plane].min_length,
 						plane);
@@ -1064,7 +1065,7 @@ static int __prepare_userptr(struct vb2_buffer *vb)
 				planes[plane].m.userptr,
 				planes[plane].length, q->dma_dir);
 		if (IS_ERR(mem_priv)) {
-			dprintk(1, "failed acquiring userspace memory for plane %d\n",
+			dprintk(q, 1, "failed acquiring userspace memory for plane %d\n",
 				plane);
 			ret = PTR_ERR(mem_priv);
 			goto err;
@@ -1091,14 +1092,14 @@ static int __prepare_userptr(struct vb2_buffer *vb)
 		 */
 		ret = call_vb_qop(vb, buf_init, vb);
 		if (ret) {
-			dprintk(1, "buffer initialization failed\n");
+			dprintk(q, 1, "buffer initialization failed\n");
 			goto err;
 		}
 	}
 
 	ret = call_vb_qop(vb, buf_prepare, vb);
 	if (ret) {
-		dprintk(1, "buffer preparation failed\n");
+		dprintk(q, 1, "buffer preparation failed\n");
 		call_void_vb_qop(vb, buf_cleanup, vb);
 		goto err;
 	}
@@ -1141,7 +1142,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 		struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd);
 
 		if (IS_ERR_OR_NULL(dbuf)) {
-			dprintk(1, "invalid dmabuf fd for plane %d\n",
+			dprintk(q, 1, "invalid dmabuf fd for plane %d\n",
 				plane);
 			ret = -EINVAL;
 			goto err;
@@ -1152,7 +1153,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 			planes[plane].length = dbuf->size;
 
 		if (planes[plane].length < vb->planes[plane].min_length) {
-			dprintk(1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
+			dprintk(q, 1, "invalid dmabuf length %u for plane %d, minimum length %u\n",
 				planes[plane].length, plane,
 				vb->planes[plane].min_length);
 			dma_buf_put(dbuf);
@@ -1167,7 +1168,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 			continue;
 		}
 
-		dprintk(3, "buffer for plane %d changed\n", plane);
+		dprintk(q, 3, "buffer for plane %d changed\n", plane);
 
 		if (!reacquired) {
 			reacquired = true;
@@ -1187,7 +1188,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 				q->alloc_devs[plane] ? : q->dev,
 				dbuf, planes[plane].length, q->dma_dir);
 		if (IS_ERR(mem_priv)) {
-			dprintk(1, "failed to attach dmabuf\n");
+			dprintk(q, 1, "failed to attach dmabuf\n");
 			ret = PTR_ERR(mem_priv);
 			dma_buf_put(dbuf);
 			goto err;
@@ -1208,7 +1209,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 
 		ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
 		if (ret) {
-			dprintk(1, "failed to map dmabuf for plane %d\n",
+			dprintk(q, 1, "failed to map dmabuf for plane %d\n",
 				plane);
 			goto err;
 		}
@@ -1233,14 +1234,14 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 		 */
 		ret = call_vb_qop(vb, buf_init, vb);
 		if (ret) {
-			dprintk(1, "buffer initialization failed\n");
+			dprintk(q, 1, "buffer initialization failed\n");
 			goto err;
 		}
 	}
 
 	ret = call_vb_qop(vb, buf_prepare, vb);
 	if (ret) {
-		dprintk(1, "buffer preparation failed\n");
+		dprintk(q, 1, "buffer preparation failed\n");
 		call_void_vb_qop(vb, buf_cleanup, vb);
 		goto err;
 	}
@@ -1276,7 +1277,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
 	int ret;
 
 	if (q->error) {
-		dprintk(1, "fatal error occurred on queue\n");
+		dprintk(q, 1, "fatal error occurred on queue\n");
 		return -EIO;
 	}
 
@@ -1287,7 +1288,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
 	if (q->is_output) {
 		ret = call_vb_qop(vb, buf_out_validate, vb);
 		if (ret) {
-			dprintk(1, "buffer validation failed\n");
+			dprintk(q, 1, "buffer validation failed\n");
 			return ret;
 		}
 	}
@@ -1311,7 +1312,7 @@ static int __buf_prepare(struct vb2_buffer *vb)
 	}
 
 	if (ret) {
-		dprintk(1, "buffer preparation failed: %d\n", ret);
+		dprintk(q, 1, "buffer preparation failed: %d\n", ret);
 		vb->state = orig_state;
 		return ret;
 	}
@@ -1423,12 +1424,12 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
 
 	vb = q->bufs[index];
 	if (vb->state != VB2_BUF_STATE_DEQUEUED) {
-		dprintk(1, "invalid buffer state %d\n",
+		dprintk(q, 1, "invalid buffer state %d\n",
 			vb->state);
 		return -EINVAL;
 	}
 	if (vb->prepared) {
-		dprintk(1, "buffer already prepared\n");
+		dprintk(q, 1, "buffer already prepared\n");
 		return -EINVAL;
 	}
 
@@ -1439,7 +1440,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
 	/* Fill buffer information for the userspace */
 	call_void_bufop(q, fill_user_buffer, vb, pb);
 
-	dprintk(2, "prepare of buffer %d succeeded\n", vb->index);
+	dprintk(q, 2, "prepare of buffer %d succeeded\n", vb->index);
 
 	return 0;
 }
@@ -1477,7 +1478,7 @@ static int vb2_start_streaming(struct vb2_queue *q)
 
 	q->start_streaming_called = 0;
 
-	dprintk(1, "driver refused to start streaming\n");
+	dprintk(q, 1, "driver refused to start streaming\n");
 	/*
 	 * If you see this warning, then the driver isn't cleaning up properly
 	 * after a failed start_streaming(). See the start_streaming()
@@ -1515,7 +1516,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 	int ret;
 
 	if (q->error) {
-		dprintk(1, "fatal error occurred on queue\n");
+		dprintk(q, 1, "fatal error occurred on queue\n");
 		return -EIO;
 	}
 
@@ -1523,14 +1524,14 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 
 	if (!req && vb->state != VB2_BUF_STATE_IN_REQUEST &&
 	    q->requires_requests) {
-		dprintk(1, "qbuf requires a request\n");
+		dprintk(q, 1, "qbuf requires a request\n");
 		return -EBADR;
 	}
 
 	if ((req && q->uses_qbuf) ||
 	    (!req && vb->state != VB2_BUF_STATE_IN_REQUEST &&
 	     q->uses_requests)) {
-		dprintk(1, "queue in wrong mode (qbuf vs requests)\n");
+		dprintk(q, 1, "queue in wrong mode (qbuf vs requests)\n");
 		return -EBUSY;
 	}
 
@@ -1539,7 +1540,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 
 		q->uses_requests = 1;
 		if (vb->state != VB2_BUF_STATE_DEQUEUED) {
-			dprintk(1, "buffer %d not in dequeued state\n",
+			dprintk(q, 1, "buffer %d not in dequeued state\n",
 				vb->index);
 			return -EINVAL;
 		}
@@ -1547,7 +1548,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 		if (q->is_output && !vb->prepared) {
 			ret = call_vb_qop(vb, buf_out_validate, vb);
 			if (ret) {
-				dprintk(1, "buffer validation failed\n");
+				dprintk(q, 1, "buffer validation failed\n");
 				return ret;
 			}
 		}
@@ -1583,7 +1584,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 			call_void_bufop(q, fill_user_buffer, vb, pb);
 		}
 
-		dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
+		dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index);
 		return 0;
 	}
 
@@ -1600,10 +1601,10 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 		}
 		break;
 	case VB2_BUF_STATE_PREPARING:
-		dprintk(1, "buffer still being prepared\n");
+		dprintk(q, 1, "buffer still being prepared\n");
 		return -EINVAL;
 	default:
-		dprintk(1, "invalid buffer state %d\n", vb->state);
+		dprintk(q, 1, "invalid buffer state %d\n", vb->state);
 		return -EINVAL;
 	}
 
@@ -1645,7 +1646,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
 			return ret;
 	}
 
-	dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
+	dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_qbuf);
@@ -1671,22 +1672,22 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		int ret;
 
 		if (q->waiting_in_dqbuf) {
-			dprintk(1, "another dup()ped fd is waiting for a buffer\n");
+			dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n");
 			return -EBUSY;
 		}
 
 		if (!q->streaming) {
-			dprintk(1, "streaming off, will not wait for buffers\n");
+			dprintk(q, 1, "streaming off, will not wait for buffers\n");
 			return -EINVAL;
 		}
 
 		if (q->error) {
-			dprintk(1, "Queue in error state, will not wait for buffers\n");
+			dprintk(q, 1, "Queue in error state, will not wait for buffers\n");
 			return -EIO;
 		}
 
 		if (q->last_buffer_dequeued) {
-			dprintk(3, "last buffer dequeued already, will not wait for buffers\n");
+			dprintk(q, 3, "last buffer dequeued already, will not wait for buffers\n");
 			return -EPIPE;
 		}
 
@@ -1698,7 +1699,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		}
 
 		if (nonblocking) {
-			dprintk(3, "nonblocking and no buffers to dequeue, will not wait\n");
+			dprintk(q, 3, "nonblocking and no buffers to dequeue, will not wait\n");
 			return -EAGAIN;
 		}
 
@@ -1713,7 +1714,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		/*
 		 * All locks have been released, it is safe to sleep now.
 		 */
-		dprintk(3, "will sleep waiting for buffers\n");
+		dprintk(q, 3, "will sleep waiting for buffers\n");
 		ret = wait_event_interruptible(q->done_wq,
 				!list_empty(&q->done_list) || !q->streaming ||
 				q->error);
@@ -1725,7 +1726,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
 		call_void_qop(q, wait_finish, q);
 		q->waiting_in_dqbuf = 0;
 		if (ret) {
-			dprintk(1, "sleep was interrupted\n");
+			dprintk(q, 1, "sleep was interrupted\n");
 			return ret;
 		}
 	}
@@ -1773,7 +1774,7 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb,
 int vb2_wait_for_all_buffers(struct vb2_queue *q)
 {
 	if (!q->streaming) {
-		dprintk(1, "streaming off, will not wait for buffers\n");
+		dprintk(q, 1, "streaming off, will not wait for buffers\n");
 		return -EINVAL;
 	}
 
@@ -1811,13 +1812,13 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
 
 	switch (vb->state) {
 	case VB2_BUF_STATE_DONE:
-		dprintk(3, "returning done buffer\n");
+		dprintk(q, 3, "returning done buffer\n");
 		break;
 	case VB2_BUF_STATE_ERROR:
-		dprintk(3, "returning done buffer with errors\n");
+		dprintk(q, 3, "returning done buffer with errors\n");
 		break;
 	default:
-		dprintk(1, "invalid buffer state\n");
+		dprintk(q, 1, "invalid buffer state\n");
 		return -EINVAL;
 	}
 
@@ -1848,7 +1849,7 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
 		media_request_put(vb->request);
 	vb->request = NULL;
 
-	dprintk(2, "dqbuf of buffer %d, with state %d\n",
+	dprintk(q, 2, "dqbuf of buffer %d, with state %d\n",
 			vb->index, vb->state);
 
 	return 0;
@@ -1971,22 +1972,22 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 	int ret;
 
 	if (type != q->type) {
-		dprintk(1, "invalid stream type\n");
+		dprintk(q, 1, "invalid stream type\n");
 		return -EINVAL;
 	}
 
 	if (q->streaming) {
-		dprintk(3, "already streaming\n");
+		dprintk(q, 3, "already streaming\n");
 		return 0;
 	}
 
 	if (!q->num_buffers) {
-		dprintk(1, "no buffers have been allocated\n");
+		dprintk(q, 1, "no buffers have been allocated\n");
 		return -EINVAL;
 	}
 
 	if (q->num_buffers < q->min_buffers_needed) {
-		dprintk(1, "need at least %u allocated buffers\n",
+		dprintk(q, 1, "need at least %u allocated buffers\n",
 				q->min_buffers_needed);
 		return -EINVAL;
 	}
@@ -2006,7 +2007,7 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
 
 	q->streaming = 1;
 
-	dprintk(3, "successful\n");
+	dprintk(q, 3, "successful\n");
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_streamon);
@@ -2022,7 +2023,7 @@ EXPORT_SYMBOL_GPL(vb2_queue_error);
 int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
 {
 	if (type != q->type) {
-		dprintk(1, "invalid stream type\n");
+		dprintk(q, 1, "invalid stream type\n");
 		return -EINVAL;
 	}
 
@@ -2039,7 +2040,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type)
 	q->waiting_for_buffers = !q->is_output;
 	q->last_buffer_dequeued = false;
 
-	dprintk(3, "successful\n");
+	dprintk(q, 3, "successful\n");
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_streamoff);
@@ -2082,39 +2083,39 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
 	struct dma_buf *dbuf;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
 	if (!q->mem_ops->get_dmabuf) {
-		dprintk(1, "queue does not support DMA buffer exporting\n");
+		dprintk(q, 1, "queue does not support DMA buffer exporting\n");
 		return -EINVAL;
 	}
 
 	if (flags & ~(O_CLOEXEC | O_ACCMODE)) {
-		dprintk(1, "queue does support only O_CLOEXEC and access mode flags\n");
+		dprintk(q, 1, "queue does support only O_CLOEXEC and access mode flags\n");
 		return -EINVAL;
 	}
 
 	if (type != q->type) {
-		dprintk(1, "invalid buffer type\n");
+		dprintk(q, 1, "invalid buffer type\n");
 		return -EINVAL;
 	}
 
 	if (index >= q->num_buffers) {
-		dprintk(1, "buffer index out of range\n");
+		dprintk(q, 1, "buffer index out of range\n");
 		return -EINVAL;
 	}
 
 	vb = q->bufs[index];
 
 	if (plane >= vb->num_planes) {
-		dprintk(1, "buffer plane out of range\n");
+		dprintk(q, 1, "buffer plane out of range\n");
 		return -EINVAL;
 	}
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "expbuf: file io in progress\n");
+		dprintk(q, 1, "expbuf: file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -2123,20 +2124,20 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
 	dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
 				flags & O_ACCMODE);
 	if (IS_ERR_OR_NULL(dbuf)) {
-		dprintk(1, "failed to export buffer %d, plane %d\n",
+		dprintk(q, 1, "failed to export buffer %d, plane %d\n",
 			index, plane);
 		return -EINVAL;
 	}
 
 	ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE);
 	if (ret < 0) {
-		dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
+		dprintk(q, 3, "buffer %d, plane %d failed to export (%d)\n",
 			index, plane, ret);
 		dma_buf_put(dbuf);
 		return ret;
 	}
 
-	dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
+	dprintk(q, 3, "buffer %d, plane %d exported as %d descriptor\n",
 		index, plane, ret);
 	*fd = ret;
 
@@ -2153,7 +2154,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	unsigned long length;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
@@ -2161,17 +2162,17 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	 * Check memory area access mode.
 	 */
 	if (!(vma->vm_flags & VM_SHARED)) {
-		dprintk(1, "invalid vma flags, VM_SHARED needed\n");
+		dprintk(q, 1, "invalid vma flags, VM_SHARED needed\n");
 		return -EINVAL;
 	}
 	if (q->is_output) {
 		if (!(vma->vm_flags & VM_WRITE)) {
-			dprintk(1, "invalid vma flags, VM_WRITE needed\n");
+			dprintk(q, 1, "invalid vma flags, VM_WRITE needed\n");
 			return -EINVAL;
 		}
 	} else {
 		if (!(vma->vm_flags & VM_READ)) {
-			dprintk(1, "invalid vma flags, VM_READ needed\n");
+			dprintk(q, 1, "invalid vma flags, VM_READ needed\n");
 			return -EINVAL;
 		}
 	}
@@ -2179,7 +2180,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	mutex_lock(&q->mmap_lock);
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "mmap: file io in progress\n");
+		dprintk(q, 1, "mmap: file io in progress\n");
 		ret = -EBUSY;
 		goto unlock;
 	}
@@ -2200,7 +2201,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	 */
 	length = PAGE_ALIGN(vb->planes[plane].length);
 	if (length < (vma->vm_end - vma->vm_start)) {
-		dprintk(1,
+		dprintk(q, 1,
 			"MMAP invalid, as it would overflow buffer length\n");
 		ret = -EINVAL;
 		goto unlock;
@@ -2220,7 +2221,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 	if (ret)
 		return ret;
 
-	dprintk(3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
+	dprintk(q, 3, "buffer %d, plane %d successfully mapped\n", buffer, plane);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_mmap);
@@ -2239,7 +2240,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
 	int ret;
 
 	if (q->memory != VB2_MEMORY_MMAP) {
-		dprintk(1, "queue is not currently set up for mmap\n");
+		dprintk(q, 1, "queue is not currently set up for mmap\n");
 		return -EINVAL;
 	}
 
@@ -2479,7 +2480,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
 	 */
 	count = 1;
 
-	dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
+	dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
 		(read) ? "read" : "write", count, q->fileio_read_once,
 		q->fileio_write_immediately);
 
@@ -2577,7 +2578,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q)
 		fileio->count = 0;
 		vb2_core_reqbufs(q, fileio->memory, &fileio->count);
 		kfree(fileio);
-		dprintk(3, "file io emulator closed\n");
+		dprintk(q, 3, "file io emulator closed\n");
 	}
 	return 0;
 }
@@ -2606,7 +2607,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	unsigned index;
 	int ret;
 
-	dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n",
+	dprintk(q, 3, "mode %s, offset %ld, count %zd, %sblocking\n",
 		read ? "read" : "write", (long)*ppos, count,
 		nonblock ? "non" : "");
 
@@ -2614,7 +2615,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		return -EINVAL;
 
 	if (q->waiting_in_dqbuf) {
-		dprintk(3, "another dup()ped fd is %s\n",
+		dprintk(q, 3, "another dup()ped fd is %s\n",
 			read ? "reading" : "writing");
 		return -EBUSY;
 	}
@@ -2624,7 +2625,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	 */
 	if (!vb2_fileio_is_active(q)) {
 		ret = __vb2_init_fileio(q, read);
-		dprintk(3, "vb2_init_fileio result: %d\n", ret);
+		dprintk(q, 3, "vb2_init_fileio result: %d\n", ret);
 		if (ret)
 			return ret;
 	}
@@ -2641,7 +2642,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		 * Call vb2_dqbuf to get buffer back.
 		 */
 		ret = vb2_core_dqbuf(q, &index, NULL, nonblock);
-		dprintk(5, "vb2_dqbuf result: %d\n", ret);
+		dprintk(q, 5, "vb2_dqbuf result: %d\n", ret);
 		if (ret)
 			return ret;
 		fileio->dq_count += 1;
@@ -2672,20 +2673,20 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 	 */
 	if (buf->pos + count > buf->size) {
 		count = buf->size - buf->pos;
-		dprintk(5, "reducing read count: %zd\n", count);
+		dprintk(q, 5, "reducing read count: %zd\n", count);
 	}
 
 	/*
 	 * Transfer data to userspace.
 	 */
-	dprintk(3, "copying %zd bytes - buffer %d, offset %u\n",
+	dprintk(q, 3, "copying %zd bytes - buffer %d, offset %u\n",
 		count, index, buf->pos);
 	if (read)
 		ret = copy_to_user(data, buf->vaddr + buf->pos, count);
 	else
 		ret = copy_from_user(buf->vaddr + buf->pos, data, count);
 	if (ret) {
-		dprintk(3, "error copying data\n");
+		dprintk(q, 3, "error copying data\n");
 		return -EFAULT;
 	}
 
@@ -2705,7 +2706,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		 * Check if this is the last buffer to read.
 		 */
 		if (read && fileio->read_once && fileio->dq_count == 1) {
-			dprintk(3, "read limit reached\n");
+			dprintk(q, 3, "read limit reached\n");
 			return __vb2_cleanup_fileio(q);
 		}
 
@@ -2717,7 +2718,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
 		if (copy_timestamp)
 			b->timestamp = ktime_get_ns();
 		ret = vb2_core_qbuf(q, index, NULL, NULL);
-		dprintk(5, "vb2_dbuf result: %d\n", ret);
+		dprintk(q, 5, "vb2_dbuf result: %d\n", ret);
 		if (ret)
 			return ret;
 
@@ -2804,7 +2805,7 @@ static int vb2_thread(void *data)
 			if (!threadio->stop)
 				ret = vb2_core_dqbuf(q, &index, NULL, 0);
 			call_void_qop(q, wait_prepare, q);
-			dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
+			dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret);
 			if (!ret)
 				vb = q->bufs[index];
 		}
@@ -2858,7 +2859,7 @@ int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
 	threadio->priv = priv;
 
 	ret = __vb2_init_fileio(q, !q->is_output);
-	dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
+	dprintk(q, 3, "file io: vb2_init_fileio result: %d\n", ret);
 	if (ret)
 		goto nomem;
 	q->threadio = threadio;
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 40d76eb4c2fe..0f034cabcd21 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -35,10 +35,11 @@
 static int debug;
 module_param(debug, int, 0644);
 
-#define dprintk(level, fmt, arg...)					      \
+#define dprintk(q, level, fmt, arg...)					      \
 	do {								      \
 		if (debug >= level)					      \
-			pr_info("vb2-v4l2: %s: " fmt, __func__, ## arg); \
+			pr_info("vb2-v4l2: (q=%p) %s: " fmt,		      \
+				q, __func__, ## arg);			      \
 	} while (0)
 
 /* Flags that are set by us */
@@ -63,12 +64,14 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
 
 	/* Is memory for copying plane information present? */
 	if (b->m.planes == NULL) {
-		dprintk(1, "multi-planar buffer passed but planes array not provided\n");
+		dprintk(vb->vb2_queue, 1,
+			"multi-planar buffer passed but planes array not provided\n");
 		return -EINVAL;
 	}
 
 	if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) {
-		dprintk(1, "incorrect planes array length, expected %d, got %d\n",
+		dprintk(vb->vb2_queue, 1,
+			"incorrect planes array length, expected %d, got %d\n",
 			vb->num_planes, b->length);
 		return -EINVAL;
 	}
@@ -176,7 +179,7 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b
 
 	ret = __verify_length(vb, b);
 	if (ret < 0) {
-		dprintk(1, "plane parameters verification failed: %d\n", ret);
+		dprintk(q, 1, "plane parameters verification failed: %d\n", ret);
 		return ret;
 	}
 	if (b->field == V4L2_FIELD_ALTERNATE && q->is_output) {
@@ -189,7 +192,7 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b
 		 * that just says that it is either a top or a bottom field,
 		 * but not which of the two it is.
 		 */
-		dprintk(1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
+		dprintk(q, 1, "the field is incorrectly set to ALTERNATE for an output buffer\n");
 		return -EINVAL;
 	}
 	vbuf->sequence = 0;
@@ -342,23 +345,23 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
 	int ret;
 
 	if (b->type != q->type) {
-		dprintk(1, "%s: invalid buffer type\n", opname);
+		dprintk(q, 1, "%s: invalid buffer type\n", opname);
 		return -EINVAL;
 	}
 
 	if (b->index >= q->num_buffers) {
-		dprintk(1, "%s: buffer index out of range\n", opname);
+		dprintk(q, 1, "%s: buffer index out of range\n", opname);
 		return -EINVAL;
 	}
 
 	if (q->bufs[b->index] == NULL) {
 		/* Should never happen */
-		dprintk(1, "%s: buffer is NULL\n", opname);
+		dprintk(q, 1, "%s: buffer is NULL\n", opname);
 		return -EINVAL;
 	}
 
 	if (b->memory != q->memory) {
-		dprintk(1, "%s: invalid memory type\n", opname);
+		dprintk(q, 1, "%s: invalid memory type\n", opname);
 		return -EINVAL;
 	}
 
@@ -370,7 +373,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
 
 	if (!is_prepare && (b->flags & V4L2_BUF_FLAG_REQUEST_FD) &&
 	    vb->state != VB2_BUF_STATE_DEQUEUED) {
-		dprintk(1, "%s: buffer is not in dequeued state\n", opname);
+		dprintk(q, 1, "%s: buffer is not in dequeued state\n", opname);
 		return -EINVAL;
 	}
 
@@ -388,19 +391,19 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
 
 	if (!(b->flags & V4L2_BUF_FLAG_REQUEST_FD)) {
 		if (q->requires_requests) {
-			dprintk(1, "%s: queue requires requests\n", opname);
+			dprintk(q, 1, "%s: queue requires requests\n", opname);
 			return -EBADR;
 		}
 		if (q->uses_requests) {
-			dprintk(1, "%s: queue uses requests\n", opname);
+			dprintk(q, 1, "%s: queue uses requests\n", opname);
 			return -EBUSY;
 		}
 		return 0;
 	} else if (!q->supports_requests) {
-		dprintk(1, "%s: queue does not support requests\n", opname);
+		dprintk(q, 1, "%s: queue does not support requests\n", opname);
 		return -EBADR;
 	} else if (q->uses_qbuf) {
-		dprintk(1, "%s: queue does not use requests\n", opname);
+		dprintk(q, 1, "%s: queue does not use requests\n", opname);
 		return -EBUSY;
 	}
 
@@ -430,13 +433,13 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
 		return -EINVAL;
 
 	if (b->request_fd < 0) {
-		dprintk(1, "%s: request_fd < 0\n", opname);
+		dprintk(q, 1, "%s: request_fd < 0\n", opname);
 		return -EINVAL;
 	}
 
 	req = media_request_get_by_fd(mdev, b->request_fd);
 	if (IS_ERR(req)) {
-		dprintk(1, "%s: invalid request_fd\n", opname);
+		dprintk(q, 1, "%s: invalid request_fd\n", opname);
 		return PTR_ERR(req);
 	}
 
@@ -446,7 +449,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
 	 */
 	if (req->state != MEDIA_REQUEST_STATE_IDLE &&
 	    req->state != MEDIA_REQUEST_STATE_UPDATING) {
-		dprintk(1, "%s: request is not idle\n", opname);
+		dprintk(q, 1, "%s: request is not idle\n", opname);
 		media_request_put(req);
 		return -EBUSY;
 	}
@@ -629,12 +632,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
 	int ret;
 
 	if (b->type != q->type) {
-		dprintk(1, "wrong buffer type\n");
+		dprintk(q, 1, "wrong buffer type\n");
 		return -EINVAL;
 	}
 
 	if (b->index >= q->num_buffers) {
-		dprintk(1, "buffer index out of range\n");
+		dprintk(q, 1, "buffer index out of range\n");
 		return -EINVAL;
 	}
 	vb = q->bufs[b->index];
@@ -675,7 +678,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -751,7 +754,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
@@ -770,12 +773,12 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 	int ret;
 
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 
 	if (b->type != q->type) {
-		dprintk(1, "invalid buffer type\n");
+		dprintk(q, 1, "invalid buffer type\n");
 		return -EINVAL;
 	}
 
@@ -799,7 +802,7 @@ EXPORT_SYMBOL_GPL(vb2_dqbuf);
 int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return vb2_core_streamon(q, type);
@@ -809,7 +812,7 @@ EXPORT_SYMBOL_GPL(vb2_streamon);
 int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
 {
 	if (vb2_fileio_is_active(q)) {
-		dprintk(1, "file io in progress\n");
+		dprintk(q, 1, "file io in progress\n");
 		return -EBUSY;
 	}
 	return vb2_core_streamoff(q, type);
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-11  9:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 20:06 [PATCH] media: vb2: Print the queue pointer in debug messages Laurent Pinchart
2018-04-28 11:10 ` kbuild test robot
2018-04-28 11:33 ` kbuild test robot
2019-06-08 12:38 Laurent Pinchart
2019-06-11  9:46 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).