From: Geoff Levand <geoff@infradead.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v1 1/2] powerpc/ps3: Add firmware version to proc
Date: Tue, 16 Mar 2021 17:51:07 +0000 [thread overview]
Message-ID: <f5d02dfc1d9f73d2344b7661707a3efe94c06362.1615916650.git.geoff@infradead.org> (raw)
In-Reply-To: <cover.1615916650.git.geoff@infradead.org>
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
next prev parent reply other threads:[~2021-03-16 17:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 17:51 [PATCH v1 0/2] PS3 Updates Geoff Levand
2021-03-16 17:51 ` Geoff Levand [this message]
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 2/2] powerpc/ps3: Re-align DTB in image Geoff Levand
2021-06-18 3:51 ` Michael Ellerman
2021-06-04 15:58 ` [PATCH v2 1/2] powerpc/ps3: Add firmware version to sysfs Geoff Levand
2021-06-18 3:51 ` [PATCH v2 0/2] PS3 Updates Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5d02dfc1d9f73d2344b7661707a3efe94c06362.1615916650.git.geoff@infradead.org \
--to=geoff@infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).