public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
@ 2010-10-19  1:43 Nobuhiro Iwamatsu
  2010-10-19  1:50 ` Nobuhiro Iwamatsu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2010-10-19  1:43 UTC (permalink / raw)
  To: linux-sh

There is not method to confirm which of 32bit mode or 29bit mode Linux
kernel works.
This patch adds a mode to cpu_flags and can confirm it from auxv and proc
filesystem.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
---
 arch/sh/include/asm/cpu-features.h |    1 +
 arch/sh/kernel/cpu/sh4/probe.c     |    4 ++++
 arch/sh/kernel/setup.c             |    8 +++++++-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/sh/include/asm/cpu-features.h b/arch/sh/include/asm/cpu-features.h
index 694abe4..dc1265b 100644
--- a/arch/sh/include/asm/cpu-features.h
+++ b/arch/sh/include/asm/cpu-features.h
@@ -22,5 +22,6 @@
 #define CPU_HAS_L2_CACHE	0x0080	/* Secondary cache / URAM */
 #define CPU_HAS_OP32		0x0100	/* 32-bit instruction support */
 #define CPU_HAS_PTEAEX		0x0200	/* PTE ASID Extension support */
+#define CPU_IS_32BIT_MODE	0x0400	/* linux kernel works 32bit mode */
 
 #endif /* __ASM_SH_CPU_FEATURES_H */
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index b93458f..4bda234 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -189,6 +189,10 @@ void __cpuinit cpu_probe(void)
 		break;
 	}
 
+#ifdef CONFIG_32BIT
+	boot_cpu_data.flags |= CPU_IS_32BIT_MODE;
+#endif
+
 	/*
 	 * On anything that's not a direct-mapped cache, look to the CVR
 	 * for I/D-cache specifics.
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 4e27846..460ac72 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -352,7 +352,8 @@ EXPORT_SYMBOL(get_cpu_subtype);
 /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
 static const char *cpu_flags[] = {
 	"none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
-	"ptea", "llsc", "l2", "op32", "pteaex", NULL
+	"ptea", "llsc", "l2", "op32", "pteaex", "32bit",
+	NULL
 };
 
 static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c)
@@ -410,6 +411,11 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	else
 		seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor);
 
+	if (c->flags & CPU_IS_32BIT_MODE)
+		seq_printf(m, "cpu mode\t: 32bit\n");
+	else
+		seq_printf(m, "cpu mode\t: 29bit\n");
+
 	show_cpuflags(m, c);
 
 	seq_printf(m, "cache type\t: ");
-- 
1.7.1


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

* Re: [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
  2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
@ 2010-10-19  1:50 ` Nobuhiro Iwamatsu
  2010-10-19  2:47 ` Paul Mundt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2010-10-19  1:50 UTC (permalink / raw)
  To: linux-sh

Oh, sorry. Subject is wrong.
  s/cou/cpu


Nobuhiro

2010/10/19 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>:
> There is not method to confirm which of 32bit mode or 29bit mode Linux
> kernel works.
> This patch adds a mode to cpu_flags and can confirm it from auxv and proc
> filesystem.
>
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
> ---
>  arch/sh/include/asm/cpu-features.h |    1 +
>  arch/sh/kernel/cpu/sh4/probe.c     |    4 ++++
>  arch/sh/kernel/setup.c             |    8 +++++++-
>  3 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/arch/sh/include/asm/cpu-features.h b/arch/sh/include/asm/cpu-features.h
> index 694abe4..dc1265b 100644
> --- a/arch/sh/include/asm/cpu-features.h
> +++ b/arch/sh/include/asm/cpu-features.h
> @@ -22,5 +22,6 @@
>  #define CPU_HAS_L2_CACHE       0x0080  /* Secondary cache / URAM */
>  #define CPU_HAS_OP32           0x0100  /* 32-bit instruction support */
>  #define CPU_HAS_PTEAEX         0x0200  /* PTE ASID Extension support */
> +#define CPU_IS_32BIT_MODE      0x0400  /* linux kernel works 32bit mode */
>
>  #endif /* __ASM_SH_CPU_FEATURES_H */
> diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
> index b93458f..4bda234 100644
> --- a/arch/sh/kernel/cpu/sh4/probe.c
> +++ b/arch/sh/kernel/cpu/sh4/probe.c
> @@ -189,6 +189,10 @@ void __cpuinit cpu_probe(void)
>                break;
>        }
>
> +#ifdef CONFIG_32BIT
> +       boot_cpu_data.flags |= CPU_IS_32BIT_MODE;
> +#endif
> +
>        /*
>         * On anything that's not a direct-mapped cache, look to the CVR
>         * for I/D-cache specifics.
> diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
> index 4e27846..460ac72 100644
> --- a/arch/sh/kernel/setup.c
> +++ b/arch/sh/kernel/setup.c
> @@ -352,7 +352,8 @@ EXPORT_SYMBOL(get_cpu_subtype);
>  /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
>  static const char *cpu_flags[] = {
>        "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
> -       "ptea", "llsc", "l2", "op32", "pteaex", NULL
> +       "ptea", "llsc", "l2", "op32", "pteaex", "32bit",
> +       NULL
>  };
>
>  static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c)
> @@ -410,6 +411,11 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>        else
>                seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor);
>
> +       if (c->flags & CPU_IS_32BIT_MODE)
> +               seq_printf(m, "cpu mode\t: 32bit\n");
> +       else
> +               seq_printf(m, "cpu mode\t: 29bit\n");
> +
>        show_cpuflags(m, c);
>
>        seq_printf(m, "cache type\t: ");
> --
> 1.7.1
>
>



-- 
Nobuhiro Iwamatsu

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

* Re: [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
  2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
  2010-10-19  1:50 ` Nobuhiro Iwamatsu
