dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-gvt-dev@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk,
	seanpaul@chromium.org, joe@perches.com
Subject: [PATCH v6 33/57] nouveau: WIP add 2 LEVEL_NUM classmaps for CLI, SUBDEV
Date: Sun,  4 Sep 2022 15:41:10 -0600	[thread overview]
Message-ID: <20220904214134.408619-34-jim.cromie@gmail.com> (raw)
In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com>

clone the nvkm_printk,_,__ macro ladder into nvkm_drmdbg,_,__.
And alter the debug, trace, spam macros to use the renamed ladder.

This *sets-up* (not done yet) to remove the _subdev->debug >= (l)
condition, once the bitmap-param is wired up correctly, and figured
into dyndbg's jump-label enablement.  WIP.

Then undo the 1-line change that reduced count of prdbgs from 632 to 119.

ie: s/NV_SUBDEV_DBG_##l/NV_DBG_##l/

So heres what happened: new symbol is 15 (or 10), and fails this macro
test, so gets compiled out, and the dev_dbg is excluded.

        if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l))       \
                dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \

I could hack this, by doing (l + base), but base is pretty distant.

OTOH, the whole CONFIG_NOUVEAU_DEBUG check could be reworked; given
that trace is minumum recommended, theres not that many callsites
elided (SPAM only iirc) at compile-time, and dyndbg means keeping them
has "zero" run-cost (and 56 bytes per callsite).  So this config item
doesnt do much when DRM_USE_DYNAMIC_DEBUG=y.

So this is a useful place to stop and look around, try to guess which
trail to take..

nouveau has additional debug variables to consider:

drivers/gpu/drm/nouveau/include/nvkm/core/device.h
131:	if (_device->debug >= (l))                                             \

drivers/gpu/drm/nouveau/include/nvkm/core/client.h
39:	if (_client->debug >= NV_DBG_##l)                                      \

drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
54:	if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l))              \

This is another baby-step, that seems not to break, so lets get a
snapshot.

whats done here:

In nouveau_drm.c, do DECLARE_DYNDBG_CLASSMAP(LEVEL_NUM type) 2x more,
for cli and subdev, right after the drm DECLARE.  Adjust base for
each, to share the 0..30 classid-space.

These declare class-names: NV_CLI_DBG_* NV_SUBDEV_DBG_* accordingly.
Note: class-name-space is flat and wide, so super-generic names like
INFO should be prefixed; who could predict what a generic V3 does
across all modules.

s should be included

adjusting the base to avoid each other, and the 0-10
already mapped to drm-debug-categorys (just above this addition).

In nvkm/core/debug.h, add enums to match the names, with initial
values to match the bases.

In nvkm/core/subdev.h, alter (recently added) nvkm_drmdbg_() to use
NV_SUBDEV_DBG_* instead of NV_DBG_*.

NB: in both classmaps, Ive left FATAL..WARN out, they're not really
optional the way INFO..SPAM are; dyndbg shouldn't be able to turn them off.

