linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Deindentify identify_cpu()
@ 2009-02-23  2:25 Michael Ellerman
  2009-02-23  2:25 ` [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones Michael Ellerman
  2009-02-23 13:27 ` [PATCH 1/2] Deindentify identify_cpu() Dave Kleikamp
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Ellerman @ 2009-02-23  2:25 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, shaggy

The for-loop body of identify_cpu() has gotten a little big, so move the
loop body logic into a separate function. No other changes.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/kernel/cputable.c |  122 +++++++++++++++++++++-------------------
 1 files changed, 64 insertions(+), 58 deletions(-)

diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 923f87a..944bd01 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -1762,74 +1762,80 @@ static struct cpu_spec __initdata cpu_specs[] = {
 
 static struct cpu_spec the_cpu_spec;
 
-struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
+static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
 {
-	struct cpu_spec *s = cpu_specs;
 	struct cpu_spec *t = &the_cpu_spec;
-	int i;
-
-	s = PTRRELOC(s);
 	t = PTRRELOC(t);
 
-	for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++)
-		if ((pvr & s->pvr_mask) == s->pvr_value) {
-			/*
-			 * If we are overriding a previous value derived
-			 * from the real PVR with a new value obtained
-			 * using a logical PVR value, don't modify the
-			 * performance monitor fields.
-			 */
-			if (t->num_pmcs && !s->num_pmcs) {
-				t->cpu_name = s->cpu_name;
-				t->cpu_features = s->cpu_features;
-				t->cpu_user_features = s->cpu_user_features;
-				t->icache_bsize = s->icache_bsize;
-				t->dcache_bsize = s->dcache_bsize;
-				t->cpu_setup = s->cpu_setup;
-				t->cpu_restore = s->cpu_restore;
-				t->platform = s->platform;
-				/*
-				 * If we have passed through this logic once
-				 * before and have pulled the default case
-				 * because the real PVR was not found inside
-				 * cpu_specs[], then we are possibly running in
-				 * compatibility mode. In that case, let the
-				 * oprofiler know which set of compatibility
-				 * counters to pull from by making sure the
-				 * oprofile_cpu_type string is set to that of
-				 * compatibility mode. If the oprofile_cpu_type
-				 * already has a value, then we are possibly
-				 * overriding a real PVR with a logical one, and,
-				 * in that case, keep the current value for
-				 * oprofile_cpu_type.
-				 */
-				if (t->oprofile_cpu_type == NULL)
-					t->oprofile_cpu_type = s->oprofile_cpu_type;
-			} else
-				*t = *s;
-			*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
+	/*
+	 * If we are overriding a previous value derived from the real
+	 * PVR with a new value obtained using a logical PVR value,
+	 * don't modify the performance monitor fields.
+	 */
+	if (t->num_pmcs && !s->num_pmcs) {
+		t->cpu_name = s->cpu_name;
+		t->cpu_features = s->cpu_features;
+		t->cpu_user_features = s->cpu_user_features;
+		t->icache_bsize = s->icache_bsize;
+		t->dcache_bsize = s->dcache_bsize;
+		t->cpu_setup = s->cpu_setup;
+		t->cpu_restore = s->cpu_restore;
+		t->platform = s->platform;
+		/*
+		 * If we have passed through this logic once before and
+		 * have pulled the default case because the real PVR was
+		 * not found inside cpu_specs[], then we are possibly
+		 * running in compatibility mode. In that case, let the
+		 * oprofiler know which set of compatibility counters to
+		 * pull from by making sure the oprofile_cpu_type string
+		 * is set to that of compatibility mode. If the
+		 * oprofile_cpu_type already has a value, then we are
+		 * possibly overriding a real PVR with a logical one,
+		 * and, in that case, keep the current value for
+		 * oprofile_cpu_type.
+		 */
+		if (t->oprofile_cpu_type == NULL)
+			t->oprofile_cpu_type = s->oprofile_cpu_type;
+	} else
+		*t = *s;
+
+	*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
 
-			/*
-			 * Set the base platform string once; assumes
-			 * we're called with real pvr first.
-			 */
-			if (*PTRRELOC(&powerpc_base_platform) == NULL)
-				*PTRRELOC(&powerpc_base_platform) = t->platform;
+	/*
+	 * Set the base platform string once; assumes
+	 * we're called with real pvr first.
+	 */
+	if (*PTRRELOC(&powerpc_base_platform) == NULL)
+		*PTRRELOC(&powerpc_base_platform) = t->platform;
 
 #if defined(CONFIG_PPC64) || defined(CONFIG_BOOKE)
-			/* ppc64 and booke expect identify_cpu to also call
-			 * setup_cpu for that processor. I will consolidate
-			 * that at a later time, for now, just use #ifdef.
-			 * we also don't need to PTRRELOC the function pointer
-			 * on ppc64 and booke as we are running at 0 in real
-			 * mode on ppc64 and reloc_offset is always 0 on booke.
-			 */
-			if (s->cpu_setup) {
-				s->cpu_setup(offset, s);
-			}
+	/* ppc64 and booke expect identify_cpu to also call setup_cpu for
+	 * that processor. I will consolidate that at a later time, for now,
+	 * just use #ifdef. We also don't need to PTRRELOC the function
+	 * pointer on ppc64 and booke as we are running at 0 in real mode
+	 * on ppc64 and reloc_offset is always 0 on booke.
+	 */
+	if (s->cpu_setup) {
+		s->cpu_setup(offset, s);
+	}
 #endif /* CONFIG_PPC64 || CONFIG_BOOKE */
+}
+
+struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
+{
+	struct cpu_spec *s = cpu_specs;
+	int i;
+
+	s = PTRRELOC(s);
+
+	for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) {
+		if ((pvr & s->pvr_mask) == s->pvr_value) {
+			setup_cpu_spec(offset, s);
 			return s;
 		}
+	}
+
 	BUG();
+
 	return NULL;
 }
