From 24a0661ebdc6cea16d683271d448af992df3c7c3 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 15 Mar 2023 11:55:02 +0100 Subject: [PATCH] [review] core: pta: test: invoke pta command to test interrupt notif Adds mutex around itr_notif tests to prevent deadlock and errors if invoked tiwce at the same time. This prevent messing in interrupt notifier registration during the tests. Signed-off-by: Etienne Carriere --- core/pta/tests/misc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/pta/tests/misc.c b/core/pta/tests/misc.c index 167dcaf141f..4f6ebcfda1d 100644 --- a/core/pta/tests/misc.c +++ b/core/pta/tests/misc.c @@ -34,6 +34,8 @@ static struct notif_itr test_itr_notif[TEST_ITR_NOTIF_CNT]; /* Helper to release only registered resources in case of error */ static bool test_itr_notif_registered[TEST_ITR_NOTIF_CNT]; +struct mutex itr_notif_test_lock = MUTEX_INITIALIZER; + static TEE_Result register_test_itr_notif(unsigned int test_itr_index, const struct notif_itr_ops *ops) { @@ -119,6 +121,8 @@ static TEE_Result test1_itr_notif_do(void) static_assert(TEST_ITR_NOTIF_CNT >= 8); + mutex_lock(&itr_notif_test_lock); + res = register_test1_itr_notif(); if (res) goto out; @@ -236,6 +240,8 @@ static TEE_Result test1_itr_notif_do(void) out: unregister_test_all_notif(); + mutex_unlock(&itr_notif_test_lock); + if (res) EMSG("Itr-notif test1: failed with %#"PRIx32, res); @@ -279,6 +285,8 @@ static TEE_Result test2_itr_notif_do(void) static_assert(TEST_ITR_NOTIF_CNT >= 4); + mutex_lock(&itr_notif_test_lock); + for (n = 0; n <= 3; n++) { res = register_test_itr_notif(n, &test2_notif_ops); if (res) @@ -322,6 +330,7 @@ static TEE_Result test2_itr_notif_do(void) out: unregister_test_all_notif(); + mutex_unlock(&itr_notif_test_lock); if (res) EMSG("Itr-notif test2: failed with %#"PRIx32, res);