bash-5.1# modprobe nouveau
[  966.107833] dyndbg:   3 debug prints in module wmi
[  966.342188] dyndbg: class[0]: module:nouveau base:15 len:5 ty:1
[  966.342873] dyndbg:  15: 0 NV_SUBDEV_DBG_OFF
[  966.343352] dyndbg:  16: 1 NV_SUBDEV_DBG_INFO
[  966.343912] dyndbg:  17: 2 NV_SUBDEV_DBG_DEBUG
[  966.344443] dyndbg:  18: 3 NV_SUBDEV_DBG_TRACE
[  966.344938] dyndbg:  19: 4 NV_SUBDEV_DBG_SPAM
[  966.345402] dyndbg: class[1]: module:nouveau base:10 len:5 ty:1
[  966.346011] dyndbg:  10: 0 NV_CLI_DBG_OFF
[  966.346477] dyndbg:  11: 1 NV_CLI_DBG_INFO
[  966.346989] dyndbg:  12: 2 NV_CLI_DBG_DEBUG
[  966.347442] dyndbg:  13: 3 NV_CLI_DBG_TRACE
[  966.347875] dyndbg:  14: 4 NV_CLI_DBG_SPAM
[  966.348284] dyndbg: class[2]: module:nouveau base:0 len:10 ty:0
[  966.348888] dyndbg:  0: 0 DRM_UT_CORE
[  966.349310] dyndbg:  1: 1 DRM_UT_DRIVER
[  966.349694] dyndbg:  2: 2 DRM_UT_KMS
[  966.350083] dyndbg:  3: 3 DRM_UT_PRIME
[  966.350482] dyndbg:  4: 4 DRM_UT_ATOMIC
[  966.351016] dyndbg:  5: 5 DRM_UT_VBL
[  966.351475] dyndbg:  6: 6 DRM_UT_STATE
[  966.351899] dyndbg:  7: 7 DRM_UT_LEASE
[  966.352309] dyndbg:  8: 8 DRM_UT_DP
[  966.352678] dyndbg:  9: 9 DRM_UT_DRMRES
[  966.353104] dyndbg: module:nouveau attached 3 classes
[  966.353759] dyndbg: 119 debug prints in module nouveau

NOTE: it was 632 with previous commit, switching NV_DEBUG to use
NV_SUBDEV_DBG_DEBUG instead of NV_DBG_DEBUG may be the cause.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 .../gpu/drm/nouveau/include/nvkm/core/debug.h | 16 +++++++++++++
 .../drm/nouveau/include/nvkm/core/subdev.h    | 17 ++++++++++----
 drivers/gpu/drm/nouveau/nouveau_drm.c         |  7 ++++++
 drivers/gpu/drm/nouveau/nvkm/core/subdev.c    | 23 +++++++++++++++++++
 4 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h
index b4a9c7d991ca..6a155a23a3d1 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/debug.h
@@ -9,4 +9,20 @@
 #define NV_DBG_TRACE    5
 #define NV_DBG_PARANOIA 6
 #define NV_DBG_SPAM     7
+
+enum nv_cli_dbg_verbose {
+	NV_CLI_DBG_OFF = 10,
+	NV_CLI_DBG_INFO,
+	NV_CLI_DBG_DEBUG,
+	NV_CLI_DBG_TRACE,
+	NV_CLI_DBG_SPAM
+};
+enum nv_subdev_dbg_verbose {
+	NV_SUBDEV_DBG_OFF = 15,
+	NV_SUBDEV_DBG_INFO,
+	NV_SUBDEV_DBG_DEBUG,
+	NV_SUBDEV_DBG_TRACE,
+	NV_SUBDEV_DBG_SPAM
+};
+
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
index 065d07ccea87..ce33c82e5c75 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
@@ -2,6 +2,7 @@
 #ifndef __NVKM_SUBDEV_H__
 #define __NVKM_SUBDEV_H__
 #include <core/device.h>
+#include <core/debug.h>
 
 enum nvkm_subdev_type {
 #define NVKM_LAYOUT_ONCE(t,s,p,...) t,
@@ -18,7 +19,7 @@ struct nvkm_subdev {
 	enum nvkm_subdev_type type;
 	int inst;
 	char name[16];
-	u32 debug;
+	unsigned long debug;
 	struct list_head head;
 
 	void **pself;
@@ -59,9 +60,17 @@ void nvkm_subdev_intr(struct nvkm_subdev *);
 #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR,    err, f, ##a)
 #define nvkm_warn(s,f,a...)  nvkm_printk((s),  WARN, notice, f, ##a)
 #define nvkm_info(s,f,a...)  nvkm_printk((s),  INFO,   info, f, ##a)
-#define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG,    dbg, f, ##a)
-#define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE,    dbg, f, ##a)
-#define nvkm_spam(s,f,a...)  nvkm_printk((s),  SPAM,    dbg, f, ##a)
+
+#define nvkm_drmdbg__(s,l,p,f,a...) do {				\
+	const struct nvkm_subdev *_subdev = (s);			\
+	if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l))	\
+		dev_dbg(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \
+} while(0)
+#define nvkm_drmdbg_(s,l,f,a...) nvkm_drmdbg__((s), NV_SUBDEV_DBG_##l, dbg, f, ##a)
+#define nvkm_debug(s,f,a...) nvkm_drmdbg_((s), DEBUG, f, ##a)
+#define nvkm_trace(s,f,a...) nvkm_drmdbg_((s), TRACE, f, ##a)
+#define nvkm_spam(s,f,a...)  nvkm_drmdbg_((s),  SPAM, f, ##a)
 
 #define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a)
