diff options
author | Hari Bathini <hbathini@linux.ibm.com> | 2019-09-11 17:56:45 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2019-09-13 17:04:45 +0300 |
commit | 845426f3f3443c3f60737751b7af0142e3020f08 (patch) | |
tree | c448628f0759ff05f7091554b4f0a06107af7c87 /arch/powerpc/platforms/powernv/opal-core.c | |
parent | 6f713d18144ce86c9f01cdf64222d6339e26129e (diff) | |
download | linux-845426f3f3443c3f60737751b7af0142e3020f08.tar.xz |
powerpc/opalcore: provide an option to invalidate /sys/firmware/opal/core file
Writing '1' to /sys/kernel/fadump_release_opalcore would release the
memory held by kernel in exporting /sys/firmware/opal/core file.
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/156821380161.5656.17827032108471421830.stgit@hbathini.in.ibm.com
Diffstat (limited to 'arch/powerpc/platforms/powernv/opal-core.c')
-rw-r--r-- | arch/powerpc/platforms/powernv/opal-core.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-core.c b/arch/powerpc/platforms/powernv/opal-core.c index 6fa6b8a6d510..ed895d82c048 100644 --- a/arch/powerpc/platforms/powernv/opal-core.c +++ b/arch/powerpc/platforms/powernv/opal-core.c @@ -13,6 +13,8 @@ #include <linux/proc_fs.h> #include <linux/elf.h> #include <linux/elfcore.h> +#include <linux/kobject.h> +#include <linux/sysfs.h> #include <linux/slab.h> #include <linux/crash_core.h> #include <linux/of.h> @@ -561,6 +563,36 @@ error_out: of_node_put(np); } +static ssize_t fadump_release_opalcore_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int input = -1; + + if (kstrtoint(buf, 0, &input)) + return -EINVAL; + + if (input == 1) { + if (oc_conf == NULL) { + pr_err("'/sys/firmware/opal/core' file not accessible!\n"); + return -EPERM; + } + + /* + * Take away '/sys/firmware/opal/core' and release all memory + * used for exporting this file. + */ + opalcore_cleanup(); + } else + return -EINVAL; + + return count; +} + +static struct kobj_attribute opalcore_rel_attr = __ATTR(fadump_release_opalcore, + 0200, NULL, + fadump_release_opalcore_store); + static int __init opalcore_init(void) { int rc = -1; @@ -593,6 +625,12 @@ static int __init opalcore_init(void) return rc; } + rc = sysfs_create_file(kernel_kobj, &opalcore_rel_attr.attr); + if (rc) { + pr_warn("unable to create sysfs file fadump_release_opalcore (%d)\n", + rc); + } + return 0; } fs_initcall(opalcore_init); |