replace common qcom sources with samsung ones
This commit is contained in:
@@ -45,9 +45,7 @@ endif #TARGET_USES_GY
|
||||
ifeq ($(ENABLE_HYP),true)
|
||||
ifeq ($(TARGET_BOARD_PLATFORM),gen4)
|
||||
ifneq ($(TARGET_USES_GY), true)
|
||||
ifneq ($(filter $(PLATFORM_VERSION), 16 Baklava),$(PLATFORM_VERSION))
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif #TARGET_USES_GY
|
||||
endif #TARGET_BOARD_PLATFORM
|
||||
endif #ENABLE_HYP
|
||||
|
@@ -88,9 +88,6 @@ load(":build/monaco.bzl", "define_monaco")
|
||||
load(":build/pitti.bzl", "define_pitti")
|
||||
load(":build/parrot.bzl", "define_parrot")
|
||||
load(":build/canoe.bzl", "define_canoe")
|
||||
load(":build/sdxkova.bzl", "define_sdxkova")
|
||||
load(":build/sa510m.bzl", "define_sa510m")
|
||||
load(":build/autoghgvm.bzl", "define_autoghgvm")
|
||||
|
||||
define_pineapple()
|
||||
define_blair()
|
||||
@@ -100,6 +97,3 @@ define_sun()
|
||||
define_pitti()
|
||||
define_parrot()
|
||||
define_canoe()
|
||||
define_sdxkova()
|
||||
define_sa510m()
|
||||
define_autoghgvm()
|
||||
|
@@ -1,15 +0,0 @@
|
||||
load(":securemsm_kernel.bzl", "define_consolidate_gki_modules")
|
||||
|
||||
def define_autoghgvm():
|
||||
define_consolidate_gki_modules(
|
||||
target = "autoghgvm",
|
||||
modules = [
|
||||
"smcinvoke_dlkm",
|
||||
"qrng_dlkm",
|
||||
"qseecom_dlkm",
|
||||
],
|
||||
extra_options = [
|
||||
"CONFIG_QCOM_SMCINVOKE",
|
||||
"CONFIG_QSEECOM_COMPAT",
|
||||
],
|
||||
)
|
@@ -1,23 +0,0 @@
|
||||
load(":securemsm_kernel.bzl", "define_consolidate_gki_modules")
|
||||
|
||||
def define_sa510m():
|
||||
define_consolidate_gki_modules(
|
||||
target = "sa510m",
|
||||
modules = [
|
||||
"qce50_dlkm",
|
||||
"qcedev-mod_dlkm",
|
||||
"qcrypto-msm_dlkm",
|
||||
"qrng_dlkm",
|
||||
"qseecom_dlkm",
|
||||
"smcinvoke_dlkm",
|
||||
"tz_log_dlkm",
|
||||
"si_core_test"
|
||||
],
|
||||
extra_options = [
|
||||
"CONFIG_QCOM_SI_CORE",
|
||||
"CONFIG_QCOM_SI_CORE_TEST",
|
||||
"CONFIG_QCOM_SMCINVOKE",
|
||||
"CONFIG_QSEECOM_COMPAT",
|
||||
],
|
||||
arch = "arm",
|
||||
)
|
@@ -1,24 +0,0 @@
|
||||
load(":securemsm_kernel.bzl", "define_consolidate_gki_modules")
|
||||
|
||||
def define_sdxkova():
|
||||
define_consolidate_gki_modules(
|
||||
target = "sdxkova",
|
||||
modules = [
|
||||
"smcinvoke_dlkm",
|
||||
"tz_log_dlkm",
|
||||
"qseecom_dlkm",
|
||||
"hdcp_qseecom_dlkm",
|
||||
"qce50_dlkm",
|
||||
"qcedev-mod_dlkm",
|
||||
"qrng_dlkm",
|
||||
"qcrypto-msm_dlkm",
|
||||
"smmu_proxy_dlkm",
|
||||
"si_core_test"
|
||||
],
|
||||
extra_options = [
|
||||
"CONFIG_QCOM_SI_CORE_TEST",
|
||||
"CONFIG_QCOM_SMCINVOKE",
|
||||
"CONFIG_QSEECOM_COMPAT",
|
||||
"CONFIG_QCOM_SI_CORE",
|
||||
],
|
||||
)
|
@@ -3,7 +3,7 @@
|
||||
* QTI CE device driver.
|
||||
*
|
||||
* Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/mman.h>
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "qce.h"
|
||||
#include "qcedev_smmu.h"
|
||||
#include "qcom_crypto_device.h"
|
||||
#include <linux/compat.h>
|
||||
#if IS_ENABLED(CONFIG_COMPAT)
|
||||
#include "compat_qcedev.h"
|
||||
#endif
|
||||
@@ -51,7 +50,7 @@
|
||||
* This is temporary, and we can use the 1500 value once the
|
||||
* core irqs are enabled.
|
||||
*/
|
||||
#define MAX_OFFLOAD_CRYPTO_WAIT_TIME 50
|
||||
#define MAX_OFFLOAD_CRYPTO_WAIT_TIME 30
|
||||
|
||||
#define MAX_REQUEST_TIME 5000
|
||||
|
||||
@@ -394,10 +393,6 @@ void qcedev_sha_req_cb(void *cookie, unsigned char *digest,
|
||||
if (!areq || !areq->cookie)
|
||||
return;
|
||||
handle = (struct qcedev_handle *) areq->cookie;
|
||||
|
||||
if (!handle || !handle->cntl)
|
||||
return;
|
||||
|
||||
pdev = handle->cntl;
|
||||
if (!pdev)
|
||||
return;
|
||||
@@ -426,10 +421,6 @@ void qcedev_cipher_req_cb(void *cookie, unsigned char *icv,
|
||||
if (!areq || !areq->cookie)
|
||||
return;
|
||||
handle = (struct qcedev_handle *) areq->cookie;
|
||||
|
||||
if (!handle || !handle->cntl)
|
||||
return;
|
||||
|
||||
podev = handle->cntl;
|
||||
if (!podev)
|
||||
return;
|
||||
@@ -558,8 +549,6 @@ void qcedev_offload_cipher_req_cb(void *cookie, unsigned char *icv,
|
||||
if (!areq || !areq->cookie)
|
||||
return;
|
||||
handle = (struct qcedev_handle *) areq->cookie;
|
||||
if (!handle || !handle->cntl)
|
||||
return;
|
||||
podev = handle->cntl;
|
||||
if (!podev)
|
||||
return;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
@@ -254,10 +254,8 @@ int qcedev_check_and_map_buffer(void *handle,
|
||||
}
|
||||
binfo->ion_buf.buf_ion_fd = fd;
|
||||
buf = dma_buf_get(fd);
|
||||
if (IS_ERR_OR_NULL(buf)) {
|
||||
rc = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
if (IS_ERR_OR_NULL(buf))
|
||||
return -EINVAL;
|
||||
rc = msm_gpce_ion_smmu_map(buf, binfo, drv_handles);
|
||||
if (rc) {
|
||||
pr_err("%s: err: failed to map fd (%d) error = %d\n",
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* QTI Secure Execution Environment Communicator (QSEECOM) driver
|
||||
*
|
||||
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "QSEECOM: %s: " fmt, __func__
|
||||
@@ -153,14 +153,6 @@ enum qseecom_bandwidth_request_mode {
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
};
|
||||
/**
|
||||
* For requests that get TZ busy, qseecom will
|
||||
* put them on hold and re-send them after TZ
|
||||
* free. The timeout for waiting TZ free is
|
||||
* 30 seconds.
|
||||
*/
|
||||
#define TZ_BUSY_TIMEOUT_MSECS (30*1000)
|
||||
|
||||
#define K_COPY_FROM_USER(err, dst, src, size) \
|
||||
do {\
|
||||
if (!(is_compat_task()))\
|
||||
@@ -558,7 +550,7 @@ static void __qseecom_free_coherent_buf(uint32_t size,
|
||||
static int __qseecom_scm_call2_locked(uint32_t smc_id, struct qseecom_scm_desc *desc)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long tz_busy_timeout = msecs_to_jiffies(TZ_BUSY_TIMEOUT_MSECS);
|
||||
int retry_count = 0;
|
||||
|
||||
if (!desc) {
|
||||
pr_err("Invalid buffer pointer\n");
|
||||
@@ -567,45 +559,15 @@ static int __qseecom_scm_call2_locked(uint32_t smc_id, struct qseecom_scm_desc *
|
||||
|
||||
do {
|
||||
ret = qcom_scm_qseecom_call(smc_id, desc, false);
|
||||
if (ret != -EBUSY && desc->ret[0] != -QSEE_RESULT_FAIL_APP_BUSY) {
|
||||
break;
|
||||
}
|
||||
if(qseecom.app_block_ref_cnt == 0){
|
||||
if ((ret == -EBUSY) || (desc && (desc->ret[0] == -QSEE_RESULT_FAIL_APP_BUSY))) {
|
||||
mutex_unlock(&app_access_lock);
|
||||
msleep(QSEECOM_SCM_EBUSY_WAIT_MS);
|
||||
mutex_lock(&app_access_lock);
|
||||
if(tz_busy_timeout >= msecs_to_jiffies(QSEECOM_SCM_EBUSY_WAIT_MS)){
|
||||
tz_busy_timeout -= msecs_to_jiffies(QSEECOM_SCM_EBUSY_WAIT_MS);
|
||||
} else {
|
||||
tz_busy_timeout = 0;
|
||||
}
|
||||
} else {
|
||||
mutex_unlock(&app_access_lock);
|
||||
/* wait until no listener is active, or timeout/interrupted */
|
||||
ret = wait_event_interruptible_timeout(qseecom.app_block_wq,
|
||||
(!qseecom.app_block_ref_cnt), tz_busy_timeout);
|
||||
mutex_lock(&app_access_lock);
|
||||
/* no listner is active: re-send */
|
||||
if(ret > 0){
|
||||
tz_busy_timeout = ret;
|
||||
}
|
||||
/* interrupted or error */
|
||||
else if (ret < 0){
|
||||
pr_err("Waiting for TZ free is interrupted");
|
||||
return ret;
|
||||
} else {
|
||||
/* timed out */
|
||||
tz_busy_timeout = 0;
|
||||
}
|
||||
}
|
||||
if(tz_busy_timeout == 0){
|
||||
pr_err("Secure World has been busy for 30 seconds!");
|
||||
ret = -EBUSY;
|
||||
desc->ret[0] = -QSEE_RESULT_FAIL_APP_BUSY;
|
||||
break;
|
||||
}
|
||||
pr_info_ratelimited("re-sending syscall with TZ busy");
|
||||
} while (true);
|
||||
if (retry_count == 33)
|
||||
pr_warn("secure world has been busy for 1 second!\n");
|
||||
} while (((ret == -EBUSY) || (desc && (desc->ret[0] == -QSEE_RESULT_FAIL_APP_BUSY))) &&
|
||||
(retry_count++ < QSEECOM_SCM_EBUSY_MAX_RETRY));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1885,48 +1847,39 @@ static void __qseecom_processing_pending_lsnr_unregister(void)
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&listener_access_lock);
|
||||
|
||||
if (!list_empty(&qseecom.unregister_lsnr_pending_list_head)) {
|
||||
|
||||
while (!list_empty(&qseecom.unregister_lsnr_pending_list_head)) {
|
||||
pos = qseecom.unregister_lsnr_pending_list_head.next;
|
||||
|
||||
do {
|
||||
entry = list_entry(pos,
|
||||
entry = list_entry(pos,
|
||||
struct qseecom_unregister_pending_list, list);
|
||||
if (entry && entry->data) {
|
||||
pr_debug("process pending unregister %d\n",
|
||||
entry->data->listener.id);
|
||||
/* don't process the entry if qseecom_release is not called*/
|
||||
if (!entry->data->listener.release_called) {
|
||||
pr_err("listener release yet to be called for lstnr :%d\n",
|
||||
entry->data->listener.id);
|
||||
pos = pos->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
ptr_svc = __qseecom_find_svc(
|
||||
entry->data->listener.id);
|
||||
pr_debug("Unregistering listener %d\n", entry->data->listener.id);
|
||||
if (ptr_svc) {
|
||||
ret = __qseecom_unregister_listener(
|
||||
entry->data, ptr_svc);
|
||||
if (ret) {
|
||||
pr_debug("unregister %d pending again\n",
|
||||
entry->data->listener.id);
|
||||
mutex_unlock(&listener_access_lock);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
pr_err("invalid listener %d\n",
|
||||
entry->data->listener.id);
|
||||
__qseecom_free_tzbuf(&entry->data->sglistinfo_shm);
|
||||
kfree_sensitive(entry->data);
|
||||
if (entry && entry->data) {
|
||||
pr_debug("process pending unregister %d\n",
|
||||
entry->data->listener.id);
|
||||
/* don't process the entry if qseecom_release is not called*/
|
||||
if (!entry->data->listener.release_called) {
|
||||
list_del(pos);
|
||||
list_add_tail(&entry->list,
|
||||
&qseecom.unregister_lsnr_pending_list_head);
|
||||
break;
|
||||
}
|
||||
|
||||
pos = pos->next;
|
||||
list_del(pos->prev);
|
||||
kfree_sensitive(entry);
|
||||
} while (!list_is_head(pos, &qseecom.unregister_lsnr_pending_list_head));
|
||||
ptr_svc = __qseecom_find_svc(
|
||||
entry->data->listener.id);
|
||||
if (ptr_svc) {
|
||||
ret = __qseecom_unregister_listener(
|
||||
entry->data, ptr_svc);
|
||||
if (ret) {
|
||||
pr_debug("unregister %d pending again\n",
|
||||
entry->data->listener.id);
|
||||
mutex_unlock(&listener_access_lock);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
pr_err("invalid listener %d\n",
|
||||
entry->data->listener.id);
|
||||
__qseecom_free_tzbuf(&entry->data->sglistinfo_shm);
|
||||
kfree_sensitive(entry->data);
|
||||
}
|
||||
list_del(pos);
|
||||
kfree_sensitive(entry);
|
||||
}
|
||||
mutex_unlock(&listener_access_lock);
|
||||
wake_up_interruptible(&qseecom.register_lsnr_pending_wq);
|
||||
@@ -3277,6 +3230,11 @@ static int qseecom_unload_app(struct qseecom_dev_handle *data,
|
||||
goto unload_exit;
|
||||
}
|
||||
|
||||
if (!memcmp(data->client.app_name, "tz_hdm", strlen("tz_hdm"))) {
|
||||
pr_debug("Do not unload tz_hdm app from tz\n");
|
||||
goto unload_exit;
|
||||
}
|
||||
|
||||
ret = __qseecom_cleanup_app(data);
|
||||
if (ret && !app_crash) {
|
||||
pr_err("cleanup app failed, pending ioctl:%d\n", data->ioctl_count.counter);
|
||||
@@ -3351,15 +3309,6 @@ static int qseecom_prepare_unload_app(struct qseecom_dev_handle *data)
|
||||
|
||||
if (!memcmp(data->client.app_name, "keymaste", strlen("keymaste"))) {
|
||||
pr_debug("Do not add keymaster app from tz to unload list\n");
|
||||
/* release the associated dma-buf */
|
||||
if (data->client.dmabuf) {
|
||||
qseecom_vaddr_unmap(data->client.sb_virt, data->client.sgt,
|
||||
data->client.attach, data->client.dmabuf);
|
||||
MAKE_NULL(data->client.sgt,
|
||||
data->client.attach, data->client.dmabuf);
|
||||
}
|
||||
data->released = true;
|
||||
__qseecom_free_tzbuf(&data->sglistinfo_shm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9910,11 +9859,8 @@ exit_unregister_bridge:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
|
||||
static int qseecom_remove(struct platform_device *pdev)
|
||||
#else
|
||||
static void qseecom_remove(struct platform_device *pdev)
|
||||
#endif
|
||||
{
|
||||
struct qseecom_registered_kclient_list *kclient = NULL;
|
||||
struct qseecom_registered_kclient_list *kclient_tmp = NULL;
|
||||
@@ -9958,9 +9904,7 @@ static void qseecom_remove(struct platform_device *pdev)
|
||||
qseecom_deinit_clk();
|
||||
qseecom_release_ce_data();
|
||||
qseecom_deinit_dev();
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int qseecom_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
|
@@ -61,7 +61,7 @@ def _get_module_srcs(target, variant, module, options):
|
||||
|
||||
return globbed_srcs
|
||||
|
||||
def define_target_variant_modules(target, variant, modules, extra_options = [], config_option = None, arch = "arm64"):
|
||||
def define_target_variant_modules(target, variant, modules, extra_options = [], config_option = None):
|
||||
kernel_build_variant = "{}_{}".format(target, variant)
|
||||
options = _get_options(target, variant, config_option, modules, extra_options)
|
||||
module_rules = []
|
||||
@@ -71,11 +71,6 @@ def define_target_variant_modules(target, variant, modules, extra_options = [],
|
||||
|
||||
target_local_defines = ["SMCINVOKE_TRACE_INCLUDE_PATH=../../../{}/smcinvoke/compat".format(native.package_name())]
|
||||
|
||||
if arch == "arm":
|
||||
headers = ["//msm-kernel:all_headers_arm"]
|
||||
else:
|
||||
headers = ["//msm-kernel:all_headers"]
|
||||
|
||||
for config in extra_options:
|
||||
target_local_defines.append(config)
|
||||
for module in modules:
|
||||
@@ -87,7 +82,7 @@ def define_target_variant_modules(target, variant, modules, extra_options = [],
|
||||
kernel_build = "//msm-kernel:{}".format(kernel_build_variant),
|
||||
srcs = module_srcs,
|
||||
out = "{}.ko".format(module["name"]),
|
||||
deps = headers + [_replace_formatting_codes(target, variant, dep) for dep in module["deps"]],
|
||||
deps = ["//msm-kernel:all_headers"] + [_replace_formatting_codes(target, variant, dep) for dep in module["deps"]],
|
||||
hdrs = module["hdrs"],
|
||||
local_defines = target_local_defines,
|
||||
copts = module["copts"],
|
||||
@@ -111,9 +106,7 @@ def define_target_variant_modules(target, variant, modules, extra_options = [],
|
||||
kernel_modules = module_rules,
|
||||
)
|
||||
|
||||
def define_consolidate_gki_modules(target, modules, extra_options = [], config_option = None, arch = "arm64"):
|
||||
define_target_variant_modules(target, "consolidate", modules, extra_options, config_option, arch)
|
||||
define_target_variant_modules(target, "gki", modules, extra_options, config_option, arch)
|
||||
define_target_variant_modules(target, "perf", modules, extra_options, config_option, arch)
|
||||
define_target_variant_modules(target, "perf-defconfig", modules, extra_options, config_option, arch)
|
||||
define_target_variant_modules(target, "debug-defconfig", modules, extra_options, config_option, arch)
|
||||
def define_consolidate_gki_modules(target, modules, extra_options = [], config_option = None):
|
||||
define_target_variant_modules(target, "consolidate", modules, extra_options, config_option)
|
||||
define_target_variant_modules(target, "gki", modules, extra_options, config_option)
|
||||
define_target_variant_modules(target, "perf", modules, extra_options, config_option)
|
||||
|
@@ -18,9 +18,7 @@ endif
|
||||
ifeq ($(ENABLE_HYP),true)
|
||||
ifeq ($(TARGET_BOARD_PLATFORM),gen4)
|
||||
ifneq ($(TARGET_USES_GY), true)
|
||||
ifneq ($(filter $(PLATFORM_VERSION), 16 Baklava),$(PLATFORM_VERSION))
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif #TARGET_USES_GY
|
||||
endif #TARGET_BOARD_PLATFORM
|
||||
endif #ENABLE_HYP
|
||||
@@ -88,7 +86,5 @@ PRODUCT_PACKAGES += qseecom_dlkm.ko
|
||||
endif #ENABLE_QSEECOM_DLKM
|
||||
|
||||
ifeq ($(ENABLE_QCEDEV_FE), true)
|
||||
ifneq ($(filter $(PLATFORM_VERSION), 16 Baklava),$(PLATFORM_VERSION))
|
||||
PRODUCT_PACKAGES += qcedev_fe_dlkm.ko
|
||||
endif
|
||||
endif #ENABLE_QCEDEV_FE
|
||||
|
@@ -44,9 +44,7 @@ endif #TARGET_USES_GY
|
||||
ifeq ($(ENABLE_HYP),true)
|
||||
ifeq ($(TARGET_BOARD_PLATFORM),gen4)
|
||||
ifneq ($(TARGET_USES_GY), true)
|
||||
ifneq ($(filter $(PLATFORM_VERSION), 16 Baklava),$(PLATFORM_VERSION))
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif
|
||||
ENABLE_QCEDEV_FE := true
|
||||
endif #TARGET_USES_GY
|
||||
endif #TARGET_BOARD_PLATFORM
|
||||
endif #ENABLE_HYP
|
||||
@@ -68,11 +66,11 @@ endif #ENABLE_QRNG_DLKM
|
||||
ifeq ($(ENABLE_HDCP_QSEECOM_DLKM), true)
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/hdcp_qseecom_dlkm.ko
|
||||
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/hdcp_qseecom_dlkm.ko
|
||||
BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD += $(KERNEL_MODULES_OUT)/hdcp_qseecom_dlkm.ko
|
||||
endif #ENABLE_HDCP_QSEECOM_DLKM
|
||||
|
||||
ifeq ($(ENABLE_SMMU_PROXY), true)
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/smmu_proxy_dlkm.ko
|
||||
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/smmu_proxy_dlkm.ko
|
||||
endif #ENABLE_SMMU_PROXY
|
||||
|
||||
ifeq ($(ENABLE_SMCINVOKE_DLKM), true)
|
||||
@@ -96,9 +94,6 @@ ifeq ($(ENABLE_QSEECOM_DLKM), true)
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/qseecom_dlkm.ko
|
||||
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/qseecom_dlkm.ko
|
||||
BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD += $(KERNEL_MODULES_OUT)/qseecom_dlkm.ko
|
||||
ifeq ($(TARGET_ENABLE_SECUREMSM_QSEECOM_FIRST_STAGE), true)
|
||||
BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD += $(KERNEL_MODULES_OUT)/qseecom_dlkm.ko
|
||||
endif #TARGET_ENABLE_SECUREMSM_FIRST_STAGE
|
||||
endif #ENABLE_QSEECOM_DLKM
|
||||
|
||||
ifeq ($(ENABLE_QCEDEV_FE), true)
|
||||
|
@@ -28,8 +28,6 @@ static ssize_t device_write(struct file *file, const char __user *buf,
|
||||
// Define IOCTL commands
|
||||
#define IOCTL_RUN_TEST _IOW(1, 0, int)
|
||||
|
||||
#define SI_CORE_TEST_TIMED
|
||||
|
||||
static struct class *driver_class;
|
||||
static dev_t si_core_device_no;
|
||||
static struct cdev si_core_cdev;
|
||||
@@ -43,24 +41,6 @@ static const struct file_operations fops = {
|
||||
.write = device_write
|
||||
};
|
||||
|
||||
#ifdef SI_CORE_TEST_TIMED
|
||||
#define si_object_do_invoke_timed(oic, o, op, args, result, msg) ({ \
|
||||
int ret; \
|
||||
ktime_t start_time, end_time, diff; \
|
||||
start_time = ktime_get(); \
|
||||
ret = si_object_do_invoke((oic), (o), (op), (args), (result)); \
|
||||
end_time = ktime_get(); \
|
||||
if (!ret) { \
|
||||
diff = ktime_to_ns(ktime_sub(end_time, start_time)); \
|
||||
pr_info("%s took(ns): %llu", msg, diff); \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
#else
|
||||
#define si_object_do_invoke_timed(oic, o, op, args, result, msg) \
|
||||
si_object_do_invoke((oic), (o), (op), (args), (result))
|
||||
#endif
|
||||
|
||||
// Device open function
|
||||
static int device_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
@@ -103,8 +83,7 @@ int get_client_env(struct si_object_invoke_ctx *oic, struct si_object **client_e
|
||||
args[2].type = SI_AT_END;
|
||||
|
||||
/* IClientEnv_OP_registerWithCredentials is 5. */
|
||||
ret = si_object_do_invoke_timed(oic, ROOT_SI_OBJECT, 5, args, &result,
|
||||
"IClientEnv_OP_registerWithCredentials");
|
||||
ret = si_object_do_invoke(oic, ROOT_SI_OBJECT, 5, args, &result);
|
||||
if (ret || result) {
|
||||
pr_err("failed with result %d(ret = %d).\n", result, ret);
|
||||
return -EINVAL;
|
||||
@@ -128,8 +107,7 @@ int client_env_open(struct si_object_invoke_ctx *oic, struct si_object *client_e
|
||||
args[2].type = SI_AT_END;
|
||||
|
||||
/* IClientEnv_OP_open is 0. */
|
||||
ret = si_object_do_invoke_timed(oic, client_env, 0, args, &result,
|
||||
"IClientEnv_OP_open");
|
||||
ret = si_object_do_invoke(oic, client_env, 0, args, &result);
|
||||
if (ret || result) {
|
||||
pr_err("failed with result %d(ret = %d).\n", result, ret);
|
||||
return -EINVAL;
|
||||
@@ -152,8 +130,7 @@ static int query_heap_info(struct si_object_invoke_ctx *oic, struct si_object *s
|
||||
args[1].type = SI_AT_END;
|
||||
|
||||
/* IDiagnostics_OP_queryHeapInfo is 0. */
|
||||
ret = si_object_do_invoke_timed(oic, service, 0, args, &result,
|
||||
"IDiagnostics_OP_queryHeapInfo");
|
||||
ret = si_object_do_invoke(oic, service, 0, args, &result);
|
||||
if (ret || result) {
|
||||
pr_err("failed with result %d(ret = %d).\n", result, ret);
|
||||
return -EINVAL;
|
||||
@@ -183,8 +160,7 @@ static int load_app(struct si_object *appLoader, void *file, int len,
|
||||
args[2].type = SI_AT_END;
|
||||
|
||||
/* IAppLoader_OP_loadFromBuffer is 0. */
|
||||
ret = si_object_do_invoke_timed(oic, appLoader, 0, args, &result,
|
||||
"IAppLoader_OP_loadFromBuffer");
|
||||
ret = si_object_do_invoke(oic, appLoader, 0, args, &result);
|
||||
if (ret || result) {
|
||||
pr_err("failed IAppLoader_OP_loadFromBuffer with result %d(ret = %d).\n",
|
||||
result, ret);
|
||||
@@ -199,8 +175,7 @@ static int load_app(struct si_object *appLoader, void *file, int len,
|
||||
app_ctr_args[1].type = SI_AT_END;
|
||||
|
||||
/* IAppController_OP_getAppObject is 2. */
|
||||
ret = si_object_do_invoke_timed(oic, *appController, 2, app_ctr_args, &result,
|
||||
"IAppController_OP_getAppObject");
|
||||
ret = si_object_do_invoke(oic, *appController, 2, app_ctr_args, &result);
|
||||
if (ret || result) {
|
||||
put_si_object(*appController);
|
||||
pr_err("failed appController with result %d(ret = %d).\n", result, ret);
|
||||
@@ -243,8 +218,7 @@ static int send_command(struct si_object *appObj, struct si_object_invoke_ctx *o
|
||||
args[3].type = SI_AT_END;
|
||||
|
||||
// ISMCIExampleApp_computeHash
|
||||
ret = si_object_do_invoke_timed(oic, appObj, 1, args, &result,
|
||||
"ISMCIExampleApp_computeHash");
|
||||
ret = si_object_do_invoke(oic, appObj, 1, args, &result);
|
||||
if (ret || result) {
|
||||
pr_err("failed ISMCIExampleApp_computeHash with result %d(ret = %d).\n",
|
||||
result, ret);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "smcinvoke: %s: " fmt, __func__
|
||||
@@ -2485,7 +2485,7 @@ static void add_mem_obj_info_to_async_side_channel_locked(void *buf, size_t buf_
|
||||
|
||||
msg->count = index;
|
||||
|
||||
pr_debug("Added %zu memory objects to the side channel, total size = %zu\n", index, used);
|
||||
pr_debug("Added %lu memory objects to the side channel, total size = %zu\n", index, used);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -2780,7 +2780,6 @@ static long process_invoke_req(struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
int ret = -1, nr_args = 0;
|
||||
int nr_args_cnt = 0;
|
||||
struct smcinvoke_cmd_req req = {0};
|
||||
void *in_msg = NULL, *out_msg = NULL;
|
||||
size_t inmsg_size = 0, outmsg_size = SMCINVOKE_TZ_MIN_BUF_SIZE;
|
||||
@@ -2847,16 +2846,11 @@ static long process_invoke_req(struct file *filp, unsigned int cmd,
|
||||
|
||||
nr_args = OBJECT_COUNTS_NUM_buffers(req.counts) +
|
||||
OBJECT_COUNTS_NUM_objects(req.counts);
|
||||
/*
|
||||
* In case nr_args is zero, allocate one buffer so that args_buf points to a valid
|
||||
* buffer. There is no need to copy anything to the buffer
|
||||
*/
|
||||
nr_args_cnt = ((nr_args > 0) ? nr_args : 1);
|
||||
|
||||
args_buf = kcalloc(nr_args_cnt, req.argsize, GFP_KERNEL);
|
||||
if (!args_buf)
|
||||
return -ENOMEM;
|
||||
if (nr_args) {
|
||||
args_buf = kcalloc(nr_args, req.argsize, GFP_KERNEL);
|
||||
if (!args_buf)
|
||||
return -ENOMEM;
|
||||
if (context_type == SMCINVOKE_OBJ_TYPE_TZ_OBJ) {
|
||||
ret = copy_from_user(args_buf,
|
||||
u64_to_user_ptr(req.args),
|
||||
@@ -3267,11 +3261,7 @@ exit_destroy_wkthread:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
static int smcinvoke_remove(struct platform_device *pdev)
|
||||
#else
|
||||
static void smcinvoke_remove(struct platform_device *pdev)
|
||||
#endif
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
@@ -3280,9 +3270,7 @@ static void smcinvoke_remove(struct platform_device *pdev)
|
||||
device_destroy(driver_class, smcinvoke_device_no);
|
||||
class_destroy(driver_class);
|
||||
unregister_chrdev_region(smcinvoke_device_no, count);
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int __maybe_unused smcinvoke_suspend(struct platform_device *pdev,
|
||||
|
@@ -900,7 +900,7 @@ static void dequeue_and_put_txn(struct cb_txn *cb_txn)
|
||||
static int wait_for_pending_txn(struct server_info *si, struct cb_txn **cb_txn)
|
||||
{
|
||||
int ret = 0;
|
||||
struct cb_txn *t = NULL;
|
||||
struct cb_txn *t;
|
||||
|
||||
DEFINE_WAIT_FUNC(wait, woken_wake_function);
|
||||
|
||||
@@ -1437,6 +1437,8 @@ static long process_invoke_req(struct file *filp, unsigned int cmd, unsigned lon
|
||||
|
||||
struct si_arg *u = NULL; /* Array of arguments passed to the QTEE. */
|
||||
|
||||
u32 op;
|
||||
|
||||
struct si_object_invoke_ctx *oic;
|
||||
|
||||
/* Do some sanity check! */
|
||||
@@ -1447,16 +1449,23 @@ static long process_invoke_req(struct file *filp, unsigned int cmd, unsigned lon
|
||||
if (copy_from_user(&u_req, (void __user *)arg, sizeof(u_req)))
|
||||
return -EFAULT;
|
||||
|
||||
op = SI_OBJECT_OP_METHOD_ID(u_req.op);
|
||||
if (op == SI_OBJECT_OP_RELEASE || op == SI_OBJECT_OP_RETAIN) {
|
||||
pr_err("OP (RELEASE || RETAIN) is not permitted.\n");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (typeof_si_object(object) == SI_OT_ROOT) {
|
||||
if ((u_req.op == IClientEnv_OP_notifyDomainChange) ||
|
||||
(u_req.op == IClientEnv_OP_adciAccept) ||
|
||||
(u_req.op == IClientEnv_OP_adciShutdown)) {
|
||||
pr_err("invalid rootenv op\n");
|
||||
if ((op == IClientEnv_OP_notifyDomainChange) ||
|
||||
(op == IClientEnv_OP_adciAccept) ||
|
||||
(op == IClientEnv_OP_adciShutdown)) {
|
||||
pr_err("invalid rootenv OP %u\n", op);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (u_req.op == IClientEnv_OP_registerWithCredentials) {
|
||||
if (op == IClientEnv_OP_registerWithCredentials) {
|
||||
if (u_req.counts != OBJECT_COUNTS_PACK(0, 0, 1, 1)) {
|
||||
pr_err("IClientEnv_OP_registerWithCredentials: incorrect number of arguments.\n");
|
||||
|
||||
@@ -1498,7 +1507,7 @@ static long process_invoke_req(struct file *filp, unsigned int cmd, unsigned lon
|
||||
}
|
||||
|
||||
if (typeof_si_object(object) == SI_OT_ROOT) {
|
||||
if (u_req.op == IClientEnv_OP_registerWithCredentials) {
|
||||
if (op == IClientEnv_OP_registerWithCredentials) {
|
||||
if (U_HANDLE_IS_NULL(u_args[0].o.fd)) {
|
||||
pr_err("IClientEnv_OP_registerWithCredentials: privileged credential.\n");
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "smcinvoke_kernel: %s: " fmt, __func__
|
||||
@@ -124,7 +124,7 @@ static int32_t do_invoke(void *context, uint32_t op,
|
||||
goto out_failed;
|
||||
}
|
||||
|
||||
pr_info("%s object invocation with %zu arguments (%04x) and op %d.\n",
|
||||
pr_info("%s object invocation with %lu arguments (%04x) and op %d.\n",
|
||||
si_object_name(object), OBJECT_COUNTS_TOTAL(counts), counts, op);
|
||||
|
||||
/* + INITIATE an invocation. */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __QTI_SMMU_PROXY_H_
|
||||
#define __QTI_SMMU_PROXY_H_
|
||||
@@ -12,16 +12,7 @@
|
||||
#include <smmu-proxy/include/uapi/linux/qti-smmu-proxy.h>
|
||||
|
||||
#define SMMU_PROXY_MEM_ALIGNMENT (1 << 21)
|
||||
#define SMMU_PROXY_SWITCH_OP_ACQUIRE_SID 0
|
||||
#define SMMU_PROXY_SWITCH_OP_RELEASE_SID 1
|
||||
|
||||
int smmu_proxy_get_csf_version(struct csf_version *csf_version);
|
||||
|
||||
/*
|
||||
* Decouple the unmap call from the SID switch, to allow the SID switch
|
||||
* to happen more deterministically compared to the lazy unmap call which
|
||||
* delays the SID switch.
|
||||
*/
|
||||
int smmu_proxy_switch_sid(struct device *client_dev, u32 op);
|
||||
|
||||
#endif /* __QTI_SMMU_PROXY_H_ */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022,2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef SMMU_PROXY_MSGQ_H
|
||||
#define SMMU_PROXY_MSGQ_H
|
||||
@@ -28,8 +28,6 @@ enum smmu_proxy_msg_type {
|
||||
SMMU_PROXY_UNMAP,
|
||||
SMMU_PROXY_UNMAP_RESP,
|
||||
SMMU_PROXY_ERR_RESP,
|
||||
SMMU_PROXY_SWITCH_SID,
|
||||
SMMU_PROXY_SWITCH_SID_RESP,
|
||||
SMMU_PROXY_MSG_MAX,
|
||||
};
|
||||
|
||||
@@ -106,26 +104,4 @@ struct smmu_proxy_unmap_resp {
|
||||
struct smmu_proxy_resp_hdr hdr;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct smmu_proxy_switch_req: The message format for an SID switch request from
|
||||
* another VM.
|
||||
* @hdr: Message header
|
||||
* @cb_id: The context bank id to-be switched.
|
||||
* @switch_dir: One of the values in enum sid_switch_direction.
|
||||
* SID_ACQUIRE or SID_RELEASE.
|
||||
*/
|
||||
struct smmu_proxy_switch_sid_req {
|
||||
struct smmu_proxy_msg_hdr hdr;
|
||||
u32 cb_id;
|
||||
u32 switch_dir;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct smmu_proxy_switch_resp: The message format for an SID switch
|
||||
* request response.
|
||||
* @hdr: Response header
|
||||
*/
|
||||
struct smmu_proxy_switch_sid_resp {
|
||||
struct smmu_proxy_resp_hdr hdr;
|
||||
} __packed;
|
||||
#endif /* SMMU_PROXY_MSGQ_H */
|
||||
|
@@ -5,13 +5,11 @@
|
||||
|
||||
#include "qti-smmu-proxy-common.h"
|
||||
|
||||
#include <linux/qcom-iommu-util.h>
|
||||
#include <linux/qti-smmu-proxy-callbacks.h>
|
||||
#include <linux/qcom-dma-mapping.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/delay.h>
|
||||
#define DELAY_MS 30
|
||||
#define GH_MSGQ_RECV_RETRY_CNT 10
|
||||
|
||||
static void *msgq_hdl;
|
||||
|
||||
@@ -60,7 +58,7 @@ int smmu_proxy_unmap(void *data)
|
||||
* No need to validate size - gh_msgq_recv() ensures that sizeof(*resp) <
|
||||
* GH_MSGQ_MAX_MSG_SIZE_BYTES
|
||||
*/
|
||||
retry_cnt = GH_MSGQ_RECV_RETRY_CNT;
|
||||
retry_cnt = 10;
|
||||
do {
|
||||
ret = gh_msgq_recv(msgq_hdl, buf, sizeof(*resp), &size, 0);
|
||||
if (ret >= 0)
|
||||
@@ -96,96 +94,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int smmu_proxy_switch_sid(struct device *client_dev, u32 op)
|
||||
{
|
||||
void *buf;
|
||||
size_t size;
|
||||
int ret;
|
||||
struct smmu_proxy_switch_sid_req *req;
|
||||
struct smmu_proxy_switch_sid_resp *resp;
|
||||
int retry_cnt;
|
||||
|
||||
mutex_lock(&sender_mutex);
|
||||
buf = kzalloc(GH_MSGQ_MAX_MSG_SIZE_BYTES, GFP_KERNEL);
|
||||
if (!buf) {
|
||||
ret = -ENOMEM;
|
||||
pr_err("%s: Failed to allocate memory!\n", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
req = buf;
|
||||
|
||||
req->hdr.msg_type = SMMU_PROXY_SWITCH_SID;
|
||||
req->hdr.msg_size = sizeof(*req);
|
||||
ret = of_property_read_u32(client_dev->of_node,
|
||||
"qti,smmu-proxy-cb-id",
|
||||
&req->cb_id);
|
||||
if (ret) {
|
||||
dev_err(client_dev, "%s: Err reading 'qti,smmu-proxy-cb-id' rc: %d\n",
|
||||
__func__, ret);
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
case SMMU_PROXY_SWITCH_OP_RELEASE_SID:
|
||||
req->switch_dir = SID_RELEASE;
|
||||
break;
|
||||
case SMMU_PROXY_SWITCH_OP_ACQUIRE_SID:
|
||||
req->switch_dir = SID_ACQUIRE;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
ret = gh_msgq_send(msgq_hdl, (void *) req, req->hdr.msg_size, 0);
|
||||
if (ret < 0) {
|
||||
pr_err("%s: failed to send switch message rc: %d cb_id: %d\n",
|
||||
__func__, ret, req->cb_id);
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* No need to validate size - gh_msgq_recv() ensures that sizeof(*resp) <
|
||||
* GH_MSGQ_MAX_MSG_SIZE_BYTES
|
||||
*/
|
||||
retry_cnt = GH_MSGQ_RECV_RETRY_CNT;
|
||||
do {
|
||||
ret = gh_msgq_recv(msgq_hdl, buf, sizeof(*resp), &size, 0);
|
||||
if (ret >= 0)
|
||||
break;
|
||||
|
||||
if (retry_cnt == 1) {
|
||||
pr_err_ratelimited("%s: failed to receive message rc: %d cb_id: %d\n",
|
||||
__func__, ret, req->cb_id);
|
||||
goto free_buf;
|
||||
}
|
||||
pr_err_ratelimited("%s: failed to receive message rc: %d, retry cb_id: %d\n",
|
||||
__func__, ret, req->cb_id);
|
||||
mdelay(DELAY_MS);
|
||||
} while (--retry_cnt);
|
||||
|
||||
resp = buf;
|
||||
if (resp->hdr.ret) {
|
||||
ret = resp->hdr.ret;
|
||||
pr_err("%s: Switch call failed on remote VM, rc: %d\n", __func__,
|
||||
resp->hdr.ret);
|
||||
}
|
||||
|
||||
if (resp->hdr.msg_type != SMMU_PROXY_SWITCH_SID_RESP) {
|
||||
pr_err("%s: received incorrect msg (type: %d) for cb_id: %d\n", __func__,
|
||||
resp->hdr.msg_type, req->cb_id);
|
||||
}
|
||||
|
||||
free_buf:
|
||||
kfree(buf);
|
||||
out:
|
||||
mutex_unlock(&sender_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(smmu_proxy_switch_sid);
|
||||
|
||||
int smmu_proxy_map(struct device *client_dev, struct sg_table *proxy_iova,
|
||||
struct dma_buf *dmabuf)
|
||||
{
|
||||
@@ -272,7 +180,7 @@ int smmu_proxy_map(struct device *client_dev, struct sg_table *proxy_iova,
|
||||
* No need to validate size - gh_msgq_recv() ensures that sizeof(*resp) <
|
||||
* GH_MSGQ_MAX_MSG_SIZE_BYTES
|
||||
*/
|
||||
retry_cnt = GH_MSGQ_RECV_RETRY_CNT;
|
||||
retry_cnt = 10;
|
||||
resp = buf;
|
||||
flags = 0;
|
||||
do {
|
||||
|
@@ -30,12 +30,7 @@ static DEFINE_MUTEX(buffer_state_lock);
|
||||
static DEFINE_XARRAY(buffer_state_arr);
|
||||
|
||||
static unsigned int cb_map_counts[QTI_SMMU_PROXY_CB_IDS_LEN] = { 0 };
|
||||
struct cb_dev {
|
||||
struct device *dev;
|
||||
struct {
|
||||
uint32_t acquired : 1;
|
||||
};
|
||||
} cb_devices[QTI_SMMU_PROXY_CB_IDS_LEN] = { 0 };
|
||||
struct device *cb_devices[QTI_SMMU_PROXY_CB_IDS_LEN] = { 0 };
|
||||
|
||||
struct task_struct *receiver_msgq_handler_thread;
|
||||
|
||||
@@ -100,14 +95,13 @@ static int iommu_unmap_and_relinquish(u32 hdl)
|
||||
|
||||
/* If nothing left is mapped for this CB, unprogram its SMR */
|
||||
cb_map_counts[cb_id]--;
|
||||
if (!cb_map_counts[cb_id] && cb_devices[cb_id].acquired) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id].dev, SID_RELEASE);
|
||||
if (!cb_map_counts[cb_id]) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id], SID_RELEASE);
|
||||
if (ret) {
|
||||
pr_err("%s: Failed to unprogram SMR for cb_id %d rc: %d\n",
|
||||
__func__, cb_id, ret);
|
||||
break;
|
||||
}
|
||||
cb_devices[cb_id].acquired = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,59 +148,6 @@ static int process_unmap_request(struct smmu_proxy_unmap_req *req, size_t size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int process_switch_sid_request(struct smmu_proxy_switch_sid_req *req, size_t size)
|
||||
{
|
||||
struct smmu_proxy_switch_sid_resp *resp;
|
||||
int ret = 0;
|
||||
|
||||
resp = kzalloc(sizeof(*resp), GFP_KERNEL);
|
||||
if (!resp)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
if (req->cb_id >= QTI_SMMU_PROXY_CB_IDS_LEN) {
|
||||
ret = -ERANGE;
|
||||
goto exit_resp;
|
||||
}
|
||||
|
||||
/*
|
||||
* For now, we only expect sid switch for the Display CB,
|
||||
* but we are not disabling other CBs in case it is needed.
|
||||
*/
|
||||
|
||||
mutex_lock(&buffer_state_lock);
|
||||
if (req->switch_dir == SID_ACQUIRE && cb_devices[req->cb_id].acquired)
|
||||
pr_info("cb_id: %d has already been acquired. Ignoring request.\n", req->cb_id);
|
||||
else if (req->switch_dir == SID_RELEASE && !cb_devices[req->cb_id].acquired)
|
||||
pr_info("cb_id: %d has already been released. Ignoring request.\n", req->cb_id);
|
||||
else
|
||||
ret = qcom_iommu_sid_switch(cb_devices[req->cb_id].dev, req->switch_dir);
|
||||
|
||||
if (ret)
|
||||
pr_err("%s: Failed to switch sid request: %d for cb_id %d %s\n", __func__,
|
||||
ret, req->cb_id, (req->switch_dir == SID_ACQUIRE) ? "ACQUIRE" : "RELEASE");
|
||||
else
|
||||
cb_devices[req->cb_id].acquired = (req->switch_dir == SID_ACQUIRE);
|
||||
mutex_unlock(&buffer_state_lock);
|
||||
|
||||
exit_resp:
|
||||
resp->hdr.msg_type = SMMU_PROXY_SWITCH_SID_RESP;
|
||||
resp->hdr.msg_size = sizeof(*resp);
|
||||
resp->hdr.ret = ret;
|
||||
|
||||
ret = gh_msgq_send(msgq_hdl, resp, resp->hdr.msg_size, 0);
|
||||
if (ret < 0)
|
||||
pr_err("%s: failed to send response to switch request rc: %d\n", __func__, ret);
|
||||
else
|
||||
pr_info("%s: response to switch sid request: %d for cb_id %d %s\n", __func__,
|
||||
resp->hdr.ret, req->cb_id,
|
||||
(req->switch_dir == SID_ACQUIRE) ? "ACQUIRE" : "RELEASE");
|
||||
|
||||
kfree(resp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
struct sg_table *retrieve_and_iommu_map(struct mem_buf_retrieve_kernel_arg *retrieve_arg,
|
||||
@@ -224,7 +165,7 @@ struct sg_table *retrieve_and_iommu_map(struct mem_buf_retrieve_kernel_arg *retr
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
if (!cb_devices[cb_id].dev) {
|
||||
if (!cb_devices[cb_id]) {
|
||||
pr_err("%s: CB of ID %d not defined\n", __func__, cb_id);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
@@ -270,7 +211,7 @@ struct sg_table *retrieve_and_iommu_map(struct mem_buf_retrieve_kernel_arg *retr
|
||||
buf_state->dmabuf = dmabuf;
|
||||
}
|
||||
|
||||
attachment = dma_buf_attach(dmabuf, cb_devices[cb_id].dev);
|
||||
attachment = dma_buf_attach(dmabuf, cb_devices[cb_id]);
|
||||
if (IS_ERR(attachment)) {
|
||||
ret = PTR_ERR(attachment);
|
||||
pr_err("%s: Failed to attach rc: %d\n", __func__, ret);
|
||||
@@ -294,14 +235,13 @@ struct sg_table *retrieve_and_iommu_map(struct mem_buf_retrieve_kernel_arg *retr
|
||||
buf_state->cb_info[cb_id].attachment = attachment;
|
||||
buf_state->cb_info[cb_id].sg_table = table;
|
||||
|
||||
if (!cb_devices[cb_id].acquired) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id].dev, SID_ACQUIRE);
|
||||
if (!cb_map_counts[cb_id]) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id], SID_ACQUIRE);
|
||||
if (ret) {
|
||||
pr_err("%s: Failed to program SMRs for cb_id %d rc: %d\n", __func__,
|
||||
cb_id, ret);
|
||||
goto unmap;
|
||||
}
|
||||
cb_devices[cb_id].acquired = true;
|
||||
}
|
||||
cb_map_counts[cb_id]++;
|
||||
|
||||
@@ -320,13 +260,11 @@ unlock:
|
||||
|
||||
dec_cb_map_count:
|
||||
cb_map_counts[cb_id]--;
|
||||
if (!cb_map_counts[cb_id] && cb_devices[cb_id].acquired) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id].dev, SID_RELEASE);
|
||||
if (!cb_map_counts[cb_id]) {
|
||||
ret = qcom_iommu_sid_switch(cb_devices[cb_id], SID_RELEASE);
|
||||
if (ret)
|
||||
pr_err("%s: Failed to unprogram SMR for cb_id %d rc: %d\n",
|
||||
__func__, cb_id, ret);
|
||||
else
|
||||
cb_devices[cb_id].acquired = false;
|
||||
}
|
||||
unmap:
|
||||
dma_buf_unmap_attachment(attachment, table, DMA_BIDIRECTIONAL);
|
||||
@@ -443,9 +381,6 @@ static void smmu_proxy_process_msg(void *buf, size_t size)
|
||||
case SMMU_PROXY_UNMAP:
|
||||
ret = process_unmap_request(buf, size);
|
||||
break;
|
||||
case SMMU_PROXY_SWITCH_SID:
|
||||
ret = process_switch_sid_request(buf, size);
|
||||
break;
|
||||
default:
|
||||
pr_err("%s: received message of unknown type: %d\n", __func__,
|
||||
msg_hdr->msg_type);
|
||||
@@ -761,7 +696,7 @@ static int cb_probe_handler(struct device *dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cb_devices[context_bank_id].dev) {
|
||||
if (cb_devices[context_bank_id]) {
|
||||
dev_err(dev, "Context bank %u is already populated\n", context_bank_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -785,7 +720,7 @@ static int cb_probe_handler(struct device *dev)
|
||||
}
|
||||
|
||||
iommu_set_fault_handler(domain, proxy_fault_handler, NULL);
|
||||
cb_devices[context_bank_id].dev = dev;
|
||||
cb_devices[context_bank_id] = dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "%s:[%s][%d]: " fmt, KBUILD_MODNAME, __func__, __LINE__
|
||||
@@ -1362,7 +1362,7 @@ static ssize_t tzdbg_fs_read_encrypted(int tz_id, char __user *buf,
|
||||
stat->display_offset += ret;
|
||||
stat->display_len -= ret;
|
||||
pr_debug("ret = %d, offset = %d\n", ret, (int)(*offp));
|
||||
pr_debug("display_len = %zu, offset = %zu\n",
|
||||
pr_debug("display_len = %lu, offset = %lu\n",
|
||||
stat->display_len, stat->display_offset);
|
||||
return ret;
|
||||
}
|
||||
@@ -1944,11 +1944,7 @@ exit_free_diag_buf:
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
static int tz_log_remove(struct platform_device *pdev)
|
||||
#else
|
||||
static void tz_log_remove(struct platform_device *pdev)
|
||||
#endif
|
||||
{
|
||||
tzdbg_fs_exit(pdev);
|
||||
dma_free_coherent(&pdev->dev, display_buf_size,
|
||||
@@ -1957,9 +1953,7 @@ static void tz_log_remove(struct platform_device *pdev)
|
||||
tzdbg_free_qsee_log_buf(pdev);
|
||||
if (!tzdbg.is_encrypted_log_enabled)
|
||||
kfree(tzdbg.diag_buf);
|
||||
#if KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static const struct of_device_id tzlog_match[] = {
|
||||
|
Reference in New Issue
Block a user