diff mbox series

[v2,4/7] media: mtk-vcodec: fix debugging defines

Message ID 20211117130635.11633-5-dafna.hirschfeld@collabora.com (mailing list archive)
State New, archived
Headers show
Series media: mtk-vcodec: few fixes | expand

Commit Message

Dafna Hirschfeld Nov. 17, 2021, 1:06 p.m. UTC
The mtk-vcodec uses some internal defined debug formats for
printing. This patch fixes some things in those defines:

1. use the 'pr_fmt' define to print function name and line.

2. remove 'if(DEBUG)' condition for the defines. This condition
prevents the debugs from being shown in case of dynamic debugs.
Instead replace 'pr_info' with 'pr_debug'

3. remove module parameters that enable/disable debug.
There is no reason for the driver to have those params. Having
those params require the user to explicitly set them when user
wants to see debug prints instead of using the global debugs
setting as expected by drivers to conform.

In addition to that, fix some warnings about debug formatting

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  3 --
 .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  3 --
 .../platform/mtk-vcodec/mtk_vcodec_util.c     | 10 -----
 .../platform/mtk-vcodec/mtk_vcodec_util.h     | 45 +++++--------------
 .../mtk-vcodec/vdec/vdec_h264_req_if.c        |  4 +-
 5 files changed, 12 insertions(+), 53 deletions(-)

Comments

kernel test robot Nov. 18, 2021, 4:03 p.m. UTC | #1
Hi Dafna,

