diff mbox series

[11/16] x86/amd_smn: Fixup __amd_smn_rw()

Message ID 20241023172150.659002-12-yazen.ghannam@amd.com (mailing list archive)
State Handled Elsewhere
Headers show
Series AMD NB and SMN rework | expand

Commit Message

Yazen Ghannam Oct. 23, 2024, 5:21 p.m. UTC
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>
---
 arch/x86/kernel/amd_smn.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Borislav Petkov Nov. 4, 2024, 2:32 p.m. UTC | #1
On Wed, Oct 23, 2024 at 05:21:45PM +0000, Yazen Ghannam wrote:
> Subject: Re: [PATCH 11/16] x86/amd_smn: Fixup __amd_smn_rw()

Needs a more descriptive title...
Yazen Ghannam Nov. 5, 2024, 2:59 p.m. UTC | #2
On Mon, Nov 04, 2024 at 03:32:12PM +0100, Borislav Petkov wrote:
> On Wed, Oct 23, 2024 at 05:21:45PM +0000, Yazen Ghannam wrote:
> > Subject: Re: [PATCH 11/16] x86/amd_smn: Fixup __amd_smn_rw()
> 
> Needs a more descriptive title...
>

Okay, will update it.

Thanks,
Yazen
diff mbox series

Patch

diff --git a/arch/x86/kernel/amd_smn.c b/arch/x86/kernel/amd_smn.c
index 06160a9e2444..e53db07d1a77 100644
--- a/arch/x86/kernel/amd_smn.c
+++ b/arch/x86/kernel/amd_smn.c
@@ -57,28 +57,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)