From 9ca89c03ab30694aca01532a0bc80bac96c51a24 Mon Sep 17 00:00:00 2001 From: wangzhongping Date: Fri, 23 May 2025 14:16:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9Atzdriver=E7=BB=91=E6=A0=B8CPU0=E6=9C=AA=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E7=94=9F=E6=95=88,CA/TA=E9=80=9A=E4=BF=A1=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB,=E5=AF=BC=E8=87=B4=E5=86=85=E6=A0=B8=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tzdriver/core/smc_smp.c | 1 + tzdriver/include/internal_functions.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tzdriver/core/smc_smp.c b/tzdriver/core/smc_smp.c index 32d25b2..4441599 100644 --- a/tzdriver/core/smc_smp.c +++ b/tzdriver/core/smc_smp.c @@ -1794,6 +1794,7 @@ clean: static int smc_svc_thread_fn(void *arg) { (void)arg; + init_kthread_cpumask(); set_freezable(); while (!kthread_should_stop()) { struct tc_ns_smc_cmd smc_cmd = { {0}, 0 }; diff --git a/tzdriver/include/internal_functions.h b/tzdriver/include/internal_functions.h index 336da09..1a0677c 100644 --- a/tzdriver/include/internal_functions.h +++ b/tzdriver/include/internal_functions.h @@ -16,6 +16,7 @@ #define INTERNAL_FUNCTIONS_H #include +#include #include #include "teek_ns_client.h" #include "teek_client_constants.h" @@ -38,6 +39,24 @@ static inline void fault_monitor_end(void) #else static inline void init_kthread_cpumask(void) { +#ifdef CONFIG_CPU_AFF_NR + unsigned int i; + struct cpumask cpu_mask; + + for (i = 0; i < CONFIG_CPU_AFF_NR; i++) + cpumask_set_cpu(i, &cpu_mask); + + if (cpumask_empty(&cpu_mask)) + return; + if(set_cpus_allowed_ptr(current, &cpu_mask)) + return; +#ifdef CONFIG_CPU_ISOLATION_OPT + /*wait for cpu affined */ + while (!cpumask_test_cpu(task_cpu(current), &cpu_mask)) { + usleep_range(100, 500); + } +#endif /*CONFIG_CPU_ISOLATION_OPT*/ +#endif /*CONFIG_CPU_AFF_NR*/ } static inline void tz_kthread_bind_mask(struct task_struct *kthread) -- Gitee From 289c3819600884d357a4ee80412a10c355ac153c Mon Sep 17 00:00:00 2001 From: wangzhongping Date: Fri, 23 May 2025 14:16:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9Atzdriver=E7=BB=91=E6=A0=B8CPU0=E6=9C=AA=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E7=94=9F=E6=95=88,CA/TA=E9=80=9A=E4=BF=A1=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB,=E5=AF=BC=E8=87=B4=E5=86=85=E6=A0=B8=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhongping --- tzdriver/core/smc_smp.c | 1 + tzdriver/include/internal_functions.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tzdriver/core/smc_smp.c b/tzdriver/core/smc_smp.c index 32d25b2..4441599 100644 --- a/tzdriver/core/smc_smp.c +++ b/tzdriver/core/smc_smp.c @@ -1794,6 +1794,7 @@ clean: static int smc_svc_thread_fn(void *arg) { (void)arg; + init_kthread_cpumask(); set_freezable(); while (!kthread_should_stop()) { struct tc_ns_smc_cmd smc_cmd = { {0}, 0 }; diff --git a/tzdriver/include/internal_functions.h b/tzdriver/include/internal_functions.h index 336da09..1a0677c 100644 --- a/tzdriver/include/internal_functions.h +++ b/tzdriver/include/internal_functions.h @@ -16,6 +16,7 @@ #define INTERNAL_FUNCTIONS_H #include +#include #include #include "teek_ns_client.h" #include "teek_client_constants.h" @@ -38,6 +39,24 @@ static inline void fault_monitor_end(void) #else static inline void init_kthread_cpumask(void) { +#ifdef CONFIG_CPU_AFF_NR + unsigned int i; + struct cpumask cpu_mask; + + for (i = 0; i < CONFIG_CPU_AFF_NR; i++) + cpumask_set_cpu(i, &cpu_mask); + + if (cpumask_empty(&cpu_mask)) + return; + if(set_cpus_allowed_ptr(current, &cpu_mask)) + return; +#ifdef CONFIG_CPU_ISOLATION_OPT + /*wait for cpu affined */ + while (!cpumask_test_cpu(task_cpu(current), &cpu_mask)) { + usleep_range(100, 500); + } +#endif /*CONFIG_CPU_ISOLATION_OPT*/ +#endif /*CONFIG_CPU_AFF_NR*/ } static inline void tz_kthread_bind_mask(struct task_struct *kthread) -- Gitee