All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/6] powerpc: Add hardware description string
@ 2022-09-29 14:22 Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 2/6] powerpc: Add PVR & CPU name to hardware description Michael Ellerman
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Create a hardware description string, which we will use to record
various details of the hardware platform we are running on.

Print the accumulated description at boot, and use it to set the generic
description which is printed in oopses.

To begin with add ppc_md.name, aka the "machine description".

Example output at boot with the full series applied:

  Linux version 6.0.0-rc2-gcc-11.1.0-00199-g893f9007a5ce-dirty (michael@alpine1-p1) (powerpc64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #844 SMP Thu Sep 29 22:29:53 AEST 2022
  Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER8 (raw)' pvr:0x4d0200 lpvr:0xf000004 of:'SLOF,HEAD' machine:pSeries
  printk: bootconsole [udbg0] enabled

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/setup.h   |  2 ++
 arch/powerpc/kernel/setup-common.c | 19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

v2: Print the string at boot as suggested by Nathan.
    Add some comments, update change log.

diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 85143849a586..e29e83f8a89c 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -88,6 +88,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
 			       unsigned long pp, unsigned long r6,
 			       unsigned long r7, unsigned long kbase);
 
+extern struct seq_buf ppc_hw_desc;
+
 #endif /* !__ASSEMBLY__ */
 
 #endif	/* _ASM_POWERPC_SETUP_H */
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index dd98f43bd685..99f1c52a3ca4 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/initrd.h>
 #include <linux/platform_device.h>
+#include <linux/printk.h>
 #include <linux/seq_file.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
@@ -25,6 +26,7 @@
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
 #include <linux/unistd.h>
+#include <linux/seq_buf.h>
 #include <linux/serial.h>
 #include <linux/serial_8250.h>
 #include <linux/percpu.h>
@@ -588,6 +590,15 @@ static __init int add_pcspkr(void)
 device_initcall(add_pcspkr);
 #endif	/* CONFIG_PCSPKR_PLATFORM */
 
+static char ppc_hw_desc_buf[128] __initdata;
+
+struct seq_buf ppc_hw_desc __initdata = {
+	.buffer = ppc_hw_desc_buf,
+	.size = sizeof(ppc_hw_desc_buf),
+	.len = 0,
+	.readpos = 0,
+};
+
 static __init void probe_machine(void)
 {
 	extern struct machdep_calls __machine_desc_start;
@@ -628,7 +639,13 @@ static __init void probe_machine(void)
 		for (;;);
 	}
 
-	printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
+	// Append the machine name to other info we've gathered
+	seq_buf_printf(&ppc_hw_desc, "machine:%s", ppc_md.name);
+
+	// Set the generic hardware description shown in oopses
+	dump_stack_set_arch_desc(ppc_hw_desc.buffer);
+
+	pr_info("Hardware name: %s\n", ppc_hw_desc.buffer);
 }
 
 /* Match a class of boards, not a specific device configuration. */
-- 
2.37.3


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

* [PATCH v2 2/6] powerpc: Add PVR & CPU name to hardware description
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
@ 2022-09-29 14:22 ` Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 3/6] powerpc/64: Add logical PVR to the " Michael Ellerman
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Add the PVR and CPU name to the hardware description, which is printed
at boot and in case of an oops.

eg: Hardware name: ... cpu:'POWER8E (raw)' pvr:0x4b0201

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 2e7a04dab2f7..b42e2dbeb021 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -30,6 +30,7 @@
 #include <linux/libfdt.h>
 #include <linux/cpu.h>
 #include <linux/pgtable.h>
+#include <linux/seq_buf.h>
 
 #include <asm/rtas.h>
 #include <asm/page.h>
@@ -819,6 +820,10 @@ void __init early_init_devtree(void *params)
 
 	dt_cpu_ftrs_scan();
 
+	// We can now add the CPU name & PVR to the hardware description
+	seq_buf_printf(&ppc_hw_desc, "cpu:'%s' pvr:0x%04lx ", cur_cpu_spec->cpu_name,
+		       mfspr(SPRN_PVR));
+
 	/* Retrieve CPU related informations from the flat tree
 	 * (altivec support, boot CPU ID, ...)
 	 */
-- 
2.37.3


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

* [PATCH v2 3/6] powerpc/64: Add logical PVR to the hardware description
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 2/6] powerpc: Add PVR & CPU name to hardware description Michael Ellerman
@ 2022-09-29 14:22 ` Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 4/6] powerpc: Add device-tree model " Michael Ellerman
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

