mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.ibm.com>
To: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	chleroy@kernel.org, Srikar Dronamraju <srikar@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] powerpc/numa: Consolidate VPHN associativity lookup
Date: Fri, 16 Oct 2026 16:34:07 +0530	[thread overview]
Message-ID: <20261016110412.1380298-3-srikar@linux.ibm.com> (raw)
In-Reply-To: <20261016110412.1380298-1-srikar@linux.ibm.com>

There are two helpers for retrieving the associativity of a virtual
processor using VPHN. The helper used during NUMA initialization also
handles the case where the CPU is not yet mapped to a logical CPU,
while the helper used for topology updates operates on a logical CPU.

Consolidate them by extending the former helper to handle both cases.
If the argument corresponds to a possible CPU, translate it to its
hardware ID; otherwise, treat it as a hardware CPU ID directly.

Rename __vphn_get_associativity() to vphn_get_associativity() and use
it for both NUMA initialization and topology updates. Return the VPHN
hypercall return code instead of converting all failures to -1, and
remove the duplicate implementation.

Signed-off-by: Srikar Dronamraju <srikar@linux.ibm.com>
---
 arch/powerpc/mm/numa.c | 54 ++++--------------------------------------
 1 file changed, 5 insertions(+), 49 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 09f7e7b2b192..df3b51a1beb4 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -641,7 +641,7 @@ int of_drconf_to_nid_single(struct drmem_lmb *lmb)
 
 #ifdef CONFIG_PPC_SPLPAR
 
-static int __vphn_get_associativity(long lcpu, __be32 *associativity)
+static long vphn_get_associativity(unsigned long lcpu, __be32 *associativity)
 {
 	long rc, hwid;
 
@@ -665,7 +665,7 @@ static int __vphn_get_associativity(long lcpu, __be32 *associativity)
 			return 0;
 	}
 
-	return -1;
+	return rc;
 }
 
 static int vphn_get_nid(long lcpu)
@@ -673,7 +673,7 @@ static int vphn_get_nid(long lcpu)
 	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
 
 
-	if (!__vphn_get_associativity(lcpu, associativity))
+	if (!vphn_get_associativity(lcpu, associativity))
 		return associativity_to_nid(associativity);
 
 	return NUMA_NO_NODE;
@@ -681,7 +681,7 @@ static int vphn_get_nid(long lcpu)
 }
 #else
 
-static int __vphn_get_associativity(long lcpu, __be32 *associativity)
+static long vphn_get_associativity(unsigned long lcpu, __be32 *associativity)
 {
 	return -1;
 }
@@ -951,7 +951,7 @@ static int __init parse_numa_properties(void)
 
 		memset(vphn_assoc, 0, VPHN_ASSOC_BUFSIZE * sizeof(__be32));
 
-		if (__vphn_get_associativity(i, vphn_assoc) == 0) {
+		if (vphn_get_associativity(i, vphn_assoc) == 0) {
 			nid = associativity_to_nid(vphn_assoc);
 			initialize_form1_numa_distance(vphn_assoc);
 			index = detect_and_enable_coregroup(vphn_assoc, index);
@@ -1384,43 +1384,6 @@ u64 memory_hotplug_max(void)
 #ifdef CONFIG_PPC_SPLPAR
 static int topology_inited;
 
-/*
- * Retrieve the new associativity information for a virtual processor's
- * home node.
- */
-static long vphn_get_associativity(unsigned long cpu,
-					__be32 *associativity)
-{
-	long rc;
-
-	rc = hcall_vphn(get_hard_smp_processor_id(cpu),
-				VPHN_FLAG_VCPU, associativity);
-
-	switch (rc) {
-	case H_SUCCESS:
-		pr_debug("VPHN hcall succeeded. Reset polling...\n");
-		goto out;
-
-	case H_FUNCTION:
-		pr_err_ratelimited("VPHN unsupported. Disabling polling...\n");
-		break;
-	case H_HARDWARE:
-		pr_err_ratelimited("hcall_vphn() experienced a hardware fault "
-			"preventing VPHN. Disabling polling...\n");
-		break;
-	case H_PARAMETER:
-		pr_err_ratelimited("hcall_vphn() was passed an invalid parameter. "
-			"Disabling polling...\n");
-		break;
-	default:
-		pr_err_ratelimited("hcall_vphn() returned %ld. Disabling polling...\n"
-			, rc);
-		break;
-	}
-out:
-	return rc;
-}
-
 void find_and_update_cpu_nid(int cpu)
 {
 	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
@@ -1449,13 +1412,6 @@ static int topology_update_init(void)
 	return 0;
 }
 device_initcall(topology_update_init);
-
-#else
-static long vphn_get_associativity(unsigned long cpu,
-					__be32 *associativity)
-{
-	return -1;
-}
 #endif /* CONFIG_PPC_SPLPAR */
 
 int cpu_to_coregroup_id(int cpu)
-- 
2.47.1


  parent reply	other threads:[~2026-10-16 11:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 11:04 [PATCH 0/7] powerpc/numa: Enable coregroup support for shared LPARs Srikar Dronamraju
2026-10-16 11:04 ` [PATCH 1/7] powerpc/numa: Remove redundant coregroup enablement Srikar Dronamraju
2026-10-16 11:04 ` Srikar Dronamraju [this message]
2026-10-16 11:04 ` [PATCH 3/7] powerpc/numa: Factor out coregroup availability check Srikar Dronamraju
2026-10-16 11:04 ` [PATCH 4/7] powerpc/numa: Allow coregroup detection when NUMA is disabled Srikar Dronamraju
2026-10-16 11:04 ` [PATCH 5/7] powerpc/numa: Consolidate associativity lookup in parse_numa_properties Srikar Dronamraju
2026-10-16 11:04 ` [PATCH 6/7] powerpc/numa: Extract CPU associativity processing into separate function Srikar Dronamraju
2026-10-16 11:04 ` [PATCH 7/7] powerpc/numa: Enable coregroup support for shared LPARs Srikar Dronamraju

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=20261016110412.1380298-3-srikar@linux.ibm.com \
    --to=srikar@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=sshegde@linux.ibm.com \
    /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®