Skip to content

Commit aeb71e4

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
dt-bindings: riscv: deprecate riscv,isa
intro ===== When the RISC-V dt-bindings were accepted upstream in Linux, the base ISA etc had yet to be ratified. By the ratification of the base ISA, incompatible changes had snuck into the specifications - for example the Zicsr and Zifencei extensions were spun out of the base ISA. Fast forward to today, and the reason for this patch. Currently the riscv,isa dt property permits only a specific subset of the ISA string - in particular it excludes version numbering. With the current constraints, it is not possible to discern whether "rv64i" means that the hart supports the fence.i instruction, for example. Future systems may choose to implement their own instruction fencing, perhaps using a vendor extension, or they may not implement the optional counter extensions. Software needs a way to determine this. versioning schemes ================== "Use the extension versions that are described in the ISA manual" you may say, and it's not like this has not been considered. Firstly, software that parses the riscv,isa property at runtime will need to contain a lookup table of some sort that maps arbitrary versions to versions it understands. There is not a consistent application of version number applied to extensions, with a higgledy-piggledy collection of tags, "bare" and versioned documents awaiting the reader on the "recently ratified extensions" page: https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions As an aside, and this is reflected in the patch too, since many extensions have yet to appear in a release of the ISA specs, they are defined by commits in their respective "working draft" repositories. Secondly, there is an issue of backwards compatibility, whereby allowing numbers in the ISA string, some parsers may be broken. This would require an additional property to be created to even use the versions in this manner. ~boolean properties~ string array property ========================================== If a new property is needed, the whole approach may as well be looked at from the bottom up. A string with limited character choices etc is hardly the best approach for communicating extension information to software. Switching to using properties that are defined on a per extension basis, allows us to define explicit meanings for the DT representation of each extension - rather than the current situation where different operating systems or other bits of software may impart different meanings to characters in the string. Clearly the best source of meanings is the specifications themselves, this just provides us the ability to choose at what point in time the meaning is set. If an extension changes incompatibility in the future, a new property will be required. Off-list, some of the RVI folks have committed to shoring up the wording in either the ISA specifications, the riscv-isa-manual or so that in the future, modifications to and additions or removals of features will require a new extension. Codifying that assertion somewhere would make it quite unlikely that compatibility would be broken, but we have the tools required to deal with it, if & when it crops up. It is in our collective interest, as consumers of extension meanings, to define a scheme that enforces compatibility. The use of individual elements, rather than a single string, will also permit validation that the properties have a meaning, as well as potentially reject mutually exclusive combinations, or enforce dependencies between extensions. That would not have be possible with the current dt-schema infrastructure for arbitrary strings, as we would need to add a riscv,isa parser to dt-validate! That's not implemented in this patch, but rather left as future work (for the brave, or the foolish). parser simplicity ================= Many systems that parse DT at runtime already implement an function that can check for the presence of a string in an array of string, as it is similar to the process for parsing a list of compatible strings, so a bunch of new, custom, DT parsing should not be needed. Getting rid of "riscv,isa" parsing would be a nice simplification, but unfortunately for backwards compatibility with old dtbs, existing parsers may not be removable - which may greatly simplify dt parsing code. In Linux, for example, checking for whether a hart supports an extension becomes as simple as: of_property_match_string(node, "riscv,isa-extensions", "zicbom") vendor extensions ================= Compared to riscv,isa, this proposed scheme promotes vendor extensions, oft touted as the strength of RISC-V, to first-class citizens. At present, extensions are defined as meaning what the RISC-V ISA specifications say they do. There is no realistic way of using that interface to provide cross-platform definitions for what vendor extensions mean. Vendor extensions may also have even less consistency than RVI do in terms of versioning, or no care about backwards compatibility. The new property allows us to assign explicit meanings on a per vendor extension basis, backed up by a description of their meanings. fin === Create a new file to store the extension meanings and a new riscv,isa-base property to replace the aspect of riscv,isa that is not represented by the new property - the base ISA implemented by a hart. As a starting point, add properties for extensions currently used in Linux. Finally, mark riscv,isa as deprecated, as removing support for it in existing programs would be an ABI break. CC: Palmer Dabbelt <[email protected]> CC: Paul Walmsley <[email protected]> CC: Rob Herring <[email protected]> CC: Krzysztof Kozlowski <[email protected]> CC: Alistair Francis <[email protected]> CC: Andrew Jones <[email protected]> CC: Anup Patel <[email protected]> CC: Atish Patra <[email protected]> CC: Jessica Clarke <[email protected]> CC: Rick Chen <[email protected]> CC: Leo <[email protected]> CC: Oleksii <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected] Reviewed-by: Palmer Dabbelt <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/20230702-eats-scorebook-c951f170d29f@spud Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 52909f1 commit aeb71e4

