linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 10/14] ps3: get firmware version
@ 2007-01-25  2:40 Geoff Levand
  2007-01-25  3:56 ` Benjamin Herrenschmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Geoff Levand @ 2007-01-25  2:40 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev

Output the PS3 firmware version to dmesg and /proc/cpuinfo.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>

---
 arch/powerpc/platforms/ps3/setup.c |   30 +++++++++++++++++++++++++++++-
 include/asm-powerpc/ps3.h          |    9 +++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

--- ps3-linux-dev.orig/arch/powerpc/platforms/ps3/setup.c
+++ ps3-linux-dev/arch/powerpc/platforms/ps3/setup.c
@@ -32,6 +32,7 @@
 #include <asm/udbg.h>
 #include <asm/prom.h>
 #include <asm/lv1call.h>
+#include <asm/ps3.h>
 
 #include "platform.h"
 
@@ -41,9 +42,29 @@
 #define DBG(fmt...) do{if(0)printk(fmt);}while(0)
 #endif
 
+int ps3_get_firmware_version(struct ps3_firmware_version *v)
+{
+	int result = lv1_get_version_info(&v->raw);
+
+	if(result) {
+		memset(v, 0, sizeof(struct ps3_firmware_version));
+		return -1;
+	}
+
+	v->rev = v->raw & 0xffff;
+	v->minor = (v->raw >> 16) & 0xffff;
+	v->major = (v->raw >> 32) & 0xffff;
+
+	return result;
+}
+EXPORT_SYMBOL_GPL(ps3_get_firmware_version);
+
 static void ps3_show_cpuinfo(struct seq_file *m)
 {
-	seq_printf(m, "machine\t\t: %s\n", ppc_md.name);
+	struct ps3_firmware_version v;
+
+	ps3_get_firmware_version(&v);
+	seq_printf(m, "firmware\t: %u.%u.%u\n", v.major, v.minor, v.rev);
 }
 
 static void ps3_power_save(void)
@@ -74,8 +95,14 @@ static void ps3_panic(char *str)
 
 static void __init ps3_setup_arch(void)
 {
+	struct ps3_firmware_version v;
+
 	DBG(" -> %s:%d\n", __func__, __LINE__);
 
+	ps3_get_firmware_version(&v);
+	printk(KERN_INFO "PS3 firmware version %u.%u.%u\n", v.major, v.minor,
+		v.rev);
+
 	ps3_spu_set_platform();
 	ps3_map_htab();
 
@@ -89,6 +116,7 @@ static void __init ps3_setup_arch(void)
 
 	ppc_md.power_save = ps3_power_save;
 
+
 	DBG(" <- %s:%d\n", __func__, __LINE__);
 }
 
--- ps3-linux-dev.orig/include/asm-powerpc/ps3.h
+++ ps3-linux-dev/include/asm-powerpc/ps3.h
@@ -27,6 +27,15 @@
 #include <linux/device.h>
 #include <scsi/scsi.h>
 
+struct ps3_firmware_version {
+	u64 raw;
+	unsigned int major;
+	unsigned int minor;
+	unsigned int rev;
+};
+
+int ps3_get_firmware_version(struct ps3_firmware_version *v);
+
 /**
  * struct ps3_device_id - HV bus device identifier from the system repository
  * @bus_id: HV bus id, {1..} (zero invalid)

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-25  2:40 [PATCH 10/14] ps3: get firmware version Geoff Levand
@ 2007-01-25  3:56 ` Benjamin Herrenschmidt
  2007-01-25  6:23 ` Arnd Bergmann
  2007-01-26  2:59 ` Christoph Hellwig
  2 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-01-25  3:56 UTC (permalink / raw)
  To: Geoff Levand; +Cc: linuxppc-dev, paulus

On Wed, 2007-01-24 at 18:40 -0800, Geoff Levand wrote:

> +struct ps3_firmware_version {
> +	u64 raw;
> +	unsigned int major;
> +	unsigned int minor;
> +	unsigned int rev;
> +};

Wouldn't it be better to have a union here ?