If we detect a logical PVR add that to the hardware description, which
is printed at boot and in case of an oops.

eg: Hardware name: ... lpvr:0xf000004

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index b42e2dbeb021..8c4cce6dc1e8 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -390,8 +390,10 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	 */
 	if (!dt_cpu_ftrs_in_use()) {
 		prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
-		if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
+		if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000) {
 			identify_cpu(0, be32_to_cpup(prop));
+			seq_buf_printf(&ppc_hw_desc, "lpvr:0x%04x ", be32_to_cpup(prop));
+		}
 
 		check_cpu_feature_properties(node);
 		check_cpu_features(node, "ibm,pa-features", ibm_pa_features,
-- 
2.37.3


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

* [PATCH v2 4/6] powerpc: Add device-tree model to the hardware description
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 2/6] powerpc: Add PVR & CPU name to hardware description Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 3/6] powerpc/64: Add logical PVR to the " Michael Ellerman
@ 2022-09-29 14:22 ` Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 5/6] powerpc/powernv: Add opal details " Michael Ellerman
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Add the model of the machine we're on to the hardware description, which
is printed at boot and in case of an oops.

eg: Hardware name: model:'IBM,8247-22L'

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 8c4cce6dc1e8..93315c6483de 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -715,6 +715,23 @@ static void __init tm_init(void)
 static void tm_init(void) { }
 #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
 
+static int __init
+early_init_dt_scan_model(unsigned long node, const char *uname,
+			 int depth, void *data)
+{
+	const char *prop;
+
+	if (depth != 0)
+		return 0;
+
+	prop = of_get_flat_dt_prop(node, "model", NULL);
+	if (prop)
+		seq_buf_printf(&ppc_hw_desc, "model:'%s' ", prop);
+
+	/* break now */
+	return 1;
+}
+
 #ifdef CONFIG_PPC64
 static void __init save_fscr_to_task(void)
 {
@@ -743,6 +760,8 @@ void __init early_init_devtree(void *params)
 	if (!early_init_dt_verify(params))
 		panic("BUG: Failed verifying flat device tree, bad version?");
 
+	of_scan_flat_dt(early_init_dt_scan_model, NULL);
+
 #ifdef CONFIG_PPC_RTAS
 	/* Some machines might need RTAS info for debugging, grab it now. */
 	of_scan_flat_dt(early_init_dt_scan_rtas, NULL);
-- 
2.37.3


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

* [PATCH v2 5/6] powerpc/powernv: Add opal details to the hardware description
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
                   ` (2 preceding siblings ...)
  2022-09-29 14:22 ` [PATCH v2 4/6] powerpc: Add device-tree model " Michael Ellerman
@ 2022-09-29 14:22 ` Michael Ellerman
  2022-09-29 14:22 ` [PATCH v2 6/6] powerpc/pseries: Add firmware " Michael Ellerman
  2022-09-29 22:01 ` [PATCH v2 1/6] powerpc: Add hardware description string Nathan Lynch
  5 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Add OPAL version details to the hardware description, which is printed
at boot and in case of an oops.

eg: Hardware name: ... opal:v6.2

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/platforms/powernv/setup.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

v2: Use of_property_read_string()

diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index dac545aa0308..61ab2d38ff4b 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -17,6 +17,7 @@
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
+#include <linux/seq_buf.h>
 #include <linux/seq_file.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
