Re: [RFC PATCH v2 4/5] x86/amd_node: Add smn_set_roots() and smn_activate() for external SMN registration
From: Lin Wang
Date: Thu Apr 23 2026 - 21:45:48 EST
Hi Mario,
You're right. After a successful smn_set_roots(), smn_num_nodes is guaranteed to be non-zero because smn_set_roots() already rejects (!roots || !num_nodes). So checking !smn_roots here is sufficient.
Will fix in v3.
Thanks & Br,
Lin
On 4/24/2026 3:12 AM, Mario Limonciello wrote:
+/*
+ * Activate the SMN access layer after roots have been registered via
+ * smn_set_roots(). Creates the optional debugfs interface (gated by
+ * the amd_smn_debugfs_enable boot parameter) and sets smn_exclusive so
+ * that amd_smn_read()/amd_smn_write() begin accepting requests.
+ *
+ * @debugfs_name: directory name under arch_debugfs_dir (e.g. "amd_smn")
+ *
+ * Same serialization rules as smn_set_roots(): must be called exactly
+ * once, at boot, after smn_set_roots() succeeds.
+ */
+int smn_activate(const char *debugfs_name)
+{
+ if (!smn_roots || !smn_num_nodes)
+ return -EINVAL;
You don't need the !smn_num_nodes check here. smn_set_roots() already has it.