Ben

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-25  2:40 [PATCH 10/14] ps3: get firmware version Geoff Levand
  2007-01-25  3:56 ` Benjamin Herrenschmidt
@ 2007-01-25  6:23 ` Arnd Bergmann
  2007-01-26  2:59 ` Christoph Hellwig
  2 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2007-01-25  6:23 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus

On Thursday 25 January 2007 03:40, Geoff Levand wrote:
> Output the PS3 firmware version to dmesg and /proc/cpuinfo.
> 
> Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
> 
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>

I agree with benh that you should avoid the copy of individual fields
inside of the struct ps3_firmware_version, since you can directly
read into a 

struct ps3_firmware_version {
	u16 pad;
	u16 major;
	u16 minor;
	u16 rev;
};

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-25  2:40 [PATCH 10/14] ps3: get firmware version Geoff Levand
  2007-01-25  3:56 ` Benjamin Herrenschmidt
  2007-01-25  6:23 ` Arnd Bergmann
@ 2007-01-26  2:59 ` Christoph Hellwig
  2007-01-26 18:52   ` Geoff Levand
  2 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2007-01-26  2:59 UTC (permalink / raw)
  To: Geoff Levand; +Cc: linuxppc-dev, paulus

On Wed, Jan 24, 2007 at 06:40:17PM -0800, Geoff Levand wrote:
> Output the PS3 firmware version to dmesg and /proc/cpuinfo.

Do we really need to bloat /proc/cpuinfo with more information that's
totally platform-specific?  The file is enough of a mess already..

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26  2:59 ` Christoph Hellwig
@ 2007-01-26 18:52   ` Geoff Levand
  2007-01-26 20:25     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Geoff Levand @ 2007-01-26 18:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linuxppc-dev, paulus

Christoph Hellwig wrote:
> On Wed, Jan 24, 2007 at 06:40:17PM -0800, Geoff Levand wrote:
>> Output the PS3 firmware version to dmesg and /proc/cpuinfo.
> 
> Do we really need to bloat /proc/cpuinfo with more information that's
> totally platform-specific?  The file is enough of a mess already..

I wanted to make the firmware version available to user space utilities, so
for example, I plan to make a utility to write the kernel to flash.  If the
utility can query the firmware version, it can prompt the user that a firmware
update would allow the kernel to take advantage of some new or updated feature.
Without this, the only way to notify the user is with a message to the system
log when the new kernel is running.

Anyway, that is the need, the question is where to make it available.  I thought
/proc/cpuinfo already has the platform type (coming from the generic powerpc
code), so it would be convenient for utilities to have the firmware version
there too.  I don't think parsing the dmsg is an option for minimal
configs like bootloaders and distro installers, as they may not keep the boot
messages around, and in general doesn't seem a reliable way.  If you can make
a suggestion, I'd like to hear it.

-Geoff

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26 18:52   ` Geoff Levand
@ 2007-01-26 20:25     ` Benjamin Herrenschmidt
  2007-01-26 20:37       ` Nathan Lynch
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-01-26 20:25 UTC (permalink / raw)
  To: Geoff Levand; +Cc: linuxppc-dev, paulus


> Anyway, that is the need, the question is where to make it available.  I thought
> /proc/cpuinfo already has the platform type (coming from the generic powerpc
> code), so it would be convenient for utilities to have the firmware version
> there too.  I don't think parsing the dmsg is an option for minimal
> configs like bootloaders and distro installers, as they may not keep the boot
> messages around, and in general doesn't seem a reliable way.  If you can make
> a suggestion, I'd like to hear it.

Yeah, /proc/cpuinfo is actually a fairly convenient place for that...

Ben.

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26 20:25     ` Benjamin Herrenschmidt
@ 2007-01-26 20:37       ` Nathan Lynch
  2007-01-26 23:12         ` Geoff Levand
  0 siblings, 1 reply; 10+ messages in thread
From: Nathan Lynch @ 2007-01-26 20:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, paulus

Benjamin Herrenschmidt wrote:

> > Anyway, that is the need, the question is where to make it
> > available.  I thought /proc/cpuinfo already has the platform type
> > (coming from the generic powerpc code), so it would be convenient
> > for utilities to have the firmware version there too.  I don't
> > think parsing the dmsg is an option for minimal configs like
> > bootloaders and distro installers, as they may not keep the boot
> > messages around, and in general doesn't seem a reliable way.  If
> > you can make a suggestion, I'd like to hear it.
>
> Yeah, /proc/cpuinfo is actually a fairly convenient place for that...

Other firmwares provide a property in the device tree with version
information, for example on Power5:

$ lsprop /proc/device-tree/openprom/ibm,fw-vernum_encoded
/proc/device-tree/openprom/ibm,fw-vernum_encoded "SF225_096"

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26 20:37       ` Nathan Lynch
@ 2007-01-26 23:12         ` Geoff Levand
  2007-01-26 23:27           ` Geoff Levand
  0 siblings, 1 reply; 10+ messages in thread
