diff --git a/msm/eva/cvp_hfi.c b/msm/eva/cvp_hfi.c index 4823bfd58b..73d8ca8415 100644 --- a/msm/eva/cvp_hfi.c +++ b/msm/eva/cvp_hfi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -2342,6 +2343,7 @@ static int iris_hfi_core_release(void *dev) struct iris_hfi_device *device = dev; struct cvp_hal_session *session, *next; struct dev_pm_qos_request *qos_hdl; + u32 ipcc_iova; if (!device) { dprintk(CVP_ERR, "invalid device\n"); @@ -2370,6 +2372,8 @@ static int iris_hfi_core_release(void *dev) __dsp_shutdown(device); __disable_subcaches(device); + ipcc_iova = __read_register(device, CVP_MMAP_ADDR); + msm_cvp_unmap_ipcc_regs(ipcc_iova); __unload_fw(device); __hwfence_regs_unmap(device); @@ -2521,6 +2525,11 @@ static int iris_debug_hook(void *device) dprintk(CVP_ERR, "%s Invalid device\n", __func__); return -ENODEV; } + __write_register(dev, CVP_WRAPPER_CORE_CLOCK_CONFIG, 0x11); + __write_register(dev, CVP_WRAPPER_TZ_CPU_CLOCK_CONFIG, 0x1); + dprintk(CVP_ERR, "Halt Tensilica and core and axi\n"); + return 0; + /******* FDU & MPU *****/ #define CVP0_CVP_SS_FDU_SECURE_ENABLE 0x90 #define CVP0_CVP_SS_MPU_SECURE_ENABLE 0x94 diff --git a/msm/eva/cvp_hfi_io.h b/msm/eva/cvp_hfi_io.h index a28e459e95..46322c5b83 100644 --- a/msm/eva/cvp_hfi_io.h +++ b/msm/eva/cvp_hfi_io.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __CVP_HFI_IO_H__ @@ -111,6 +112,7 @@ #define CVP_WRAPPER_TZ_BASE_OFFS 0x000C0000 +#define CVP_WRAPPER_TZ_CPU_CLOCK_CONFIG (CVP_WRAPPER_TZ_BASE_OFFS) #define CVP_WRAPPER_INTR_CLEAR_A2HWD_BMSK 0x10 #define CVP_WRAPPER_INTR_CLEAR_A2HWD_SHFT 0x4 #define CVP_WRAPPER_INTR_CLEAR_A2H_BMSK 0x4 diff --git a/msm/eva/cvp_smem.c b/msm/eva/cvp_smem.c index ac3a86f268..673db56b3f 100644 --- a/msm/eva/cvp_smem.c +++ b/msm/eva/cvp_smem.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -606,3 +607,36 @@ int msm_cvp_map_ipcc_regs(u32 *iova) } return 0; } + +int msm_cvp_unmap_ipcc_regs(u32 iova) +{ + struct context_bank_info *cb; + struct msm_cvp_core *core; + struct cvp_hfi_device *hfi_ops; + struct iris_hfi_device *dev = NULL; + u32 size; + + core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + if (core) { + hfi_ops = core->device; + if (hfi_ops) + dev = hfi_ops->hfi_device_data; + } + + if (!dev) + return -EINVAL; + + size = dev->res->ipcc_reg_size; + + if (!iova || !size) + return -EINVAL; + + cb = msm_cvp_smem_get_context_bank(dev->res, 0); + if (!cb) { + dprintk(CVP_ERR, "%s: fail to get context bank\n", __func__); + return -EINVAL; + } + dma_unmap_resource(cb->dev, iova, size, DMA_BIDIRECTIONAL, 0); + + return 0; +} diff --git a/msm/eva/msm_cvp_buf.h b/msm/eva/msm_cvp_buf.h index 4bbfa191ef..ddf15853e3 100644 --- a/msm/eva/msm_cvp_buf.h +++ b/msm/eva/msm_cvp_buf.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _MSM_CVP_BUF_H_ @@ -194,6 +195,7 @@ int msm_cvp_smem_cache_operations(struct dma_buf *dbuf, unsigned long offset, unsigned long size); int msm_cvp_map_ipcc_regs(u32 *iova); +int msm_cvp_unmap_ipcc_regs(u32 iova); /* CVP driver internal buffer management functions*/ struct cvp_internal_buf *cvp_allocate_arp_bufs(struct msm_cvp_inst *inst, diff --git a/msm/eva/msm_cvp_res_parse.c b/msm/eva/msm_cvp_res_parse.c index 49f8fb0fc2..f9bb54170d 100644 --- a/msm/eva/msm_cvp_res_parse.c +++ b/msm/eva/msm_cvp_res_parse.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1038,12 +1039,16 @@ int msm_cvp_smmu_fault_handler(struct iommu_domain *domain, return -EINVAL; } + dprintk(CVP_ERR, "%s - faulting address: %lx fault cnt %d\n", + __func__, iova, core->smmu_fault_count); + if (core->smmu_fault_count > 0) { + core->smmu_fault_count++; + return -ENOSYS; + } mutex_lock(&core->lock); core->smmu_fault_count++; if (!core->last_fault_addr) core->last_fault_addr = iova; - dprintk(CVP_ERR, "%s - faulting address: %lx, %d\n", - __func__, iova, core->smmu_fault_count); log = (core->log.snapshot_index > 0)? false : true; list_for_each_entry(inst, &core->instances, list) {