@@ -207,8 +208,29 @@ static void __init pnv_setup_arch(void)
 	pnv_rng_init();
 }
 
+static void __init pnv_add_hw_description(void)
+{
+	struct device_node *dn;
+	const char *s;
+
+	dn = of_find_node_by_path("/ibm,opal/firmware");
+	if (!dn)
+		return;
+
+	if (of_property_read_string(dn, "version", &s) == 0 ||
+	    of_property_read_string(dn, "git-id", &s) == 0)
+		seq_buf_printf(&ppc_hw_desc, "opal:%s ", s);
+
+	if (of_property_read_string(dn, "mi-version", &s) == 0)
+		seq_buf_printf(&ppc_hw_desc, "mi:%s ", s);
+
+	of_node_put(dn);
+}
+
 static void __init pnv_init(void)
 {
+	pnv_add_hw_description();
+
 	/*
 	 * Initialize the LPC bus now so that legacy serial
 	 * ports can be found on it
-- 
2.37.3


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

* [PATCH v2 6/6] powerpc/pseries: Add firmware details to the hardware description
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
                   ` (3 preceding siblings ...)
  2022-09-29 14:22 ` [PATCH v2 5/6] powerpc/powernv: Add opal details " Michael Ellerman
@ 2022-09-29 14:22 ` Michael Ellerman
  2022-09-29 22:10   ` Nathan Lynch
  2022-09-29 22:01 ` [PATCH v2 1/6] powerpc: Add hardware description string Nathan Lynch
  5 siblings, 1 reply; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Add firmware version details to the hardware description, which is
printed at boot and in case of an oops.

Use /hypervisor if we find it, though currently it only exists if we're
running under qemu.

Look for "ibm,powervm-partition" which is specified in PAPR+ v2.11 and
tells us we're running under PowerVM.

Failing that look for "ibm,fw-net-version" which is seen on PowerVM
going back to at least Power6.

eg: Hardware name: ... of:'IBM,FW860.42 (SV860_138)' hv:'phyp'

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/platforms/pseries/setup.c | 30 ++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

v2: Look for "ibm,powervm-partition" as suggested by Nathan.
    Use of_property_read_string().

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 5e44c65a032c..83b047db35da 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -41,6 +41,7 @@
 #include <linux/of_pci.h>
 #include <linux/memblock.h>
 #include <linux/swiotlb.h>
+#include <linux/seq_buf.h>
 
 #include <asm/mmu.h>
 #include <asm/processor.h>
@@ -1011,6 +1012,33 @@ static void __init pSeries_cmo_feature_init(void)
 	pr_debug(" <- fw_cmo_feature_init()\n");
 }
 
+static void __init pseries_add_hw_description(void)
+{
+	struct device_node *dn;
+	const char *s;
+
+	dn = of_find_node_by_path("/openprom");
+	if (dn) {
+		if (of_property_read_string(dn, "model", &s) == 0)
+			seq_buf_printf(&ppc_hw_desc, "of:'%s' ", s);
+
+		of_node_put(dn);
+	}
+
+	dn = of_find_node_by_path("/hypervisor");
+	if (dn) {
+		if (of_property_read_string(dn, "compatible", &s) == 0)
+			seq_buf_printf(&ppc_hw_desc, "hv:'%s' ", s);
+
+		of_node_put(dn);
+		return;
+	}
+
+	if (of_property_read_bool(of_root, "ibm,powervm-partition") ||
+	    of_property_read_bool(of_root, "ibm,fw-net-version"))
+		seq_buf_printf(&ppc_hw_desc, "hv:'phyp' ");
+}
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
@@ -1018,6 +1046,8 @@ static void __init pseries_init(void)
 {
 	pr_debug(" -> pseries_init()\n");
 
+	pseries_add_hw_description();
+
 #ifdef CONFIG_HVC_CONSOLE
 	if (firmware_has_feature(FW_FEATURE_LPAR))
 		hvc_vio_init_early();
-- 
2.37.3


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

* Re: [PATCH v2 1/6] powerpc: Add hardware description string
  2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
                   ` (4 preceding siblings ...)
  2022-09-29 14:22 ` [PATCH v2 6/6] powerpc/pseries: Add firmware " Michael Ellerman
@ 2022-09-29 22:01 ` Nathan Lynch
  2022-09-30  2:13   ` Michael Ellerman
  5 siblings, 1 reply; 12+ messages in thread
From: Nathan Lynch @ 2022-09-29 22:01 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev

Michael Ellerman <mpe@ellerman.id.au> writes:
> Create a hardware description string, which we will use to record
> various details of the hardware platform we are running on.
>
> Print the accumulated description at boot, and use it to set the generic
> description which is printed in oopses.
>
> To begin with add ppc_md.name, aka the "machine description".
>
> Example output at boot with the full series applied:
>
>   Linux version 6.0.0-rc2-gcc-11.1.0-00199-g893f9007a5ce-dirty (michael@alpine1-p1) (powerpc64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #844 SMP Thu Sep 29 22:29:53 AEST 2022
>   Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER8 (raw)' pvr:0x4d0200 lpvr:0xf000004 of:'SLOF,HEAD' machine:pSeries
>   printk: bootconsole [udbg0] enabled
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/setup.h   |  2 ++
>  arch/powerpc/kernel/setup-common.c | 19 ++++++++++++++++++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> v2: Print the string at boot as suggested by Nathan.

Thanks!

I've booted the series on P8 and P9 LPARs:

Hardware name: model:'IBM,8408-E8E' cpu:'POWER8E (raw)' pvr:0x4b0201 lpvr:0xf000004 of:'IBM,FW860.50 (SV860_146)' hv:'phyp' machine:pSeries

Hardware name: model:'IBM,9040-MR9' cpu:'POWER9 (raw)' pvr:0x4e2102 lpvr:0xf000005 of:'IBM,FW950.01 (VM950_047)' hv:'phyp' machine:pSeries

Not on objection but just an FYI: we're already very close to exceeding
the arch description buffer's size on PowerVM. Both of the above are
over 120 bytes.

It also occurs to me that we'll want to rebuild the arch description
string after partition migration. Probably immediately after processing
the device tree updates.

Regardless, LGTM.

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

* Re: [PATCH v2 6/6] powerpc/pseries: Add firmware details to the hardware description
  2022-09-29 14:22 ` [PATCH v2 6/6] powerpc/pseries: Add firmware " Michael Ellerman
@ 2022-09-29 22:10   ` Nathan Lynch
  2022-09-30  2:06     ` Michael Ellerman
  0 siblings, 1 reply; 12+ messages in thread
From: Nathan Lynch @ 2022-09-29 22:10 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev

Michael Ellerman <mpe@ellerman.id.au> writes:
> Add firmware version details to the hardware description, which is
> printed at boot and in case of an oops.
>
> Use /hypervisor if we find it, though currently it only exists if we're
> running under qemu.
>
> Look for "ibm,powervm-partition" which is specified in PAPR+ v2.11 and
> tells us we're running under PowerVM.
>
> Failing that look for "ibm,fw-net-version" which is seen on PowerVM
> going back to at least Power6.
>
> eg: Hardware name: ... of:'IBM,FW860.42 (SV860_138)' hv:'phyp'
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/platforms/pseries/setup.c | 30 ++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> v2: Look for "ibm,powervm-partition" as suggested by Nathan.
>     Use of_property_read_string().

LGTM.

I noticed that we don't get an "of:" report with qemu+vof, because there's no
/openprom node.

$ qemu-system-ppc64 -nographic -vga none -M pseries,x-vof=off -kernel vmlinux | grep Hardware
Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER9 (raw)' pvr:0x4e1200 lpvr:0xf000005 of:'SLOF,HEAD' machine:pSeries
$ qemu-system-ppc64 -nographic -vga none -M pseries,x-vof=on -kernel vmlinux | grep Hardware
Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER9 (raw)' pvr:0x4e1200 lpvr:0xf000005 machine:pSeries
$ qemu-system-ppc64 --version
QEMU emulator version 7.0.0 (qemu-7.0.0-6.fc36)

I didn't see anything in the vof device tree that would help though.


> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index 5e44c65a032c..83b047db35da 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -41,6 +41,7 @@
>  #include <linux/of_pci.h>
>  #include <linux/memblock.h>
>  #include <linux/swiotlb.h>
> +#include <linux/seq_buf.h>
>  
>  #include <asm/mmu.h>
>  #include <asm/processor.h>
> @@ -1011,6 +1012,33 @@ static void __init pSeries_cmo_feature_init(void)
>  	pr_debug(" <- fw_cmo_feature_init()\n");
>  }
>  
> +static void __init pseries_add_hw_description(void)
> +{
> +	struct device_node *dn;
> +	const char *s;
> +
> +	dn = of_find_node_by_path("/openprom");
> +	if (dn) {
> +		if (of_property_read_string(dn, "model", &s) == 0)
> +			seq_buf_printf(&ppc_hw_desc, "of:'%s' ", s);
> +
> +		of_node_put(dn);
> +	}
> +
> +	dn = of_find_node_by_path("/hypervisor");
> +	if (dn) {
> +		if (of_property_read_string(dn, "compatible", &s) == 0)
> +			seq_buf_printf(&ppc_hw_desc, "hv:'%s' ", s);
> +
> +		of_node_put(dn);
> +		return;
> +	}
> +
> +	if (of_property_read_bool(of_root, "ibm,powervm-partition") ||
> +	    of_property_read_bool(of_root, "ibm,fw-net-version"))
> +		seq_buf_printf(&ppc_hw_desc, "hv:'phyp' ");
> +}

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

* Re: [PATCH v2 6/6] powerpc/pseries: Add firmware details to the hardware description
  2022-09-29 22:10   ` Nathan Lynch
@ 2022-09-30  2:06     ` Michael Ellerman
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-30  2:06 UTC (permalink / raw)
  To: Nathan Lynch, linuxppc-dev

Nathan Lynch <nathanl@linux.ibm.com> writes:
> Michael Ellerman <mpe@ellerman.id.au> writes:
>> Add firmware version details to the hardware description, which is
>> printed at boot and in case of an oops.
>>
>> Use /hypervisor if we find it, though currently it only exists if we're
>> running under qemu.
>>
>> Look for "ibm,powervm-partition" which is specified in PAPR+ v2.11 and
>> tells us we're running under PowerVM.
>>
>> Failing that look for "ibm,fw-net-version" which is seen on PowerVM
>> going back to at least Power6.
>>
>> eg: Hardware name: ... of:'IBM,FW860.42 (SV860_138)' hv:'phyp'
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>>  arch/powerpc/platforms/pseries/setup.c | 30 ++++++++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>>
>> v2: Look for "ibm,powervm-partition" as suggested by Nathan.
>>     Use of_property_read_string().
>
> LGTM.
>
> I noticed that we don't get an "of:" report with qemu+vof, because there's no
> /openprom node.
>
> $ qemu-system-ppc64 -nographic -vga none -M pseries,x-vof=off -kernel vmlinux | grep Hardware
> Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER9 (raw)' pvr:0x4e1200 lpvr:0xf000005 of:'SLOF,HEAD' machine:pSeries
> $ qemu-system-ppc64 -nographic -vga none -M pseries,x-vof=on -kernel vmlinux | grep Hardware
> Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER9 (raw)' pvr:0x4e1200 lpvr:0xf000005 machine:pSeries
> $ qemu-system-ppc64 --version
> QEMU emulator version 7.0.0 (qemu-7.0.0-6.fc36)
>
> I didn't see anything in the vof device tree that would help though.

OK. We don't boot via prom_init when booting with vof, so in that sense
there is no OF.

I think the combo of seeing qemu but no "of" is sufficient to recognise
that case.

cheers

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

* Re: [PATCH v2 1/6] powerpc: Add hardware description string
  2022-09-29 22:01 ` [PATCH v2 1/6] powerpc: Add hardware description string Nathan Lynch
@ 2022-09-30  2:13   ` Michael Ellerman
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-30  2:13 UTC (permalink / raw)
  To: Nathan Lynch, linuxppc-dev

Nathan Lynch <nathanl@linux.ibm.com> writes:
> Michael Ellerman <mpe@ellerman.id.au> writes:
>> Create a hardware description string, which we will use to record
>> various details of the hardware platform we are running on.
>>
>> Print the accumulated description at boot, and use it to set the generic
>> description which is printed in oopses.
>>
>> To begin with add ppc_md.name, aka the "machine description".
>>
>> Example output at boot with the full series applied:
>>
>>   Linux version 6.0.0-rc2-gcc-11.1.0-00199-g893f9007a5ce-dirty (michael@alpine1-p1) (powerpc64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #844 SMP Thu Sep 29 22:29:53 AEST 2022
>>   Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER8 (raw)' pvr:0x4d0200 lpvr:0xf000004 of:'SLOF,HEAD' machine:pSeries
>>   printk: bootconsole [udbg0] enabled
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>>  arch/powerpc/include/asm/setup.h   |  2 ++
>>  arch/powerpc/kernel/setup-common.c | 19 ++++++++++++++++++-
>>  2 files changed, 20 insertions(+), 1 deletion(-)
>>
>> v2: Print the string at boot as suggested by Nathan.
>
> Thanks!
>
> I've booted the series on P8 and P9 LPARs:
>
> Hardware name: model:'IBM,8408-E8E' cpu:'POWER8E (raw)' pvr:0x4b0201 lpvr:0xf000004 of:'IBM,FW860.50 (SV860_146)' hv:'phyp' machine:pSeries
>
> Hardware name: model:'IBM,9040-MR9' cpu:'POWER9 (raw)' pvr:0x4e2102 lpvr:0xf000005 of:'IBM,FW950.01 (VM950_047)' hv:'phyp' machine:pSeries
>
> Not on objection but just an FYI: we're already very close to exceeding
> the arch description buffer's size on PowerVM. Both of the above are
> over 120 bytes.

Hmm yeah that's a good point.

I was tossing up whether the tags (model:, cpu: etc) are worth the space
they consume.

I erred on the side of keeping them because although I know what the raw
values mean, I figured other folks might not.

But given we are getting tight for space I might change my mind on that
and just use the values with no tags. It will make the value harder to
parse programmatically, but we will probably never do that anyway.

> It also occurs to me that we'll want to rebuild the arch description
> string after partition migration. Probably immediately after processing
> the device tree updates.

OK I hadn't thought of that.

It won't be entirely straight forward because the existing code wants to
build the value up incrementally, so we have as much info as possible at
any point during the boot.

But we can probably just have a pseries specific routine that
reconstructs the value in a similar format to the existing one after
migration.

cheers

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

* Re: [PATCH v2 1/6] powerpc: Add hardware description string
  2022-09-29 13:59 Michael Ellerman
@ 2022-09-29 14:12 ` Michael Ellerman
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 14:12 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Michael Ellerman <mpe@ellerman.id.au> writes:
> Create a hardware description string, which we will use to record
> various details of the hardware platform we are running on.
>
> Print the accumulated description at boot, and use it to set the generic
> description which is printed in oopses.
>
> To begin with add ppc_md.name, aka the "machine description".
>
> Example output at boot with the full series applied:
>
>   Linux version 6.0.0-rc2-gcc-11.1.0-00199-g893f9007a5ce-dirty (michael@alpine1-p1) (powerpc64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #844 SMP Thu Sep 29 22:29:53 AEST 2022
>   Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER8 (raw)' pvr:0x4d0200 lpvr:0xf000004 of:'SLOF,HEAD' machine:pSeries
>   printk: bootconsole [udbg0] enabled
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/setup.h   |  2 ++
>  arch/powerpc/kernel/setup-common.c | 19 ++++++++++++++++++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> v2: Print the string at boot as suggested by Nathan.
>     Add some comments, update change log.

Ugh, I managed to bork the patches when sending. Don't send patches at
midnight.

New version coming.

cheers

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

* [PATCH v2 1/6] powerpc: Add hardware description string
@ 2022-09-29 13:59 Michael Ellerman
  2022-09-29 14:12 ` Michael Ellerman
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Ellerman @ 2022-09-29 13:59 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nathanl

Create a hardware description string, which we will use to record
various details of the hardware platform we are running on.

Print the accumulated description at boot, and use it to set the generic
description which is printed in oopses.

To begin with add ppc_md.name, aka the "machine description".

Example output at boot with the full series applied:

  Linux version 6.0.0-rc2-gcc-11.1.0-00199-g893f9007a5ce-dirty (michael@alpine1-p1) (powerpc64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #844 SMP Thu Sep 29 22:29:53 AEST 2022
  Hardware name: model:'IBM pSeries (emulated by qemu)' cpu:'POWER8 (raw)' pvr:0x4d0200 lpvr:0xf000004 of:'SLOF,HEAD' machine:pSeries
  printk: bootconsole [udbg0] enabled

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/setup.h   |  2 ++
 arch/powerpc/kernel/setup-common.c | 19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

v2: Print the string at boot as suggested by Nathan.
    Add some comments, update change log.

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index dd98f43bd685..99f1c52a3ca4 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -588,6 +590,15 @@ static __init int add_pcspkr(void)
 device_initcall(add_pcspkr);
 #endif	/* CONFIG_PCSPKR_PLATFORM */
 
+static char ppc_hw_desc_buf[128] __initdata;
+
+struct seq_buf ppc_hw_desc __initdata = {
+	.buffer = ppc_hw_desc_buf,
+	.size = sizeof(ppc_hw_desc_buf),
+	.len = 0,
+	.readpos = 0,
+};
+
 static __init void probe_machine(void)
 {
 	extern struct machdep_calls __machine_desc_start;
@@ -628,7 +639,13 @@ static __init void probe_machine(void)
 		for (;;);
 	}
 
-	printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
+	// Append the machine name to other info we've gathered
+	seq_buf_printf(&ppc_hw_desc, "machine:%s", ppc_md.name);
+
+	// Set the generic hardware description shown in oopses
+	dump_stack_set_arch_desc(ppc_hw_desc.buffer);
+
+	pr_info("Hardware name: %s\n", ppc_hw_desc.buffer);
 }
 
 /* Match a class of boards, not a specific device configuration. */
-- 
2.37.3


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

end of thread, other threads:[~2022-09-30  2:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 14:22 [PATCH v2 1/6] powerpc: Add hardware description string Michael Ellerman
2022-09-29 14:22 ` [PATCH v2 2/6] powerpc: Add PVR & CPU name to hardware description Michael Ellerman
2022-09-29 14:22 ` [PATCH v2 3/6] powerpc/64: Add logical PVR to the " Michael Ellerman
2022-09-29 14:22 ` [PATCH v2 4/6] powerpc: Add device-tree model " Michael Ellerman
2022-09-29 14:22 ` [PATCH v2 5/6] powerpc/powernv: Add opal details " Michael Ellerman
2022-09-29 14:22 ` [PATCH v2 6/6] powerpc/pseries: Add firmware " Michael Ellerman
2022-09-29 22:10   ` Nathan Lynch
2022-09-30  2:06     ` Michael Ellerman
2022-09-29 22:01 ` [PATCH v2 1/6] powerpc: Add hardware description string Nathan Lynch
2022-09-30  2:13   ` Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2022-09-29 13:59 Michael Ellerman
2022-09-29 14:12 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.