File tree

2 files changed

+270
-23
lines changed

2 files changed

+270
-23
lines changed

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ description: |
2525
2626
allOf:
2727
- $ref: /schemas/cpu.yaml#
28+
- $ref: extensions.yaml
2829

2930
properties:
3031
compatible:
@@ -82,25 +83,6 @@ properties:
8283
description:
8384
The blocksize in bytes for the Zicboz cache operations.
8485

85-
riscv,isa:
86-
description:
87-
Identifies the specific RISC-V instruction set architecture
88-
supported by the hart. These are documented in the RISC-V
89-
User-Level ISA document, available from
90-
https://riscv.org/specifications/
91-
92-
Due to revisions of the ISA specification, some deviations
93-
have arisen over time.
94-
Notably, riscv,isa was defined prior to the creation of the
95-
Zicntr, Zicsr, Zifencei and Zihpm extensions and thus "i"
96-
implies "zicntr_zicsr_zifencei_zihpm".
97-
98-
While the isa strings in ISA specification are case
99-
insensitive, letters in the riscv,isa string must be all
100-
lowercase.
101-
$ref: /schemas/types.yaml#/definitions/string
102-
pattern: ^rv(?:64|32)imaf?d?q?c?b?k?j?p?v?h?(?:[hsxz](?:[a-z])+)?(?:_[hsxz](?:[a-z])+)*$
103-
10486
# RISC-V has multiple properties for cache op block sizes as the sizes
10587
# differ between individual CBO extensions
10688
cache-op-block-size: false
@@ -139,8 +121,17 @@ properties:
139121
DMIPS/MHz, relative to highest capacity-dmips-mhz
140122
in the system.
141123

124+
anyOf:
125+
- required:
126+
- riscv,isa
127+
- required:
128+
- riscv,isa-base
129+
130+
dependencies:
131+
riscv,isa-base: [ "riscv,isa-extensions" ]
132+
riscv,isa-extensions: [ "riscv,isa-base" ]
133+
142134
required:
143-
- riscv,isa
144135
- interrupt-controller
145136

