linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joel Schopp <jschopp@austin.ibm.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCHv2 2/2] Update ibm,client-architecture call field based on device tree
Date: Mon, 01 Feb 2010 16:51:02 -0600	[thread overview]
Message-ID: <1265064662.5391.19.camel@jschopp-laptop> (raw)
In-Reply-To: <1263501674.4869.142.camel@jschopp-laptop>

In the previous patch the client-architecture field for the number of
cores supported is set statically as high as is possible.  However, that
static setting could be too high if the system supports smt, resulting
in cpus assigned to Linux that are not booted.  This patch reads the
device tree (before it is unflattened) to determine the amount of smt.
It then dynamically updates the entires in the array with the proper
number of cores supported.  Tests show this correctly detecting SMT4 on
a Power7 and still booting all the supported cores on a large machine.

Signed-off-by: Joel Schopp <jschopp@austin.ibm.com> 
---
Index: linux-2.6.git/arch/powerpc/kernel/prom_init.c
===================================================================
--- linux-2.6.git.orig/arch/powerpc/kernel/prom_init.c
+++ linux-2.6.git/arch/powerpc/kernel/prom_init.c
@@ -807,13 +807,55 @@ static struct fake_elf {
 	}
 };
 
+static int __init prom_smt_way(void)
+{
+	phandle node;
+	char type[64];
+	unsigned int plen;
+
+	for (node = 0; prom_next_node(&node); ) {
+		type[0] = 0;
+		prom_getprop(node, "device_type", type, sizeof(type));
+
+		if (strcmp(type, RELOC("cpu")))
+			continue;
+
+		/*
+		 * There is an entry for each smt thread, each entry being
+		 * 4 bytes long.  All cpus should have the same number of
+		 * smt threads, so return after finding the first.
+		 */
+		plen = prom_getproplen(node, "ibm,ppc-interrupt-server#s");
+		prom_printf("smt threads per core %x\n", (unsigned long) plen);
+		if (plen >= 4)
+			return plen / 4;
+	}
+	/*
+	 * If things go wrong and we get here fallback to SMT1
+	 */
+	prom_debug("unable to determine smt from device tree, guessing smt1\n");
+	return 1;
+
+}
+
+
 static void __init prom_send_capabilities(void)
 {
 	ihandle elfloader, root;
 	prom_arg_t ret;
+	u32 *cores;
 
 	root = call_prom("open", 1, 1, ADDR("/"));
 	if (root != 0) {
+		/*
+		 * If you add to the struct, please be sure the 100 index
+		 * didn't change.  The BUILD_BUG_ON is a reminder.
+		 */
+		cores = (u32 *) &ibm_architecture_vec[100];
+		if(*cores != NR_CPUS)
+			prom_printf("client-architecture structure corrupted\n");
+		*cores = (NR_CPUS / prom_smt_way());
+		prom_printf("setting client-architecture cores to %x\n", *cores);
 		/* try calling the ibm,client-architecture-support method */
 		prom_printf("Calling ibm,client-architecture-support...");
 		if (call_prom_ret("call-method", 3, 2, &ret,

  parent reply	other threads:[~2010-02-01 22:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 20:38 [PATCH 0/2] Add max CPU nodes field to ibm,client-architecture call Joel Schopp
2010-01-14 20:40 ` [PATCH 1/2] Add static fields " Joel Schopp
2010-01-14 23:01   ` Joel Schopp
2010-01-15  2:51     ` Benjamin Herrenschmidt
2010-01-15  2:52       ` Benjamin Herrenschmidt
2010-02-01 22:50     ` [PATCHv2 " Joel Schopp
2010-01-14 20:41 ` [PATCH 2/2] Update ibm,client-architecture call field based on device tree Joel Schopp
2010-01-15  2:58   ` Benjamin Herrenschmidt
2010-02-01 22:51   ` Joel Schopp [this message]
2010-02-02  3:48     ` [PATCHv2 " Tony Breeds
2010-02-02 18:37       ` Joel Schopp
2010-02-04  3:27         ` Benjamin Herrenschmidt
2010-02-01 22:50 ` [PATCHv2 0/2] Add max CPU nodes field to ibm,client-architecture call Joel Schopp

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=1265064662.5391.19.camel@jschopp-laptop \
    --to=jschopp@austin.ibm.com \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).