diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 39550fefcf0f..328722ba2d8e 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -56,6 +56,34 @@ struct _ddebug {
 #endif
 } __attribute__((aligned(8)));
 
+struct ddebug_known_classes_map {
+	struct list_head link;
+	struct module *mod;
+	const char *mod_name;	/* needed for builtins */
+	const int base;		/* index of 1st .class_id, allows split/shared space */
+	const int length;
+	const char *classes[];	/* index maps .class_id */
+};
+
+#define NUM_TYPE_ARGS(eltype, ...) \
+	(sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype))
+/**
+ * DYNAMIC_DEBUG_CLASSES - declare classnames known by a module
+ * @_var: passed to dynamic_debug_register_classes(_var)
+ * @_base: offset of 1st class-name. splits .class_id space
+ * @classes: class-names known/used by of .class_ids[_base.._base+length]
+ *
+ * @classes specifies names for the classids used by a module; dyndbg
+ * accepts "class <name>" commands if <name> is known and registered.
+ */
+#define DYNAMIC_DEBUG_CLASSES(_var, _base, ...)				\
+	static __maybe_unused struct ddebug_known_classes_map _var = {	\
+		.mod = THIS_MODULE,					\
+		.mod_name = KBUILD_MODNAME,				\
+		.base = _base,						\
+		.length = NUM_TYPE_ARGS(char*, __VA_ARGS__),		\
+		.classes = { __VA_ARGS__ }				\
+	}
 
 
 #if defined(CONFIG_DYNAMIC_DEBUG_CORE)
@@ -206,6 +234,9 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
 				   KERN_DEBUG, prefix_str, prefix_type,	\
 				   rowsize, groupsize, buf, len, ascii)
 
+int  dynamic_debug_register_classes(struct ddebug_known_classes_map *map);
+void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map);
+
 #else /* !CONFIG_DYNAMIC_DEBUG_CORE */
 
 #include <linux/string.h>
@@ -247,6 +278,11 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
 	} while (0)
 
 
+static inline int dynamic_debug_register_classes(const struct ddebug_known_classes_map *map)
+{ return 0; }
+static inline void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map)
+{}
+
 #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */
 
 #endif
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index cdc0b03b1148..8f600c13048a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -45,6 +45,8 @@ extern struct _ddebug __stop___dyndbg[];
 struct ddebug_table {
 	struct list_head link;
 	const char *mod_name;
+	/* a module can have multiple class-sets eventually, but not yet */
+	struct ddebug_known_classes_map const *map;
 	unsigned int num_ddebugs;
 	struct _ddebug *ddebugs;
 };
@@ -916,6 +918,57 @@ static const struct proc_ops proc_fops = {
 	.proc_write = ddebug_proc_write
 };
 
+/**
+ * dynamic_debug_register_classes - register a module's known classes
+ * @map:  &struct ddebug_known_classes_map
+ *
+ * modules using non-default pr_debug.class_id's should call this to
+ * inform dyndbg which classes they use (0..N), and what their
+ * classnames are.  They are then usable in ```echo $cmd >control```
+ */
+int dynamic_debug_register_classes(struct ddebug_known_classes_map *map)
+{
+	struct ddebug_table *dt;
+	int rc = -ENOENT;
+
+	mutex_lock(&ddebug_lock);
+#ifdef CONFIG_MODULES
+	if (map->mod) {
+		/* loadable module */
+		list_for_each_entry(dt, &ddebug_tables, link) {
+			if (dt->mod_name == map->mod->name) {
+				rc = 0;
+				dt->map = map;
+				break;
+			}
+		}
+	}
+#endif
+	if (!map->mod) {
+		/* builtin module */
+		list_for_each_entry(dt, &ddebug_tables, link) {
+			if (!strcmp(dt->mod_name, map->mod_name)) {
+				rc = 0;
+				dt->map = map;
+				break;
+			}
+		}
+	}
+	mutex_unlock(&ddebug_lock);
+	if (rc)
+		pr_warn("register_classes: module %s not found\n", map->mod_name);
+	else
+		vpr_info("register_classes: %s\n", map->mod_name);
+
+	return rc;
+}
+EXPORT_SYMBOL(dynamic_debug_register_classes);
+
+void dynamic_debug_unregister_classes(struct ddebug_known_classes_map *map)
+{
+	vpr_info("unregister_classes: %s\n", map->mod_name);
+}
+
 /*
  * Allocate a new ddebug_table for the given module
  * and add it to the global list.