-- 
1.5.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones
  2009-02-23  2:25 [PATCH 1/2] Deindentify identify_cpu() Michael Ellerman
@ 2009-02-23  2:25 ` Michael Ellerman
  2009-02-23 13:28   ` Dave Kleikamp
  2009-02-23 13:27 ` [PATCH 1/2] Deindentify identify_cpu() Dave Kleikamp
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2009-02-23  2:25 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, shaggy

When identify_cpu() is called a second time with a logical PVR, it
only copies a subset of the cpu_spec fields so as to avoid overwriting
the performance monitor fields that were initialized based on the
real PVR.

However some of the other, non performance monitor related fields are
also not copied:
 * pvr_mask
 * pvr_value
 * mmu_features
 * machine_check

The fact that pvr_mask is not copied can result in show_cpuinfo()
showing the cpu as "unknown", if we override an unknown PVR with a
logical one - as reported by Shaggy.

So change the logic to copy all fields, and then put back the PMC
related ones in the case that we're overwriting a real PVR with a
logical one.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/kernel/cputable.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 944bd01..77febd3 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -1765,22 +1765,27 @@ static struct cpu_spec the_cpu_spec;
 static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
 {
 	struct cpu_spec *t = &the_cpu_spec;
+	struct cpu_spec old;
+
 	t = PTRRELOC(t);
+	old = *t;
+
+	/* Copy everything, then do fixups */
+	*t = *s;
 
 	/*
 	 * If we are overriding a previous value derived from the real
 	 * PVR with a new value obtained using a logical PVR value,
 	 * don't modify the performance monitor fields.
 	 */
-	if (t->num_pmcs && !s->num_pmcs) {
-		t->cpu_name = s->cpu_name;
-		t->cpu_features = s->cpu_features;
-		t->cpu_user_features = s->cpu_user_features;
-		t->icache_bsize = s->icache_bsize;
-		t->dcache_bsize = s->dcache_bsize;
-		t->cpu_setup = s->cpu_setup;
-		t->cpu_restore = s->cpu_restore;
-		t->platform = s->platform;
+	if (old.num_pmcs && !s->num_pmcs) {
+		t->num_pmcs = old.num_pmcs;
+		t->pmc_type = old.pmc_type;
+		t->oprofile_type = old.oprofile_type;
+		t->oprofile_mmcra_sihv = old.oprofile_mmcra_sihv;
+		t->oprofile_mmcra_sipr = old.oprofile_mmcra_sipr;
+		t->oprofile_mmcra_clear = old.oprofile_mmcra_clear;
+
 		/*
 		 * If we have passed through this logic once before and
 		 * have pulled the default case because the real PVR was
@@ -1794,10 +1799,9 @@ static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
 		 * and, in that case, keep the current value for
 		 * oprofile_cpu_type.
 		 */
-		if (t->oprofile_cpu_type == NULL)
+		if (old.oprofile_cpu_type == NULL)
 			t->oprofile_cpu_type = s->oprofile_cpu_type;
-	} else
-		*t = *s;
+	}
 
 	*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
 
-- 
1.5.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Deindentify identify_cpu()
  2009-02-23  2:25 [PATCH 1/2] Deindentify identify_cpu() Michael Ellerman
  2009-02-23  2:25 ` [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones Michael Ellerman
@ 2009-02-23 13:27 ` Dave Kleikamp
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Kleikamp @ 2009-02-23 13:27 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras

On Mon, 2009-02-23 at 13:25 +1100, Michael Ellerman wrote:
> The for-loop body of identify_cpu() has gotten a little big, so move the
> loop body logic into a separate function. No other changes.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

Looks good to me.

Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>

-- 
David Kleikamp
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones
  2009-02-23  2:25 ` [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones Michael Ellerman
@ 2009-02-23 13:28   ` Dave Kleikamp
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Kleikamp @ 2009-02-23 13:28 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras

On Mon, 2009-02-23 at 13:25 +1100, Michael Ellerman wrote:
> When identify_cpu() is called a second time with a logical PVR, it
> only copies a subset of the cpu_spec fields so as to avoid overwriting
> the performance monitor fields that were initialized based on the
> real PVR.
> 
> However some of the other, non performance monitor related fields are
> also not copied:
>  * pvr_mask
>  * pvr_value
>  * mmu_features
>  * machine_check
> 
> The fact that pvr_mask is not copied can result in show_cpuinfo()
> showing the cpu as "unknown", if we override an unknown PVR with a
> logical one - as reported by Shaggy.
> 
> So change the logic to copy all fields, and then put back the PMC
> related ones in the case that we're overwriting a real PVR with a
> logical one.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>

-- 
David Kleikamp
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-23 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-23  2:25 [PATCH 1/2] Deindentify identify_cpu() Michael Ellerman
2009-02-23  2:25 ` [PATCH 2/2] Make sure we copy all cpu_spec features except PMC related ones Michael Ellerman
2009-02-23 13:28   ` Dave Kleikamp
2009-02-23 13:27 ` [PATCH 1/2] Deindentify identify_cpu() Dave Kleikamp

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).