Skip to content

Commit

Permalink
x86/amd_node: Update __amd_smn_rw() error paths
Browse files Browse the repository at this point in the history
Use guard(mutex) and convert PCI error codes to common ones.

Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20241206161210.163701-12-yazen.ghannam@amd.com
  • Loading branch information
Yazen Ghannam authored and Borislav Petkov (AMD) committed Jan 8, 2025
1 parent d6caeaf commit 35df797
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions arch/x86/kernel/amd_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,24 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write)
int err = -ENODEV;

if (node >= amd_nb_num())
goto out;
return err;

root = node_to_amd_nb(node)->root;
if (!root)
goto out;
return err;

mutex_lock(&smn_mutex);
guard(mutex)(&smn_mutex);

err = pci_write_config_dword(root, 0x60, address);
if (err) {
pr_warn("Error programming SMN address 0x%x.\n", address);
goto out_unlock;
return pcibios_err_to_errno(err);
}

err = (write ? pci_write_config_dword(root, 0x64, *value)
: pci_read_config_dword(root, 0x64, value));

out_unlock:
mutex_unlock(&smn_mutex);

out:
return err;
return pcibios_err_to_errno(err);
}

int __must_check amd_smn_read(u16 node, u32 address, u32 *value)
Expand Down

0 comments on commit 35df797

Please sign in to comment.