From: Hari Bathini <hbathini@linux.ibm.com>
To: linuxppc-dev <linuxppc-dev@ozlabs.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.ibm.com>,
Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
Vasant Hegde <hegdevasant@linux.ibm.com>,
Oliver <oohall@gmail.com>, Nicholas Piggin <npiggin@gmail.com>,
Stewart Smith <stewart@linux.ibm.com>,
Daniel Axtens <dja@axtens.net>
Subject: [PATCH v4 05/25] pseries/fadump: introduce callbacks for platform specific operations
Date: Tue, 16 Jul 2019 17:02:30 +0530 [thread overview]
Message-ID: <156327675065.27462.14816232938604700506.stgit@hbathini.in.ibm.com> (raw)
In-Reply-To: <156327668777.27462.5297279227799429100.stgit@hbathini.in.ibm.com>
Introduce callback functions for platform specific operations like
register, unregister, invalidate & such. Also, define place-holders
for the same on pSeries platform.
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
arch/powerpc/kernel/fadump-common.h | 33 ++++++
arch/powerpc/kernel/fadump.c | 47 +--------
arch/powerpc/platforms/pseries/Makefile | 1
arch/powerpc/platforms/pseries/rtas-fadump.c | 134 ++++++++++++++++++++++++++
4 files changed, 171 insertions(+), 44 deletions(-)
create mode 100644 arch/powerpc/platforms/pseries/rtas-fadump.c
diff --git a/arch/powerpc/kernel/fadump-common.h b/arch/powerpc/kernel/fadump-common.h
index 09d6161..020d582 100644
--- a/arch/powerpc/kernel/fadump-common.h
+++ b/arch/powerpc/kernel/fadump-common.h
@@ -50,6 +50,12 @@
#define FADUMP_UNREGISTER 2
#define FADUMP_INVALIDATE 3
+/* Firmware-Assited Dump platforms */
+enum fadump_platform_type {
+ FADUMP_PLATFORM_UNKNOWN = 0,
+ FADUMP_PLATFORM_PSERIES,
+};
+
/*
* Copy the ascii values for first 8 characters from a string into u64
* variable at their respective indexes.
@@ -84,6 +90,9 @@ struct fad_crash_memory_ranges {
unsigned long long size;
};
+/* Platform specific callback functions */
+struct fadump_ops;
+
/* Firmware-assisted dump configuration details. */
struct fw_dump {
unsigned long reserve_dump_area_start;
@@ -106,6 +115,21 @@ struct fw_dump {
unsigned long dump_active:1;
unsigned long dump_registered:1;
unsigned long nocma:1;
+
+ enum fadump_platform_type fadump_platform;
+ struct fadump_ops *ops;
+};
+
+struct fadump_ops {
+ ulong (*init_fadump_mem_struct)(struct fw_dump *fadump_config);
+ int (*register_fadump)(struct fw_dump *fadump_config);
+ int (*unregister_fadump)(struct fw_dump *fadump_config);
+ int (*invalidate_fadump)(struct fw_dump *fadump_config);
+ int (*process_fadump)(struct fw_dump *fadump_config);
+ void (*fadump_region_show)(struct fw_dump *fadump_config,
+ struct seq_file *m);
+ void (*fadump_trigger)(struct fadump_crash_info_header *fdh,
+ const char *msg);
};
/* Helper functions */
@@ -116,4 +140,13 @@ void fadump_update_elfcore_header(struct fw_dump *fadump_config, char *bufp);
int is_fadump_boot_mem_contiguous(struct fw_dump *fadump_conf);
int is_fadump_reserved_mem_contiguous(struct fw_dump *fadump_conf);
+#ifdef CONFIG_PPC_PSERIES
+extern int rtas_fadump_dt_scan(struct fw_dump *fadump_config, ulong node);
+#else
+static inline int rtas_fadump_dt_scan(struct fw_dump *fadump_config, ulong node)
+{
+ return 1;
+}
+#endif
+
#endif /* __PPC64_FA_DUMP_INTERNAL_H__ */
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index f571cb3..a901ca1 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -112,24 +112,12 @@ static int __init fadump_cma_init(void) { return 1; }
int __init early_init_dt_scan_fw_dump(unsigned long node, const char *uname,
int depth, void *data)
{
- const __be32 *sections;
- int i, num_sections;
- int size;
- const __be32 *token;
+ int ret;
if (depth != 1 || strcmp(uname, "rtas") != 0)
return 0;
- /*
- * Check if Firmware Assisted dump is supported. if yes, check
- * if dump has been initiated on last reboot.
- */
- token = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump", NULL);
- if (!token)
- return 1;
-
- fw_dump.fadump_supported = 1;
- fw_dump.ibm_configure_kernel_dump = be32_to_cpu(*token);
+ ret = rtas_fadump_dt_scan(&fw_dump, node);
/*
* The 'ibm,kernel-dump' rtas node is present only if there is
@@ -139,36 +127,7 @@ int __init early_init_dt_scan_fw_dump(unsigned long node, const char *uname,
if (fdm_active)
fw_dump.dump_active = 1;
- /* Get the sizes required to store dump data for the firmware provided
- * dump sections.
- * For each dump section type supported, a 32bit cell which defines
- * the ID of a supported section followed by two 32 bit cells which
- * gives teh size of the section in bytes.
- */
- sections = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump-sizes",
- &size);
-
- if (!sections)
- return 1;
-
- num_sections = size / (3 * sizeof(u32));
-
- for (i = 0; i < num_sections; i++, sections += 3) {
- u32 type = (u32)of_read_number(sections, 1);
-
- switch (type) {
- case RTAS_FADUMP_CPU_STATE_DATA:
- fw_dump.cpu_state_data_size =
- of_read_ulong(§ions[1], 2);
- break;
- case RTAS_FADUMP_HPTE_REGION:
- fw_dump.hpte_region_size =
- of_read_ulong(§ions[1], 2);
- break;
- }
- }
-
- return 1;
+ return ret;
}
/*
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index ab3d59a..e248724 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_IBMVIO) += vio.o
obj-$(CONFIG_IBMEBUS) += ibmebus.o
obj-$(CONFIG_PAPR_SCM) += papr_scm.o
obj-$(CONFIG_PPC_SPLPAR) += vphn.o
+obj-$(CONFIG_FA_DUMP) += rtas-fadump.o
ifdef CONFIG_PPC_PSERIES
obj-$(CONFIG_SUSPEND) += suspend.o
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
new file mode 100644
index 0000000..9e7c9bf
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -0,0 +1,134 @@
+/*
+ * Firmware-Assisted Dump support on POWERVM platform.
+ *
+ * Copyright 2011, IBM Corporation
+ * Author: Mahesh Salgaonkar <mahesh@linux.ibm.com>
+ *
+ * Copyright 2019, IBM Corp.
+ * Author: Hari Bathini <hbathini@linux.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#undef DEBUG
+#define pr_fmt(fmt) "rtas fadump: " fmt
+
+#include <linux/string.h>
+#include <linux/memblock.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/crash_dump.h>
+
+#include <asm/page.h>
+#include <asm/prom.h>
+#include <asm/rtas.h>
+#include <asm/fadump.h>
+
+#include "../../kernel/fadump-common.h"
+#include "rtas-fadump.h"
+
+static ulong rtas_fadump_init_mem_struct(struct fw_dump *fadump_conf)
+{
+ return fadump_conf->reserve_dump_area_start;
+}
+
+static int rtas_fadump_register_fadump(struct fw_dump *fadump_conf)
+{
+ return -EIO;
+}
+
+static int rtas_fadump_unregister_fadump(struct fw_dump *fadump_conf)
+{
+ return -EIO;
+}
+
+static int rtas_fadump_invalidate_fadump(struct fw_dump *fadump_conf)
+{
+ return -EIO;
+}
+
+/*
+ * Validate and process the dump data stored by firmware before exporting
+ * it through '/proc/vmcore'.
+ */
+static int __init rtas_fadump_process_fadump(struct fw_dump *fadump_conf)
+{
+ return -EINVAL;
+}
+
+static void rtas_fadump_region_show(struct fw_dump *fadump_conf,
+ struct seq_file *m)
+{
+}
+
+static void rtas_fadump_trigger(struct fadump_crash_info_header *fdh,
+ const char *msg)
+{
+ /* Call ibm,os-term rtas call to trigger firmware assisted dump */
+ rtas_os_term((char *)msg);
+}
+
+static struct fadump_ops rtas_fadump_ops = {
+ .init_fadump_mem_struct = rtas_fadump_init_mem_struct,
+ .register_fadump = rtas_fadump_register_fadump,
+ .unregister_fadump = rtas_fadump_unregister_fadump,
+ .invalidate_fadump = rtas_fadump_invalidate_fadump,
+ .process_fadump = rtas_fadump_process_fadump,
+ .fadump_region_show = rtas_fadump_region_show,
+ .fadump_trigger = rtas_fadump_trigger,
+};
+
+int __init rtas_fadump_dt_scan(struct fw_dump *fadump_conf, ulong node)
+{
+ const __be32 *sections;
+ int i, num_sections;
+ int size;
+ const __be32 *token;
+
+ /*
+ * Check if Firmware Assisted dump is supported. if yes, check
+ * if dump has been initiated on last reboot.
+ */
+ token = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump", NULL);
+ if (!token)
+ return 1;
+
+ fadump_conf->ibm_configure_kernel_dump = be32_to_cpu(*token);
+ fadump_conf->ops = &rtas_fadump_ops;
+ fadump_conf->fadump_platform = FADUMP_PLATFORM_PSERIES;
+ fadump_conf->fadump_supported = 1;
+
+ /* Get the sizes required to store dump data for the firmware provided
+ * dump sections.
+ * For each dump section type supported, a 32bit cell which defines
+ * the ID of a supported section followed by two 32 bit cells which
+ * gives the size of the section in bytes.
+ */
+ sections = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump-sizes",
+ &size);
+
+ if (!sections)
+ return 1;
+
+ num_sections = size / (3 * sizeof(u32));
+
+ for (i = 0; i < num_sections; i++, sections += 3) {
+ u32 type = (u32)of_read_number(sections, 1);
+
+ switch (type) {
+ case RTAS_FADUMP_CPU_STATE_DATA:
+ fadump_conf->cpu_state_data_size =
+ of_read_ulong(§ions[1], 2);
+ break;
+ case RTAS_FADUMP_HPTE_REGION:
+ fadump_conf->hpte_region_size =
+ of_read_ulong(§ions[1], 2);
+ break;
+ }
+ }
+
+ return 1;
+}
next prev parent reply other threads:[~2019-07-16 11:43 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-16 11:31 [PATCH v4 00/25] Add FADump support on PowerNV platform Hari Bathini
2019-07-16 11:32 ` [PATCH v4 01/25] powerpc/fadump: move internal macros/definitions to a new header Hari Bathini
2019-07-16 11:32 ` [PATCH v4 02/25] powerpc/fadump: move internal code to a new file Hari Bathini
2019-07-16 11:32 ` [PATCH v4 03/25] powerpc/fadump: Improve fadump documentation Hari Bathini
2019-08-12 6:55 ` Mahesh Jagannath Salgaonkar
2019-07-16 11:32 ` [PATCH v4 04/25] pseries/fadump: move rtas specific definitions to platform code Hari Bathini
2019-07-16 11:32 ` Hari Bathini [this message]
2019-08-12 9:42 ` [PATCH v4 05/25] pseries/fadump: introduce callbacks for platform specific operations Mahesh J Salgaonkar
2019-08-14 6:39 ` Hari Bathini
2019-07-16 11:32 ` [PATCH v4 06/25] pseries/fadump: define register/un-register callback functions Hari Bathini
2019-08-12 16:01 ` Mahesh J Salgaonkar
2019-08-14 6:41 ` Hari Bathini
2019-07-16 11:32 ` [PATCH v4 07/25] pseries/fadump: move out platform specific support from generic code Hari Bathini
2019-08-13 5:16 ` Mahesh J Salgaonkar
2019-07-16 11:32 ` [PATCH v4 08/25] powerpc/fadump: use FADump instead of fadump for how it is pronounced Hari Bathini
2019-07-16 11:33 ` [PATCH v4 09/25] opal: add MPIPL interface definitions Hari Bathini
2019-07-16 11:33 ` [PATCH v4 10/25] powernv/fadump: add fadump support on powernv Hari Bathini
2019-07-16 11:33 ` [PATCH v4 11/25] powernv/fadump: register kernel metadata address with opal Hari Bathini
2019-08-13 10:41 ` Mahesh J Salgaonkar
2019-08-14 7:06 ` Hari Bathini
2019-08-14 10:21 ` Mahesh Jagannath Salgaonkar
2019-08-19 15:49 ` Hari Bathini
2019-07-16 11:33 ` [PATCH v4 12/25] powernv/fadump: define register/un-register callback functions Hari Bathini
2019-08-13 14:34 ` Mahesh J Salgaonkar
2019-08-14 7:11 ` Hari Bathini
2019-07-16 11:33 ` [PATCH v4 13/25] powernv/fadump: support copying multiple kernel memory regions Hari Bathini
2019-08-13 15:03 ` Mahesh J Salgaonkar
2019-08-14 7:14 ` Hari Bathini
2019-07-16 11:33 ` [PATCH v4 14/25] powernv/fadump: process the crashdump by exporting it as /proc/vmcore Hari Bathini
2019-08-14 10:18 ` Mahesh J Salgaonkar
2019-08-14 11:11 ` Hari Bathini
2019-07-16 11:33 ` [PATCH v4 15/25] powerpc/fadump: Update documentation about OPAL platform support Hari Bathini
2019-07-16 11:33 ` [PATCH v4 16/25] powerpc/fadump: consider reserved ranges while reserving memory Hari Bathini
2019-07-16 11:34 ` [PATCH v4 17/25] powerpc/fadump: consider reserved ranges while releasing memory Hari Bathini
2019-07-16 11:34 ` [PATCH v4 18/25] powernv/fadump: process architected register state data provided by firmware Hari Bathini
2019-08-14 17:15 ` Mahesh J Salgaonkar
2019-08-16 2:38 ` Hari Bathini
2019-07-16 11:34 ` [PATCH v4 19/25] powernv/fadump: add support to preserve crash data on FADUMP disabled kernel Hari Bathini
2019-08-16 5:01 ` Mahesh J Salgaonkar
2019-07-16 11:34 ` [PATCH v4 20/25] powerpc/fadump: update documentation about CONFIG_PRESERVE_FA_DUMP Hari Bathini
2019-07-16 11:34 ` [PATCH v4 21/25] powernv/opalcore: export /sys/firmware/opal/core for analysing opal crashes Hari Bathini
2019-07-16 11:34 ` [PATCH v4 22/25] powernv/fadump: Warn before processing partial crashdump Hari Bathini
2019-08-16 5:59 ` Mahesh J Salgaonkar
2019-07-16 11:34 ` [PATCH v4 23/25] powernv/opalcore: provide an option to invalidate /sys/firmware/opal/core file Hari Bathini
2019-07-16 11:34 ` [PATCH v4 24/25] powernv/fadump: consider f/w load area Hari Bathini
2019-07-16 11:35 ` [PATCH v4 25/25] powernv/fadump: update documentation about option to release opalcore Hari Bathini
2019-07-19 6:19 ` [PATCH v4 00/25] Add FADump support on PowerNV platform Hari Bathini
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=156327675065.27462.14816232938604700506.stgit@hbathini.in.ibm.com \
--to=hbathini@linux.ibm.com \
--cc=ananth@linux.ibm.com \
--cc=dja@axtens.net \
--cc=hegdevasant@linux.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahesh@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=stewart@linux.ibm.com \
/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).