All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] PS3 Updates
@ 2021-03-16 17:51 Geoff Levand
  2021-03-16 17:51 ` [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc Geoff Levand
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Geoff Levand @ 2021-03-16 17:51 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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(-)

-- 
2.25.1


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

* [PATCH v1 2/2] powerpc/ps3: Re-align DTB in image
  2021-03-16 17:51 [PATCH v1 0/2] PS3 Updates Geoff Levand
  2021-03-16 17:51 ` [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc Geoff Levand
@ 2021-03-16 17:51 ` Geoff Levand
  2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
  2 siblings, 0 replies; 8+ messages in thread
From: Geoff Levand @ 2021-03-16 17:51 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/zImage.ps3.lds.S b/arch/powerpc/boot/zImage.ps3.lds.S
index 7b2ff2eaa73a..d0ffb493614d 100644
--- a/arch/powerpc/boot/zImage.ps3.lds.S
+++ b/arch/powerpc/boot/zImage.ps3.lds.S
@@ -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 = .;
-- 
2.25.1


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

* [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc
  2021-03-16 17:51 [PATCH v1 0/2] PS3 Updates Geoff Levand
@ 2021-03-16 17:51 ` Geoff Levand
  2021-03-16 17:51 ` [PATCH v1 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
  2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
  2 siblings, 0 replies; 8+ messages in thread
From: Geoff Levand @ 2021-03-16 17:51 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/platforms/ps3/setup.c | 62 ++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index e9ae5dd03593..c3c4cbf16632 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -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();
 
-- 
2.25.1



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

* [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image
  2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
  2021-06-04 15:58   ` [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs Geoff Levand
@ 2021-06-04 15:58   ` Geoff Levand
  2021-06-18  3:51     ` Michael Ellerman
  2021-06-18  3:51   ` [PATCH v2 0/2] PS3 Updates Michael Ellerman
  2 siblings, 1 reply; 8+ messages in thread
From: Geoff Levand @ 2021-06-04 15:58 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/boot/zImage.ps3.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/zImage.ps3.lds.S b/arch/powerpc/boot/zImage.ps3.lds.S
index 7b2ff2eaa73a..d0ffb493614d 100644
--- a/arch/powerpc/boot/zImage.ps3.lds.S
+++ b/arch/powerpc/boot/zImage.ps3.lds.S
@@ -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 = .;
-- 
2.25.1


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

* [PATCH v2 0/2] PS3 Updates
  2021-03-16 17:51 [PATCH v1 0/2] PS3 Updates Geoff Levand
  2021-03-16 17:51 ` [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc Geoff Levand
  2021-03-16 17:51 ` [PATCH v1 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
@ 2021-06-04 15:58 ` Geoff Levand
  2021-06-04 15:58   ` [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs Geoff Levand
                     ` (2 more replies)
  2 siblings, 3 replies; 8+ messages in thread
From: Geoff Levand @ 2021-06-04 15:58 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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(-)

-- 
2.25.1


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

* [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs
  2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
@ 2021-06-04 15:58   ` Geoff Levand
  2021-06-04 15:58   ` [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
  2021-06-18  3:51   ` [PATCH v2 0/2] PS3 Updates Michael Ellerman
  2 siblings, 0 replies; 8+ messages in thread
From: Geoff Levand @ 2021-06-04 15:58 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

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.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/platforms/ps3/setup.c | 43 +++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index e9ae5dd03593..3de9145c20bc 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -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();
 
-- 
2.25.1



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

* Re: [PATCH v2 0/2] PS3 Updates
  2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
  2021-06-04 15:58   ` [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs Geoff Levand
  2021-06-04 15:58   ` [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
@ 2021-06-18  3:51   ` Michael Ellerman
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2021-06-18  3:51 UTC (permalink / raw)
  To: Geoff Levand, Michael Ellerman; +Cc: linuxppc-dev

On Fri, 04 Jun 2021 15:58:25 +0000, Geoff Levand wrote:
> 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

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

* Re: [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image
  2021-06-04 15:58   ` [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
@ 2021-06-18  3:51     ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2021-06-18  3:51 UTC (permalink / raw)
  To: Geoff Levand, Michael Ellerman; +Cc: linuxppc-dev

On Fri, 04 Jun 2021 15:58:25 +0000, Geoff Levand wrote:
> 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

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

end of thread, other threads:[~2021-06-18  4:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 17:51 [PATCH v1 0/2] PS3 Updates Geoff Levand
2021-03-16 17:51 ` [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc Geoff Levand
2021-03-16 17:51 ` [PATCH v1 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
2021-06-04 15:58 ` [PATCH v2 0/2] PS3 Updates Geoff Levand
2021-06-04 15:58   ` [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs Geoff Levand
2021-06-04 15:58   ` [PATCH v2 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
2021-06-18  3:51     ` Michael Ellerman
2021-06-18  3:51   ` [PATCH v2 0/2] PS3 Updates 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.