diff mbox series

[RESEND,v2,17/18] board: xen: De-initialize before jumping to Linux

Message ID 20200806094301.4999-18-vicooodin@gmail.com
State Accepted
Commit d17f6698b8e07b15941dd888a4b2d69aa046ae1e
Delegated to: Tom Rini
Headers show
Series Add new board: Xen guest for ARM64 | expand

Commit Message

Anastasiia Lukianenko Aug. 6, 2020, 9:43 a.m. UTC
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

Free resources used by Xen board before jumping to Linux kernel.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes since v1:
 - add comment

 board/xen/xenguest_arm64/xenguest_arm64.c | 6 ++++++
 drivers/xen/hypervisor.c                  | 8 ++++++++
 include/xen.h                             | 8 ++++++++
 3 files changed, 22 insertions(+)

Comments

Tom Rini Aug. 14, 2020, 7:51 p.m. UTC | #1
On Thu, Aug 06, 2020 at 12:43:00PM +0300, Anastasiia Lukianenko wrote:

> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> Free resources used by Xen board before jumping to Linux kernel.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c b/board/xen/xenguest_arm64/xenguest_arm64.c
index 9861edac33..927d87ae37 100644
--- a/board/xen/xenguest_arm64/xenguest_arm64.c
+++ b/board/xen/xenguest_arm64/xenguest_arm64.c
@@ -12,6 +12,7 @@ 
 #include <dm.h>
 #include <errno.h>
 #include <malloc.h>
+#include <xen.h>
 
 #include <asm/io.h>
 #include <asm/armv8/mmu.h>
@@ -194,3 +195,8 @@  int print_cpuinfo(void)
 	return 0;
 }
 
+void board_cleanup_before_linux(void)
+{
+	xen_fini();
+}
+
diff --git a/drivers/xen/hypervisor.c b/drivers/xen/hypervisor.c
index 58b0865e6a..178c206f5b 100644
--- a/drivers/xen/hypervisor.c
+++ b/drivers/xen/hypervisor.c
@@ -242,3 +242,11 @@  void xen_init(void)
 	init_gnttab();
 }
 
+void xen_fini(void)
+{
+	debug("%s\n", __func__);
+
+	fini_gnttab();
+	fini_xenbus();
+	fini_events();
+}
diff --git a/include/xen.h b/include/xen.h
index 686b7148b5..a952a2c84b 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -13,4 +13,12 @@ 
  */
 void xen_init(void);
 
+/**
+ * xen_fini() - Board cleanup before Linux kernel start
+ *
+ * Unmap Xen memory pages the specified guest's pseudophysical
+ * address space and unbind all event channels.
+ */
+void xen_fini(void);
+
 #endif /* __XEN_H__ */