diff mbox series

[v3,1/3] core: Implement generic dump region opal call

Message ID 20180531042943.15804-2-joel@jms.id.au
State New
Headers show
Series BMC dumping | expand

Commit Message

Joel Stanley May 31, 2018, 4:29 a.m. UTC
This provides an implementation of the OPAL_REGISTER_DUMP_REGION and
OPAL_UNREGISTER_DUMP_REGION calls that can be used by all systems.

It enables the callbacks for the ibm-fsp machine, preserving the
existing behaviour.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 core/Makefile.inc       |  2 +-
 core/dump-region.c      | 39 +++++++++++++++++++++++++++++++++++++++
 hw/fsp/fsp-mdst-table.c |  8 +++-----
 include/platform.h      | 12 ++++++++++++
 4 files changed, 55 insertions(+), 6 deletions(-)
 create mode 100644 core/dump-region.c

Comments

Vasant Hegde May 31, 2018, 9:08 a.m. UTC | #1
On 05/31/2018 09:59 AM, Joel Stanley wrote:
> This provides an implementation of the OPAL_REGISTER_DUMP_REGION and
> OPAL_UNREGISTER_DUMP_REGION calls that can be used by all systems.
> 
> It enables the callbacks for the ibm-fsp machine, preserving the
> existing behaviour.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>   core/Makefile.inc       |  2 +-
>   core/dump-region.c      | 39 +++++++++++++++++++++++++++++++++++++++
>   hw/fsp/fsp-mdst-table.c |  8 +++-----
>   include/platform.h      | 12 ++++++++++++
>   4 files changed, 55 insertions(+), 6 deletions(-)
>   create mode 100644 core/dump-region.c
> 
> diff --git a/core/Makefile.inc b/core/Makefile.inc
> index d36350590edb..2d2f74778f4c 100644
> --- a/core/Makefile.inc
> +++ b/core/Makefile.inc
> @@ -9,7 +9,7 @@ CORE_OBJS += vpd.o hostservices.o platform.o nvram.o nvram-format.o hmi.o
>   CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
>   CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o
>   CORE_OBJS += flash-subpartition.o bitmap.o buddy.o pci-quirk.o powercap.o psr.o
> -CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o
> +CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o dump-region.o
>   
>   ifeq ($(SKIBOOT_GCOV),1)
>   CORE_OBJS += gcov-profiling.o
> diff --git a/core/dump-region.c b/core/dump-region.c
> new file mode 100644
> index 000000000000..afa4c2685b89
> --- /dev/null
> +++ b/core/dump-region.c
> @@ -0,0 +1,39 @@
> +/* Copyright 2018 IBM Corp.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * 	http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> + * implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#define pr_fmt(fmt) "DUMP: " fmt
> +
> +#include <opal.h>
> +#include <skiboot.h>
> +
> +static int64_t opal_register_dump_region(uint32_t id, uint64_t addr,
> +					 uint64_t size)
> +{
> +	if (platform.register_dump_region)
> +		return platform.register_dump_region(id, addr, size);
> +
> +	return OPAL_UNSUPPORTED;
> +}
> +opal_call(OPAL_REGISTER_DUMP_REGION, opal_register_dump_region, 3);
> +
> +static int64_t opal_unregister_dump_region(uint32_t id)
> +{
> +	if (platform.unregister_dump_region)
> +		return platform.unregister_dump_region(id);
> +
> +	return OPAL_UNSUPPORTED;
> +}
> +opal_call(OPAL_UNREGISTER_DUMP_REGION, opal_unregister_dump_region, 1);
> diff --git a/hw/fsp/fsp-mdst-table.c b/hw/fsp/fsp-mdst-table.c
> index 0f145ba5551a..54d3c0613687 100644
> --- a/hw/fsp/fsp-mdst-table.c
> +++ b/hw/fsp/fsp-mdst-table.c
> @@ -415,11 +415,9 @@ void fsp_mdst_table_init(void)
>   	if (!fsp_present())
>   		return;
>   
> -	/* OPAL interface */
> -	opal_register(OPAL_REGISTER_DUMP_REGION,
> -		      fsp_opal_register_dump_region, 3);
> -	opal_register(OPAL_UNREGISTER_DUMP_REGION,
> -		      fsp_opal_unregister_dump_region, 1);
> +	/* Register callbacks */
> +	platform.register_dump_region = fsp_opal_register_dump_region;
> +	platform.unregister_dump_region = fsp_opal_unregister_dump_region;

