summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2023-04-17 13:53:11 -0700
committerBrandon Anderson <brandonand@google.com>2024-02-15 23:04:03 +0000
commitcbf80eca7622ddad39d8b9e1c9c6b6f45229c17d (patch)
tree49af2285952cd508a900e5a3cb7a40871c717d61
parent3b5b0a31866e2393e352d419d6a5537495c2ba36 (diff)
downloadtrusty-cbf80eca7622ddad39d8b9e1c9c6b6f45229c17d.tar.gz
ANDROID: trusty: Make trusty-irq part of trusty-core module.
The core trusty driver needs to make an std-call at init time. This might need interrupts, so merge these two modules, so loading the trusty module will never block waiting for the trusty-irq module to be loaded. Bug: 276729665 Change-Id: Iad3817b806ec18aeac1ea284a472466a4bc136db Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--drivers/trusty/Kconfig9
-rw-r--r--drivers/trusty/Makefile2
-rw-r--r--drivers/trusty/trusty-irq.c11
-rw-r--r--drivers/trusty/trusty-irq.h17
-rw-r--r--drivers/trusty/trusty.c14
5 files changed, 39 insertions, 14 deletions
diff --git a/drivers/trusty/Kconfig b/drivers/trusty/Kconfig
index fcde7f0..92b164a 100644
--- a/drivers/trusty/Kconfig
+++ b/drivers/trusty/Kconfig
@@ -22,16 +22,17 @@ config TRUSTY
if TRUSTY
config TRUSTY_IRQ
- tristate "Trusty IRQ support"
+ bool "Trusty IRQ support"
default y
help
- Enable forwarding of IRQs from Linux to Trusty. This module retrieves
+ Enable forwarding of IRQs from Linux to Trusty. This driver retrieves
from Trusty a list of IRQs that Trusty uses, and it registers handlers
for them which notify Trusty that the IRQ has been received.
- If you build this as a module, it will be called trusty-irq.
+ If you build the trusty core driver as a module, this will be part of the
+ trusty-core module.
- Usually this is needed for Trusty to work, so say 'y' or 'm'.
+ Usually this is needed for Trusty to work, so say 'y'.
config TRUSTY_LOG
tristate "Trusty log support"
diff --git a/drivers/trusty/Makefile b/drivers/trusty/Makefile
index 42424ad..eb0765e 100644
--- a/drivers/trusty/Makefile
+++ b/drivers/trusty/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_TRUSTY) += trusty-core.o
trusty-core-objs += trusty.o trusty-mem.o trusty-sched-share.o
trusty-core-$(CONFIG_ARM) += trusty-smc-arm.o
trusty-core-$(CONFIG_ARM64) += trusty-smc-arm64.o
-obj-$(CONFIG_TRUSTY_IRQ) += trusty-irq.o
+trusty-core-$(CONFIG_TRUSTY_IRQ)+= trusty-irq.o
obj-$(CONFIG_TRUSTY_LOG) += trusty-log.o
obj-$(CONFIG_TRUSTY_TEST) += trusty-test.o
obj-$(CONFIG_TRUSTY_VIRTIO) += trusty-virtio.o
diff --git a/drivers/trusty/trusty-irq.c b/drivers/trusty/trusty-irq.c
index 0cbbe70..caa24ef 100644
--- a/drivers/trusty/trusty-irq.c
+++ b/drivers/trusty/trusty-irq.c
@@ -17,6 +17,7 @@
#include <linux/trusty/sm_err.h>
#include <linux/trusty/trusty.h>
+#include "trusty-irq.h"
#include "trusty-irq-trace.h"
struct trusty_irq {
@@ -606,7 +607,7 @@ static struct platform_driver trusty_irq_driver = {
},
};
-static int __init trusty_irq_driver_init(void)
+int __init trusty_irq_driver_init(void)
{
int ret;
@@ -634,18 +635,12 @@ err_driver_register:
return ret;
}
-static void __exit trusty_irq_driver_exit(void)
+void trusty_irq_driver_exit(void)
{
platform_driver_unregister(&trusty_irq_driver);
cpuhp_remove_multi_state(trusty_irq_cpuhp_slot);
trusty_irq_cpuhp_slot = -1;
}
-module_init(trusty_irq_driver_init);
-module_exit(trusty_irq_driver_exit);
-
#define CREATE_TRACE_POINTS
#include "trusty-irq-trace.h"
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Trusty IRQ driver");
diff --git a/drivers/trusty/trusty-irq.h b/drivers/trusty/trusty-irq.h
new file mode 100644
index 0000000..d3444f9
--- /dev/null
+++ b/drivers/trusty/trusty-irq.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2023 Google, Inc.
+ */
+
+#if !defined(_TRUSTY_IRQ_H)
+#define _TRUSTY_IRQ_H
+
+#ifdef CONFIG_TRUSTY_IRQ
+int __init trusty_irq_driver_init(void);
+void trusty_irq_driver_exit(void);
+#else
+static inline int trusty_irq_driver_init(void) { return 0; }
+static inline void trusty_irq_driver_exit(void) {}
+#endif
+
+#endif /* _TRUSTY_IRQ_H */
diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c
index 8d18368..0ff1cf2 100644
--- a/drivers/trusty/trusty.c
+++ b/drivers/trusty/trusty.c
@@ -20,6 +20,7 @@
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
+#include "trusty-irq.h"
#include "trusty-smc.h"
#include "trusty-trace.h"
#include "trusty-sched-share-api.h"
@@ -1208,13 +1209,21 @@ static int __init trusty_driver_init(void)
{
int ret;
+ /*
+ * Initialize trusty_irq_driver first since trusty_probe makes an
+ * std-call at the end where interrupts might be needed.
+ */
+ ret = trusty_irq_driver_init();
+ if (ret < 0)
+ return ret;
+
/* allocate dynamic cpuhp state slot */
ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
"trusty:online",
trusty_cpu_up,
trusty_cpu_down);
if (ret < 0)
- return ret;
+ goto err_cpuhp_setup;
trusty_cpuhp_slot = ret;
@@ -1227,6 +1236,8 @@ static int __init trusty_driver_init(void)
err_driver_register:
cpuhp_remove_multi_state(trusty_cpuhp_slot);
trusty_cpuhp_slot = -1;
+err_cpuhp_setup:
+ trusty_irq_driver_exit();
return ret;
}
@@ -1235,6 +1246,7 @@ static void __exit trusty_driver_exit(void)
platform_driver_unregister(&trusty_driver);
cpuhp_remove_multi_state(trusty_cpuhp_slot);
trusty_cpuhp_slot = -1;
+ trusty_irq_driver_exit();
}
subsys_initcall(trusty_driver_init);