146137
unevaluatedProperties: false
@@ -160,7 +151,9 @@ examples:
160151
i-cache-sets = <128>;
161152
i-cache-size = <16384>;
162153
reg = <0>;
163-
riscv,isa = "rv64imac";
154+
riscv,isa-base = "rv64i";
155+
riscv,isa-extensions = "i", "m", "a", "c";
156+
164157
cpu_intc0: interrupt-controller {
165158
#interrupt-cells = <1>;
166159
compatible = "riscv,cpu-intc";
@@ -183,8 +176,10 @@ examples:
183176
i-tlb-size = <32>;
184177
mmu-type = "riscv,sv39";
185178
reg = <1>;
186-
riscv,isa = "rv64imafdc";
187179
tlb-split;
180+
riscv,isa-base = "rv64i";
181+
riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
182+
188183
cpu_intc1: interrupt-controller {
189184
#interrupt-cells = <1>;
190185
compatible = "riscv,cpu-intc";
@@ -202,8 +197,10 @@ examples:
202197
device_type = "cpu";
203198
reg = <0>;
204199
compatible = "riscv";
205-
riscv,isa = "rv64imafdc";
206200
mmu-type = "riscv,sv48";
201+
riscv,isa-base = "rv64i";
202+
riscv,isa-extensions = "i", "m", "a", "f", "d", "c";
203+
207204
interrupt-controller {
208205
#interrupt-cells = <1>;
209206
interrupt-controller;
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR MIT)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/riscv/extensions.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: RISC-V ISA extensions
8+
9+
maintainers:
10+
- Paul Walmsley <[email protected]>
11+
- Palmer Dabbelt <[email protected]>
12+
- Conor Dooley <[email protected]>
13+
14+
description: |
15+
RISC-V has a large number of extensions, some of which are "standard"
16+
extensions, meaning they are ratified by RISC-V International, and others
17+
are "vendor" extensions.
18+
This document defines properties that indicate whether a hart supports a
19+
given extension.
20+
21+
Once a standard extension has been ratified, no changes in behaviour can be
22+
made without the creation of a new extension.
23+
The properties for standard extensions therefore map to their originally
24+
ratified states, with the exception of the I, Zicntr & Zihpm extensions.
25+
See the "i" property for more information.
26+
27+
select:
28+
properties:
29+
compatible:
30+
contains:
31+
const: riscv
32+
33+
properties:
34+
riscv,isa:
35+
description:
36+
Identifies the specific RISC-V instruction set architecture
37+
supported by the hart. These are documented in the RISC-V
38+
User-Level ISA document, available from
39+
https://riscv.org/specifications/
40+
41+
Due to revisions of the ISA specification, some deviations
42+
have arisen over time.
43+
Notably, riscv,isa was defined prior to the creation of the
44+
Zicntr, Zicsr, Zifencei and Zihpm extensions and thus "i"
45+
implies "zicntr_zicsr_zifencei_zihpm".
46+
47+
While the isa strings in ISA specification are case
48+
insensitive, letters in the riscv,isa string must be all
49+
lowercase.
50+
$ref: /schemas/types.yaml#/definitions/string
51+
pattern: ^rv(?:64|32)imaf?d?q?c?b?k?j?p?v?h?(?:[hsxz](?:[a-z])+)?(?:_[hsxz](?:[a-z])+)*$
52+
deprecated: true
53+
54+
riscv,isa-base:
55+
description:
56+
The base ISA implemented by this hart, as described by the 20191213
57+
version of the unprivileged ISA specification.
58+
enum:
59+
- rv32i
60+
- rv64i
61+
62+
riscv,isa-extensions:
63+
$ref: /schemas/types.yaml#/definitions/string-array
64+
minItems: 1
65+
description: Extensions supported by the hart.
66+
items:
67+
anyOf:
68+
# single letter extensions, in canonical order
69+
- const: i
70+
description: |
71+
The base integer instruction set, as ratified in the 20191213
72+
version of the unprivileged ISA specification.
73+
74+
This does not include Chapter 10, "Counters", which was moved into
75+
the Zicntr and Zihpm extensions after the ratification of the
76+
20191213 version of the unprivileged specification.
77+
78+
- const: m
79+
description:
80+
The standard M extension for integer multiplication and division, as
81+
ratified in the 20191213 version of the unprivileged ISA
82+
specification.
83+
84+
- const: a
85+
description:
86+
The standard A extension for atomic instructions, as ratified in the
87+
20191213 version of the unprivileged ISA specification.
88+
89+
- const: f
90+
description:
91+
The standard F extension for single-precision floating point, as
92+
ratified in the 20191213 version of the unprivileged ISA
93+
specification.
94+
95+
- const: d
96+
description:
97+
The standard D extension for double-precision floating-point, as
98+
ratified in the 20191213 version of the unprivileged ISA
99+
specification.
100+
101+
- const: q
102+
description:
103+
The standard Q extension for quad-precision floating-point, as
104+
ratified in the 20191213 version of the unprivileged ISA
105+
specification.
106+
107+
- const: c
108+
description:
109+
The standard C extension for compressed instructions, as ratified in
110+
the 20191213 version of the unprivileged ISA specification.
111+
112+
- const: v
113+
description:
114+
The standard V extension for vector operations, as ratified
115+
in-and-around commit 7a6c8ae ("Fix text that describes vfmv.v.f
116+
encoding") of the riscv-v-spec.
117+
118+
- const: h
119+
description:
120+
The standard H extension for hypervisors as ratified in the 20191213
121+
version of the privileged ISA specification.
122+
123+
# multi-letter extensions, sorted alphanumerically
124+
- const: smaia
125+
description: |
126+
The standard Smaia supervisor-level extension for the advanced
127+
interrupt architecture for machine-mode-visible csr and behavioural
128+
changes to interrupts as frozen at commit ccbddab ("Merge pull
129+
request #42 from riscv/jhauser-2023-RC4") of riscv-aia.
130+
131+
- const: ssaia
132+
description: |
133+
The standard Ssaia supervisor-level extension for the advanced
134+
interrupt architecture for supervisor-mode-visible csr and
135+
behavioural changes to interrupts as frozen at commit ccbddab
136+
("Merge pull request #42 from riscv/jhauser-2023-RC4") of riscv-aia.
137+
138+
- const: sscofpmf
139+
description: |
140+
The standard Sscofpmf supervisor-level extension for count overflow
141+
and mode-based filtering as ratified at commit 01d1df0 ("Add ability
142+
to manually trigger workflow. (#2)") of riscv-count-overflow.
143+
144+
- const: sstc
145+
description: |
146+
The standard Sstc supervisor-level extension for time compare as
147+
ratified at commit 3f9ed34 ("Add ability to manually trigger
148+
workflow. (#2)") of riscv-time-compare.
149+
150+
- const: svinval
151+
description:
152+
The standard Svinval supervisor-level extension for fine-grained
153+
address-translation cache invalidation as ratified in the 20191213
154+
version of the privileged ISA specification.
155+
156+
- const: svnapot
157+
description:
158+
The standard Svnapot supervisor-level extensions for napot
159+
translation contiguity as ratified in the 20191213 version of the
160+
privileged ISA specification.
161+
162+
- const: svpbmt
163+
description:
164+
The standard Svpbmt supervisor-level extensions for page-based
165+
memory types as ratified in the 20191213 version of the privileged
166+
ISA specification.
167+
168+
- const: zba
169+
description: |
170+
The standard Zba bit-manipulation extension for address generation
171+
acceleration instructions as ratified at commit 6d33919 ("Merge pull
172+
request #158 from hirooih/clmul-fix-loop-end-condition") of
173+
riscv-bitmanip.
174+
175+
- const: zbb
176+
description: |
177+
The standard Zbb bit-manipulation extension for basic bit-manipulation
178+
as ratified at commit 6d33919 ("Merge pull request #158 from
179+
hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
180+
181+
- const: zbc
182+
description: |
183+
The standard Zbc bit-manipulation extension for carry-less
184+
multiplication as ratified at commit 6d33919 ("Merge pull request
185+
#158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
186+
187+
- const: zbs
188+
description: |
189+
The standard Zbs bit-manipulation extension for single-bit
190+
instructions as ratified at commit 6d33919 ("Merge pull request #158
191+
from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
192+
193+
- const: zicbom
194+
description:
195+
The standard Zicbom extension for base cache management operations as
196+
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
197+
198+
- const: zicbop
199+
description:
200+
The standard Zicbop extension for cache-block prefetch instructions
201+
as ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of
202+
riscv-CMOs.
203+
204+
- const: zicboz
205+
description:
206+
The standard Zicboz extension for cache-block zeroing as ratified
207+
in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
208+
209+
- const: zicntr
210+
description:
211+
The standard Zicntr extension for base counters and timers, as
212+
ratified in the 20191213 version of the unprivileged ISA
213+
specification.
214+
215+
- const: zicsr
216+
description: |
217+
The standard Zicsr extension for control and status register
218+
instructions, as ratified in the 20191213 version of the
219+
unprivileged ISA specification.
220+
221+
This does not include Chapter 10, "Counters", which documents
222+
special case read-only CSRs, that were moved into the Zicntr and
223+
Zihpm extensions after the ratification of the 20191213 version of
224+
the unprivileged specification.
225+
226+
- const: zifencei
227+
description:
228+
The standard Zifencei extension for instruction-fetch fence, as
229+
ratified in the 20191213 version of the unprivileged ISA
230+
specification.
231+
232+
- const: zihintpause
233+
description:
234+
The standard Zihintpause extension for pause hints, as ratified in
235+
commit d8ab5c7 ("Zihintpause is ratified") of the riscv-isa-manual.
236+
237+
- const: zihpm
238+
description:
239+
The standard Zihpm extension for hardware performance counters, as
240+
ratified in the 20191213 version of the unprivileged ISA
241+
specification.
242+
243+
- const: ztso
244+
description:
245+
The standard Ztso extension for total store ordering, as ratified
246+
in commit 2e5236 ("Ztso is now ratified.") of the
247+
riscv-isa-manual.
248+
249+
additionalProperties: true
250+
...

0 commit comments

Comments
 (0)