Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails

From: Yazen Ghannam

Date: Mon Nov 30 2026 - 13:12:35 EST


On Mon, Nov 30, 2026 at 06:28:15PM +0100, Ilan Bonneau-Zamon wrote:
> On multi-root AMD systems, another driver or firmware mechanism may
> already have reserved the PCI config space of a single root device.
> Aborting amd_smn_init() on the first reservation failure needlessly
> prevents initializing and protecting the SMN registers on the remaining
> roots.
>
> However, if reserving PCI config space fails for every discovered root,
> no SMN protection is in place at all and initialization must still
> fail with -EEXIST.
>
> Suggested-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> Suggested-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> Signed-off-by: Ilan Bonneau-Zamon <ilan.bonneauzamon@xxxxxxxxx>
> ---
> Changes in v9:
> - Rewrite commit message to focus on why the change is needed rather
> than describing what the diff does.
> Changes in v8:
> - Track failed reservations and return -EEXIST if all roots fail.
> - Add Suggested-by tag for Mario Limonciello.
> ---
> arch/x86/kernel/amd_node.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c
> index b7926ba3610a..14a97df63ce2 100644
> --- a/arch/x86/kernel/amd_node.c
> +++ b/arch/x86/kernel/amd_node.c
> @@ -250,8 +250,8 @@ __setup("amd_smn_debugfs_enable", amd_smn_enable_dfs);
>
> static int __init amd_smn_init(void)
> {
> - u16 count, num_roots, roots_per_node, node, num_nodes;
> - struct pci_dev *root __free(pci_dev_put) = NULL;
> + u16 count, num_roots = 0, failed = 0, roots_per_node, node, num_nodes;
> + struct pci_dev *root = NULL;
>
> if (!cpu_feature_enabled(X86_FEATURE_ZEN))
> return 0;
> @@ -261,7 +261,6 @@ static int __init amd_smn_init(void)
> if (amd_roots)
> return 0;
>
> - num_roots = 0;
> while ((root = get_next_root(root))) {
> pci_dbg(root, "Reserving PCI config space\n");
>

You didn't answer about these changes.

Thanks,
Yazen