Browse Source

msm: eva: Remove deprecated header

Allows compiling independent of synx, fastrpc and mmrm readiness.

Avoid including KP 2.0 deprecated headers.

Change-Id: Ibf026f409b7f6284705c95b01a5251ac6a498b32
Signed-off-by: George Shen <[email protected]>
George Shen 3 years ago
parent
commit
f8342d4cf9

+ 4 - 0
msm/eva/cvp_comm_def.h

@@ -22,4 +22,8 @@ enum queue_state {
 	QUEUE_STOP,
 	QUEUE_INVALID,
 };
+
+#define CVP_SYNX_ENABLED 1
+#define CVP_MMRM_ENABLED 1
+#define CVP_FASTRPC_ENABLED 1
 #endif

+ 0 - 1
msm/eva/cvp_hfi.h

@@ -6,7 +6,6 @@
 #ifndef __H_CVP_HFI_H__
 #define __H_CVP_HFI_H__
 
-#include <media/msm_media_info.h>
 #include "cvp_hfi_helper.h"
 #include "cvp_hfi_api.h"
 #include "cvp_comm_def.h"

+ 1 - 7
msm/eva/msm_cvp.c

@@ -1028,7 +1028,6 @@ int msm_cvp_session_delete(struct msm_cvp_inst *inst)
 int msm_cvp_session_create(struct msm_cvp_inst *inst)
 {
 	int rc = 0;
-	struct synx_initialization_params params;
 	struct cvp_session_queue *sq;
 
 	if (!inst || !inst->core)
@@ -1059,12 +1058,7 @@ int msm_cvp_session_create(struct msm_cvp_inst *inst)
 		goto fail_init;
 	}
 
-	params.name = "cvp-kernel-client";
-	if (synx_initialize(&inst->synx_session_id, &params)) {
-		dprintk(CVP_ERR, "%s synx_initialize failed\n", __func__);
-		rc = -EFAULT;
-	}
-
+	cvp_sess_init_synx(inst);
 	sq = &inst->session_queue;
 	spin_lock(&sq->lock);
 	sq->state = QUEUE_ACTIVE;

+ 5 - 0
msm/eva/msm_cvp_buf.c

@@ -9,6 +9,7 @@
 #include <linux/fs.h>
 #include <linux/dma-buf.h>
 #include <linux/sched/task.h>
+#include <linux/version.h>
 #include "msm_cvp_common.h"
 #include "cvp_hfi_api.h"
 #include "msm_cvp_debug.h"
@@ -190,7 +191,11 @@ static struct file *msm_cvp_fget(unsigned int fd, struct task_struct *task,
 
 	rcu_read_lock();
 loop:
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0))
 	file = fcheck_files(files, fd);
