Re: [PATCH 4/4] i915: POC use dynamic_debug_exec_queries to control pr_debugs in gvt

2020-08-26 Thread kernel test robot
Hi Jim,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on linux/master tegra-drm/drm/tegra/for-next 
drm-tip/drm-tip linus/master v5.9-rc2 next-20200826]
[cannot apply to drm/drm-next]
[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/Jim-Cromie/dyndbg-POC-use-dynamic_debug_exec_queries-in-DRM/20200827-010409
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/i915/i915_params.c: In function 'param_set_dyndbg':
>> drivers/gpu/drm/i915/i915_params.c:307:11: error: implicit declaration of 
>> function 'dynamic_debug_exec_queries' [-Werror=implicit-function-declaration]
 307 |   chgct = dynamic_debug_exec_queries(query, "i915");
 |   ^~
   cc1: some warnings being treated as errors

# 
https://github.com/0day-ci/linux/commit/1b9bcd2cceed427d96bc9bf4eae6619201d645d6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Jim-Cromie/dyndbg-POC-use-dynamic_debug_exec_queries-in-DRM/20200827-010409
git checkout 1b9bcd2cceed427d96bc9bf4eae6619201d645d6
vim +/dynamic_debug_exec_queries +307 drivers/gpu/drm/i915/i915_params.c

   283  
   284  static int param_set_dyndbg(const char *instr, const struct 
kernel_param *kp)
   285  {
   286  static unsigned long int old_val;
   287  unsigned int val;
   288  unsigned long int changes, result;
   289  int rc, chgct = 0, totct = 0, bitpos;
   290  char query[OUR_QUERY_SIZE];
   291  
   292  rc = kstrtouint(instr, 0, );
   293  if (rc) {
   294  pr_err("set_dyndbg: failed\n");
   295  return -EINVAL;
   296  }
   297  result = val;
   298  pr_info("set_dyndbg: result:0x%lx from %s\n", result, instr);
   299  
   300  changes = result ^ old_val;
   301  
   302  for_each_set_bit(bitpos, , NUM_CLASSES) {
   303  
   304  sprintf(query, "format='^%s' %cp", 
pr_debug_classes[bitpos],
   305  test_bit(bitpos, ) ? '+' : '-');
   306  
 > 307  chgct = dynamic_debug_exec_queries(query, "i915");
   308  totct += chgct;
   309  pr_info("change ct:%d on format='%s'\n", chgct,
   310  pr_debug_classes[bitpos]);
   311  }
   312  old_val = result;
   313  pr_info("change ct:%d\n", totct);
   314  return 0;
   315  }
   316  static int param_get_dyndbg(char *buffer, const struct kernel_param *kp)
   317  {
   318  return scnprintf(buffer, PAGE_SIZE, "%u\n",
   319   *((unsigned int *)kp->arg));
   320  }
   321  static const struct kernel_param_ops param_ops_dyndbg = {
   322  .set = param_set_dyndbg,
   323  .get = param_get_dyndbg,
   324  };
   325  

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


.config.gz
Description: application/gzip


[PATCH 4/4] i915: POC use dynamic_debug_exec_queries to control pr_debugs in gvt

2020-08-26 Thread Jim Cromie
The gvt component of this driver has ~120 pr_debugs, in 9 "classes".
Add a "knob", like drm.debug, to map bits to these classes.

bash-5.0# echo 0x01 > /sys/module/i915/parameters/debug_dyn
 set_dyndbg: result:0x1 from 0x01
 dyndbg: query 0: "format='^gvt: cmd: ' +p"
 dyndbg: entry, buf:'format='^gvt: cmd: ' +p'
 dyndbg: start-of-word:0 'format='^gvt: cmd: ' +p'
 dyndbg: start-of-word:1 ''^gvt: cmd: ' +p'
 dyndbg: start-of-word:2 '+p'
 dyndbg: split into words: "format" "^gvt: cmd: " "+p"
 dyndbg: op='+'
 dyndbg: flags=0x1
 dyndbg: *flagsp=0x1 *maskp=0x
 dyndbg: key:'format' arg:'^gvt: cmd: '
 dyndbg: parsed: func="" file="" module="i915" format="^gvt: cmd: " lineno=0-0
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:3081 
[i915]init_cmd_table =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:1376 
[i915]gen8_check_mi_display_flip =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:1373 
[i915]gen8_check_mi_display_flip =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:745 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:744 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:742 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:733 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:729 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:722 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:716 
[i915]parser_exec_state_dump =p
 dyndbg: changed drivers/gpu/drm/i915/gvt/cmd_parser.c:691 [i915]print_opcode =p
 dyndbg: applied: func="" file="" module="i915" format="^gvt: cmd: " lineno=0-0
 dyndbg: processed 1 queries, with 11 matches, 0 errs
 change ct:11 on format='gvt: cmd: '
 change ct:11

Signed-off-by: Jim Cromie 
---
 drivers/gpu/drm/i915/i915_params.c | 76 ++
 1 file changed, 76 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_params.c 
b/drivers/gpu/drm/i915/i915_params.c
index 8d8db9ff0a48..4e1f01ab4865 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -255,3 +255,79 @@ void i915_params_free(struct i915_params *params)
I915_PARAMS_FOR_EACH(FREE);
 #undef FREE
 }
