blob: 0815c223b1a9931621e984947c0aab9561d04106 [file] [log] [blame]
Joel Stanley2d7d3432019-10-09 16:55:26 +10301From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Hari Bathini <hbathini@linux.ibm.com>
3Date: Wed, 9 Oct 2019 10:45:19 +0530
4Subject: [PATCH 2/6] powerpc/opal: add MPIPL interface definitions
5
6MPIPL is Memory Preserving IPL supported from POWER9. This enables the
7kernel to reset the system with memory 'preserved'. Also, it supports
8copying memory from a source address to some destination address during
9MPIPL boot. Add MPIPL interface definitions here to leverage these f/w
10features in adding FADump support for PowerNV platform.
11
12This is the backport of upstream commit 6f5f193e84d3 ("powerpc/opal:
13add MPIPL interface definitions").
14
15Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
16Signed-off-by: Joel Stanley <joel@jms.id.au>
17---
18 arch/powerpc/include/asm/opal-api.h | 44 +++++++++++++++++++++-
19 arch/powerpc/include/asm/opal.h | 5 +++
20 arch/powerpc/platforms/powernv/opal-call.c | 3 ++
21 3 files changed, 51 insertions(+), 1 deletion(-)
22
23diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
24index 383242eb0dea..3c39e7f7ba4c 100644
25--- a/arch/powerpc/include/asm/opal-api.h
26+++ b/arch/powerpc/include/asm/opal-api.h
27@@ -208,7 +208,10 @@
28 #define OPAL_HANDLE_HMI2 166
29 #define OPAL_NX_COPROC_INIT 167
30 #define OPAL_XIVE_GET_VP_STATE 170
31-#define OPAL_LAST 170
32+#define OPAL_MPIPL_UPDATE 173
33+#define OPAL_MPIPL_REGISTER_TAG 174
34+#define OPAL_MPIPL_QUERY_TAG 175
35+#define OPAL_LAST 175
36
37 #define QUIESCE_HOLD 1 /* Spin all calls at entry */
38 #define QUIESCE_REJECT 2 /* Fail all calls with OPAL_BUSY */
39@@ -1059,6 +1062,7 @@ enum {
40 OPAL_REBOOT_NORMAL = 0,
41 OPAL_REBOOT_PLATFORM_ERROR = 1,
42 OPAL_REBOOT_FULL_IPL = 2,
43+ OPAL_REBOOT_MPIPL = 3,
44 };
45
46 /* Argument to OPAL_PCI_TCE_KILL */
47@@ -1135,6 +1139,44 @@ enum {
48 #define OPAL_PCI_P2P_LOAD 0x2
49 #define OPAL_PCI_P2P_STORE 0x4
50
51+/* MPIPL update operations */
52+enum opal_mpipl_ops {
53+ OPAL_MPIPL_ADD_RANGE = 0,
54+ OPAL_MPIPL_REMOVE_RANGE = 1,
55+ OPAL_MPIPL_REMOVE_ALL = 2,
56+ OPAL_MPIPL_FREE_PRESERVED_MEMORY = 3,
57+};
58+
59+/* Tag will point to various metadata area. Kernel will
60+ * use tag to get metadata value.
61+ */
62+enum opal_mpipl_tags {
63+ OPAL_MPIPL_TAG_CPU = 0,
64+ OPAL_MPIPL_TAG_OPAL = 1,
65+ OPAL_MPIPL_TAG_KERNEL = 2,
66+ OPAL_MPIPL_TAG_BOOT_MEM = 3,
67+};
68+
69+/* Preserved memory details */
70+struct opal_mpipl_region {
71+ __be64 src;
72+ __be64 dest;
73+ __be64 size;
74+};
75+
76+/* Structure version */
77+#define OPAL_MPIPL_VERSION 0x01
78+
79+struct opal_mpipl_fadump {
80+ u8 version;
81+ u8 reserved[7];
82+ __be32 crashing_pir; /* OPAL crashing CPU PIR */
83+ __be32 cpu_data_version;
84+ __be32 cpu_data_size;
85+ __be32 region_cnt;
86+ struct opal_mpipl_region region[];
87+} __packed;
88+
89 #endif /* __ASSEMBLY__ */
90
91 #endif /* __OPAL_API_H */
92diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
93index d5a0807d21db..a0cf8fba4d12 100644
94--- a/arch/powerpc/include/asm/opal.h
95+++ b/arch/powerpc/include/asm/opal.h
96@@ -39,6 +39,7 @@ int64_t opal_npu_spa_clear_cache(uint64_t phb_id, uint32_t bdfn,
97 uint64_t PE_handle);
98 int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn, long cap,
99 uint64_t rate_phys, uint32_t size);
100+
101 int64_t opal_console_write(int64_t term_number, __be64 *length,
102 const uint8_t *buffer);
103 int64_t opal_console_read(int64_t term_number, __be64 *length,
104@@ -297,6 +298,10 @@ int opal_sensor_group_clear(u32 group_hndl, int token);
105 int opal_sensor_group_enable(u32 group_hndl, int token, bool enable);
106 int opal_nx_coproc_init(uint32_t chip_id, uint32_t ct);
107
108+s64 opal_mpipl_update(enum opal_mpipl_ops op, u64 src, u64 dest, u64 size);
109+s64 opal_mpipl_register_tag(enum opal_mpipl_tags tag, u64 addr);
110+s64 opal_mpipl_query_tag(enum opal_mpipl_tags tag, u64 *addr);
111+
112 s64 opal_signal_system_reset(s32 cpu);
113 s64 opal_quiesce(u64 shutdown_type, s32 cpu);
114
115diff --git a/arch/powerpc/platforms/powernv/opal-call.c b/arch/powerpc/platforms/powernv/opal-call.c
116index dccdc9df5213..a2aa5e433ac8 100644
117--- a/arch/powerpc/platforms/powernv/opal-call.c
118+++ b/arch/powerpc/platforms/powernv/opal-call.c
119@@ -287,3 +287,6 @@ OPAL_CALL(opal_pci_set_pbcq_tunnel_bar, OPAL_PCI_SET_PBCQ_TUNNEL_BAR);
120 OPAL_CALL(opal_sensor_read_u64, OPAL_SENSOR_READ_U64);
121 OPAL_CALL(opal_sensor_group_enable, OPAL_SENSOR_GROUP_ENABLE);
122 OPAL_CALL(opal_nx_coproc_init, OPAL_NX_COPROC_INIT);
123+OPAL_CALL(opal_mpipl_update, OPAL_MPIPL_UPDATE);
124+OPAL_CALL(opal_mpipl_register_tag, OPAL_MPIPL_REGISTER_TAG);
125+OPAL_CALL(opal_mpipl_query_tag, OPAL_MPIPL_QUERY_TAG);