+#else
+	file = files_lookup_fd_rcu(files, fd);
+#endif
 	if (file) {
 		/* File object ref couldn't be taken.
 		 * dup2() atomicity guarantee is the reason

+ 0 - 1
msm/eva/msm_cvp_buf.h

@@ -10,7 +10,6 @@
 #include <linux/types.h>
 #include <linux/dma-buf.h>
 #include <linux/dma-heap.h>
-#include <linux/ion.h>
 #include <linux/msm_ion.h>
 #include <linux/refcount.h>
 #include <media/msm_eva_private.h>

+ 33 - 3
msm/eva/msm_cvp_clocks.c

@@ -8,6 +8,36 @@
 #include "msm_cvp_debug.h"
 #include "msm_cvp_clocks.h"
 
+static struct mmrm_client *__mmrm_client_register(
+				struct mmrm_client_desc *client)
+{
+#ifdef CVP_MMRM_ENABLED
+	return mmrm_client_register(client);
+#else
+	return NULL;
+#endif
+}
+
+static int __mmrm_client_deregister(struct mmrm_client *client)
+{
+#ifdef CVP_MMRM_ENABLED
+	return mmrm_client_deregister(client);
+#else
+	return -ENODEV;
+#endif
+}
+
+static int __mmrm_client_set_value_in_range(struct mmrm_client *client,
+					struct mmrm_client_data *data,
+					struct mmrm_client_res_value *val)
+{
+#ifdef CVP_MMRM_ENABLED
+	return mmrm_client_set_value_in_range(client, data, val);
+#else
+	return -ENODEV;
+#endif
+}
+
 int msm_cvp_mmrm_notifier_cb(
 	struct mmrm_client_notifier_data *notifier_data)
 {
@@ -85,7 +115,7 @@ int msm_cvp_mmrm_register(struct iris_hfi_device *device)
 		__func__, device->mmrm_desc.client_info.desc.name,
 		device->mmrm_desc.client_info.desc.client_id);
 
-	device->mmrm_cvp = mmrm_client_register(&(device->mmrm_desc));
+	device->mmrm_cvp = __mmrm_client_register(&(device->mmrm_desc));
 	if (device->mmrm_cvp == NULL) {
 		dprintk(CVP_ERR,
 			"%s: Failed mmrm_client_register with mmrm_cvp: %pK\n",
@@ -128,7 +158,7 @@ int msm_cvp_mmrm_deregister(struct iris_hfi_device *device)
 		}
 	}
 
-	rc = mmrm_client_deregister(device->mmrm_cvp);
+	rc = __mmrm_client_deregister(device->mmrm_cvp);
 	if (rc) {
 		dprintk(CVP_ERR,
 			"%s: Failed mmrm_client_deregister with rc: %d\n",
@@ -166,7 +196,7 @@ int msm_cvp_mmrm_set_value_in_range(struct iris_hfi_device *device,
 		"%s: set clock rate to min %u cur %u: %d\n",
 		__func__, val.min, val.cur, rc);
 
-	rc = mmrm_client_set_value_in_range(device->mmrm_cvp, &data, &val);
+	rc = __mmrm_client_set_value_in_range(device->mmrm_cvp, &data, &val);
 	if (rc) {
 		dprintk(CVP_ERR,
 			"%s: Failed to set clock rate to min %u cur %u: %d\n",

+ 0 - 3
msm/eva/msm_cvp_common.c

@@ -8,9 +8,6 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
-#ifndef CVP_MDT_ENABLED
-#include <soc/qcom/subsystem_restart.h>
-#endif
 #include <asm/div64.h>
 #include "msm_cvp_common.h"
 #include "cvp_hfi_api.h"

+ 1 - 2
msm/eva/msm_cvp_core.c

@@ -15,7 +15,6 @@
 #include "cvp_hfi_api.h"
 #include "msm_cvp_clocks.h"
 #include <linux/dma-buf.h>
-#include <media/msm_media_info.h>
 
 #define MAX_EVENTS 30
 #define NUM_CYCLES16X16_HCD_FRAME 95
@@ -343,7 +342,7 @@ int msm_cvp_destroy(struct msm_cvp_inst *inst)
 
 	__deinit_session_queue(inst);
 	__deinit_fence_queue(inst);
-	synx_uninitialize(inst->synx_session_id);
+	cvp_sess_deinit_synx(inst);
 
 	pr_info(CVP_DBG_TAG "Closed cvp instance: %pK session_id = %d\n",
 		"sess", inst, hash32_ptr(inst->session));

+ 0 - 1
msm/eva/msm_cvp_core.h

@@ -9,7 +9,6 @@
 #include <linux/poll.h>
 #include <linux/types.h>
 #include <linux/dma-buf.h>
-#include <linux/ion.h>
 #include <linux/msm_ion.h>
 #include <linux/refcount.h>
 #include <media/msm_eva_private.h>

+ 34 - 7
msm/eva/msm_cvp_dsp.c

@@ -20,6 +20,33 @@ static int hlosVMperm[HLOS_VM_NUM] = { PERM_READ | PERM_WRITE | PERM_EXEC };
 
 static int cvp_reinit_dsp(void);
 
+static int __fastrpc_driver_register(struct fastrpc_driver *driver)
+{
+#ifdef CVP_FASTRPC_ENABLED
+	return fastrpc_driver_register(driver);
+#else
+	return -ENODEV;
+#endif
+}
+
+static void __fastrpc_driver_unregister(struct fastrpc_driver *driver)
+{
+#ifdef CVP_FASTRPC_ENABLED
+	return fastrpc_driver_unregister(driver);
+#endif
+}
+
+static int __fastrpc_driver_invoke(struct fastrpc_device *dev,
+				enum fastrpc_driver_invoke_nums invoke_num,
+				unsigned long invoke_param)
+{
+#ifdef CVP_FASTRPC_ENABLED
+	return fastrpc_driver_invoke(dev, invoke_num, invoke_param);
+#else
+	return -ENODEV;
+#endif
+}
+
 static int cvp_dsp_send_cmd(struct cvp_dsp_cmd_msg *cmd, uint32_t len)
 {
 	int rc = 0;
@@ -83,7 +110,7 @@ static int cvp_dsp_send_cmd_hfi_queue(phys_addr_t *phys_addr,
 	cmd.type = CPU2DSP_SEND_HFI_QUEUE;
 	cmd.msg_ptr = (uint64_t)phys_addr;
 	cmd.msg_ptr_len = size_in_bytes;
-	cmd.ddr_type = of_fdt_get_ddrtype();
+	cmd.ddr_type = cvp_of_fdt_get_ddrtype();
 	if (cmd.ddr_type < 0) {
 		dprintk(CVP_WARN,
 			"%s: Incorrect DDR type value %d, use default %d\n",
@@ -315,7 +342,7 @@ static void cvp_dsp_rpmsg_remove(struct rpmsg_device *rpdev)
 			dprintk(CVP_DSP, "%s list_del fastrpc node 0x%x\n",
 					__func__, frpc_node);
 			list_del(&frpc_node->list);
-			fastrpc_driver_unregister(
+			__fastrpc_driver_unregister(
 				&frpc_node->cvp_fastrpc_driver);
 			dprintk(CVP_DSP,
 				"%s Unregistered fastrpc handle 0x%x\n",
@@ -866,7 +893,7 @@ static int eva_fastrpc_dev_map_dma(struct fastrpc_device *frpc_device,
 			"%s frpc_map_buf size %d, dma_buf %pK, map %pK, 0x%x\n",
 			__func__, frpc_map_buf.size, frpc_map_buf.buf,
 			&frpc_map_buf, (unsigned long)&frpc_map_buf);
-		rc = fastrpc_driver_invoke(frpc_device, FASTRPC_DEV_MAP_DMA,
+		rc = __fastrpc_driver_invoke(frpc_device, FASTRPC_DEV_MAP_DMA,
 			(unsigned long)(&frpc_map_buf));
 		if (rc) {
 			dprintk(CVP_ERR,
@@ -892,7 +919,7 @@ static int eva_fastrpc_dev_unmap_dma(struct fastrpc_device *frpc_device,
 	/* Only if buffer is mapped to dsp */
 	if (buf->fd != 0) {
 		frpc_unmap_buf.buf = buf->smem->dma_buf;
-		rc = fastrpc_driver_invoke(frpc_device, FASTRPC_DEV_UNMAP_DMA,
+		rc = __fastrpc_driver_invoke(frpc_device, FASTRPC_DEV_UNMAP_DMA,
 				(unsigned long)(&frpc_unmap_buf));
 		if (rc) {
 			dprintk(CVP_ERR, "%s Failed to unmap buffer 0x%x\n",
@@ -1022,7 +1049,7 @@ static int eva_fastrpc_driver_register(uint32_t handle)
 		INIT_MSM_CVP_LIST(&frpc_node->dsp_sessions);
 
 		/* register fastrpc device to this session */
-		rc = fastrpc_driver_register(&frpc_node->cvp_fastrpc_driver);
+		rc = __fastrpc_driver_register(&frpc_node->cvp_fastrpc_driver);
 		if (rc) {
 			dprintk(CVP_ERR, "%s fastrpc driver reg fail err %d\n",
 				__func__, rc);
@@ -1045,7 +1072,7 @@ static int eva_fastrpc_driver_register(uint32_t handle)
 	return rc;
 
 fail_fastrpc_driver_timeout:
-	fastrpc_driver_unregister(&frpc_node->cvp_fastrpc_driver);
+	__fastrpc_driver_unregister(&frpc_node->cvp_fastrpc_driver);
 fail_fastrpc_driver_register:
 	/* remove list if this is the last session */
 	mutex_lock(&me->fastrpc_driver_list.lock);
@@ -1089,7 +1116,7 @@ static void eva_fastrpc_driver_unregister(uint32_t handle, bool force_exit)
 		list_del(&frpc_node->list);
 		mutex_unlock(&me->fastrpc_driver_list.lock);
 
-		fastrpc_driver_unregister(&frpc_node->cvp_fastrpc_driver);
+		__fastrpc_driver_unregister(&frpc_node->cvp_fastrpc_driver);
 		mutex_lock(&me->driver_name_lock);
 		eva_fastrpc_driver_release_name(frpc_node);
 		mutex_unlock(&me->driver_name_lock);

+ 0 - 1
msm/eva/msm_cvp_internal.h

@@ -20,7 +20,6 @@
 #include <linux/kthread.h>
 #include <linux/dma-mapping.h>
 #include "msm_cvp_core.h"
-#include <media/msm_media_info.h>
 #include <media/msm_eva_private.h>
 #include "cvp_hfi_api.h"
 #include "cvp_hfi_helper.h"

+ 79 - 1
msm/eva/msm_cvp_platform.c

@@ -99,6 +99,62 @@ static struct msm_cvp_common_data sm8450_common_data[] = {
 	}
 };
 
+static struct msm_cvp_common_data sm8550_common_data[] = {
+	{
+		.key = "qcom,auto-pil",
+		.value = 0,
+	},
+	{
+		.key = "qcom,never-unload-fw",
+		.value = 1,
+	},
+	{
+		.key = "qcom,sw-power-collapse",
+		.value = 0,
+	},
+	{
+		.key = "qcom,domain-attr-non-fatal-faults",
+		.value = 0,
+	},
+	{
+		.key = "qcom,max-secure-instances",
+		.value = 2,             /*
+					 * As per design driver allows 3rd
+					 * instance as well since the secure
+					 * flags were updated later for the
+					 * current instance. Hence total
+					 * secure sessions would be
+					 * max-secure-instances + 1.
+					 */
+	},
+	{
+		.key = "qcom,max-ssr-allowed",
+		.value = 1,		/*
+					 * Maxinum number of SSR before BUG_ON
+					 */
+	},
+	{
+		.key = "qcom,power-collapse-delay",
+		.value = 3000,
+	},
+	{
+		.key = "qcom,hw-resp-timeout",
+		.value = 2000,
+	},
+	{
+		.key = "qcom,dsp-resp-timeout",
+		.value = 1000,
+	},
+	{
+		.key = "qcom,debug-timeout",
+		.value = 0,
+	},
+	{
+		.key = "qcom,dsp-enabled",
+		.value = 0,
+	}
+};
+
 
 
 /* Default UBWC config for LPDDR5 */
@@ -123,12 +179,24 @@ static struct msm_cvp_platform_data sm8450_data = {
 	.ubwc_config = kona_ubwc_data,
 };
 
+static struct msm_cvp_platform_data sm8550_data = {
+	.common_data = sm8550_common_data,
+	.common_data_length =  ARRAY_SIZE(sm8550_common_data),
+	.sku_version = 0,
+	.vpu_ver = VPU_VERSION_5,
+	.ubwc_config = kona_ubwc_data,
+};
 
 static const struct of_device_id msm_cvp_dt_match[] = {
 	{
 		.compatible = "qcom,waipio-cvp",
 		.data = &sm8450_data,
 	},
+	{
+		.compatible = "qcom,kailua-cvp",
+		.data = &sm8550_data,
+	},
+
 	{},
 };
 
@@ -394,6 +462,16 @@ int get_pkt_index(struct cvp_hal_session_cmd_pkt *hdr)
 
 MODULE_DEVICE_TABLE(of, msm_cvp_dt_match);
 
+int cvp_of_fdt_get_ddrtype(void)
+{
+#ifdef FIXED_DDR_TYPE
+	/* of_fdt_get_ddrtype() is usually unavailable during pre-sil */
+	return DDR_TYPE_LPDDR5;
+#else
+	return of_fdt_get_ddrtype();
+#endif
+}
+
 void *cvp_get_drv_data(struct device *dev)
 {
 	struct msm_cvp_platform_data *driver_data;
@@ -413,7 +491,7 @@ void *cvp_get_drv_data(struct device *dev)
 	driver_data = (struct msm_cvp_platform_data *)match->data;
 
 	if (!strcmp(match->compatible, "qcom,waipio-cvp")) {
-		ddr_type = of_fdt_get_ddrtype();
+		ddr_type = cvp_of_fdt_get_ddrtype();
 		if (ddr_type == -ENOENT) {
 			dprintk(CVP_ERR,
 				"Failed to get ddr type, use LPDDR5\n");

+ 1 - 0
msm/eva/msm_cvp_resources.h

@@ -188,5 +188,6 @@ static inline bool is_iommu_present(struct msm_cvp_platform_resources *res)
 	return !list_empty(&res->context_banks);
 }
 
+int cvp_of_fdt_get_ddrtype(void);
 #endif
 

+ 25 - 1
msm/eva/msm_cvp_synx.c

@@ -9,6 +9,30 @@
 #include "msm_cvp_core.h"
 #include "msm_cvp_dsp.h"
 
+#ifdef CVP_SYNX_ENABLED
+int cvp_sess_init_synx(struct msm_cvp_inst *inst)
+{
+	struct synx_initialization_params params;
+
+	params.name = "cvp-kernel-client";
+	if (synx_initialize(&inst->synx_session_id, &params)) {
+		dprintk(CVP_ERR, "%s synx_initialize failed\n", __func__);
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+int cvp_sess_deinit_synx(struct msm_cvp_inst *inst)
+{
+	if (!inst) {
+		dprintk(CVP_ERR, "Used invalid sess in deinit_synx\n");
+		return -EINVAL;
+	}
+	synx_uninitialize(inst->synx_session_id);
+	return 0;
+}
+
 void cvp_dump_fence_queue(struct msm_cvp_inst *inst)
 {
 	struct cvp_fence_queue *q;
@@ -242,4 +266,4 @@ int cvp_synx_ops(struct msm_cvp_inst *inst, enum cvp_synx_type type,
 		return -EINVAL;
 	}
 }
-
+#endif

+ 48 - 0
msm/eva/msm_cvp_synx.h

@@ -44,6 +44,9 @@ enum cvp_synx_type {
 	CVP_INVALID_SYNX,
 };
 
+#ifdef CVP_SYNX_ENABLED
+int cvp_sess_init_synx(struct msm_cvp_inst *inst);
+int cvp_sess_deinit_synx(struct msm_cvp_inst *inst);
 int cvp_import_synx(struct msm_cvp_inst *inst, struct cvp_fence_command *fc,
 		u32 *fence);
 int cvp_release_synx(struct msm_cvp_inst *inst, struct cvp_fence_command *fc);
@@ -52,4 +55,49 @@ int cvp_cancel_synx(struct msm_cvp_inst *inst, enum cvp_synx_type type,
 int cvp_synx_ops(struct msm_cvp_inst *inst, enum cvp_synx_type type,
 		struct cvp_fence_command *fc, u32 *synx_state);
 void cvp_dump_fence_queue(struct msm_cvp_inst *inst);
+#else
+static inline int cvp_sess_init_synx(struct msm_cvp_inst *inst)
+{
+	return -ENODEV;
+}
+
+static inline int cvp_sess_deinit_synx(struct msm_cvp_inst *inst)
+{
+	return -ENODEV;
+}
+
+static inline int cvp_import_synx(struct msm_cvp_inst *inst,
+				struct cvp_fence_command *fc,
+				u32 *fence)
+{
+	return -ENODEV;
+}
+
+static inline int cvp_release_synx(struct msm_cvp_inst *inst,
+				struct cvp_fence_command *fc)
+{
+	return -ENODEV;
+}
+
+static inline int cvp_cancel_synx(struct msm_cvp_inst *inst,
+				enum cvp_synx_type type,
+				struct cvp_fence_command *fc,
+				int synx_state)
+{
+	return -ENODEV;
+}
+
+static inline int cvp_synx_ops(struct msm_cvp_inst *inst,
+			enum cvp_synx_type type,
+			struct cvp_fence_command *fc,
+			u32 *synx_state)
+{
+	return -ENODEV;
+}
+
+static inline void cvp_dump_fence_queue(struct msm_cvp_inst *inst)
+{
+	return;
+}
+#endif
 #endif

+ 35 - 3
msm/eva/msm_smem.c

@@ -8,19 +8,51 @@
 #include <linux/dma-direction.h>
 #include <linux/iommu.h>
 #include <linux/msm_dma_iommu_mapping.h>
-#include <linux/ion.h>
 #include <linux/msm_ion.h>
 #include <soc/qcom/secure_buffer.h>
 #include <linux/mem-buf.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/qcom-dma-mapping.h>
+#include <linux/version.h>
 #include "msm_cvp_core.h"
 #include "msm_cvp_debug.h"
 #include "msm_cvp_resources.h"
 #include "cvp_core_hfi.h"
 #include "msm_cvp_dsp.h"
 
+static void * __cvp_dma_buf_vmap(struct dma_buf *dbuf)
+{
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0))
+	return dma_buf_vmap(dbuf);
+#else
+	struct dma_buf_map map;
+	void *dma_map;
+	int err;
+
+	err = dma_buf_vmap(dbuf, &map);
+	dma_map = err ? NULL : map.vaddr;
+	if (!dma_map)
+		dprintk(CVP_ERR, "map to kvaddr failed\n");
+
+	return dma_map;
+#endif
+}
+
+static void __cvp_dma_buf_vunmap(void *vaddr, struct dma_buf *dbuf)
+{
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0))
+	dma_buf_vunmap(dbuf, vaddr);
+#else
+	struct dma_buf_map map = { \
+			.vaddr = vaddr, \
+			.is_iomem = false, \
+	};
+
+	if (vaddr)
+		dma_buf_vunmap(dbuf, &map);
+#endif
+}
 
 static int msm_dma_get_device_address(struct dma_buf *dbuf, u32 align,
 	dma_addr_t *iova, u32 flags, struct msm_cvp_platform_resources *res,
@@ -335,7 +367,7 @@ static int alloc_dma_mem(size_t size, u32 align, int map_kernel,
 
 	if (map_kernel) {
 		dma_buf_begin_cpu_access(dbuf, DMA_BIDIRECTIONAL);
-		mem->kvaddr = dma_buf_vmap(dbuf);
+		mem->kvaddr = __cvp_dma_buf_vmap(dbuf);
 		if (!mem->kvaddr) {
 			dprintk(CVP_ERR,
 				"Failed to map shared mem in kernel\n");
@@ -371,7 +403,7 @@ static int free_dma_mem(struct msm_cvp_smem *mem)
 	}
 
 	if (mem->kvaddr) {
-		dma_buf_vunmap(mem->dma_buf, mem->kvaddr);
+		__cvp_dma_buf_vunmap(mem->dma_buf, mem->kvaddr);
 		mem->kvaddr = NULL;
 		dma_buf_end_cpu_access(mem->dma_buf, DMA_BIDIRECTIONAL);
 	}