+
+/* POC for callback -> dynamic_debug_exec_queries */
+unsigned long __new_knob;
+EXPORT_SYMBOL(__new_knob);
+
+static char *pr_debug_classes[] = {
+   "gvt: cmd: ",
+   "gvt: core: ",
+   "gvt: dpy: ",
+   "gvt: el: ",
+   "gvt: irq: ",
+   "gvt: mm: ",
+   "gvt: mmio: ",
+   "gvt: render: ",
+   "gvt: sched: "
+};
+#define NUM_CLASSESARRAY_SIZE(pr_debug_classes)
+#define OUR_QUERY_SIZE 128 /* we need about 20 */
+
+#include 
+
+static int param_set_dyndbg(const char *instr, const struct kernel_param *kp)
+{
+   static unsigned long int old_val;
+unsigned int val;
+   unsigned long int changes, result;
+   int rc, chgct = 0, totct = 0, bitpos;
+   char query[OUR_QUERY_SIZE];
+
+   rc = kstrtouint(instr, 0, );
+   if (rc) {
+   pr_err("set_dyndbg: failed\n");
+   return -EINVAL;
+   }
+   result = val;
+   pr_info("set_dyndbg: result:0x%lx from %s\n", result, instr);
+
+   changes = result ^ old_val;
+
+   for_each_set_bit(bitpos, , NUM_CLASSES) {
+
+   sprintf(query, "format='^%s' %cp", pr_debug_classes[bitpos],
+   test_bit(bitpos, ) ? '+' : '-');
+
+   chgct = dynamic_debug_exec_queries(query, "i915");
+   totct += chgct;
+   pr_info("change ct:%d on format='%s'\n", chgct,
+   pr_debug_classes[bitpos]);
+   }
+   old_val = result;
+   pr_info("change ct:%d\n", totct);
+   return 0;
+}
+static int param_get_dyndbg(char *buffer, const struct kernel_param *kp)
+{
+   return scnprintf(buffer, PAGE_SIZE, "%u\n",
+*((unsigned int *)kp->arg));
+}
+static const struct kernel_param_ops param_ops_dyndbg = {
+   .set = param_set_dyndbg,
+   .get = param_get_dyndbg,
+};
+
+MODULE_PARM_DESC(debug_dyn, " enable dynamic-debug by format-string 
classifications.\n"
+"\t\twhich are:"
+"\n\t\t gvt: cmd:"
+"\n\t\t gvt: core:"
+"\n\t\t gvt: dpy:"
+"\n\t\t gvt: el:"
+"\n\t\t gvt: irq:"
+"\n\t\t gvt: mm:"
+"\n\t\t gvt: mmio:"
+"\n\t\t gvt: render:"
+"\n\t\t gvt: sched:" "\n");
+
+module_param_cb(debug_dyn, _ops_dyndbg, &__new_knob, 0644);
-- 
2.26.2