Skip to contentSkip to conversation

PS3 Updates

PATCH Superseded Geoff Levand 2 participants 8 messages Mar 16, 2021 – Jun 18, 2021

Subsystems (2)
lore
Share & tools
lore
author maintainer
#2 lore raw

PATCH 2/2 powerpc/ps3: Re-align DTB in image

In reply to Geoff Levand

Change the PS3 linker script to align the DTB at 8 bytes, the same alignment as that of the of the 'generic' powerpc linker script.

---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/zImage.ps3.lds.S +1 -1
index 7b2ff2eaa73a..d0ffb493614d 100644
@@ -8,7 +8,7 @@ SECTIONS
   .kernel:vmlinux.bin : { *(.kernel:vmlinux.bin) }
   _vmlinux_end =  .;
 
-  . = ALIGN(4096);
+  . = ALIGN(8);
   _dtb_start = .;
   .kernel:dtb : { *(.kernel:dtb) }
   _dtb_end = .;
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/2 powerpc/ps3: Add firmware version to proc

In reply to Geoff Levand

Add a new proc FS entry /proc/ps3/firmware-version that exports the PS3's firmware version.

The firmware version is available through an LV1 hypercall, and we've been printing it to the boot log, but haven't provided an easy way for user utilities to get it.

---
 arch/powerpc/platforms/ps3/setup.c | 62 ++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/setup.c +59 -3
index e9ae5dd03593..c3c4cbf16632 100644
@@ -13,6 +13,7 @@
 #include <linux/console.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
+#include <linux/proc_fs.h>
 
 #include <asm/machdep.h>
 #include <asm/firmware.h>
@@ -36,6 +37,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);
 EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
 
 static union ps3_firmware_version ps3_firmware_version;
+static char ps3_firmware_version_str[16];
 
 void ps3_get_firmware_version(union ps3_firmware_version *v)
 {
@@ -182,6 +184,58 @@ static int ps3_set_dabr(unsigned long dabr, unsigned long dabrx)
 	return lv1_set_dabr(dabr, dabrx) ? -1 : 0;
 }
 
+static ssize_t ps3_fw_ver_read(struct file *file, char __user *buf, size_t size,
+	loff_t *ppos)
+{
+	ssize_t bytes = simple_read_from_buffer(buf, size, ppos,
+		ps3_firmware_version_str, strlen(ps3_firmware_version_str));
+
+	pr_debug("%s:%d: %zd bytes '%s'\n", __func__, __LINE__, bytes,
+	       ps3_firmware_version_str);
+
+	if (bytes < 0) {
+		pr_err("%s:%d: failed: %zd\n", __func__, __LINE__, bytes);
+		return bytes;
+	}
+
+	buf += bytes;
+	size -= bytes;
+
+	return bytes;
+}
+
+static int __init ps3_setup_proc(void)
+{
+	static const struct proc_ops proc_ops = {
+		.proc_read = ps3_fw_ver_read,
+		.proc_lseek = default_llseek,
+	};
+	struct proc_dir_entry *entry;
+
+	entry = proc_mkdir("ps3", NULL);
+
+	if (!entry) {
+		pr_err("%s:%d: failed.\n", __func__, __LINE__);
+		return 1;
+	}
+
+	entry = proc_create_data("ps3/firmware-version", S_IFREG | 0444, NULL,
+		&proc_ops, NULL);
+
+	if (!entry) {
+		pr_err("%s:%d: failed.\n", __func__, __LINE__);
+		return 1;
+	}
+
+	proc_set_size(entry, strlen(ps3_firmware_version_str));
+
+	pr_debug("%s:%d: '%s' = %zd bytes\n", __func__, __LINE__,
+		ps3_firmware_version_str, strlen(ps3_firmware_version_str));
+
+	return 0;
+}
+core_initcall(ps3_setup_proc);
+
 static void __init ps3_setup_arch(void)
 {
 	u64 tmp;
@@ -190,9 +244,11 @@ static void __init ps3_setup_arch(void)
 
 	lv1_get_version_info(&ps3_firmware_version.raw, &tmp);
 
-	printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",
-	       ps3_firmware_version.major, ps3_firmware_version.minor,
-	       ps3_firmware_version.rev);
+	snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
+		"%u.%u.%u", ps3_firmware_version.major,
+		ps3_firmware_version.minor, ps3_firmware_version.rev);
+
+	printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str);
 
 	ps3_spu_set_platform();
 
Signature · 1 line
2.25.1

Geoff Levand

author maintainer
#0 lore raw

cover PS3 Updates

Hi Michael,

Here are two minor updates for PS3. The first exports the firmware version to the proc FS, and the second re-aligns the DTB to save a little space in the PS3's limited flash memory.

-Geoff

The following changes since commit f40ddce88593482919761f74910f42f4b84c004b:

Linux 5.11 (2021-02-14 14:32:24 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git for-merge-powerpc

for you to fetch changes up to 7bee1153671a3ec71775246887894eefbfcb4b25:

powerpc/ps3: Re-align DTB in image (2021-03-13 18:43:16 -0800)

----------------------------------------------------------------
Geoff Levand (2):
powerpc/ps3: Add firmware version to proc
powerpc/ps3: Re-align DTB in image

 arch/powerpc/boot/zImage.ps3.lds.S |  2 +-
 arch/powerpc/platforms/ps3/setup.c | 62 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH v2 2/2 powerpc/ps3: Re-align DTB in image

In reply to Geoff Levand

Change the PS3 linker script to align the DTB at 8 bytes, the same alignment as that of the of the 'generic' powerpc linker script.

---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/zImage.ps3.lds.S +1 -1
index 7b2ff2eaa73a..d0ffb493614d 100644
@@ -8,7 +8,7 @@ SECTIONS
   .kernel:vmlinux.bin : { *(.kernel:vmlinux.bin) }
   _vmlinux_end =  .;
 
-  . = ALIGN(4096);
+  . = ALIGN(8);
   _dtb_start = .;
   .kernel:dtb : { *(.kernel:dtb) }
   _dtb_end = .;
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

v2 cover PS3 Updates

In reply to Geoff Levand

Hi Michael,

I've rebased the V1 patches to v5.13-rc4, and moved the firmware version export from procfs to sysfs/firmware.

Please consider.

-Geoff

The following changes since commit 8124c8a6b35386f73523d27eacb71b5364a68c4c:

Linux 5.13-rc4 (2021-05-30 11:58:25 -1000)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git for-merge-powerpc

for you to fetch changes up to 245897ed65e402686a4b114ba618e935cb5c6506:

powerpc/ps3: Re-align DTB in image (2021-06-04 08:35:45 -0700)

----------------------------------------------------------------
Geoff Levand (2):
powerpc/ps3: Add firmware version to sysfs
powerpc/ps3: Re-align DTB in image

 arch/powerpc/boot/zImage.ps3.lds.S |  2 +-
 arch/powerpc/platforms/ps3/setup.c | 43 +++++++++++++++++++++++++++++++++++---
 2 files changed, 41 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH v2 1/2 powerpc/ps3: Add firmware version to sysfs

Add a new sysfs entry /sys/firmware/ps3/fw-version that exports the PS3's firmware version.

The firmware version is available through an LV1 hypercall, and we've been printing it to the boot log, but haven't provided an easy way for user utilities to get it.

---
 arch/powerpc/platforms/ps3/setup.c | 43 +++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/setup.c +40 -3
index e9ae5dd03593..3de9145c20bc 100644
@@ -36,6 +36,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);
 EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
 
 static union ps3_firmware_version ps3_firmware_version;
+static char ps3_firmware_version_str[16];
 
 void ps3_get_firmware_version(union ps3_firmware_version *v)
 {
@@ -182,6 +183,40 @@ static int ps3_set_dabr(unsigned long dabr, unsigned long dabrx)
 	return lv1_set_dabr(dabr, dabrx) ? -1 : 0;
 }
 
+static ssize_t ps3_fw_version_show(struct kobject *kobj,
+	struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%s", ps3_firmware_version_str);
+}
+
+static int __init ps3_setup_sysfs(void)
+{
+	static struct kobj_attribute attr = __ATTR(fw-version, S_IRUGO,
+		ps3_fw_version_show, NULL);
+	static struct kobject *kobj;
+	int result;
+
+	kobj = kobject_create_and_add("ps3", firmware_kobj);
+
+	if (!kobj) {
+		pr_warn("%s:%d: kobject_create_and_add failed.\n", __func__,
+			__LINE__);
+		return -ENOMEM;
+	}
+
+	result = sysfs_create_file(kobj, &attr.attr);
+
+	if (result) {
+		pr_warn("%s:%d: sysfs_create_file failed.\n", __func__,
+			__LINE__);
+		kobject_put(kobj);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+core_initcall(ps3_setup_sysfs);
+
 static void __init ps3_setup_arch(void)
 {
 	u64 tmp;
@@ -190,9 +225,11 @@ static void __init ps3_setup_arch(void)
 
 	lv1_get_version_info(&ps3_firmware_version.raw, &tmp);
 
-	printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",
-	       ps3_firmware_version.major, ps3_firmware_version.minor,
-	       ps3_firmware_version.rev);
+	snprintf(ps3_firmware_version_str, sizeof(ps3_firmware_version_str),
+		"%u.%u.%u", ps3_firmware_version.major,
+		ps3_firmware_version.minor, ps3_firmware_version.rev);
+
+	printk(KERN_INFO "PS3 firmware version %s\n", ps3_firmware_version_str);
 
 	ps3_spu_set_platform();
 
Signature · 1 line
2.25.1