Better move this under DECLARE_PLATFORM() as its not going to change later?

Also looks like you missed to add these two hooks for BMC platform in patch 3.

-Vasant
diff mbox series

Patch

diff --git a/core/Makefile.inc b/core/Makefile.inc
index d36350590edb..2d2f74778f4c 100644
--- a/core/Makefile.inc
+++ b/core/Makefile.inc
@@ -9,7 +9,7 @@  CORE_OBJS += vpd.o hostservices.o platform.o nvram.o nvram-format.o hmi.o
 CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
 CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o
 CORE_OBJS += flash-subpartition.o bitmap.o buddy.o pci-quirk.o powercap.o psr.o
-CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o
+CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o dump-region.o
 
 ifeq ($(SKIBOOT_GCOV),1)
 CORE_OBJS += gcov-profiling.o
diff --git a/core/dump-region.c b/core/dump-region.c
new file mode 100644
index 000000000000..afa4c2685b89
--- /dev/null
+++ b/core/dump-region.c
@@ -0,0 +1,39 @@ 
+/* Copyright 2018 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 	http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define pr_fmt(fmt) "DUMP: " fmt
+
+#include <opal.h>
+#include <skiboot.h>
+
+static int64_t opal_register_dump_region(uint32_t id, uint64_t addr,
+					 uint64_t size)
+{
+	if (platform.register_dump_region)
+		return platform.register_dump_region(id, addr, size);
+
+	return OPAL_UNSUPPORTED;
+}
+opal_call(OPAL_REGISTER_DUMP_REGION, opal_register_dump_region, 3);
+
+static int64_t opal_unregister_dump_region(uint32_t id)
+{
+	if (platform.unregister_dump_region)
+		return platform.unregister_dump_region(id);
+
+	return OPAL_UNSUPPORTED;
+}
+opal_call(OPAL_UNREGISTER_DUMP_REGION, opal_unregister_dump_region, 1);
diff --git a/hw/fsp/fsp-mdst-table.c b/hw/fsp/fsp-mdst-table.c
index 0f145ba5551a..54d3c0613687 100644
--- a/hw/fsp/fsp-mdst-table.c
+++ b/hw/fsp/fsp-mdst-table.c
@@ -415,11 +415,9 @@  void fsp_mdst_table_init(void)
 	if (!fsp_present())
 		return;
 
-	/* OPAL interface */
-	opal_register(OPAL_REGISTER_DUMP_REGION,
-		      fsp_opal_register_dump_region, 3);
-	opal_register(OPAL_UNREGISTER_DUMP_REGION,
-		      fsp_opal_unregister_dump_region, 1);
+	/* Register callbacks */
+	platform.register_dump_region = fsp_opal_register_dump_region;
+	platform.unregister_dump_region = fsp_opal_unregister_dump_region;
 
 	if (!fsp_mdst_supported())
 		return;
diff --git a/include/platform.h b/include/platform.h
index a77764464001..c9b2dd88e4f6 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -207,6 +207,18 @@  struct platform {
 	 * OPAL terminate
 	 */
 	void __attribute__((noreturn)) (*terminate)(const char *msg);
+
+	/*
+	 * Dump region registration
+	 *
+	 * Allows machine specific actions to be taken when
+	 * OPAL_REGISTER_DUMP_REGION and OPAL_UNREGISTER_DUMP_REGION
+	 * are called.
+	 */
+	int64_t		(*register_dump_region)(uint32_t id,
+						uint64_t addr,
+						uint64_t size);
+	int64_t		(*unregister_dump_region)(uint32_t id);
 };
 
 extern struct platform __platforms_start;