+
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index fd99ec0f4257..864750451dc8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -83,6 +83,13 @@ DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0,
 			"DRM_UT_DP",
 			"DRM_UT_DRMRES");
 
+DECLARE_DYNDBG_CLASSMAP(nv_cli_debug_verbose, DD_CLASS_TYPE_LEVEL_NUM, 10,
+			"NV_CLI_DBG_OFF",
+			"NV_CLI_DBG_INFO",
+			"NV_CLI_DBG_DEBUG",
+			"NV_CLI_DBG_TRACE",
+			"NV_CLI_DBG_SPAM");
+
 MODULE_PARM_DESC(config, "option string to pass to driver core");
 static char *nouveau_config;
 module_param_named(config, nouveau_config, charp, 0400);
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
index a74b7acb6832..20cd99cce2a4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c
@@ -26,6 +26,27 @@
 #include <core/option.h>
 #include <subdev/mc.h>
 
+#include <linux/dynamic_debug.h>
+#include <linux/module.h>
+
+#define DEBUG
+
+DECLARE_DYNDBG_CLASSMAP(nv_subdev_debug_verbose, DD_CLASS_TYPE_LEVEL_NAMES, 15,
+			"NV_SUBDEV_DBG_OFF",
+			"NV_SUBDEV_DBG_INFO",
+			"NV_SUBDEV_DBG_DEBUG",
+			"NV_SUBDEV_DBG_TRACE",
+			"NV_SUBDEV_DBG_SPAM");
+
+static struct ddebug_class_param nv_subdev_verbose = {
+	.bits = NULL, // wants &_subdev->debug
+	.flags = "p",
+	.map = &nv_subdev_debug_verbose,
+};
+module_param_cb(debug_subdev, &param_ops_dyndbg_classes, &nv_subdev_verbose, 0600);
+
+
+
 const char *
 nvkm_subdev_type[NVKM_SUBDEV_NR] = {
 #define NVKM_LAYOUT_ONCE(type,data,ptr,...) [type] = #ptr,
@@ -180,6 +201,8 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func, struct nvkm_device *device
 	else
 		strscpy(subdev->name, nvkm_subdev_type[type], sizeof(subdev->name));
 	subdev->debug = nvkm_dbgopt(device->dbgopt, subdev->name);
+	nv_subdev_verbose.bits = &subdev->debug;
+	pr_debug("updated bitmap: %px\n", &nv_subdev_verbose.bits);
 	list_add_tail(&subdev->head, &device->subdev);
 }
 