From: Geoff Levand @ 2007-01-26 23:12 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: paulus, linuxppc-dev

Nathan Lynch wrote:
> Benjamin Herrenschmidt wrote:
> 
>> > Anyway, that is the need, the question is where to make it
>> > available.  I thought /proc/cpuinfo already has the platform type
>> > (coming from the generic powerpc code), so it would be convenient
>> > for utilities to have the firmware version there too.  I don't
>> > think parsing the dmsg is an option for minimal configs like
>> > bootloaders and distro installers, as they may not keep the boot
>> > messages around, and in general doesn't seem a reliable way.  If
>> > you can make a suggestion, I'd like to hear it.
>>
>> Yeah, /proc/cpuinfo is actually a fairly convenient place for that...
> 
> Other firmwares provide a property in the device tree with version
> information, for example on Power5:

But this firmware does not.  The kernel must do it sometime after
startup.  I don't see any reason why the kernel should try to
emulate the behavior of firmware on some other platform.

-Geoff

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26 23:12         ` Geoff Levand
@ 2007-01-26 23:27           ` Geoff Levand
  2007-01-27  4:34             ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Geoff Levand @ 2007-01-26 23:27 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: paulus, linuxppc-dev

Geoff Levand wrote:
> Nathan Lynch wrote:
>> Benjamin Herrenschmidt wrote:
>> 
>>> > Anyway, that is the need, the question is where to make it
>>> > available.  I thought /proc/cpuinfo already has the platform type
>>> > (coming from the generic powerpc code), so it would be convenient
>>> > for utilities to have the firmware version there too.  I don't
>>> > think parsing the dmsg is an option for minimal configs like
>>> > bootloaders and distro installers, as they may not keep the boot
>>> > messages around, and in general doesn't seem a reliable way.  If
>>> > you can make a suggestion, I'd like to hear it.
>>>
>>> Yeah, /proc/cpuinfo is actually a fairly convenient place for that...
>> 
>> Other firmwares provide a property in the device tree with version
>> information, for example on Power5:
> 
> But this firmware does not.  The kernel must do it sometime after
> startup.  I don't see any reason why the kernel should try to
> emulate the behavior of firmware on some other platform.

Actually, now that I think about it, your suggestion seems like the best
way to do it :-) 

Since /proc/device-tree/model gives the model, and I can arrange for
/proc/device-tree/firmware to give a firmware version.  I'll just need to
add a property to the tree after bootup.

-Geoff

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

* Re: [PATCH 10/14] ps3: get firmware version
  2007-01-26 23:27           ` Geoff Levand
@ 2007-01-27  4:34             ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-01-27  4:34 UTC (permalink / raw)
  To: Geoff Levand; +Cc: linuxppc-dev, Nathan Lynch, paulus


> Actually, now that I think about it, your suggestion seems like the best
> way to do it :-) 
> 
> Since /proc/device-tree/model gives the model, and I can arrange for
> /proc/device-tree/firmware to give a firmware version.  I'll just need to
> add a property to the tree after bootup.

In fact, the most logical place to do that is in the kboot wrapper, when
the tree is created initially. That way, it will be naturally passed
from kernel to kernel via kexec.

The zImage is built with a library to hack at the device-tree so it
should be trivial to do it there.

Ben.

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

end of thread, other threads:[~2007-01-27  4:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-25  2:40 [PATCH 10/14] ps3: get firmware version Geoff Levand
2007-01-25  3:56 ` Benjamin Herrenschmidt
2007-01-25  6:23 ` Arnd Bergmann
2007-01-26  2:59 ` Christoph Hellwig
2007-01-26 18:52   ` Geoff Levand
2007-01-26 20:25     ` Benjamin Herrenschmidt
2007-01-26 20:37       ` Nathan Lynch
2007-01-26 23:12         ` Geoff Levand
2007-01-26 23:27           ` Geoff Levand
2007-01-27  4:34             ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).