lib: Add irqchip exit API
authorAnup Patel <anup.patel@wdc.com>
Fri, 3 Jan 2020 04:21:58 +0000 (09:51 +0530)
committerAnup Patel <anup.patel@wdc.com>
Tue, 7 Jan 2020 06:41:19 +0000 (12:11 +0530)
We add an optional platform irqchip exit hook for exit path handling
in sbi_exit() implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
include/sbi/sbi_platform.h
lib/sbi/sbi_init.c

index 21082fc..0de8be4 100644 (file)
@@ -109,6 +109,8 @@ struct sbi_platform_operations {
 
        /** Initialize the platform interrupt controller for current HART */
        int (*irqchip_init)(bool cold_boot);
+       /** Exit the platform interrupt controller for current HART */
+       void (*irqchip_exit)(void);
 
        /** Send IPI to a target HART */
        void (*ipi_send)(u32 target_hart);
@@ -460,6 +462,17 @@ static inline int sbi_platform_irqchip_init(const struct sbi_platform *plat,
 }
 
 /**
+ * Exit the platform interrupt controller for current HART
+ *
+ * @param plat pointer to struct sbi_platform
+ */
+static inline void sbi_platform_irqchip_exit(const struct sbi_platform *plat)
+{
+       if (plat && sbi_platform_ops(plat)->irqchip_exit)
+               sbi_platform_ops(plat)->irqchip_exit();
+}
+
+/**
  * Send IPI to a target HART
  *
  * @param plat pointer to struct sbi_platform
index c491bd8..3753800 100644 (file)
@@ -209,6 +209,8 @@ void __noreturn sbi_exit(struct sbi_scratch *scratch)
 
        sbi_ipi_exit(scratch);
 
+       sbi_platform_irqchip_exit(plat);
+
        sbi_platform_final_exit(plat);
 
        sbi_hart_hang();