@ 2010-10-19  2:47 ` Paul Mundt
  2010-10-20  2:13 ` Nobuhiro Iwamatsu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Mundt @ 2010-10-19  2:47 UTC (permalink / raw)
  To: linux-sh

On Tue, Oct 19, 2010 at 10:43:29AM +0900, Nobuhiro Iwamatsu wrote:
> There is not method to confirm which of 32bit mode or 29bit mode Linux
> kernel works.
> This patch adds a mode to cpu_flags and can confirm it from auxv and proc
> filesystem.
> 
Is there some use you had in mind for this?

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

* Re: [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
  2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
  2010-10-19  1:50 ` Nobuhiro Iwamatsu
  2010-10-19  2:47 ` Paul Mundt
@ 2010-10-20  2:13 ` Nobuhiro Iwamatsu
  2010-10-25  6:14 ` Paul Mundt
  2010-10-26  0:19 ` Nobuhiro Iwamatsu
  4 siblings, 0 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2010-10-20  2:13 UTC (permalink / raw)
  To: linux-sh

2010/10/19 Paul Mundt <lethal@linux-sh.org>:
> On Tue, Oct 19, 2010 at 10:43:29AM +0900, Nobuhiro Iwamatsu wrote:
>> There is not method to confirm which of 32bit mode or 29bit mode Linux
>> kernel works.
>> This patch adds a mode to cpu_flags and can confirm it from auxv and proc
>> filesystem.
>>
> Is there some use you had in mind for this?

First , I wanted these as information simply.

And I am debuging kexec-toos for 32bit mode.
I need this information to use as __pa in kernel.
If there is a good method, please teach it.

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu

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

* Re: [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
  2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
                   ` (2 preceding siblings ...)
  2010-10-20  2:13 ` Nobuhiro Iwamatsu
@ 2010-10-25  6:14 ` Paul Mundt
  2010-10-26  0:19 ` Nobuhiro Iwamatsu
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Mundt @ 2010-10-25  6:14 UTC (permalink / raw)
  To: linux-sh

On Wed, Oct 20, 2010 at 11:13:09AM +0900, Nobuhiro Iwamatsu wrote:
> 2010/10/19 Paul Mundt <lethal@linux-sh.org>:
> > On Tue, Oct 19, 2010 at 10:43:29AM +0900, Nobuhiro Iwamatsu wrote:
> >> There is not method to confirm which of 32bit mode or 29bit mode Linux
> >> kernel works.
> >> This patch adds a mode to cpu_flags and can confirm it from auxv and proc
> >> filesystem.
> >>
> > Is there some use you had in mind for this?
> 
> First , I wanted these as information simply.
> 
> And I am debuging kexec-toos for 32bit mode.
> I need this information to use as __pa in kernel.
> If there is a good method, please teach it.
> 
While I agree that having this information exposed is useful, I don't
think it really falls under a CPU capability as such. 32-bit capable CPUs
can be either in 29 or 32-bit physical mode, so the existence of the PMB
is not sufficient for determining configuration.

The x86 approach for reporting the physical address space size seems like
a pretty good fit for this though, so how about this instead?

---

diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index 0a58cb2..c9e7cbc 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -89,6 +89,7 @@ struct sh_cpuinfo {
 	struct task_struct *idle;
 #endif
 
+	unsigned int phys_bits;
 	unsigned long flags;
 } __attribute__ ((aligned(L1_CACHE_BYTES)));
 
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index 9766106..fac742e 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -340,6 +340,8 @@ asmlinkage void __cpuinit cpu_init(void)
 	 */
 	current_cpu_data.asid_cache = NO_CONTEXT;
 
+	current_cpu_data.phys_bits = __in_29bit_mode() ? 29 : 32;
+
 	speculative_execution_init();
 	expmask_init();
 
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 4e27846..0af25e0 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -432,6 +432,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	if (c->flags & CPU_HAS_L2_CACHE)
 		show_cacheinfo(m, "scache", c->scache);
 
+	seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits);
+
 	seq_printf(m, "bogomips\t: %lu.%02lu\n",
 		     c->loops_per_jiffy/(500000/HZ),
 		     (c->loops_per_jiffy/(5000/HZ)) % 100);

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

* Re: [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags
  2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
                   ` (3 preceding siblings ...)
  2010-10-25  6:14 ` Paul Mundt
@ 2010-10-26  0:19 ` Nobuhiro Iwamatsu
  4 siblings, 0 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2010-10-26  0:19 UTC (permalink / raw)
  To: linux-sh

Hi, Paul.

2010/10/25 Paul Mundt <lethal@linux-sh.org>:
> On Wed, Oct 20, 2010 at 11:13:09AM +0900, Nobuhiro Iwamatsu wrote:
>> 2010/10/19 Paul Mundt <lethal@linux-sh.org>:
>> > On Tue, Oct 19, 2010 at 10:43:29AM +0900, Nobuhiro Iwamatsu wrote:
>> >> There is not method to confirm which of 32bit mode or 29bit mode Linux
>> >> kernel works.
>> >> This patch adds a mode to cpu_flags and can confirm it from auxv and proc
>> >> filesystem.
>> >>
>> > Is there some use you had in mind for this?
>>
>> First , I wanted these as information simply.
>>
>> And I am debuging kexec-toos for 32bit mode.
>> I need this information to use as __pa in kernel.
>> If there is a good method, please teach it.
>>
> While I agree that having this information exposed is useful, I don't
> think it really falls under a CPU  as such. 32-bit capable CPUs
> can be either in 29 or 32-bit physical mode, so the existence of the PMB
> is not sufficient for determining configuration.
>

I thought whether I might be able to be in auxv, because the mode of
the CPU was changed,
But I agree.

> The x86 approach for reporting the physical address space size seems like
> a pretty good fit for this though, so how about this instead?

Looks good to me, thanks for fixing it.

Best regards,
  Nobuhiro
-- 
Nobuhiro Iwamatsu

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

end of thread, other threads:[~2010-10-26  0:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-19  1:43 [RFC/PATCH] sh: Add 32bit cou mode to cpu_flags Nobuhiro Iwamatsu
2010-10-19  1:50 ` Nobuhiro Iwamatsu
2010-10-19  2:47 ` Paul Mundt
2010-10-20  2:13 ` Nobuhiro Iwamatsu
2010-10-25  6:14 ` Paul Mundt
2010-10-26  0:19 ` Nobuhiro Iwamatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox