Skip to contentSkip to conversation

dt: add /cpus/ibm, powerpc-cpu-features device tree bindings

PATCH Superseded Nicholas Piggin 2 participants 5 messages Feb 3, 2018 – Feb 5, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt: add /cpus/ibm, powerpc-cpu-features device tree bindings

This is a new CPU feature advertising interface that is fine-grained, extensible, aware of privilege levels, and gives control of features to all levels of the stack (firmware, hypervisor, and OS).

The design and binding specification is described in detail in doc/.

---
 core/Makefile.inc                                  |   2 +-
 core/cpufeatures.c                                 | 932 +++++++++++++++++++++
 core/device.c                                      |   7 +
 core/init.c                                        |   1 +
 .../ibm,powerpc-cpu-features/binding.txt           | 245 ++++++
 .../ibm,powerpc-cpu-features/design.txt            | 157 ++++
 include/device.h                                   |   1 +
 include/skiboot.h                                  |   5 +
 8 files changed, 1349 insertions(+), 1 deletion(-)
 create mode 100644 core/cpufeatures.c
 create mode 100644 doc/device-tree/ibm,powerpc-cpu-features/binding.txt
 create mode 100644 doc/device-tree/ibm,powerpc-cpu-features/design.txt
core/Makefile.inc +1 -1
index d6a7269fa..5c1205646 100644
@@ -9,7 +9,7 @@ CORE_OBJS += vpd.o hostservices.o platform.o nvram.o nvram-format.o hmi.o
 CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
 CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o
 CORE_OBJS += flash-subpartition.o bitmap.o buddy.o pci-quirk.o powercap.o psr.o
-CORE_OBJS += pci-dt-slot.o direct-controls.o
+CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o
 
 ifeq ($(SKIBOOT_GCOV),1)
 CORE_OBJS += gcov-profiling.o
core/cpufeatures.c new file +932 -0

932 lines not on this page · raw message

core/device.c +7 -0
index fc1db5689..11c50af3f 100644
@@ -598,6 +598,13 @@ u32 dt_property_get_cell(const struct dt_property *prop, u32 index)
 	return fdt32_to_cpu(((const u32 *)prop->prop)[index]);
 }
 
+void dt_property_set_cell(struct dt_property *prop, u32 index, u32 val)
+{
+	assert(prop->len >= (index+1)*sizeof(u32));
+	/* Always aligned, so this works. */
+	((u32 *)prop->prop)[index] = cpu_to_fdt32(val);
+}
+
 /* First child of this node. */
 struct dt_node *dt_first(const struct dt_node *root)
 {
core/init.c +1 -0
index ec9f32981..cf99e5f4f 100644
@@ -860,6 +860,7 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
 	} else {
 		dt_expand(fdt);
 	}
+	dt_add_cpufeatures(dt_root);
 
 	/* Now that we have a full devicetree, verify that we aren't on fire. */
 	per_thread_sanity_checks();
doc/device-tree/ibm,powerpc-cpu-features/binding.txt new file +245 -0

245 lines not on this page · raw message

doc/device-tree/ibm,powerpc-cpu-features/design.txt new file +157 -0

157 lines not on this page · raw message

include/device.h +1 -0
index 1e5875dca..fd66df11a 100644
@@ -141,6 +141,7 @@ void dt_check_del_prop(struct dt_node *node, const char *name);
 /* Warning: moves *prop! */
 void dt_resize_property(struct dt_property **prop, size_t len);
 
+void dt_property_set_cell(struct dt_property *prop, u32 index, u32 val);
 u32 dt_property_get_cell(const struct dt_property *prop, u32 index);
 
 /* First child of this node. */
include/skiboot.h +5 -0
index e94f21212..bcbdb4829 100644
@@ -195,6 +195,11 @@ extern void start_kernel_secondary(uint64_t entry) __noreturn;
 /* Get description of machine from HDAT and create device-tree */
 extern int parse_hdat(bool is_opal);
 
+struct dt_node;
+
+/* Add /cpus/features node for boot environment that passes an fdt */
+extern void dt_add_cpufeatures(struct dt_node *root);
+
 /* Root of device tree. */
 extern struct dt_node *dt_root;
 
Signature · 1 line
2.15.1
#1 lore raw

Re: [PATCH (skiboot)] dt: add /cpus/ibm,powerpc-cpu-features device tree bindings

Quoted 23 lines · On Sat, 3 Feb 2018 14:27:32 +1000 Nicholas Piggin <[email protected]> wrote:
core/cpufeatures.c new file +17 -0
new file mode 100644
index 000000000..ca9df91f0
@@ -0,0 +1,932 @@
+/* Copyright 2017 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 	http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*

core/cpufeatures.c line 27

Quoted 10 lines
core/cpufeatures.c new file +10 -0
+ * This file deals with setup of /cpus/ibm,powerpc-cpu-features dt
+ */
+
+#include <skiboot.h>
+#include <cpu.h>
+#include <processor.h>
+#include <ccan/str/str.h>
+#include <device.h>
+
+#define DEBUG

Sorry, didn't send the right version after testing. This line should be deleted before going upstream.

Thanks,
Nick

#2 lore raw
In reply to Nicholas Piggin

Hi! Some remarks:

core/cpufeatures.c line 612

Quoted 4 lines · Nicholas Piggin
core/cpufeatures.c new file +4 -0
+	/*
+	 * ISAv3.0B deliver a random number instruction (darn)
+	 */
+	{ "random-number-generator",

That's not such a great name... "darn-instruction" maybe? Just "wait" as a name is a bit too short too I guess (and there is "wait-v3", so that could be "wait-v2" or so? Or "wait-instruction").

core/cpufeatures.c line 687

Quoted 5 lines
core/cpufeatures.c new file +5 -0
+	/*
+	 * ISAv3.0B branch instruction and register additions
+	 * CA32, OV32, mcrxrx, setb
+	 */
+	{ "branch-v3",

Those aren't branch instructions, they are integer instructions. Some of which use the XER, some of which use CR fields.

doc/device-tree/ibm,powerpc-cpu-features/binding.txt line 54

Quoted 13 lines

+- isa

doc/device-tree/ibm,powerpc-cpu-features/binding.txt new file +12 -0
+  Usage: required
+  Value type: <u32>
+  Definition:
+
+  isa that the CPU is currently running in. This provides instruction set
+  compatibility, less the individual feature nodes. For example, an ISA v3.0
+  implementation that lacks the "transactional-memory" cpufeature node
+  should not use transactional memory facilities.
+
+  Value corresponds to the "Power ISA Version" multiplied by 1000.
+  For example, <3000> corresponds to Version 3.0, <2070> to Version 2.07.
+  The minor digit is available for revisions.

So the 2.07B, 3.0B (in the code above) should really be 2071 and 3001 (instead of 2070 and 3000)? Or you could make it hex and have 0x207B :-)

Quoted 1 line

+The policy for seleting and configuring which features to advertise and use

Typo ("selecting").

Segher

#3 lore raw
Quoted 1 line · On Sat, 3 Feb 2018 09:36:20 -0600 Segher Boessenkool…

Hi! Some remarks:

Hi Segher,

Thanks for looking, we're a bit constrained in what we should do because Linux side of the patch is already merged.

Quoted 10 lines · Nicholas Piggin

core/cpufeatures.c line 612

Quoted 4 lines
core/cpufeatures.c new file +4 -0
+	/*
+	 * ISAv3.0B deliver a random number instruction (darn)
+	 */
+	{ "random-number-generator",  

That's not such a great name... "darn-instruction" maybe? Just "wait" as a name is a bit too short too I guess (and there is "wait-v3", so that could be "wait-v2" or so? Or "wait-instruction").

You're probably right, I don't know if it's worth changing now though. -vX is meant to be an indication of an ISA version that changed or superseded the older function.

Quoted 9 lines

core/cpufeatures.c line 687

Quoted 6 lines
core/cpufeatures.c new file +5 -0
+	/*
+	 * ISAv3.0B branch instruction and register additions
+	 * CA32, OV32, mcrxrx, setb
+	 */
+	{ "branch-v3",  

Those aren't branch instructions, they are integer instructions. Some of which use the XER, some of which use CR fields.

Okay, well the register changes are for branch facility registers, I guess instructions could move to integer. We have nothing relying on exact definition of these things at the moment, so these we can change.

Quoted 17 lines
Quoted 4 lines

+- isa

doc/device-tree/ibm,powerpc-cpu-features/binding.txt new file +2 -0
+  Usage: required
+  Value type: <u32>

doc/device-tree/ibm,powerpc-cpu-features/binding.txt line 54

Quoted 10 lines
doc/device-tree/ibm,powerpc-cpu-features/binding.txt new file +10 -0
+  Definition:
+
+  isa that the CPU is currently running in. This provides instruction set
+  compatibility, less the individual feature nodes. For example, an ISA v3.0
+  implementation that lacks the "transactional-memory" cpufeature node
+  should not use transactional memory facilities.
+
+  Value corresponds to the "Power ISA Version" multiplied by 1000.
+  For example, <3000> corresponds to Version 3.0, <2070> to Version 2.07.
+  The minor digit is available for revisions.  

So the 2.07B, 3.0B (in the code above) should really be 2071 and 3001 (instead of 2070 and 3000)? Or you could make it hex and have 0x207B :-)

This I think we can change (Linux code is supposed to be largely version agnostic, and it looks like it is except one special case that will do the right thing if we change it.

Quoted 4 lines
Quoted 2 lines

+The policy for seleting and configuring which features to advertise and use

Typo ("selecting").

Thanks,
Nick

#4 lore raw
Quoted 11 lines · Nicholas Piggin

On Sat, 3 Feb 2018 09:36:20 -0600

Quoted 9 lines · Nicholas Piggin

core/cpufeatures.c line 687

Quoted 5 lines
core/cpufeatures.c new file +5 -0
+	/*
+	 * ISAv3.0B branch instruction and register additions
+	 * CA32, OV32, mcrxrx, setb
+	 */
+	{ "branch-v3",  

Those aren't branch instructions, they are integer instructions. Some of which use the XER, some of which use CR fields.

Quoted 3 lines

Okay, well the register changes are for branch facility registers, I guess instructions could move to integer. We have nothing relying on exact definition of these things at the moment, so these we can change.

XER is a fixed-point facility register (that's what the "X" means even!)

Thanks,

Segher