This patch series have some unrelated fixes related
to clocksource, dt-bindings and isa strings.
I combined them into series as most of them are
prerequisite for kvm patch series.
Changes from v2->v3:
1. Updated commit text of dt binding patch.
2. Removed couple of remaining uppercase usage.
Changes from v1->v2:
1. Dropped the case-insensitive support patch and added a dt-bindings
update patch.
2. Added a export symbol patch.
Anup Patel (1):
RISC-V: Add riscv_isa reprensenting ISA features common across CPUs
Atish Patra (4):
RISC-V: Remove per cpu clocksource
RISC-V: Fix unsupported isa string info.
RISC-V: Export few kernel symbols
dt-bindings: Update the riscv,isa string description
.../devicetree/bindings/riscv/cpus.yaml | 4 +-
arch/riscv/include/asm/hwcap.h | 16 +++++++
arch/riscv/kernel/cpu.c | 47 +++++++++++++++----
arch/riscv/kernel/cpufeature.c | 39 +++++++++++++--
arch/riscv/kernel/smp.c | 2 +-
arch/riscv/kernel/time.c | 1 +
drivers/clocksource/timer-riscv.c | 6 +--
7 files changed, 96 insertions(+), 19 deletions(-)
--
2.21.0
Currently, kernel prints a info warning if any of the extensions
from "mafdcsu" is missing in device tree. This is not entirely
correct as Linux can boot with "f or d" extensions if kernel is
configured accordingly. Moreover, it will continue to print the
info string for future extensions such as hypervisor as well which
is misleading. /proc/cpuinfo also doesn't print any other extensions
except "mafdcsu".
Make sure that info log is only printed only if kernel is configured
to have any mandatory extensions but device tree doesn't describe it.
All the extensions present in device tree and follow the order
described in the RISC-V specification (except 'S') are printed via
/proc/cpuinfo always.
Signed-off-by: Atish Patra <[email protected]>
---
arch/riscv/kernel/cpu.c | 47 ++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 7da3c6a93abd..9b1d4550fbe6 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -7,6 +7,7 @@
#include <linux/seq_file.h>
#include <linux/of.h>
#include <asm/smp.h>
+#include <asm/hwcap.h>
/*
* Returns the hart ID of the given device tree node, or -ENODEV if the node
@@ -46,11 +47,14 @@ int riscv_of_processor_hartid(struct device_node *node)
#ifdef CONFIG_PROC_FS
-static void print_isa(struct seq_file *f, const char *orig_isa)
+static void print_isa(struct seq_file *f, const char *orig_isa,
+ unsigned long cpuid)
{
- static const char *ext = "mafdcsu";
+ static const char *mandatory_ext = "mafdcsu";
const char *isa = orig_isa;
const char *e;
+ char unsupported_isa[26] = {0};
+ int index = 0;
/*
* Linux doesn't support rv32e or rv128i, and we only support booting
@@ -70,27 +74,50 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
isa += 5;
/*
- * Check the rest of the ISA string for valid extensions, printing those
- * we find. RISC-V ISA strings define an order, so we only print the
+ * RISC-V ISA strings define an order, so we only print all the
* extension bits when they're in order. Hide the supervisor (S)
* extension from userspace as it's not accessible from there.
+ * Throw a warning only if any mandatory extensions are not available
+ * and kernel is configured to have that mandatory extensions.
*/
- for (e = ext; *e != '\0'; ++e) {
- if (isa[0] == e[0]) {
+ for (e = mandatory_ext; *e != '\0'; ++e) {
+ if (isa[0] != e[0]) {
+#if defined(CONFIG_ISA_RISCV_C)
+ if (isa[0] == 'c')
+ continue;
+#endif
+#if defined(CONFIG_FP)
+ if ((isa[0] == 'f') || (isa[0] == 'd'))
+ continue;
+#endif
+ unsupported_isa[index] = e[0];
+ index++;
+ }
+ /* Only write if part of isa string */
+ if (isa[0] != '\0') {
if (isa[0] != 's')
seq_write(f, isa, 1);
-
isa++;
}
}
+ if (isa[0] != '\0') {
+ /* Add remainging isa strings */
+ for (e = isa; *e != '\0'; ++e) {
+#if !defined(CONFIG_VIRTUALIZATION)
+ if (e[0] != 'h')
+#endif
+ seq_write(f, e, 1);
+ }
+ }
seq_puts(f, "\n");
/*
* If we were given an unsupported ISA in the device tree then print
* a bit of info describing what went wrong.
*/
- if (isa[0] != '\0')
- pr_info("unsupported ISA \"%s\" in device tree\n", orig_isa);
+ if (unsupported_isa[0])
+ pr_info("unsupported ISA extensions \"%s\" in device tree for cpu [%ld]\n",
+ unsupported_isa, cpuid);
}
static void print_mmu(struct seq_file *f, const char *mmu_type)
@@ -134,7 +161,7 @@ static int c_show(struct seq_file *m, void *v)
seq_printf(m, "processor\t: %lu\n", cpu_id);
seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id));
if (!of_property_read_string(node, "riscv,isa", &isa))
- print_isa(m, isa);
+ print_isa(m, isa, cpu_id);
if (!of_property_read_string(node, "mmu-type", &mmu))
print_mmu(m, mmu);
if (!of_property_read_string(node, "compatible", &compat)
--
2.21.0
There is only one clocksource in RISC-V. The boot cpu initializes
that clocksource. No need to keep a percpu data structure.
Signed-off-by: Atish Patra <[email protected]>
---
drivers/clocksource/timer-riscv.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index 5e6038fbf115..09e031176bc6 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -55,7 +55,7 @@ static u64 riscv_sched_clock(void)
return get_cycles64();
}
-static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = {
+static struct clocksource riscv_clocksource = {
.name = "riscv_clocksource",
.rating = 300,
.mask = CLOCKSOURCE_MASK(64),
@@ -92,7 +92,6 @@ void riscv_timer_interrupt(void)
static int __init riscv_timer_init_dt(struct device_node *n)
{
int cpuid, hartid, error;
- struct clocksource *cs;
hartid = riscv_of_processor_hartid(n);
if (hartid < 0) {
@@ -112,8 +111,7 @@ static int __init riscv_timer_init_dt(struct device_node *n)
pr_info("%s: Registering clocksource cpuid [%d] hartid [%d]\n",
__func__, cpuid, hartid);
- cs = per_cpu_ptr(&riscv_clocksource, cpuid);
- error = clocksource_register_hz(cs, riscv_timebase);
+ error = clocksource_register_hz(&riscv_clocksource, riscv_timebase);
if (error) {
pr_err("RISCV timer register failed [%d] for cpu = [%d]\n",
error, cpuid);
--
2.21.0
From: Anup Patel <[email protected]>
This patch adds riscv_isa integer to represent ISA features common
across all CPUs. The riscv_isa is not same as elf_hwcap because
elf_hwcap will only have ISA features relevant for user-space apps
whereas riscv_isa will have ISA features relevant to both kernel
and user-space apps.
One of the use case is KVM hypervisor where riscv_isa will be used
to do following operations:
1. Check whether hypervisor extension is available
2. Find ISA features that need to be virtualized (e.g. floating
point support, vector extension, etc.)
Signed-off-by: Anup Patel <[email protected]>
Signed-off-by: Atish Patra <[email protected]>
---
arch/riscv/include/asm/hwcap.h | 16 ++++++++++++++
arch/riscv/kernel/cpufeature.c | 39 +++++++++++++++++++++++++++++++---
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h
index 7ecb7c6a57b1..717306780add 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -22,5 +22,21 @@ enum {
};
extern unsigned long elf_hwcap;
+
+#define RISCV_ISA_EXT_a (1UL << ('a' - 'a'))
+#define RISCV_ISA_EXT_c (1UL << ('c' - 'a'))
+#define RISCV_ISA_EXT_d (1UL << ('d' - 'a'))
+#define RISCV_ISA_EXT_f (1UL << ('f' - 'a'))
+#define RISCV_ISA_EXT_h (1UL << ('h' - 'a'))
+#define RISCV_ISA_EXT_i (1UL << ('i' - 'a'))
+#define RISCV_ISA_EXT_m (1UL << ('m' - 'a'))
+#define RISCV_ISA_EXT_s (1UL << ('s' - 'a'))
+#define RISCV_ISA_EXT_u (1UL << ('u' - 'a'))
+
+extern unsigned long riscv_isa;
+
+#define riscv_isa_extension_available(ext_char) \
+ (riscv_isa & RISCV_ISA_EXT_##ext_char)
+
#endif
#endif
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index b1ade9a49347..becc99272341 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -12,6 +12,9 @@
#include <asm/smp.h>
unsigned long elf_hwcap __read_mostly;
+unsigned long riscv_isa __read_mostly;
+EXPORT_SYMBOL_GPL(riscv_isa);
+
#ifdef CONFIG_FPU
bool has_fpu __read_mostly;
#endif
@@ -20,7 +23,8 @@ void riscv_fill_hwcap(void)
{
struct device_node *node;
const char *isa;
- size_t i;
+ char print_str[BITS_PER_LONG+1];
+ size_t i, j, isa_len;
static unsigned long isa2hwcap[256] = {0};
isa2hwcap['i'] = isa2hwcap['I'] = COMPAT_HWCAP_ISA_I;
@@ -31,9 +35,11 @@ void riscv_fill_hwcap(void)
isa2hwcap['c'] = isa2hwcap['C'] = COMPAT_HWCAP_ISA_C;
elf_hwcap = 0;
+ riscv_isa = 0;
for_each_of_cpu_node(node) {
unsigned long this_hwcap = 0;
+ unsigned long this_isa = 0;
if (riscv_of_processor_hartid(node) < 0)
continue;
@@ -43,8 +49,20 @@ void riscv_fill_hwcap(void)
continue;
}
- for (i = 0; i < strlen(isa); ++i)
+ i = 0;
+ isa_len = strlen(isa);
+#if defined(CONFIG_32BIT)
+ if (!strncmp(isa, "rv32", 4))
+ i += 4;
+#elif defined(CONFIG_64BIT)
+ if (!strncmp(isa, "rv64", 4))
+ i += 4;
+#endif
+ for (; i < isa_len; ++i) {
this_hwcap |= isa2hwcap[(unsigned char)(isa[i])];
+ if ('a' <= isa[i] && isa[i] <= 'z')
+ this_isa |= (1UL << (isa[i] - 'a'));
+ }
/*
* All "okay" hart should have same isa. Set HWCAP based on
@@ -55,6 +73,11 @@ void riscv_fill_hwcap(void)
elf_hwcap &= this_hwcap;
else
elf_hwcap = this_hwcap;
+
+ if (riscv_isa)
+ riscv_isa &= this_isa;
+ else
+ riscv_isa = this_isa;
}
/* We don't support systems with F but without D, so mask those out
@@ -64,7 +87,17 @@ void riscv_fill_hwcap(void)
elf_hwcap &= ~COMPAT_HWCAP_ISA_F;
}
- pr_info("elf_hwcap is 0x%lx\n", elf_hwcap);
+ memset(print_str, 0, sizeof(print_str));
+ for (i = 0, j = 0; i < BITS_PER_LONG; i++)
+ if (riscv_isa & (1UL << i))
+ print_str[j++] = (char)('a' + i);
+ pr_info("riscv: ISA extensions %s\n", print_str);
+
+ memset(print_str, 0, sizeof(print_str));
+ for (i = 0, j = 0; i < BITS_PER_LONG; i++)
+ if (elf_hwcap & (1UL << i))
+ print_str[j++] = (char)('a' + i);
+ pr_info("riscv: ELF capabilities %s\n", print_str);
#ifdef CONFIG_FPU
if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
--
2.21.0
Since the RISC-V specification states that ISA description strings are
case-insensitive, there's no functional difference between mixed-case,
upper-case, and lower-case ISA strings. Thus, to simplify parsing,
specify that the letters present in "riscv,isa" must be all lowercase.
Suggested-by: Paul Walmsley <[email protected]>
Signed-off-by: Atish Patra <[email protected]>
---
Documentation/devicetree/bindings/riscv/cpus.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/riscv/cpus.yaml b/Documentation/devicetree/bindings/riscv/cpus.yaml
index c899111aa5e3..4f0acb00185a 100644
--- a/Documentation/devicetree/bindings/riscv/cpus.yaml
+++ b/Documentation/devicetree/bindings/riscv/cpus.yaml
@@ -46,10 +46,12 @@ properties:
- rv64imafdc
description:
Identifies the specific RISC-V instruction set architecture
- supported by the hart. These are documented in the RISC-V
+ supported by the hart. These are documented in the RISC-V
User-Level ISA document, available from
https://riscv.org/specifications/
+ Letters in the riscv,isa string must be all lowercase.
+
timebase-frequency:
type: integer
minimum: 1
--
2.21.0
On Wed, Jul 31, 2019 at 6:58 PM Atish Patra <[email protected]> wrote:
>
> Since the RISC-V specification states that ISA description strings are
> case-insensitive, there's no functional difference between mixed-case,
> upper-case, and lower-case ISA strings. Thus, to simplify parsing,
> specify that the letters present in "riscv,isa" must be all lowercase.
>
> Suggested-by: Paul Walmsley <[email protected]>
> Signed-off-by: Atish Patra <[email protected]>
> ---
> Documentation/devicetree/bindings/riscv/cpus.yaml | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/riscv/cpus.yaml b/Documentation/devicetree/bindings/riscv/cpus.yaml
> index c899111aa5e3..4f0acb00185a 100644
> --- a/Documentation/devicetree/bindings/riscv/cpus.yaml
> +++ b/Documentation/devicetree/bindings/riscv/cpus.yaml
> @@ -46,10 +46,12 @@ properties:
> - rv64imafdc
> description:
> Identifies the specific RISC-V instruction set architecture
> - supported by the hart. These are documented in the RISC-V
> + supported by the hart. These are documented in the RISC-V
> User-Level ISA document, available from
> https://riscv.org/specifications/
>
> + Letters in the riscv,isa string must be all lowercase.
> +
The schemas are case sensitive this looks pretty pointless without the
context of the commit msg. Can you prefix with 'While the
specification is case insensitive, "
For some background, FDT generally always has been case sensitive too
(dtc won't merge/override nodes/properties with differing case). It's
really only some older true OF systems that were case insensitive. The
kernel had a mixture of case sensitive and insensitive comparisons
somewhat depending on the arch and whether of_prop_cmp/of_node_cmp or
str*cmp functions were used. There's been a lot of clean-up and now
most comparisons are case sensitive with only Sparc having some
deviation.
Rob
On Thu, 2019-08-01 at 09:50 -0600, Rob Herring wrote:
> On Wed, Jul 31, 2019 at 6:58 PM Atish Patra <[email protected]>
> wrote:
> > Since the RISC-V specification states that ISA description strings
> > are
> > case-insensitive, there's no functional difference between mixed-
> > case,
> > upper-case, and lower-case ISA strings. Thus, to simplify parsing,
> > specify that the letters present in "riscv,isa" must be all
> > lowercase.
> >
> > Suggested-by: Paul Walmsley <[email protected]>
> > Signed-off-by: Atish Patra <[email protected]>
> > ---
> > Documentation/devicetree/bindings/riscv/cpus.yaml | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/riscv/cpus.yaml
> > b/Documentation/devicetree/bindings/riscv/cpus.yaml
> > index c899111aa5e3..4f0acb00185a 100644
> > --- a/Documentation/devicetree/bindings/riscv/cpus.yaml
> > +++ b/Documentation/devicetree/bindings/riscv/cpus.yaml
> > @@ -46,10 +46,12 @@ properties:
> > - rv64imafdc
> > description:
> > Identifies the specific RISC-V instruction set architecture
> > - supported by the hart. These are documented in the RISC-V
> > + supported by the hart. These are documented in the RISC-V
> > User-Level ISA document, available from
> > https://riscv.org/specifications/
> >
> > + Letters in the riscv,isa string must be all lowercase.
> > +
>
> The schemas are case sensitive this looks pretty pointless without
> the
> context of the commit msg. Can you prefix with 'While the
> specification is case insensitive, "
>
Sure. How about this ?
"While the above isa strings in ISA specification are case insensitive,
letters in the riscv,isa string must be all lowercase to simplify
parsing."
> For some background, FDT generally always has been case sensitive too
> (dtc won't merge/override nodes/properties with differing case). It's
> really only some older true OF systems that were case insensitive.
> The
> kernel had a mixture of case sensitive and insensitive comparisons
> somewhat depending on the arch and whether of_prop_cmp/of_node_cmp or
> str*cmp functions were used. There's been a lot of clean-up and now
> most comparisons are case sensitive with only Sparc having some
> deviation.
>
> Rob
--
Regards,
Atish
On Wed, 31 Jul 2019, Atish Patra wrote:
> Currently, kernel prints a info warning if any of the extensions
> from "mafdcsu" is missing in device tree. This is not entirely
> correct as Linux can boot with "f or d" extensions if kernel is
> configured accordingly. Moreover, it will continue to print the
> info string for future extensions such as hypervisor as well which
> is misleading. /proc/cpuinfo also doesn't print any other extensions
> except "mafdcsu".
>
> Make sure that info log is only printed only if kernel is configured
> to have any mandatory extensions but device tree doesn't describe it.
> All the extensions present in device tree and follow the order
> described in the RISC-V specification (except 'S') are printed via
> /proc/cpuinfo always.
>
> Signed-off-by: Atish Patra <[email protected]>
I tested this patch after dropping the CONFIG_ISA_RISCV_C test (see
below). Running "cat /proc/cpuinfo" generated the following kernel
warnings:
[ 73.412626] unsupported ISA extensions "su" in device tree for cpu [0]
[ 73.418417] unsupported ISA extensions "su" in device tree for cpu [1]
[ 73.424912] unsupported ISA extensions "su" in device tree for cpu [2]
[ 73.431425] unsupported ISA extensions "su" in device tree for cpu [3]
Seems like the "su" should be dropped from mandatory_ext. What do you
think?
> ---
> arch/riscv/kernel/cpu.c | 47 ++++++++++++++++++++++++++++++++---------
> 1 file changed, 37 insertions(+), 10 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> index 7da3c6a93abd..9b1d4550fbe6 100644
> --- a/arch/riscv/kernel/cpu.c
> +++ b/arch/riscv/kernel/cpu.c
> @@ -7,6 +7,7 @@
> #include <linux/seq_file.h>
> #include <linux/of.h>
> #include <asm/smp.h>
> +#include <asm/hwcap.h>
>
> /*
> * Returns the hart ID of the given device tree node, or -ENODEV if the node
> @@ -46,11 +47,14 @@ int riscv_of_processor_hartid(struct device_node *node)
>
> #ifdef CONFIG_PROC_FS
>
> -static void print_isa(struct seq_file *f, const char *orig_isa)
> +static void print_isa(struct seq_file *f, const char *orig_isa,
> + unsigned long cpuid)
> {
> - static const char *ext = "mafdcsu";
> + static const char *mandatory_ext = "mafdcsu";
> const char *isa = orig_isa;
> const char *e;
> + char unsupported_isa[26] = {0};
> + int index = 0;
>
> /*
> * Linux doesn't support rv32e or rv128i, and we only support booting
> @@ -70,27 +74,50 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
> isa += 5;
>
> /*
> - * Check the rest of the ISA string for valid extensions, printing those
> - * we find. RISC-V ISA strings define an order, so we only print the
> + * RISC-V ISA strings define an order, so we only print all the
> * extension bits when they're in order. Hide the supervisor (S)
> * extension from userspace as it's not accessible from there.
> + * Throw a warning only if any mandatory extensions are not available
> + * and kernel is configured to have that mandatory extensions.
> */
> - for (e = ext; *e != '\0'; ++e) {
> - if (isa[0] == e[0]) {
> + for (e = mandatory_ext; *e != '\0'; ++e) {
> + if (isa[0] != e[0]) {
> +#if defined(CONFIG_ISA_RISCV_C)
There's no Kconfig option by this name, and we're requiring compressed
instruction support as part of the RISC-V Linux baseline. Could you share
the rationale behind this? Looks to me like this should be dropped.
> + if (isa[0] == 'c')
> + continue;
> +#endif
> +#if defined(CONFIG_FP)
> + if ((isa[0] == 'f') || (isa[0] == 'd'))
> + continue;
> +#endif
> + unsupported_isa[index] = e[0];
> + index++;
> + }
> + /* Only write if part of isa string */
> + if (isa[0] != '\0') {
> if (isa[0] != 's')
> seq_write(f, isa, 1);
> -
> isa++;
> }
> }
> + if (isa[0] != '\0') {
> + /* Add remainging isa strings */
> + for (e = isa; *e != '\0'; ++e) {
> +#if !defined(CONFIG_VIRTUALIZATION)
> + if (e[0] != 'h')
> +#endif
> + seq_write(f, e, 1);
> + }
> + }
> seq_puts(f, "\n");
>
> /*
> * If we were given an unsupported ISA in the device tree then print
> * a bit of info describing what went wrong.
> */
> - if (isa[0] != '\0')
> - pr_info("unsupported ISA \"%s\" in device tree\n", orig_isa);
> + if (unsupported_isa[0])
> + pr_info("unsupported ISA extensions \"%s\" in device tree for cpu [%ld]\n",
> + unsupported_isa, cpuid);
> }
>
> static void print_mmu(struct seq_file *f, const char *mmu_type)
> @@ -134,7 +161,7 @@ static int c_show(struct seq_file *m, void *v)
> seq_printf(m, "processor\t: %lu\n", cpu_id);
> seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id));
> if (!of_property_read_string(node, "riscv,isa", &isa))
> - print_isa(m, isa);
> + print_isa(m, isa, cpu_id);
> if (!of_property_read_string(node, "mmu-type", &mmu))
> print_mmu(m, mmu);
> if (!of_property_read_string(node, "compatible", &compat)
> --
> 2.21.0
>
>
- Paul
On Tue, 2019-08-06 at 16:27 -0700, Paul Walmsley wrote:
> On Wed, 31 Jul 2019, Atish Patra wrote:
>
> > Currently, kernel prints a info warning if any of the extensions
> > from "mafdcsu" is missing in device tree. This is not entirely
> > correct as Linux can boot with "f or d" extensions if kernel is
> > configured accordingly. Moreover, it will continue to print the
> > info string for future extensions such as hypervisor as well which
> > is misleading. /proc/cpuinfo also doesn't print any other
> > extensions
> > except "mafdcsu".
> >
> > Make sure that info log is only printed only if kernel is
> > configured
> > to have any mandatory extensions but device tree doesn't describe
> > it.
> > All the extensions present in device tree and follow the order
> > described in the RISC-V specification (except 'S') are printed via
> > /proc/cpuinfo always.
> >
> > Signed-off-by: Atish Patra <[email protected]>
>
> I tested this patch after dropping the CONFIG_ISA_RISCV_C test (see
> below). Running "cat /proc/cpuinfo" generated the following kernel
> warnings:
>
> [ 73.412626] unsupported ISA extensions "su" in device tree for cpu
> [0]
> [ 73.418417] unsupported ISA extensions "su" in device tree for cpu
> [1]
> [ 73.424912] unsupported ISA extensions "su" in device tree for cpu
> [2]
> [ 73.431425] unsupported ISA extensions "su" in device tree for cpu
> [3]
>
yeah. I just tested in QEMU. It seems that QEMU has
"rv64imafdcsu" as isa string in its DT. That's why I never saw this.
> Seems like the "su" should be dropped from mandatory_ext. What do
> you
> think?
>
Yup. As DT binding only mention imafdc, mandatory extensions should
contain only that and just consider "su" extensions are considered as
implicit as we are running Linux.
Do you think QEMU DT should be updated to reflect that ?
> > ---
> > arch/riscv/kernel/cpu.c | 47 ++++++++++++++++++++++++++++++++-----
> > ----
> > 1 file changed, 37 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> > index 7da3c6a93abd..9b1d4550fbe6 100644
> > --- a/arch/riscv/kernel/cpu.c
> > +++ b/arch/riscv/kernel/cpu.c
> > @@ -7,6 +7,7 @@
> > #include <linux/seq_file.h>
> > #include <linux/of.h>
> > #include <asm/smp.h>
> > +#include <asm/hwcap.h>
> >
> > /*
> > * Returns the hart ID of the given device tree node, or -ENODEV
> > if the node
> > @@ -46,11 +47,14 @@ int riscv_of_processor_hartid(struct
> > device_node *node)
> >
> > #ifdef CONFIG_PROC_FS
> >
> > -static void print_isa(struct seq_file *f, const char *orig_isa)
> > +static void print_isa(struct seq_file *f, const char *orig_isa,
> > + unsigned long cpuid)
> > {
> > - static const char *ext = "mafdcsu";
> > + static const char *mandatory_ext = "mafdcsu";
> > const char *isa = orig_isa;
> > const char *e;
> > + char unsupported_isa[26] = {0};
> > + int index = 0;
> >
> > /*
> > * Linux doesn't support rv32e or rv128i, and we only support
> > booting
> > @@ -70,27 +74,50 @@ static void print_isa(struct seq_file *f, const
> > char *orig_isa)
> > isa += 5;
> >
> > /*
> > - * Check the rest of the ISA string for valid extensions,
> > printing those
> > - * we find. RISC-V ISA strings define an order, so we only
> > print the
> > + * RISC-V ISA strings define an order, so we only print all the
> > * extension bits when they're in order. Hide the supervisor
> > (S)
> > * extension from userspace as it's not accessible from there.
> > + * Throw a warning only if any mandatory extensions are not
> > available
> > + * and kernel is configured to have that mandatory extensions.
> > */
> > - for (e = ext; *e != '\0'; ++e) {
> > - if (isa[0] == e[0]) {
> > + for (e = mandatory_ext; *e != '\0'; ++e) {
> > + if (isa[0] != e[0]) {
> > +#if defined(CONFIG_ISA_RISCV_C)
>
> There's no Kconfig option by this name, and we're requiring
> compressed
Sorry. This was a typo. It should have been CONFIG_RISCV_ISA_C.
> instruction support as part of the RISC-V Linux baseline. Could you
> share
> the rationale behind this?
I think I added this check at the config file. Looking at the Kconfig,
RISCV_ISA_C is always enabled. So we can drop this.
Regards,
Atish
> Looks to me like this should be dropped.
>
>
> > + if (isa[0] == 'c')
> > + continue;
> > +#endif
> > +#if defined(CONFIG_FP)
> > + if ((isa[0] == 'f') || (isa[0] == 'd'))
> > + continue;
> > +#endif
> > + unsupported_isa[index] = e[0];
> > + index++;
> > + }
> > + /* Only write if part of isa string */
> > + if (isa[0] != '\0') {
> > if (isa[0] != 's')
> > seq_write(f, isa, 1);
> > -
> > isa++;
> > }
> > }
> > + if (isa[0] != '\0') {
> > + /* Add remainging isa strings */
> > + for (e = isa; *e != '\0'; ++e) {
> > +#if !defined(CONFIG_VIRTUALIZATION)
> > + if (e[0] != 'h')
> > +#endif
> > + seq_write(f, e, 1);
> > + }
> > + }
> > seq_puts(f, "\n");
> >
> > /*
> > * If we were given an unsupported ISA in the device tree then
> > print
> > * a bit of info describing what went wrong.
> > */
> > - if (isa[0] != '\0')
> > - pr_info("unsupported ISA \"%s\" in device tree\n",
> > orig_isa);
> > + if (unsupported_isa[0])
> > + pr_info("unsupported ISA extensions \"%s\" in device
> > tree for cpu [%ld]\n",
> > + unsupported_isa, cpuid);
> > }
> >
> > static void print_mmu(struct seq_file *f, const char *mmu_type)
> > @@ -134,7 +161,7 @@ static int c_show(struct seq_file *m, void *v)
> > seq_printf(m, "processor\t: %lu\n", cpu_id);
> > seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id));
> > if (!of_property_read_string(node, "riscv,isa", &isa))
> > - print_isa(m, isa);
> > + print_isa(m, isa, cpu_id);
> > if (!of_property_read_string(node, "mmu-type", &mmu))
> > print_mmu(m, mmu);
> > if (!of_property_read_string(node, "compatible", &compat)
> > --
> > 2.21.0
> >
> >
>
> - Paul
On Wed, 7 Aug 2019, Atish Patra wrote:
> On Tue, 2019-08-06 at 16:27 -0700, Paul Walmsley wrote:
>
> > Seems like the "su" should be dropped from mandatory_ext. What do you
> > think?
> >
>
> Yup. As DT binding only mention imafdc, mandatory extensions should
> contain only that and just consider "su" extensions are considered as
> implicit as we are running Linux.
Discussing this with Andrew and Palmer, it looks like "su" is currently
non-compliant. Section 22.6 of the user-level specification states that
the "s" character indicates that a longer standard supervisor extension
name will follow. So far I don't think any of these have been defined.
> Do you think QEMU DT should be updated to reflect that ?
Yes.
> > There's no Kconfig option by this name, and we're requiring
> > compressed
>
> Sorry. This was a typo. It should have been CONFIG_RISCV_ISA_C.
>
> > instruction support as part of the RISC-V Linux baseline. Could you
> > share the rationale behind this?
>
> I think I added this check at the config file. Looking at the Kconfig,
> RISCV_ISA_C is always enabled. So we can drop this.
OK great. Do you want to resend an updated patch, or would you like me to
fix it up here?
I'll also send a patch to drop CONFIG_RISCV_ISA_C.
- Paul
On Tue, 06 Aug 2019 18:26:08 PDT (-0700), Paul Walmsley wrote:
> On Wed, 7 Aug 2019, Atish Patra wrote:
>
>> On Tue, 2019-08-06 at 16:27 -0700, Paul Walmsley wrote:
>>
>> > Seems like the "su" should be dropped from mandatory_ext. What do you
>> > think?
>> >
>>
>> Yup. As DT binding only mention imafdc, mandatory extensions should
>> contain only that and just consider "su" extensions are considered as
>> implicit as we are running Linux.
>
> Discussing this with Andrew and Palmer, it looks like "su" is currently
> non-compliant. Section 22.6 of the user-level specification states that
> the "s" character indicates that a longer standard supervisor extension
> name will follow. So far I don't think any of these have been defined.
>
>> Do you think QEMU DT should be updated to reflect that ?
>
> Yes.
https://lists.nongnu.org/archive/html/qemu-riscv/2019-08/msg00141.html
>
>> > There's no Kconfig option by this name, and we're requiring
>> > compressed
>>
>> Sorry. This was a typo. It should have been CONFIG_RISCV_ISA_C.
>>
>> > instruction support as part of the RISC-V Linux baseline. Could you
>> > share the rationale behind this?
>>
>> I think I added this check at the config file. Looking at the Kconfig,
>> RISCV_ISA_C is always enabled. So we can drop this.
>
> OK great. Do you want to resend an updated patch, or would you like me to
> fix it up here?
>
> I'll also send a patch to drop CONFIG_RISCV_ISA_C.
>
>
> - Paul
On Tue, 2019-08-06 at 18:26 -0700, Paul Walmsley wrote:
> On Wed, 7 Aug 2019, Atish Patra wrote:
>
> > On Tue, 2019-08-06 at 16:27 -0700, Paul Walmsley wrote:
> >
> > > Seems like the "su" should be dropped from mandatory_ext. What
> > > do you
> > > think?
> > >
> >
> > Yup. As DT binding only mention imafdc, mandatory extensions should
> > contain only that and just consider "su" extensions are considered
> > as
> > implicit as we are running Linux.
>
> Discussing this with Andrew and Palmer, it looks like "su" is
> currently
> non-compliant. Section 22.6 of the user-level specification states
> that
> the "s" character indicates that a longer standard supervisor
> extension
> name will follow. So far I don't think any of these have been
> defined.
>
> > Do you think QEMU DT should be updated to reflect that ?
>
> Yes.
>
> > > There's no Kconfig option by this name, and we're requiring
> > > compressed
> >
> > Sorry. This was a typo. It should have been CONFIG_RISCV_ISA_C.
> >
> > > instruction support as part of the RISC-V Linux baseline. Could
> > > you
> > > share the rationale behind this?
> >
> > I think I added this check at the config file. Looking at the
> > Kconfig,
> > RISCV_ISA_C is always enabled. So we can drop this.
>
> OK great. Do you want to resend an updated patch, or would you like
> me to
> fix it up here?
>
I am sending the patch right now. We can remove the 'S' mode check as
palmer have already sent the QEMU patch as well, .
Regards,
Atish
> I'll also send a patch to drop CONFIG_RISCV_ISA_C.
>
>
> - Paul
On Wed, 07 Aug 2019 10:31:51 PDT (-0700), Atish Patra wrote:
> On Tue, 2019-08-06 at 18:26 -0700, Paul Walmsley wrote:
>> On Wed, 7 Aug 2019, Atish Patra wrote:
>>
>> > On Tue, 2019-08-06 at 16:27 -0700, Paul Walmsley wrote:
>> >
>> > > Seems like the "su" should be dropped from mandatory_ext. What
>> > > do you
>> > > think?
>> > >
>> >
>> > Yup. As DT binding only mention imafdc, mandatory extensions should
>> > contain only that and just consider "su" extensions are considered
>> > as
>> > implicit as we are running Linux.
>>
>> Discussing this with Andrew and Palmer, it looks like "su" is
>> currently
>> non-compliant. Section 22.6 of the user-level specification states
>> that
>> the "s" character indicates that a longer standard supervisor
>> extension
>> name will follow. So far I don't think any of these have been
>> defined.
>>
>> > Do you think QEMU DT should be updated to reflect that ?
>>
>> Yes.
>>
>> > > There's no Kconfig option by this name, and we're requiring
>> > > compressed
>> >
>> > Sorry. This was a typo. It should have been CONFIG_RISCV_ISA_C.
>> >
>> > > instruction support as part of the RISC-V Linux baseline. Could
>> > > you
>> > > share the rationale behind this?
>> >
>> > I think I added this check at the config file. Looking at the
>> > Kconfig,
>> > RISCV_ISA_C is always enabled. So we can drop this.
>>
>> OK great. Do you want to resend an updated patch, or would you like
>> me to
>> fix it up here?
>>
>
> I am sending the patch right now. We can remove the 'S' mode check as
> palmer have already sent the QEMU patch as well, .
Looks like I missed the boat for 4.1, though.
>
> Regards,
> Atish
>> I'll also send a patch to drop CONFIG_RISCV_ISA_C.
>>
>>
>> - Paul
>