mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <bp@alien8.de>, <linux-edac@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH v10 2/7] RAS/AMD/ATL: Refactor PRM address translation into a common helper
Date: Tue, 22 Sep 2026 15:23:12 -0500	[thread overview]
Message-ID: <20260922202318.4079080-3-yazen.ghannam@amd.com> (raw)
In-Reply-To: <20260922202318.4079080-1-yazen.ghannam@amd.com>

Every PRM address translation follows the same pattern. Each fills a
parameter buffer, invokes the handler, and checks the result. Only the
handler GUID and the output buffer differ.

Factor the common sequence into prm_umc_norm_to_addr().

Assisted-by: LLM
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 drivers/ras/amd/atl/prm.c | 42 +++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/ras/amd/atl/prm.c b/drivers/ras/amd/atl/prm.c
index eba9d104d09e..b3ff33a668c2 100644
--- a/drivers/ras/amd/atl/prm.c
+++ b/drivers/ras/amd/atl/prm.c
@@ -18,36 +18,44 @@
 
 #include <linux/prmt.h>
 
-/*
- * PRM parameter buffer - normalized to system physical address, as described
- * in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide.
- */
-struct norm_to_sys_param_buf {
+/* See "PRM Parameter Buffer" in the AMD ACPI Porting Guide. */
+struct param_buf {
 	u64 norm_addr;
 	u8 socket;
 	u64 bank_id;
 	void *out_buf;
 } __packed;
 
-unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
+static int prm_umc_norm_to_addr(guid_t guid, struct param_buf *p_buf)
 {
-	struct norm_to_sys_param_buf p_buf;
-	unsigned long ret_addr;
 	int ret;
 
-	p_buf.norm_addr = addr;
-	p_buf.socket    = socket_id;
-	p_buf.bank_id   = bank_id;
-	p_buf.out_buf   = &ret_addr;
-
-	ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
+	ret = acpi_call_prm_handler(guid, p_buf);
 	if (!ret)
-		return ret_addr;
+		return 0;
 
 	if (ret == -ENODEV || ret == -EOPNOTSUPP)
-		pr_debug("PRM module/handler not available\n");
+		pr_debug("PRM module/handler not available: %d\n", ret);
 	else
-		pr_notice_once("PRM address translation failed\n");
+		pr_notice_once("PRM address translation failed: %d\n", ret);
 
 	return ret;
 }
+
+unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
+{
+	unsigned long sys_addr;
+	struct param_buf p_buf = {
+		.norm_addr	= addr,
+		.socket		= socket_id,
+		.bank_id	= bank_id,
+		.out_buf	= &sys_addr,
+	};
+	int ret;
+
+	ret = prm_umc_norm_to_addr(norm_to_sys_guid, &p_buf);
+	if (ret)
+		return ret;
+
+	return sys_addr;
+}
-- 
2.43.0


  parent reply	other threads:[~2026-09-22 20:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 20:23 [PATCH v10 0/7] Incorporate DRAM address in EDAC messages Yazen Ghannam
2026-09-22 20:23 ` [PATCH v10 1/7] RAS/AMD/ATL: Make PRM address translation support builtin Yazen Ghannam
2026-09-22 20:23 ` Yazen Ghannam [this message]
2026-09-22 20:23 ` [PATCH v10 3/7] RAS/AMD/ATL: Add unified UMC address translation interface Yazen Ghannam
2026-09-22 20:23 ` [PATCH v10 4/7] RAS/AMD, EDAC/amd64: Use unified interface for SPA translation Yazen Ghannam
2026-09-22 20:23 ` [PATCH v10 5/7] RAS/AMD/ATL: Remove the standalone SPA translation interface Yazen Ghannam
2026-09-22 20:23 ` [PATCH v10 6/7] RAS/AMD/ATL: Add DRAM address translation via PRM Yazen Ghannam
2026-09-22 20:23 ` [PATCH v10 7/7] EDAC/amd64: Include DRAM address in output Yazen Ghannam
2026-09-28  5:30 ` [PATCH v10 0/7] Incorporate DRAM address in EDAC messages Borislav Petkov
2026-09-28 15:12   ` Yazen Ghannam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260922202318.4079080-3-yazen.ghannam@amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®