I love your patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on linux/master linus/master v5.16-rc1 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Dafna-Hirschfeld/media-mtk-vcodec-few-fixes/20211117-210840
base:   git://linuxtv.org/media_tree.git master
config: arm-buildonly-randconfig-r003-20211118 (attached as .config)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/87678e46cdd12f69edad572f8561e8ee929d1d16
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Dafna-Hirschfeld/media-mtk-vcodec-few-fixes/20211117-210840
        git checkout 87678e46cdd12f69edad572f8561e8ee929d1d16
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c:641:5: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
                            sizeof(struct mtk_h264_sps_param),
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h:46:46: note: expanded from macro 'mtk_vcodec_debug'
                   ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
                                                              ^~~~
   include/linux/printk.h:570:26: note: expanded from macro 'pr_debug'
           dynamic_pr_debug(fmt, ##__VA_ARGS__)
                            ~~~    ^~~~~~~~~~~
   include/linux/dynamic_debug.h:163:22: note: expanded from macro 'dynamic_pr_debug'
                              pr_fmt(fmt), ##__VA_ARGS__)
                                     ~~~     ^~~~~~~~~~~
   include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
                                                                 ^~~~~~~~~~~
   include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
                   func(&id, ##__VA_ARGS__);               \
                               ^~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c:642:5: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
                            sizeof(struct mtk_h264_pps_param),
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h:46:46: note: expanded from macro 'mtk_vcodec_debug'
                   ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
                                                              ^~~~
   include/linux/printk.h:570:26: note: expanded from macro 'pr_debug'
           dynamic_pr_debug(fmt, ##__VA_ARGS__)
                            ~~~    ^~~~~~~~~~~
   include/linux/dynamic_debug.h:163:22: note: expanded from macro 'dynamic_pr_debug'
                              pr_fmt(fmt), ##__VA_ARGS__)
                                     ~~~     ^~~~~~~~~~~
   include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
                                                                 ^~~~~~~~~~~
   include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
                   func(&id, ##__VA_ARGS__);               \
                               ^~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c:643:5: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
                            sizeof(struct mtk_h264_dec_slice_param),
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h:46:46: note: expanded from macro 'mtk_vcodec_debug'
                   ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
                                                              ^~~~
   include/linux/printk.h:570:26: note: expanded from macro 'pr_debug'
           dynamic_pr_debug(fmt, ##__VA_ARGS__)
                            ~~~    ^~~~~~~~~~~
   include/linux/dynamic_debug.h:163:22: note: expanded from macro 'dynamic_pr_debug'
                              pr_fmt(fmt), ##__VA_ARGS__)
                                     ~~~     ^~~~~~~~~~~
   include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
                                                                 ^~~~~~~~~~~
   include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
                   func(&id, ##__VA_ARGS__);               \
                               ^~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c:644:5: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
                            sizeof(struct mtk_h264_dpb_info));
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h:46:46: note: expanded from macro 'mtk_vcodec_debug'
                   ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
                                                              ^~~~
   include/linux/printk.h:570:26: note: expanded from macro 'pr_debug'
           dynamic_pr_debug(fmt, ##__VA_ARGS__)
                            ~~~    ^~~~~~~~~~~
   include/linux/dynamic_debug.h:163:22: note: expanded from macro 'dynamic_pr_debug'
                              pr_fmt(fmt), ##__VA_ARGS__)
                                     ~~~     ^~~~~~~~~~~
   include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
           __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
                                                                 ^~~~~~~~~~~
   include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
                   func(&id, ##__VA_ARGS__);               \
                               ^~~~~~~~~~~
   4 warnings generated.


vim +641 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c

06fa5f757dc5a5 Yunfei Dong      2021-08-06  611  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  612  static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
06fa5f757dc5a5 Yunfei Dong      2021-08-06  613  {
06fa5f757dc5a5 Yunfei Dong      2021-08-06  614  	struct vdec_h264_slice_inst *inst;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  615  	int err;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  616  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  617  	inst = kzalloc(sizeof(*inst), GFP_KERNEL);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  618  	if (!inst)
06fa5f757dc5a5 Yunfei Dong      2021-08-06  619  		return -ENOMEM;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  620  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  621  	inst->ctx = ctx;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  622  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  623  	inst->vpu.id = SCP_IPI_VDEC_H264;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  624  	inst->vpu.ctx = ctx;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  625  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  626  	err = vpu_dec_init(&inst->vpu);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  627  	if (err) {
06fa5f757dc5a5 Yunfei Dong      2021-08-06  628  		mtk_vcodec_err(inst, "vdec_h264 init err=%d", err);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  629  		goto error_free_inst;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  630  	}
06fa5f757dc5a5 Yunfei Dong      2021-08-06  631  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  632  	memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx));
06fa5f757dc5a5 Yunfei Dong      2021-08-06  633  	inst->vsi_ctx.dec.resolution_changed = true;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  634  	inst->vsi_ctx.dec.realloc_mv_buf = true;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  635  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  636  	err = allocate_predication_buf(inst);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  637  	if (err)
06fa5f757dc5a5 Yunfei Dong      2021-08-06  638  		goto error_deinit;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  639  
87678e46cdd12f Dafna Hirschfeld 2021-11-17  640  	mtk_vcodec_debug(inst, "struct size = %lu,%lu,%lu,%lu\n",
06fa5f757dc5a5 Yunfei Dong      2021-08-06 @641  			 sizeof(struct mtk_h264_sps_param),
06fa5f757dc5a5 Yunfei Dong      2021-08-06  642  			 sizeof(struct mtk_h264_pps_param),
06fa5f757dc5a5 Yunfei Dong      2021-08-06  643  			 sizeof(struct mtk_h264_dec_slice_param),
06fa5f757dc5a5 Yunfei Dong      2021-08-06  644  			 sizeof(struct mtk_h264_dpb_info));
06fa5f757dc5a5 Yunfei Dong      2021-08-06  645  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  646  	mtk_vcodec_debug(inst, "H264 Instance >> %p", inst);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  647  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  648  	ctx->drv_handle = inst;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  649  	return 0;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  650  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  651  error_deinit:
06fa5f757dc5a5 Yunfei Dong      2021-08-06  652  	vpu_dec_deinit(&inst->vpu);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  653  
06fa5f757dc5a5 Yunfei Dong      2021-08-06  654  error_free_inst:
06fa5f757dc5a5 Yunfei Dong      2021-08-06  655  	kfree(inst);
06fa5f757dc5a5 Yunfei Dong      2021-08-06  656  	return err;
06fa5f757dc5a5 Yunfei Dong      2021-08-06  657  }
06fa5f757dc5a5 Yunfei Dong      2021-08-06  658  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index e6e6a8203eeb..f3610a338a01 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -28,9 +28,6 @@ 
 #define VDEC_IRQ_CLR	0x10
 #define VDEC_IRQ_CFG_REG	0xa4
 
-module_param(mtk_v4l2_dbg_level, int, 0644);
-module_param(mtk_vcodec_dbg, bool, 0644);
-
 /* Wake up context wait_queue */
 static void wake_up_ctx(struct mtk_vcodec_ctx *ctx)
 {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index f898226fc53e..ec5ee337c1fd 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -23,9 +23,6 @@ 
 #include "mtk_vcodec_util.h"
 #include "mtk_vcodec_fw.h"
 
-module_param(mtk_v4l2_dbg_level, int, S_IRUGO | S_IWUSR);
-module_param(mtk_vcodec_dbg, bool, S_IRUGO | S_IWUSR);
-
 static const struct mtk_video_fmt mtk_video_formats_output[] = {
 	{
 		.fourcc = V4L2_PIX_FMT_NV12M,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
index ac5973b6735f..5bac820a47fc 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
@@ -10,16 +10,6 @@ 
 #include "mtk_vcodec_drv.h"
 #include "mtk_vcodec_util.h"
 
-/* For encoder, this will enable logs in venc/*/
-bool mtk_vcodec_dbg;
-EXPORT_SYMBOL(mtk_vcodec_dbg);
-
-/* The log level of v4l2 encoder or decoder driver.
- * That is, files under mtk-vcodec/.
- */
-int mtk_v4l2_dbg_level;
-EXPORT_SYMBOL(mtk_v4l2_dbg_level);
-
 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
 					unsigned int reg_idx)
 {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
index b999d7b84ed1..87c3d6d4bfa7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
@@ -25,54 +25,29 @@  struct mtk_vcodec_fb {
 struct mtk_vcodec_ctx;
 struct mtk_vcodec_dev;
 
-extern int mtk_v4l2_dbg_level;
-extern bool mtk_vcodec_dbg;
-
+#undef pr_fmt
+#define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
 
 #define mtk_v4l2_err(fmt, args...)                \
-	pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
-	       ##args)
-
-#define mtk_vcodec_err(h, fmt, args...)					\
-	pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",		\
-	       ((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
+	pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args)
 
+#define mtk_vcodec_err(h, fmt, args...)				\
+	pr_err("[MTK_VCODEC][ERROR][%d]: " fmt "\n",		\
+	       ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
 
-#if defined(DEBUG)
 
-#define mtk_v4l2_debug(level, fmt, args...)				 \
-	do {								 \
-		if (mtk_v4l2_dbg_level >= level)			 \
-			pr_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n",\
-				level, __func__, __LINE__, ##args);	 \
-	} while (0)
+#define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args)
 
 #define mtk_v4l2_debug_enter()  mtk_v4l2_debug(3, "+")
 #define mtk_v4l2_debug_leave()  mtk_v4l2_debug(3, "-")
 
-#define mtk_vcodec_debug(h, fmt, args...)				\
-	do {								\
-		if (mtk_vcodec_dbg)					\
-			pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n",	\
-				((struct mtk_vcodec_ctx *)h->ctx)->id, \
-				__func__, ##args);			\
-	} while (0)
+#define mtk_vcodec_debug(h, fmt, args...)			\
+	pr_debug("[MTK_VCODEC][%d]: " fmt "\n",			\
+		((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
 
 #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
 #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
 
-#else
-
-#define mtk_v4l2_debug(level, fmt, args...) {}
-#define mtk_v4l2_debug_enter() {}
-#define mtk_v4l2_debug_leave() {}
-
-#define mtk_vcodec_debug(h, fmt, args...) {}
-#define mtk_vcodec_debug_enter(h) {}
-#define mtk_vcodec_debug_leave(h) {}
-
-#endif
-
 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
 				unsigned int reg_idx);
 int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
index 946c23088308..88f2e8f9bfe1 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
@@ -527,7 +527,7 @@  static int alloc_mv_buf(struct vdec_h264_slice_inst *inst,
 	struct mtk_vcodec_mem *mem = NULL;
 	unsigned int buf_sz = get_mv_buf_size(pic->buf_w, pic->buf_h);
 
-	mtk_v4l2_debug(3, "size = 0x%lx", buf_sz);
+	mtk_v4l2_debug(3, "size = 0x%x", buf_sz);
 	for (i = 0; i < H264_MAX_MV_NUM; i++) {
 		mem = &inst->mv_buf[i];
 		if (mem->va)
@@ -637,7 +637,7 @@  static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
 	if (err)
 		goto error_deinit;
 
-	mtk_vcodec_debug(inst, "struct size = %d,%d,%d,%d\n",
+	mtk_vcodec_debug(inst, "struct size = %lu,%lu,%lu,%lu\n",
 			 sizeof(struct mtk_h264_sps_param),
 			 sizeof(struct mtk_h264_pps_param),
 			 sizeof(struct mtk_h264_dec_slice_param),