-- 
2.37.2


  parent reply	other threads:[~2022-09-04 21:47 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-04 21:40 [PATCH v6 00/57] DYNDBG: opt-in class'd debug for modules, use in drm Jim Cromie
2022-09-04 21:40 ` [PATCH v6 01/57] dyndbg: fix static_branch manipulation Jim Cromie
2022-09-04 21:40 ` [PATCH v6 02/57] dyndbg: fix module.dyndbg handling Jim Cromie
2022-09-04 21:40 ` [PATCH v6 03/57] dyndbg: show both old and new in change-info Jim Cromie
2022-09-04 21:40 ` [PATCH v6 04/57] dyndbg: reverse module walk in cat control Jim Cromie
2022-09-04 21:40 ` [PATCH v6 05/57] dyndbg: reverse module.callsite " Jim Cromie
2022-09-04 21:40 ` [PATCH v6 06/57] dyndbg: use ESCAPE_SPACE for " Jim Cromie
2022-09-04 21:40 ` [PATCH v6 07/57] dyndbg: let query-modname override actual module name Jim Cromie
2022-09-04 21:40 ` [PATCH v6 08/57] dyndbg: add test_dynamic_debug module Jim Cromie
2022-09-04 21:40 ` [PATCH v6 09/57] dyndbg: drop EXPORTed dynamic_debug_exec_queries Jim Cromie
2022-09-04 21:40 ` [PATCH v6 10/57] dyndbg: cleanup auto vars in dynamic_debug_init Jim Cromie
2022-09-07 14:10   ` Jason Baron
2022-09-04 21:40 ` [PATCH v6 11/57] dyndbg: gather __dyndbg[] state into struct _ddebug_info Jim Cromie
2022-09-04 21:40 ` [PATCH v6 12/57] dyndbg: add class_id to pr_debug callsites Jim Cromie
2022-09-04 21:40 ` [PATCH v6 13/57] dyndbg: add __pr_debug_cls for testing Jim Cromie
2022-09-04 21:40 ` [PATCH v6 14/57] dyndbg: add DECLARE_DYNDBG_CLASSMAP macro Jim Cromie
2022-09-04 21:40 ` [PATCH v6 15/57] kernel/module: add __dyndbg_classes section Jim Cromie
2022-09-04 21:40 ` [PATCH v6 16/57] dyndbg: add ddebug_attach_module_classes Jim Cromie
2022-09-04 21:40 ` [PATCH v6 17/57] dyndbg: validate class FOO by checking with module Jim Cromie
2022-09-07 18:19   ` Jason Baron
2022-09-09 20:44     ` jim.cromie
2022-09-12 20:17       ` Jason Baron
2022-09-12 22:08         ` jim.cromie
2022-09-04 21:40 ` [PATCH v6 18/57] doc-dyndbg: describe "class CLASS_NAME" query support Jim Cromie
2022-09-04 21:40 ` [PATCH v6 19/57] doc-dyndbg: edit dynamic-debug-howto for brevity, audience Jim Cromie
2022-09-04 21:40 ` [PATCH v6 20/57] dyndbg: add drm.debug style (drm/parameters/debug) bitmap support Jim Cromie
2022-09-04 21:40 ` [PATCH v6 21/57] dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes Jim Cromie
2022-09-07 14:54   ` Greg KH
2022-09-07 14:57     ` Greg KH
2022-09-04 21:40 ` [PATCH v6 22/57] drm_print: condense enum drm_debug_category Jim Cromie
2022-09-07  6:09   ` Daniel Vetter
2022-09-04 21:41 ` [PATCH v6 23/57] drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers Jim Cromie
2022-09-07  6:13   ` Daniel Vetter
2022-09-09 19:06     ` jim.cromie
2022-09-04 21:41 ` [PATCH v6 24/57] drm_print: interpose drm_*dbg with forwarding macros Jim Cromie
2022-09-04 21:41 ` [PATCH v6 25/57] drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro Jim Cromie
2022-09-04 21:41 ` [PATCH v6 26/57] drm-print.h: include dyndbg header Jim Cromie
2022-09-04 21:41 ` [PATCH v6 27/57] drm-print: add drm_dbg_driver to improve namespace symmetry Jim Cromie
2022-09-04 21:41 ` [PATCH v6 28/57] drm_print: refine drm_debug_enabled for jump-label Jim Cromie
2022-09-07  6:40   ` Daniel Vetter
2022-09-09 23:42     ` jim.cromie
2022-09-04 21:41 ` [PATCH v6 29/57] drm_print: prefer bare printk KERN_DEBUG on generic fn Jim Cromie
2022-09-04 21:41 ` [PATCH v6 30/57] drm_print: add _ddebug descriptor to drm_*dbg prototypes Jim Cromie
2022-09-04 21:41 ` [PATCH v6 31/57] nouveau: change nvkm_debug/trace to use dev_dbg POC Jim Cromie
2022-09-04 21:41 ` [PATCH v6 32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug Jim Cromie
2023-03-06 18:49   ` Timur Tabi
2023-03-07  5:10     ` jim.cromie
2022-09-04 21:41 ` Jim Cromie [this message]
2022-09-04 21:41 ` [PATCH v6 34/57] dyndbg: add _DPRINTK_FLAGS_ENABLED Jim Cromie
2022-09-04 21:41 ` [PATCH v6 35/57] dyndbg: add _DPRINTK_FLAGS_TRACE Jim Cromie
2022-09-04 21:41 ` [PATCH v6 36/57] dyndbg: add write-events-to-tracefs code Jim Cromie
2022-09-04 21:41 ` [PATCH v6 37/57] dyndbg: add 2 trace-events: drm_debug, drm_devdbg Jim Cromie
2022-09-04 21:41 ` [PATCH v6 38/57] dyndbg: add 2 more trace-events: pr_debug, dev_dbg Jim Cromie
2022-09-04 21:41 ` [PATCH v6 39/57] dyndbg/drm: POC add tracebits sysfs-knob Jim Cromie
2022-09-07  6:59   ` Daniel Vetter
2022-09-04 21:41 ` [PATCH v6 40/57] dyndbg: abstraction macros for modname, function, filename fields Jim Cromie
2022-09-04 21:41 ` [PATCH v6 41/57] dyndbg: split repeating columns to new struct _ddebug_site Jim Cromie
2022-09-04 21:41 ` [PATCH v6 42/57] dyndbg: shrink lineno field by 2 bits Jim Cromie
2022-09-04 21:41 ` [PATCH v6 43/57] dyndbg: add _index,_map to struct _ddebug Jim Cromie
2022-09-04 21:41 ` [PATCH v6 44/57] dyndbg: extend __ddebug_add_module proto to allow packing sites Jim Cromie
2022-09-04 21:41 ` [PATCH v6 45/57] dyndbg: de-duplicate sites Jim Cromie
2022-09-04 21:41 ` [PATCH v6 46/57] dyndbg: drop site-> in add-module, more needed Jim Cromie
2022-09-04 21:41 ` [PATCH v6 47/57] dyndbg: demote iter->site in _init Jim Cromie
2022-09-04 21:41 ` [PATCH v6 48/57] dyndbg: add .gnu.linkonce slot in vmlinux.lds.h KEEPs Jim Cromie
2022-09-04 21:41 ` [PATCH v6 49/57] dyndbg: add structs _ddebug_hdr, _ddebug_site_hdr Jim Cromie
2022-09-04 21:41 ` [PATCH v6 50/57] dyndbg: count unique callsites Jim Cromie
2022-09-04 21:41 ` [PATCH v6 51/57] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE Jim Cromie
2022-09-04 21:41 ` [PATCH v6 52/57] dyndbg: add DEFINE_DYNAMIC_DEBUG_TABLE, use it tacitly RFC Jim Cromie
2022-09-04 21:41 ` [PATCH v6 53/57] dyndbg: add/use is_dyndbg_header then set _uplink Jim Cromie
2022-09-04 21:41 ` [PATCH v6 54/57] dyndbg: add .gnu.linkonce. & __dyndbg* sections in module.lds.h Jim Cromie
2022-09-04 21:41 ` [PATCH v6 55/57] dyndbg: dynamic_debug_sites_reclaim() using free_reserved_page() WAG Jim Cromie
2022-09-04 21:41 ` [PATCH v6 56/57] dyndbg: work ddebug_map_site Jim Cromie
2022-09-04 21:41 ` [PATCH v6 57/57] dyndbg: fiddle with readback value on LEVEL_NAMES types Jim Cromie
2022-09-07 15:08 ` [PATCH v6 00/57] DYNDBG: opt-in class'd debug for modules, use in drm Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220904214134.408619-34-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jbaron@akamai.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).