From d35baa02e7c95583f3d2a62b9e84a35f4a7cd362 Mon Sep 17 00:00:00 2001 From: quebs2 Date: Tue, 8 Sep 2020 15:54:29 +0800 Subject: [PATCH] Force Trustonic TEE schedule run in Silver cores. Cherry-picked from (CR) Probably on the Gold Core, Athene is not applicable to the nq handler when Trustonic TEE sheduler is being called. As per the test results, device will be hung if the tbase is working on e.g core#6 which belongs to QC Kryto Gold core. workaround to bind the TEE scheduler with CPU core #0, #1, #2, and #3. Included logic to select silver CPU and clock mode based on device config: - RSU_SELECT_SILVER_CORES is set to force Trustonic TEE schedule run in Silver cores. - RSU_INTERNAL_CLOCK is set for platforms that use internal clock for qcom_seecom. Example: In lagoon.dtsi, node "qcom_seecom: qseecom@c1700000" has entry "qcom,no-clock-support;" Change-Id: I7d767d42070fbbbd26859ce1a9dca8ead0664dd6 Reviewed-on: https://gerrit.mot.com/1765894 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Igor Kovalenko Submit-Approved: Jira Key --- drivers/gud/MobiCoreDriver/Android.mk | 6 ++++++ drivers/gud/MobiCoreDriver/Kbuild | 8 ++++++++ drivers/gud/MobiCoreDriver/platform.h | 20 ++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gud/MobiCoreDriver/Android.mk b/drivers/gud/MobiCoreDriver/Android.mk index fbec34fac3a4..de2ee43d1712 100644 --- a/drivers/gud/MobiCoreDriver/Android.mk +++ b/drivers/gud/MobiCoreDriver/Android.mk @@ -5,4 +5,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := mcDrvModule.ko LOCAL_MODULE_TAGS := optional LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT) +ifeq ($(RSU_SELECT_SILVER_CORES), true) +KERNEL_CFLAGS += RSU_SELECT_SILVER_CORES=y +endif +ifeq ($(RSU_SELECT_INTERNAL_CLOCK), true) +KERNEL_CFLAGS += RSU_INTERNAL_CLOCK=y +endif include $(DLKM_DIR)/AndroidKernelModule.mk diff --git a/drivers/gud/MobiCoreDriver/Kbuild b/drivers/gud/MobiCoreDriver/Kbuild index da7c9880456b..150ba0afe3da 100644 --- a/drivers/gud/MobiCoreDriver/Kbuild +++ b/drivers/gud/MobiCoreDriver/Kbuild @@ -22,6 +22,14 @@ EXTRA_CFLAGS += -DNDEBUG EXTRA_CFLAGS += -Wno-declaration-after-statement EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/drivers/gud/MobiCoreDriver +ifneq ($(filter m y,$(RSU_SELECT_SILVER_CORES)),) + EXTRA_CFLAGS += -DRSU_SELECT_SILVER_CORES +endif + +ifneq ($(filter m y,$(RSU_INTERNAL_CLOCK)),) + EXTRA_CFLAGS += -DRSU_INTERNAL_CLOCK +endif + obj-m += mcDrvModule.o diff --git a/drivers/gud/MobiCoreDriver/platform.h b/drivers/gud/MobiCoreDriver/platform.h index baba44516adc..3678d0cdf60e 100644 --- a/drivers/gud/MobiCoreDriver/platform.h +++ b/drivers/gud/MobiCoreDriver/platform.h @@ -115,9 +115,11 @@ static inline int smc_fastcall(void *fc_generic, size_t size) * "core_clk" * "iface_clk" */ +#ifndef RSU_INTERNAL_CLOCK #define MC_CRYPTO_CLOCK_MANAGEMENT +#endif /* - * This should be defined only on SDM845 + * This should be defined only on platforms without ICE clock e.g SDM845, SM6150, SM7225 * #define TT_CRYPTO_NO_CLOCK_SUPPORT_FEATURE "qcom,no-clock-support" */ #define MC_CRYPTO_CLOCK_CORESRC_PROPNAME "qcom,ce-opp-freq" @@ -140,10 +142,19 @@ static inline int smc_fastcall(void *fc_generic, size_t size) /* All TZBSPv4 targets are using AARCH32_FC flag */ #define MC_AARCH32_FC -/* This should be defined only on SM8150 - * Gold cores do not support TEE interfaces - * CPU_IDS should list only silver cores +/* This should be defined only on some platforms e.g SM8150, SM6150, SM7225 + * from which the Gold cores do not support TEE interfaces + * so that CPU_IDS should list only Silver cores. */ + +#ifdef RSU_SELECT_SILVER_CORES +#define CPU_SELECTION +#if defined CPU_SELECTION +#define NB_CPU 4 +#define CPU_IDS {0x0, 0x1, 0x2, 0x3} +#endif + +#else /* Enforce/restrict statically CPUs potentially running TEE * (Customize to match platform CPU layout... 0xF0 for big cores only for ex). * If not defined TEE dynamically using all platform CPUs (recommended) @@ -152,5 +163,6 @@ static inline int smc_fastcall(void *fc_generic, size_t size) */ #define PLAT_DEFAULT_TEE_AFFINITY_MASK (0xF) #define BIG_CORE_SWITCH_AFFINITY_MASK (0xF) +#endif /* RSU_SELECT_SILVER_CORES */ #endif /* _MC_PLATFORM_H_ */