log: Test fly audio,9 fail by Initial audio tone not detected [1/1]
authorrui guo <rui.guo@amlogic.com>
Tue, 28 Dec 2021 10:32:34 +0000 (18:32 +0800)
committerBruno Martins <bgcngm@gmail.com>
Sat, 20 Jul 2024 21:19:31 +0000 (22:19 +0100)
PD#SWPL-64462

Problem:
log_timer_func timer takes a long time

Solution:
log_timer_func is move to the workqueue

Verify:
Android Q + S905X4 + kernel_4.9
Android S + S905X4 + kernel_5.4

Change-Id: I88485a50242b8ad5843d4f03c191943325ddb7fd
Signed-off-by: rui guo <rui.guo@amlogic.com>
optee/log.c

index 5f348e36b301f3c021cf038e8eeae88794fb8fc6..247f1426a91ad79a0ba3f6665c51cce641559d5f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/sysfs.h>
 #include <linux/kthread.h>
 #include <generated/uapi/linux/version.h>
+#include <linux/workqueue.h>
 
 #include "optee_smc.h"
 #include "optee_private.h"
@@ -57,6 +58,9 @@ static uint8_t line_buff[OPTEE_LOG_LINE_MAX];
 static uint32_t looped = 0;
 static void *g_shm_va;
 
+struct delayed_work log_work;
+static struct workqueue_struct *log_workqueue;
+
 static bool init_shm(phys_addr_t shm_pa, uint32_t shm_size)
 {
        struct arm_smccc_res smccc;
@@ -282,14 +286,12 @@ static void log_buff_output(void)
                log_print_text(read_buff, len);
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 34)
-static void log_timer_func(struct timer_list *timer)
-#else
-static void log_timer_func(unsigned long arg)
-#endif
+static void do_log_timer(struct work_struct *work)
 {
        log_buff_output();
-       mod_timer(&optee_log_timer, jiffies + OPTEE_LOG_TIMER_INTERVAL * HZ);
+       if (queue_delayed_work(log_workqueue, &log_work, OPTEE_LOG_TIMER_INTERVAL * HZ) == 0) {
+               pr_err("%s:%d Failed to join the workqueue\n", __func__, __LINE__);
+       }
 }
 
 int optee_log_init(struct tee_device *tee_dev, phys_addr_t shm_pa,
@@ -322,14 +324,12 @@ int optee_log_init(struct tee_device *tee_dev, phys_addr_t shm_pa,
                        goto err;
        }
 
-       /* init timer */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 34)
-       timer_setup(&optee_log_timer, log_timer_func, 0);
-#else
-       setup_timer(&optee_log_timer, log_timer_func, 0);
-#endif
-       optee_log_timer.expires = jiffies + HZ;
-       add_timer(&optee_log_timer);
+       /* init workqueue */
+       log_workqueue = create_singlethread_workqueue("tee-log-wq");
+       INIT_DELAYED_WORK(&log_work,do_log_timer);
+       if (queue_delayed_work(log_workqueue, &log_work, OPTEE_LOG_TIMER_INTERVAL * HZ) == 0) {
+               pr_err("%s:%d Failed to join the workqueue.\n", __func__, __LINE__);
+       }
 
 err:
        return rc;