PS3 Updates
Subsystems (2)
Geoff Levand
maintainercover 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
Geoff Levand
maintainerPATCH 1/2 powerpc/ps3: Add firmware version to proc
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
@@ -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
maintainerPATCH 2/2 powerpc/ps3: Re-align DTB in image
In reply to Geoff LevandChange 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
@@ -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
Geoff Levand
maintainerv2 cover PS3 Updates
In reply to Geoff LevandHi 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
Geoff Levand
maintainerPATCH 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
@@ -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
Geoff Levand
maintainerPATCH v2 2/2 powerpc/ps3: Re-align DTB in image
In reply to Geoff LevandChange 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
@@ -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
Michael Ellerman
AppliedRe: [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image
Quoted 3 lines · 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.
Applied to powerpc/next.
[2/2] powerpc/ps3: Re-align DTB in image
https://git.kernel.org/powerpc/c/ff4a825e4a24cdf7f840461ced6283bf865ab7be
cheers
Michael Ellerman
AppliedQuoted 8 lines · Geoff Levand
I've rebased the V1 patches to v5.13-rc4, and moved the firmware version export from procfs to sysfs/firmware.
Please consider.
-Geoff
[...]
Applied to powerpc/next.
[1/2] powerpc/ps3: Add firmware version to sysfs
https://git.kernel.org/powerpc/c/07e2d6cf91079ca01db7fb989a02edd8009dcacd
cheers