]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/powernv: Add ultravisor message log interface
authorClaudio Carvalho <cclaudio@linux.ibm.com>
Wed, 28 Aug 2019 13:05:21 +0000 (23:05 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 29 Aug 2019 23:40:16 +0000 (09:40 +1000)
The ultravisor (UV) provides an in-memory console which follows the
OPAL in-memory console structure.

This patch extends the OPAL msglog code to initialize the UV memory
console and provide the "/sys/firmware/ultravisor/msglog" interface
for userspace to view the UV message log.

Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Tested-by: Claudio Carvalho <cclaudio@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190828130521.26764-2-mpe@ellerman.id.au
arch/powerpc/platforms/powernv/powernv.h
arch/powerpc/platforms/powernv/ultravisor.c

index fd4a1c5a6369f4b307633f8f79697dc3f17098ac..1aa51c4fa904569a1a3106143af28b673326e81e 100644 (file)
@@ -30,4 +30,9 @@ extern void opal_event_shutdown(void);
 
 bool cpu_core_split_required(void);
 
+struct memcons;
+ssize_t memcons_copy(struct memcons *mc, char *to, loff_t pos, size_t count);
+u32 memcons_get_size(struct memcons *mc);
+struct memcons *memcons_init(struct device_node *node, const char *mc_prop_name);
+
 #endif /* _POWERNV_H */
index 02ac57b4bdedbcd809c5ff59f31326c600eca427..e4a00ad06f9d3fe6ab8239a90cc27e480381bd46 100644 (file)
@@ -8,9 +8,15 @@
 #include <linux/init.h>
 #include <linux/printk.h>
 #include <linux/of_fdt.h>
+#include <linux/of.h>
 
 #include <asm/ultravisor.h>
 #include <asm/firmware.h>
+#include <asm/machdep.h>
+
+#include "powernv.h"
+
+static struct kobject *ultravisor_kobj;
 
 int __init early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
                                         int depth, void *data)
@@ -22,3 +28,42 @@ int __init early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
        pr_debug("Ultravisor detected!\n");
        return 1;
 }
+
+static struct memcons *uv_memcons;
+
+static ssize_t uv_msglog_read(struct file *file, struct kobject *kobj,
+                             struct bin_attribute *bin_attr, char *to,
+                             loff_t pos, size_t count)
+{
+       return memcons_copy(uv_memcons, to, pos, count);
+}
+
+static struct bin_attribute uv_msglog_attr = {
+       .attr = {.name = "msglog", .mode = 0400},
+       .read = uv_msglog_read
+};
+
+static int __init uv_init(void)
+{
+       struct device_node *node;
+
+       if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR))
+               return 0;
+
+       node = of_find_compatible_node(NULL, NULL, "ibm,uv-firmware");
+       if (!node)
+               return -ENODEV;
+
+       uv_memcons = memcons_init(node, "memcons");
+       if (!uv_memcons)
+               return -ENOENT;
+
+       uv_msglog_attr.size = memcons_get_size(uv_memcons);
+
+       ultravisor_kobj = kobject_create_and_add("ultravisor", firmware_kobj);
+       if (!ultravisor_kobj)
+               return -ENOMEM;
+
+       return sysfs_create_bin_file(ultravisor_kobj, &uv_msglog_attr);
+}
+machine_subsys_initcall(powernv, uv_init);