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=0xffffffff 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 <jim.cromie@xxxxxxxxx> --- 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_CLASSES ARRAY_SIZE(pr_debug_classes) +#define OUR_QUERY_SIZE 128 /* we need about 20 */ + +#include <linux/module.h> + +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, &val); + 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, &changes, NUM_CLASSES) { + + sprintf(query, "format='^%s' %cp", pr_debug_classes[bitpos], + test_bit(bitpos, &result) ? '+' : '-'); + + 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, ¶m_ops_dyndbg, &__new_knob, 0644); -- 2.26.2 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel