Browse Source

Merge dabc96ecf3afbf9ae9267e364756168e7a5fc381 on remote branch

Change-Id: Id815d7111b1ab4784c6a9e529ae04fd7d9ed7a4e
Linux Build Service Account 2 năm trước cách đây
mục cha
commit
329646f071
7 tập tin đã thay đổi với 479 bổ sung389 xóa
  1. 2 0
      Android.mk
  2. 1 0
      Kbuild
  3. 8 2
      define_modules.bzl
  4. 171 105
      dsp/adsprpc.c
  5. 10 282
      dsp/adsprpc_shared.h
  6. 3 0
      dsp/adsprpc_socket.c
  7. 284 0
      include/uapi/fastrpc_shared.h

+ 2 - 0
Android.mk

@@ -13,6 +13,8 @@ LOCAL_PATH := $(call my-dir)
 
 DSP_BLD_DIR := $(abspath .)/vendor/qcom/opensource/dsp-kernel
 
+LOCAL_MODULE_DDK_BUILD := true
+
 include $(CLEAR_VARS)
 $(info DLKM_DIR = $(DLKM_DIR))
 LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)

+ 1 - 0
Kbuild

@@ -20,6 +20,7 @@ ccflags-y += -DCONFIG_DSP_PINEAPPLE=1
 endif
 
 LINUXINCLUDE += -I$(DSP_ROOT)/include/linux
+LINUXINCLUDE += -I$(DSP_ROOT)/include/uapi
 
 frpc-adsprpc-y := dsp/adsprpc.o	\
                   dsp/adsprpc_rpmsg.o \

+ 8 - 2
define_modules.bzl

@@ -30,8 +30,14 @@ def define_modules(target, variant):
         ],
         local_defines = ["DSP_TRACE_INCLUDE_PATH={}".format(trace_include_path)],
         out = "frpc-adsprpc.ko",
-        hdrs = ["include/linux/fastrpc.h"],
-        includes = ["include/linux"],
+        hdrs = [
+            "include/linux/fastrpc.h",
+            "include/uapi/fastrpc_shared.h",
+        ],
+        includes = [
+            "include/linux",
+            "include/uapi",
+        ],
     )
 
     ddk_module(

+ 171 - 105
dsp/adsprpc.c

@@ -22,6 +22,7 @@
 #include <linux/sched.h>
 #include <linux/module.h>
 #include <linux/list.h>
+#include <linux/arch_topology.h>
 #include <linux/hash.h>
 #include <linux/msm_ion.h>
 #include <linux/qcom_scm.h>
@@ -54,6 +55,7 @@
 #include <linux/iommu.h>
 #include <asm/arch_timer.h>
 #include <linux/genalloc.h>
+#include <soc/qcom/socinfo.h>
 
 #ifdef CONFIG_HIBERNATION
 #include <linux/suspend.h>
@@ -141,6 +143,10 @@
 #define ION_FLAG_CACHED (1)
 #endif
 
+#ifndef topology_cluster_id
+#define topology_cluster_id(cpu) topology_physical_package_id(cpu)
+#endif
+
 /*
  * ctxid of every message is OR-ed with fastrpc_remote_pd_type before
  * it is sent to DSP. So mask 2 LSBs to retrieve actual context
@@ -957,6 +963,8 @@ static int fastrpc_mmap_remove(struct fastrpc_file *fl, int fd, uintptr_t va,
 		if ((fd < 0 || map->fd == fd) && map->raddr == va &&
 			map->raddr + map->len == va + len &&
 			map->refs == 1 &&
+			/* Remove map only if it isn't being used in any pending RPC calls */
+			!map->ctx_refs &&
 			/* Skip unmap if it is fastrpc shell memory */
 			!map->is_filemap) {
 			match = map;
@@ -997,7 +1005,7 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags)
 				map->flags == ADSP_MMAP_REMOTE_HEAP_ADDR) {
 		spin_lock_irqsave(&me->hlock, irq_flags);
 		map->refs--;
-		if (!map->refs && !map->is_persistent)
+		if (!map->refs && !map->is_persistent && !map->ctx_refs)
 			hlist_del_init(&map->hn);
 		spin_unlock_irqrestore(&me->hlock, irq_flags);
 		if (map->refs > 0) {
@@ -1012,7 +1020,7 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags)
 		spin_unlock_irqrestore(&me->hlock, irq_flags);
 	} else {
 		map->refs--;
-		if (!map->refs)
+		if (!map->refs && !map->ctx_refs)
 			hlist_del_init(&map->hn);
 		if (map->refs > 0 && !flags)
 			return;
@@ -1953,8 +1961,15 @@ static void context_free(struct smq_invoke_ctx *ctx)
 	spin_unlock(&ctx->fl->hlock);
 
 	mutex_lock(&ctx->fl->map_mutex);
-	for (i = 0; i < nbufs; ++i)
+	for (i = 0; i < nbufs; ++i) {
+		/*
+		 * Decrement ctx refs count before mmap free,
+		 * indicate remote call no longer using it
+		 */
+		if (ctx->maps[i] && ctx->maps[i]->ctx_refs)
+			ctx->maps[i]->ctx_refs--;
 		fastrpc_mmap_free(ctx->maps[i], 0);
+	}
 	mutex_unlock(&ctx->fl->map_mutex);
 
 	fastrpc_buf_free(ctx->buf, 1);
@@ -2342,6 +2357,12 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
 			err = fastrpc_mmap_create(ctx->fl, ctx->fds[i], NULL,
 					ctx->attrs[i], buf, len,
 					mflags, &ctx->maps[i]);
+		 /*
+		  * Increment ctx refs count for in/out buffer if map created,
+		  * indicate map under use in remote call
+		  */
+		if (ctx->maps[i])
+			ctx->maps[i]->ctx_refs++;
 		mutex_unlock(&ctx->fl->map_mutex);
 		if (err)
 			goto bail;
@@ -2369,10 +2390,23 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
 					FASTRPC_ATTR_NOVA, 0, 0, dmaflags,
 					&ctx->maps[i]);
 		if (err) {
-			for (j = bufs; j < i; j++)
+			for (j = bufs; j < i; j++) {
+				/*
+				 * Due to error decrement ctx refs count before mmap free
+				 * for each in/out handle, if map created
+				 */
+				if (ctx->maps[j] && ctx->maps[j]->ctx_refs)
+					ctx->maps[j]->ctx_refs--;
 				fastrpc_mmap_free(ctx->maps[j], 0);
+			}
 			mutex_unlock(&ctx->fl->map_mutex);
 			goto bail;
+		} else if (ctx->maps[i]) {
+			/*
+			 * Increment ctx refs count for in/out handle if map created
+			 * and no error, indicate map under use in remote call
+			 */
+			ctx->maps[i]->ctx_refs++;
 		}
 		ipage += 1;
 	}
@@ -2704,6 +2738,12 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx,
 			}
 		} else {
 			mutex_lock(&ctx->fl->map_mutex);
+			/*
+			 * Decrement ctx refs count before mmap free,
+			 * indicate remote call no longer using it
+			 */
+			if (ctx->maps[i]->ctx_refs)
+				ctx->maps[i]->ctx_refs--;
 			fastrpc_mmap_free(ctx->maps[i], 0);
 			mutex_unlock(&ctx->fl->map_mutex);
 			ctx->maps[i] = NULL;
@@ -2714,8 +2754,15 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx,
 		if (!fdlist[i])
 			break;
 		if (!fastrpc_mmap_find(ctx->fl, (int)fdlist[i], NULL, 0, 0,
-					0, 0, &mmap))
+					0, 0, &mmap)) {
+			/*
+			 * Decrement ctx refs count before mmap free,
+			 * indicate remote call no longer using it
+			 */
+			if (mmap && mmap->ctx_refs)
+				mmap->ctx_refs--;
 			fastrpc_mmap_free(mmap, 0);
+		}
 	}
 	mutex_unlock(&ctx->fl->map_mutex);
 	if (ctx->crc && crclist && rpra)
@@ -2825,6 +2872,7 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
 {
 	struct smq_msg *msg = &ctx->msg;
 	struct smq_msg msg_temp;
+	struct smq_invoke_ctx ctx_temp;
 	struct fastrpc_file *fl = ctx->fl;
 	struct fastrpc_channel_ctx *channel_ctx = NULL;
 	int err = 0, cid = -1;
@@ -2832,6 +2880,8 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
 	int64_t ns = 0;
 	uint64_t xo_time_in_us = 0;
 	int isasync = (ctx->asyncjob.isasyncjob ? true : false);
+	unsigned long irq_flags = 0;
+	uint32_t index = 0;
 
 	if (!fl) {
 		err = -EBADF;
@@ -2870,16 +2920,27 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
 		/*
 		 * After message is sent to DSP, async response thread could immediately
 		 * get the response and free context, which will result in a use-after-free
-		 * in this function. So use a local variable for message.
+		 * in this function. So use a local variable for message and context.
 		 */
 		memcpy(&msg_temp, msg, sizeof(struct smq_msg));
 		msg = &msg_temp;
+		memcpy(&ctx_temp, ctx, sizeof(struct smq_invoke_ctx));
+		index = (uint32_t)GET_TABLE_IDX_FROM_CTXID(ctx->ctxid);
 	}
+
 	err = fastrpc_transport_send(cid, (void *)msg, sizeof(*msg), fl->tvm_remote_domain);
-	if (isasync && !err) {
-		spin_lock(&fl->hlock);
-		ctx->is_job_sent_to_remote_ss = true;
-		spin_unlock(&fl->hlock);
+	if (isasync) {
+		if (!err) {
+			/*
+			 * Validate the ctx as this could have been already
+			 * freed by async response.
+			 */
+			spin_lock_irqsave(&channel_ctx->ctxlock, irq_flags);
+			if (index < FASTRPC_CTX_MAX && channel_ctx->ctxtable[index] == ctx)
+				ctx->is_job_sent_to_remote_ss = true;
+			spin_unlock_irqrestore(&channel_ctx->ctxlock, irq_flags);
+		}
+		ctx = &ctx_temp;
 	}
 	trace_fastrpc_transport_send(cid, (uint64_t)ctx, msg->invoke.header.ctx,
 		handle, sc, msg->invoke.page.addr, msg->invoke.page.size);
@@ -2889,34 +2950,42 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
 	return err;
 }
 
-/*
- * fastrpc_get_dsp_status - Reads the property string from device node
- *                          and updates the cdsp device avialbility status
- *                          if the node belongs to cdsp device.
+/* fastrpc_get_nsp_status() - Reads the property string from soc_info
+ * denoted for nsp part, and updates the nsp device avialbility status
+ * if the nsp is not defective.
  * @me  : pointer to fastrpc_apps.
  */
 
-static void fastrpc_get_dsp_status(struct fastrpc_apps *me)
+static void fastrpc_get_nsp_status(struct fastrpc_apps *me)
 {
-	int ret = -1;
-	struct device_node *node = NULL;
-	const char *name = NULL;
+	if (socinfo_get_part_info(PART_NSP)) {
+		me->fastrpc_nsp_status = 0;
+		ADSPRPC_ERR(
+			"nsp part defective with status:%x\n", me->fastrpc_nsp_status);
+	} else {
+		me->fastrpc_nsp_status = 1;
+		ADSPRPC_INFO("nsp available with status: %x\n", me->fastrpc_nsp_status);
+	}
+}
 
-	do {
-		node = of_find_compatible_node(node, NULL, "qcom,pil-tz-generic");
-		if (node) {
-			ret = of_property_read_string(node, "qcom,firmware-name", &name);
-			if (!strcmp(name, "cdsp")) {
-				ret =  of_device_is_available(node);
-				me->remote_cdsp_status = ret;
-				ADSPRPC_INFO("cdsp node found with ret:%x\n", ret);
-				break;
-			}
-		} else {
-			ADSPRPC_ERR("cdsp node not found\n");
-			break;
-		}
-	} while (1);
+/*
+ * Counts number of cores corresponding
+ * to cluster id 0. If a core is defective or unavailable, skip counting
+ * that core.
+ * @me : pointer to fastrpc_apps.
+ */
+
+static void fastrpc_lowest_capacity_corecount(struct fastrpc_apps *me)
+{
+	unsigned int cpu = 0;
+
+	cpu =  cpumask_first(cpu_possible_mask);
+	for_each_cpu(cpu, cpu_possible_mask) {
+		if (topology_cluster_id(cpu) == 0)
+			me->lowest_capacity_core_count++;
+	}
+	ADSPRPC_INFO("lowest capacity core count: %u\n",
+					me->lowest_capacity_core_count);
 }
 
 static void fastrpc_init(struct fastrpc_apps *me)
@@ -5702,8 +5771,17 @@ static int fastrpc_file_free(struct fastrpc_file *fl)
 
 	spin_lock_irqsave(&fl->apps->hlock, irq_flags);
 	is_locked = true;
-	if (fl->is_dma_invoke_pend)
-		wait_for_completion(&fl->dma_invoke);
+	if (!fl->is_dma_invoke_pend)
+		goto skip_dmainvoke_wait;
+	is_locked = false;
+	spin_unlock_irqrestore(&fl->apps->hlock, irq_flags);
+	wait_for_completion(&fl->dma_invoke);
+
+skip_dmainvoke_wait:
+	if (!is_locked) {
+		spin_lock_irqsave(&fl->apps->hlock, irq_flags);
+		is_locked = true;
+	}
 	if (!fl->is_ramdump_pend)
 		goto skip_dump_wait;
 	is_locked = false;
@@ -5787,13 +5865,13 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
 {
 	struct fastrpc_file *fl = (struct fastrpc_file *)file->private_data;
 	struct fastrpc_apps *me = &gfa;
-	u32 ii;
+	unsigned int ii;
 
 	if (!fl)
 		return 0;
 
 	if (fl->qos_request && fl->dev_pm_qos_req) {
-		for (ii = 0; ii < me->silvercores.corecount; ii++) {
+		for (ii = 0; ii < me->lowest_capacity_core_count; ii++) {
 			if (!dev_pm_qos_request_active(&fl->dev_pm_qos_req[ii]))
 				continue;
 			dev_pm_qos_remove_request(&fl->dev_pm_qos_req[ii]);
@@ -6190,9 +6268,10 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
 	spin_lock_irqsave(&me->hlock, irq_flags);
 	hlist_add_head(&fl->hn, &me->drivers);
 	spin_unlock_irqrestore(&me->hlock, irq_flags);
-	fl->dev_pm_qos_req = kcalloc(me->silvercores.corecount,
-				sizeof(struct dev_pm_qos_request),
-				GFP_KERNEL);
+	if (me->lowest_capacity_core_count)
+		fl->dev_pm_qos_req = kzalloc((me->lowest_capacity_core_count) *
+						sizeof(struct dev_pm_qos_request),
+							GFP_KERNEL);
 	spin_lock_init(&fl->dspsignals_lock);
 	mutex_init(&fl->signal_create_mutex);
 	init_completion(&fl->shutdown);
@@ -6390,7 +6469,7 @@ int fastrpc_internal_control(struct fastrpc_file *fl,
 	unsigned int latency;
 	struct fastrpc_apps *me = &gfa;
 	int sessionid = 0;
-	u32 silver_core_count = me->silvercores.corecount, ii = 0, cpu;
+	unsigned int cpu;
 	unsigned long flags = 0;
 
 	VERIFY(err, !IS_ERR_OR_NULL(fl) && !IS_ERR_OR_NULL(fl->apps));
@@ -6414,23 +6493,29 @@ int fastrpc_internal_control(struct fastrpc_file *fl,
 			goto bail;
 		}
 
-		VERIFY(err, me->silvercores.coreno && fl->dev_pm_qos_req);
+		VERIFY(err, (me->lowest_capacity_core_count && fl->dev_pm_qos_req));
 		if (err) {
+			ADSPRPC_INFO("Skipping PM QoS latency voting, core count: %u\n",
+						me->lowest_capacity_core_count);
 			err = -EINVAL;
 			goto bail;
 		}
+		/*
+		 * Add voting request for all possible cores corresponding to cluster
+		 * id 0. If DT property 'qcom,single-core-latency-vote' is enabled
+		 * then add voting request for only one core of cluster id 0.
+		 */
+		for (cpu = 0; cpu < me->lowest_capacity_core_count; cpu++) {
 
-		for (ii = 0; ii < silver_core_count; ii++) {
-			cpu = me->silvercores.coreno[ii];
 			if (!fl->qos_request) {
 				err = dev_pm_qos_add_request(
 						get_cpu_device(cpu),
-						&fl->dev_pm_qos_req[ii],
+						&fl->dev_pm_qos_req[cpu],
 						DEV_PM_QOS_RESUME_LATENCY,
 						latency);
 			} else {
 				err = dev_pm_qos_update_request(
-						&fl->dev_pm_qos_req[ii],
+						&fl->dev_pm_qos_req[cpu],
 						latency);
 			}
 			/* PM QoS request APIs return 0 or 1 on success */
@@ -6444,7 +6529,6 @@ int fastrpc_internal_control(struct fastrpc_file *fl,
 			fl->qos_request = 1;
 			err = 0;
 		}
-
 		/* Ensure CPU feature map updated to DSP for early WakeUp */
 		fastrpc_send_cpuinfo_to_dsp(fl);
 		break;
@@ -7485,6 +7569,14 @@ static void  fastrpc_print_debug_data(int cid)
 	kfree(gmsg_log_rx);
 }
 
+void fastrpc_restart_drivers(int cid)
+{
+	struct fastrpc_apps *me = &gfa;
+
+	fastrpc_notify_drivers(me, cid);
+	me->channel[cid].ssrcount++;
+}
+
 static int fastrpc_restart_notifier_cb(struct notifier_block *nb,
 					unsigned long code,
 					void *data)
@@ -7868,39 +7960,6 @@ bail:
 	}
 }
 
-static void init_qos_cores_list(struct device *dev, char *prop_name,
-						struct qos_cores *silvercores)
-{
-	int err = 0;
-	u32 len = 0, i = 0;
-	u32 *coreslist = NULL;
-
-	if (!of_find_property(dev->of_node, prop_name, &len))
-		goto bail;
-	if (len == 0)
-		goto bail;
-	len /= sizeof(u32);
-	VERIFY(err, NULL != (coreslist = kcalloc(len, sizeof(u32),
-						 GFP_KERNEL)));
-	if (err)
-		goto bail;
-	for (i = 0; i < len; i++) {
-		err = of_property_read_u32_index(dev->of_node, prop_name, i,
-								&coreslist[i]);
-		if (err) {
-			pr_err("adsprpc: %s: failed to read QOS cores list\n",
-								 __func__);
-			goto bail;
-		}
-	}
-	silvercores->coreno = coreslist;
-	silvercores->corecount = len;
-bail:
-	if (err)
-		kfree(coreslist);
-
-}
-
 static void fastrpc_init_privileged_gids(struct device *dev, char *prop_name,
 						struct gid_list *gidlist)
 {
@@ -7999,15 +8058,15 @@ bail:
 }
 
 /*
- * remote_cdsp_status_show - Updates the buffer with remote cdsp status
- *                           by reading the fastrpc node.
+ * fastrpc_nsp_status_show() - Updates the buffer with remote nsp status
+ * by reading the fastrpc node.
  * @dev : pointer to device node.
  * @attr: pointer to device attribute.
- * @buf : Output parameter to be updated with remote cdsp status.
+ * @buf : Output parameter to be updated with remote nsp status.
  * Return : bytes written to buffer.
  */
 
-static ssize_t remote_cdsp_status_show(struct device *dev,
+static ssize_t fastrpc_nsp_status_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct fastrpc_apps *me = &gfa;
@@ -8024,15 +8083,15 @@ static ssize_t remote_cdsp_status_show(struct device *dev,
 	}
 
 	return scnprintf(buf, PAGE_SIZE, "%d",
-			me->remote_cdsp_status);
+			me->fastrpc_nsp_status);
 }
 
-/* Remote cdsp status attribute declaration as read only */
-static DEVICE_ATTR_RO(remote_cdsp_status);
+/* Remote nsp status attribute declaration as read only */
+static DEVICE_ATTR_RO(fastrpc_nsp_status);
 
 /* Declaring attribute for remote dsp */
 static struct attribute *msm_remote_dsp_attrs[] = {
-	&dev_attr_remote_cdsp_status.attr,
+	&dev_attr_fastrpc_nsp_status.attr,
 	NULL
 };
 
@@ -8062,9 +8121,14 @@ static int fastrpc_probe(struct platform_device *pdev)
 							&gcinfo[0].rhvm);
 		fastrpc_init_privileged_gids(dev, "qcom,fastrpc-gids",
 					&me->gidlist);
-		init_qos_cores_list(dev, "qcom,qos-cores",
-							&me->silvercores);
-
+		/*
+		 * Check if latency voting for only one core
+		 * is enabled for the platform
+		 */
+		me->single_core_latency_vote = of_property_read_bool(dev->of_node,
+							"qcom,single-core-latency-vote");
+		if (me->single_core_latency_vote)
+			me->lowest_capacity_core_count = 1;
 		of_property_read_u32(dev->of_node, "qcom,rpc-latency-us",
 			&me->latency);
 		if (of_get_property(dev->of_node,
@@ -8433,32 +8497,33 @@ static struct device fastrpc_bus = {
 
 static int fastrpc_bus_match(struct device *dev, struct device_driver *driver)
 {
+	struct fastrpc_apps *me = &gfa;
 	struct fastrpc_driver *frpc_driver = to_fastrpc_driver(driver);
 	struct fastrpc_device *frpc_device = to_fastrpc_device(dev);
+	unsigned long irq_flags = 0;
 
-	if (frpc_device->handle == frpc_driver->handle)
+	if (frpc_device->handle == frpc_driver->handle) {
+		spin_lock_irqsave(&me->hlock, irq_flags);
+		/* If device is being closed, fail the match */
+		if (frpc_device->dev_close) {
+			spin_unlock_irqrestore(&me->hlock, irq_flags);
+			return 0;
+		}
+		frpc_device->refs++;
+		frpc_driver->device = dev;
+		spin_unlock_irqrestore(&me->hlock, irq_flags);
 		return 1;
+	}
 	return 0;
 }
 
 static int fastrpc_bus_probe(struct device *dev)
 {
-	struct fastrpc_apps *me = &gfa;
 	struct fastrpc_device *frpc_dev = to_fastrpc_device(dev);
 	struct fastrpc_driver *frpc_drv = to_fastrpc_driver(dev->driver);
-	unsigned long irq_flags = 0;
 
-	if (frpc_drv && frpc_drv->probe) {
-		spin_lock_irqsave(&me->hlock, irq_flags);
-		if (frpc_dev->dev_close) {
-			spin_unlock_irqrestore(&me->hlock, irq_flags);
-			return 0;
-		}
-		frpc_dev->refs++;
-		frpc_drv->device = dev;
-		spin_unlock_irqrestore(&me->hlock, irq_flags);
+	if (frpc_drv && frpc_drv->probe)
 		return frpc_drv->probe(frpc_dev);
-	}
 
 	return 0;
 }
@@ -8598,7 +8663,7 @@ static int __init fastrpc_device_init(void)
 	}
 	memset(me, 0, sizeof(*me));
 	fastrpc_init(me);
-	fastrpc_get_dsp_status(me);
+	fastrpc_get_nsp_status(me);
 	me->dev = NULL;
 	me->legacy_remote_heap = false;
 	err = bus_register(&fastrpc_bus_type);
@@ -8614,6 +8679,7 @@ static int __init fastrpc_device_init(void)
 		goto bus_device_register_bail;
 	}
 	me->fastrpc_bus_register = true;
+	fastrpc_lowest_capacity_corecount(me);
 	VERIFY(err, 0 == platform_driver_register(&fastrpc_driver));
 	if (err)
 		goto register_bail;

+ 10 - 282
dsp/adsprpc_shared.h

@@ -8,38 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/cdev.h>
-
-#define FASTRPC_IOCTL_INVOKE	_IOWR('R', 1, struct fastrpc_ioctl_invoke)
-#define FASTRPC_IOCTL_MMAP	_IOWR('R', 2, struct fastrpc_ioctl_mmap)
-#define FASTRPC_IOCTL_MUNMAP	_IOWR('R', 3, struct fastrpc_ioctl_munmap)
-#define FASTRPC_IOCTL_MMAP_64	_IOWR('R', 14, struct fastrpc_ioctl_mmap_64)
-#define FASTRPC_IOCTL_MUNMAP_64	_IOWR('R', 15, struct fastrpc_ioctl_munmap_64)
-#define FASTRPC_IOCTL_INVOKE_FD	_IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
-#define FASTRPC_IOCTL_SETMODE	_IOWR('R', 5, uint32_t)
-#define FASTRPC_IOCTL_INIT	_IOWR('R', 6, struct fastrpc_ioctl_init)
-#define FASTRPC_IOCTL_INVOKE_ATTRS \
-				_IOWR('R', 7, struct fastrpc_ioctl_invoke_attrs)
-#define FASTRPC_IOCTL_GETINFO	_IOWR('R', 8, uint32_t)
-//#define FASTRPC_IOCTL_GETPERF	_IOWR('R', 9, struct fastrpc_ioctl_perf)
-#define FASTRPC_IOCTL_INIT_ATTRS _IOWR('R', 10, struct fastrpc_ioctl_init_attrs)
-#define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
-#define FASTRPC_IOCTL_CONTROL   _IOWR('R', 12, struct fastrpc_ioctl_control)
-#define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
-#define FASTRPC_IOCTL_GET_DSP_INFO \
-		_IOWR('R', 17, struct fastrpc_ioctl_capability)
-#define FASTRPC_IOCTL_INVOKE2   _IOWR('R', 18, struct fastrpc_ioctl_invoke2)
-#define FASTRPC_IOCTL_MEM_MAP   _IOWR('R', 19, struct fastrpc_ioctl_mem_map)
-#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 20, struct fastrpc_ioctl_mem_unmap)
-#define FASTRPC_IOCTL_INVOKE_PERF \
-		_IOWR('R', 21, struct fastrpc_ioctl_invoke_perf)
-#define FASTRPC_IOCTL_NOTIF_RSP \
-		_IOWR('R', 22, struct fastrpc_ioctl_notif_rsp)
-#define FASTRPC_IOCTL_DSPSIGNAL_CREATE _IOWR('R', 23, struct fastrpc_ioctl_dspsignal_create)
-#define FASTRPC_IOCTL_DSPSIGNAL_DESTROY _IOWR('R', 24, struct fastrpc_ioctl_dspsignal_destroy)
-#define FASTRPC_IOCTL_DSPSIGNAL_SIGNAL _IOWR('R', 25, struct fastrpc_ioctl_dspsignal_signal)
-#define FASTRPC_IOCTL_DSPSIGNAL_WAIT _IOWR('R', 26, struct fastrpc_ioctl_dspsignal_wait)
-#define FASTRPC_IOCTL_DSPSIGNAL_CANCEL_WAIT \
-		_IOWR('R', 27, struct fastrpc_ioctl_dspsignal_cancel_wait)
+#include "fastrpc_shared.h"
 
 #define FASTRPC_GLINK_GUID "fastrpcglink-apps-dsp"
 #define FASTRPC_SMD_GUID "fastrpcsmd-apps-dsp"
@@ -195,8 +164,6 @@ union remote_arg64 {
 	uint32_t h;
 };
 
-#define remote_arg_t    union remote_arg
-
 struct remote_buf {
 	void *pv;		/* buffer pointer */
 	size_t len;		/* length of buffer */
@@ -222,78 +189,12 @@ union remote_arg {
 	uint32_t h;		/* remote handle */
 };
 
-struct fastrpc_ioctl_invoke {
-	uint32_t handle;	/* remote handle */
-	uint32_t sc;		/* scalars describing the data */
-	remote_arg_t *pra;	/* remote arguments list */
-};
-
-struct fastrpc_ioctl_invoke_fd {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;		/* fd list */
-};
-
-struct fastrpc_ioctl_invoke_attrs {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;		/* fd list */
-	unsigned int *attrs;	/* attribute list */
-};
-
-struct fastrpc_ioctl_invoke_crc {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;		/* fd list */
-	unsigned int *attrs;	/* attribute list */
-	unsigned int *crc;
-};
-
-struct fastrpc_ioctl_invoke_perf {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;
-	unsigned int *attrs;
-	unsigned int *crc;
-	uint64_t *perf_kernel;
-	uint64_t *perf_dsp;
-};
-
 struct fastrpc_async_job {
 	uint32_t isasyncjob; /* flag to distinguish async job */
 	uint64_t jobid;      /* job id generated by user */
 	uint32_t reserved;   /* reserved */
 };
 
-struct fastrpc_ioctl_invoke_async {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;		/* fd list */
-	unsigned int *attrs;	/* attribute list */
-	unsigned int *crc;
-	uint64_t *perf_kernel;
-	uint64_t *perf_dsp;
-	struct fastrpc_async_job *job; /* async job*/
-};
-
-struct fastrpc_ioctl_invoke_async_no_perf {
-	struct fastrpc_ioctl_invoke inv;
-	int *fds;		/* fd list */
-	unsigned int *attrs;	/* attribute list */
-	unsigned int *crc;
-	struct fastrpc_async_job *job; /* async job*/
-};
-
-struct fastrpc_ioctl_async_response {
-	uint64_t jobid;/* job id generated by user */
-	int result; /* result from DSP */
-	uint64_t *perf_kernel;
-	uint64_t *perf_dsp;
-	uint32_t handle;
-	uint32_t sc;
-};
-
-struct fastrpc_ioctl_notif_rsp {
-	int domain;					/* Domain of User PD */
-	int session;				/* Session ID of User PD */
-	uint32_t status;			/* Status of the process */
-};
-
 /* FastRPC ioctl structure to set session related info */
 struct fastrpc_proc_sess_info {
 	uint32_t domain_id;  /* Set the remote subsystem, Domain ID of the session  */
@@ -321,84 +222,6 @@ enum fastrpc_invoke2_type {
 	FASTRPC_INVOKE2_SESS_INFO,
 };
 
-struct fastrpc_ioctl_invoke2 {
-	uint32_t req;       /* type of invocation request */
-	uintptr_t invparam; /* invocation request param */
-	uint32_t size;      /* size of invocation param */
-	int err;            /* reserved */
-};
-
-struct fastrpc_ioctl_init {
-	uint32_t flags;		/* one of FASTRPC_INIT_* macros */
-	uintptr_t file;		/* pointer to elf file */
-	uint32_t filelen;	/* elf file length */
-	int32_t filefd;		/* ION fd for the file */
-	uintptr_t mem;		/* mem for the PD */
-	uint32_t memlen;	/* mem length */
-	int32_t memfd;		/* ION fd for the mem */
-};
-
-struct fastrpc_ioctl_init_attrs {
-		struct fastrpc_ioctl_init init;
-		int attrs;
-		unsigned int siglen;
-};
-
-struct fastrpc_ioctl_munmap {
-	uintptr_t vaddrout;	/* address to unmap */
-	size_t size;		/* size */
-};
-
-struct fastrpc_ioctl_munmap_64 {
-	uint64_t vaddrout;	/* address to unmap */
-	size_t size;		/* size */
-};
-
-struct fastrpc_ioctl_mmap {
-	int fd;					/* ion fd */
-	uint32_t flags;			/* flags for dsp to map with */
-	uintptr_t vaddrin;		/* optional virtual address */
-	size_t size;			/* size */
-	uintptr_t vaddrout;		/* dsps virtual address */
-};
-
-struct fastrpc_ioctl_mmap_64 {
-	int fd;				/* ion fd */
-	uint32_t flags;			/* flags for dsp to map with */
-	uint64_t vaddrin;		/* optional virtual address */
-	size_t size;			/* size */
-	uint64_t vaddrout;		/* dsps virtual address */
-};
-
-struct fastrpc_ioctl_munmap_fd {
-	int     fd;				/* fd */
-	uint32_t  flags;		/* control flags */
-	uintptr_t va;			/* va */
-	ssize_t  len;			/* length */
-};
-
-struct fastrpc_ioctl_dspsignal_create {
-	uint32_t signal_id; /* Signal ID */
-	uint32_t flags;     /* Flags, currently unused */
-};
-
-struct fastrpc_ioctl_dspsignal_destroy {
-	uint32_t signal_id; /* Signal ID */
-};
-
-struct fastrpc_ioctl_dspsignal_signal {
-	uint32_t signal_id; /* Signal ID */
-};
-
-struct fastrpc_ioctl_dspsignal_wait {
-	uint32_t signal_id;    /* Signal ID */
-	uint32_t timeout_usec; /* Timeout in microseconds. UINT32_MAX for an infinite wait */
-};
-
-struct fastrpc_ioctl_dspsignal_cancel_wait {
-	uint32_t signal_id; /* Signal ID */
-};
-
 /**
  * Control flags for mapping memory on DSP user process
  */
@@ -439,44 +262,6 @@ enum fastrpc_map_flags {
 	FASTRPC_MAP_MAX,
 };
 
-struct fastrpc_mem_map {
-	int fd;			/* ion fd */
-	int offset;		/* buffer offset */
-	uint32_t flags;		/* flags defined in enum fastrpc_map_flags */
-	int attrs;		/* buffer attributes used for SMMU mapping */
-	uintptr_t vaddrin;	/* buffer virtual address */
-	size_t length;		/* buffer length */
-	uint64_t vaddrout;	/* [out] remote virtual address */
-};
-
-/* Map and unmap IOCTL methods reserved memory size for future extensions */
-#define MAP_RESERVED_NUM (14)
-#define UNMAP_RESERVED_NUM (10)
-
-/* map memory to DSP device */
-struct fastrpc_ioctl_mem_map {
-	int version;		/* Initial version 0 */
-	union {
-		struct fastrpc_mem_map m;
-		int reserved[MAP_RESERVED_NUM];
-	};
-};
-
-struct fastrpc_mem_unmap {
-	int fd;			/* ion fd */
-	uint64_t vaddr;		/* remote process (dsp) virtual address */
-	size_t length;		/* buffer size */
-};
-
-/* unmap memory to DSP device */
-struct fastrpc_ioctl_mem_unmap {
-	int version;		/* Initial version 0 */
-	union {
-		struct fastrpc_mem_unmap um;
-		int reserved[UNMAP_RESERVED_NUM];
-	};
-};
-
 /*
  * This enum is shared with DSP. So, existing values should NOT
  * be modified. Only new members can be added.
@@ -515,38 +300,6 @@ enum fastrpc_control_type {
 	FASTRPC_CONTROL_NOTIF_WAKE = 9,
 };
 
-struct fastrpc_ctrl_latency {
-	uint32_t enable;	/* latency control enable */
-	uint32_t latency;	/* latency request in us */
-};
-
-struct fastrpc_ctrl_kalloc {
-	uint32_t kalloc_support;  /* Remote memory allocation from kernel */
-};
-
-struct fastrpc_ctrl_wakelock {
-	uint32_t enable;	/* wakelock control enable */
-};
-
-struct fastrpc_ctrl_pm {
-	uint32_t timeout;	/* timeout(in ms) for PM to keep system awake */
-};
-
-struct fastrpc_ctrl_smmu {
-	uint32_t sharedcb;  /* Set to SMMU share context bank */
-};
-
-struct fastrpc_ioctl_control {
-	uint32_t req;
-	union {
-		struct fastrpc_ctrl_latency lp;
-		struct fastrpc_ctrl_kalloc kalloc;
-		struct fastrpc_ctrl_wakelock wp;
-		struct fastrpc_ctrl_pm pm;
-		struct fastrpc_ctrl_smmu smmu;
-	};
-};
-
 #define FASTRPC_MAX_DSP_ATTRIBUTES	(256)
 #define FASTRPC_MAX_ATTRIBUTES	(260)
 
@@ -555,12 +308,6 @@ enum fastrpc_dsp_capability {
 	DMA_HANDLE_REVERSE_RPC_CAP = 129,
 };
 
-struct fastrpc_ioctl_capability {
-	uint32_t domain;
-	uint32_t attribute_ID;
-	uint32_t capability;
-};
-
 struct smq_null_invoke {
 	uint64_t ctx;			/* invoke caller context */
 	uint32_t handle;	    /* handle to invoke */
@@ -670,6 +417,7 @@ void fastrpc_transport_session_init(int cid, char *subsys);
 void fastrpc_transport_session_deinit(int cid);
 int fastrpc_wait_for_transport_interrupt(int cid, unsigned int flags);
 int fastrpc_set_tvm_remote_domain(struct fastrpc_file *fl, struct fastrpc_ioctl_init *init);
+void fastrpc_restart_drivers(int cid);
 
 static inline struct smq_invoke_buf *smq_invoke_buf_start(remote_arg64_t *pra,
 							uint32_t sc)
@@ -744,11 +492,6 @@ struct gid_list {
 	unsigned int gidcount;
 };
 
-struct qos_cores {
-	int *coreno;
-	int corecount;
-};
-
 struct fastrpc_buf {
 	struct hlist_node hn;
 	struct hlist_node hn_rem;
@@ -991,17 +734,20 @@ struct fastrpc_apps {
 	/* Non-secure subsystem like CDSP will use regular client */
 	struct wakeup_source *wake_source;
 	uint32_t duplicate_rsp_err_cnt;
-	struct qos_cores silvercores;
 	uint32_t max_size_limit;
 	struct hlist_head frpc_devices;
 	struct hlist_head frpc_drivers;
 	struct mutex mut_uid;
-	/* Indicates cdsp device status */
-	int remote_cdsp_status;
+	/* Indicates nsp status */
+	int fastrpc_nsp_status;
 	/* Indicates secure context bank to be shared */
 	int share_securecb;
 	/* Indicates process type is configured for SMMU context bank */
 	bool cb_pd_type;
+	/* Number of lowest capacity cores for given platform */
+	unsigned int lowest_capacity_core_count;
+	/* Flag to check if PM QoS vote needs to be done for only one core */
+	bool single_core_latency_vote;
 };
 
 struct fastrpc_mmap {
@@ -1030,6 +776,8 @@ struct fastrpc_mmap {
 	/* Mapping for fastrpc shell */
 	bool is_filemap;
 	char *servloc_name;			/* Indicate which daemon mapped this */
+	/* Indicates map is being used by a pending RPC call */
+	unsigned int ctx_refs;
 };
 
 enum fastrpc_perfkeys {
@@ -1163,26 +911,6 @@ struct fastrpc_file {
 	struct fastrpc_proc_sharedbuf_info sharedbuf_info;
 };
 
-union fastrpc_ioctl_param {
-	struct fastrpc_ioctl_invoke_async inv;
-	struct fastrpc_ioctl_mem_map mem_map;
-	struct fastrpc_ioctl_mem_unmap mem_unmap;
-	struct fastrpc_ioctl_mmap mmap;
-	struct fastrpc_ioctl_mmap_64 mmap64;
-	struct fastrpc_ioctl_munmap munmap;
-	struct fastrpc_ioctl_munmap_64 munmap64;
-	struct fastrpc_ioctl_munmap_fd munmap_fd;
-	struct fastrpc_ioctl_init_attrs init;
-	struct fastrpc_ioctl_control cp;
-	struct fastrpc_ioctl_capability cap;
-	struct fastrpc_ioctl_invoke2 inv2;
-	struct fastrpc_ioctl_dspsignal_signal sig;
-	struct fastrpc_ioctl_dspsignal_wait wait;
-	struct fastrpc_ioctl_dspsignal_create cre;
-	struct fastrpc_ioctl_dspsignal_destroy des;
-	struct fastrpc_ioctl_dspsignal_cancel_wait canc;
-};
-
 int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
 				   uint32_t kernel,
 				   struct fastrpc_ioctl_invoke_async *inv);

+ 3 - 0
dsp/adsprpc_socket.c

@@ -205,6 +205,7 @@ static void fastrpc_recv_del_server(struct frpc_transport_session_control *sessi
 {
 	uint32_t remote_server_instance = session_control->remote_server_instance;
 	int32_t err = 0;
+	int32_t cid = 0;
 
 	/* Ignore EOF marker */
 	if (!node && !port) {
@@ -223,7 +224,9 @@ static void fastrpc_recv_del_server(struct frpc_transport_session_control *sessi
 	session_control->frpc_socket.remote_sock_addr.sq_port = 0;
 	session_control->remote_server_online = false;
 	mutex_unlock(&session_control->frpc_socket.socket_mutex);
+	cid = GET_CID_FROM_SERVER_INSTANCE(remote_server_instance);
 	ADSPRPC_INFO("Remote server is down: remote ID (0x%x)", remote_server_instance);
+	fastrpc_restart_drivers(cid);
 bail:
 	if (err != -EINVAL && err)
 		ADSPRPC_WARN("Ignoring ctrl packet: node %u, port %u, err %d", node, port, err);

+ 284 - 0
include/uapi/fastrpc_shared.h

@@ -0,0 +1,284 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/*
+ * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef FASTRPC_IOCTL_H
+#define FASTRPC_IOCTL_H
+
+#include <linux/types.h>
+
+#define remote_arg_t    union remote_arg
+/* Map and unmap IOCTL methods reserved memory size for future extensions */
+#define MAP_RESERVED_NUM (14)
+#define UNMAP_RESERVED_NUM (10)
+
+#define FASTRPC_IOCTL_INVOKE	_IOWR('R', 1, struct fastrpc_ioctl_invoke)
+#define FASTRPC_IOCTL_MMAP	_IOWR('R', 2, struct fastrpc_ioctl_mmap)
+#define FASTRPC_IOCTL_MUNMAP	_IOWR('R', 3, struct fastrpc_ioctl_munmap)
+#define FASTRPC_IOCTL_MMAP_64	_IOWR('R', 14, struct fastrpc_ioctl_mmap_64)
+#define FASTRPC_IOCTL_MUNMAP_64	_IOWR('R', 15, struct fastrpc_ioctl_munmap_64)
+#define FASTRPC_IOCTL_INVOKE_FD	_IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
+#define FASTRPC_IOCTL_SETMODE	_IOWR('R', 5, uint32_t)
+#define FASTRPC_IOCTL_INIT	_IOWR('R', 6, struct fastrpc_ioctl_init)
+#define FASTRPC_IOCTL_INVOKE_ATTRS \
+				_IOWR('R', 7, struct fastrpc_ioctl_invoke_attrs)
+#define FASTRPC_IOCTL_GETINFO	_IOWR('R', 8, uint32_t)
+//#define FASTRPC_IOCTL_GETPERF	_IOWR('R', 9, struct fastrpc_ioctl_perf)
+#define FASTRPC_IOCTL_INIT_ATTRS _IOWR('R', 10, struct fastrpc_ioctl_init_attrs)
+#define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
+#define FASTRPC_IOCTL_CONTROL   _IOWR('R', 12, struct fastrpc_ioctl_control)
+#define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
+#define FASTRPC_IOCTL_GET_DSP_INFO \
+		_IOWR('R', 17, struct fastrpc_ioctl_capability)
+#define FASTRPC_IOCTL_INVOKE2   _IOWR('R', 18, struct fastrpc_ioctl_invoke2)
+#define FASTRPC_IOCTL_MEM_MAP   _IOWR('R', 19, struct fastrpc_ioctl_mem_map)
+#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 20, struct fastrpc_ioctl_mem_unmap)
+#define FASTRPC_IOCTL_INVOKE_PERF \
+		_IOWR('R', 21, struct fastrpc_ioctl_invoke_perf)
+#define FASTRPC_IOCTL_NOTIF_RSP \
+		_IOWR('R', 22, struct fastrpc_ioctl_notif_rsp)
+#define FASTRPC_IOCTL_DSPSIGNAL_CREATE _IOWR('R', 23, struct fastrpc_ioctl_dspsignal_create)
+#define FASTRPC_IOCTL_DSPSIGNAL_DESTROY _IOWR('R', 24, struct fastrpc_ioctl_dspsignal_destroy)
+#define FASTRPC_IOCTL_DSPSIGNAL_SIGNAL _IOWR('R', 25, struct fastrpc_ioctl_dspsignal_signal)
+#define FASTRPC_IOCTL_DSPSIGNAL_WAIT _IOWR('R', 26, struct fastrpc_ioctl_dspsignal_wait)
+#define FASTRPC_IOCTL_DSPSIGNAL_CANCEL_WAIT \
+		_IOWR('R', 27, struct fastrpc_ioctl_dspsignal_cancel_wait)
+
+struct fastrpc_mem_map {
+	int fd;			/* ion fd */
+	int offset;		/* buffer offset */
+	uint32_t flags;		/* flags defined in enum fastrpc_map_flags */
+	int attrs;		/* buffer attributes used for SMMU mapping */
+	uintptr_t vaddrin;	/* buffer virtual address */
+	size_t length;		/* buffer length */
+	uint64_t vaddrout;	/* [out] remote virtual address */
+};
+
+struct fastrpc_mem_unmap {
+	int fd;			/* ion fd */
+	uint64_t vaddr;		/* remote process (dsp) virtual address */
+	size_t length;		/* buffer size */
+};
+
+struct fastrpc_ctrl_latency {
+	uint32_t enable;	/* latency control enable */
+	uint32_t latency;	/* latency request in us */
+};
+
+struct fastrpc_ctrl_kalloc {
+	uint32_t kalloc_support;  /* Remote memory allocation from kernel */
+};
+
+struct fastrpc_ctrl_wakelock {
+	uint32_t enable;	/* wakelock control enable */
+};
+
+struct fastrpc_ctrl_pm {
+	uint32_t timeout;	/* timeout(in ms) for PM to keep system awake */
+};
+
+struct fastrpc_ctrl_smmu {
+	uint32_t sharedcb;  /* Set to SMMU share context bank */
+};
+
+struct fastrpc_ioctl_invoke {
+	uint32_t handle;	/* remote handle */
+	uint32_t sc;		/* scalars describing the data */
+	remote_arg_t *pra;	/* remote arguments list */
+};
+
+struct fastrpc_ioctl_invoke_fd {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;		/* fd list */
+};
+
+struct fastrpc_ioctl_invoke_attrs {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;		/* fd list */
+	unsigned int *attrs;	/* attribute list */
+};
+
+struct fastrpc_ioctl_invoke_crc {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;		/* fd list */
+	unsigned int *attrs;	/* attribute list */
+	unsigned int *crc;
+};
+
+struct fastrpc_ioctl_invoke_perf {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;
+	unsigned int *attrs;
+	unsigned int *crc;
+	uint64_t *perf_kernel;
+	uint64_t *perf_dsp;
+};
+
+struct fastrpc_ioctl_invoke_async {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;		/* fd list */
+	unsigned int *attrs;	/* attribute list */
+	unsigned int *crc;
+	uint64_t *perf_kernel;
+	uint64_t *perf_dsp;
+	struct fastrpc_async_job *job; /* async job*/
+};
+
+struct fastrpc_ioctl_invoke_async_no_perf {
+	struct fastrpc_ioctl_invoke inv;
+	int *fds;		/* fd list */
+	unsigned int *attrs;	/* attribute list */
+	unsigned int *crc;
+	struct fastrpc_async_job *job; /* async job*/
+};
+
+struct fastrpc_ioctl_async_response {
+	uint64_t jobid;/* job id generated by user */
+	int result; /* result from DSP */
+	uint64_t *perf_kernel;
+	uint64_t *perf_dsp;
+	uint32_t handle;
+	uint32_t sc;
+};
+
+struct fastrpc_ioctl_notif_rsp {
+	int domain;					/* Domain of User PD */
+	int session;				/* Session ID of User PD */
+	uint32_t status;			/* Status of the process */
+};
+
+struct fastrpc_ioctl_invoke2 {
+	uint32_t req;       /* type of invocation request */
+	uintptr_t invparam; /* invocation request param */
+	uint32_t size;      /* size of invocation param */
+	int err;            /* reserved */
+};
+
+struct fastrpc_ioctl_init {
+	uint32_t flags;		/* one of FASTRPC_INIT_* macros */
+	uintptr_t file;		/* pointer to elf file */
+	uint32_t filelen;	/* elf file length */
+	int32_t filefd;		/* ION fd for the file */
+	uintptr_t mem;		/* mem for the PD */
+	uint32_t memlen;	/* mem length */
+	int32_t memfd;		/* ION fd for the mem */
+};
+
+struct fastrpc_ioctl_init_attrs {
+		struct fastrpc_ioctl_init init;
+		int attrs;
+		unsigned int siglen;
+};
+
+struct fastrpc_ioctl_munmap {
+	uintptr_t vaddrout;	/* address to unmap */
+	size_t size;		/* size */
+};
+
+struct fastrpc_ioctl_munmap_64 {
+	uint64_t vaddrout;	/* address to unmap */
+	size_t size;		/* size */
+};
+
+struct fastrpc_ioctl_mmap {
+	int fd;					/* ion fd */
+	uint32_t flags;			/* flags for dsp to map with */
+	uintptr_t vaddrin;		/* optional virtual address */
+	size_t size;			/* size */
+	uintptr_t vaddrout;		/* dsps virtual address */
+};
+
+struct fastrpc_ioctl_mmap_64 {
+	int fd;				/* ion fd */
+	uint32_t flags;			/* flags for dsp to map with */
+	uint64_t vaddrin;		/* optional virtual address */
+	size_t size;			/* size */
+	uint64_t vaddrout;		/* dsps virtual address */
+};
+
+struct fastrpc_ioctl_munmap_fd {
+	int     fd;				/* fd */
+	uint32_t  flags;		/* control flags */
+	uintptr_t va;			/* va */
+	ssize_t  len;			/* length */
+};
+
+struct fastrpc_ioctl_dspsignal_create {
+	uint32_t signal_id; /* Signal ID */
+	uint32_t flags;     /* Flags, currently unused */
+};
+
+struct fastrpc_ioctl_dspsignal_destroy {
+	uint32_t signal_id; /* Signal ID */
+};
+
+struct fastrpc_ioctl_dspsignal_signal {
+	uint32_t signal_id; /* Signal ID */
+};
+
+struct fastrpc_ioctl_dspsignal_wait {
+	uint32_t signal_id;    /* Signal ID */
+	uint32_t timeout_usec; /* Timeout in microseconds. UINT32_MAX for an infinite wait */
+};
+
+struct fastrpc_ioctl_dspsignal_cancel_wait {
+	uint32_t signal_id; /* Signal ID */
+};
+
+/* map memory to DSP device */
+struct fastrpc_ioctl_mem_map {
+	int version;		/* Initial version 0 */
+	union {
+		struct fastrpc_mem_map m;
+		int reserved[MAP_RESERVED_NUM];
+	};
+};
+
+/* unmap memory to DSP device */
+struct fastrpc_ioctl_mem_unmap {
+	int version;		/* Initial version 0 */
+	union {
+		struct fastrpc_mem_unmap um;
+		int reserved[UNMAP_RESERVED_NUM];
+	};
+};
+
+struct fastrpc_ioctl_control {
+	uint32_t req;
+	union {
+		struct fastrpc_ctrl_latency lp;
+		struct fastrpc_ctrl_kalloc kalloc;
+		struct fastrpc_ctrl_wakelock wp;
+		struct fastrpc_ctrl_pm pm;
+		struct fastrpc_ctrl_smmu smmu;
+	};
+};
+
+struct fastrpc_ioctl_capability {
+	uint32_t domain;
+	uint32_t attribute_ID;
+	uint32_t capability;
+};
+
+union fastrpc_ioctl_param {
+	struct fastrpc_ioctl_invoke_async inv;
+	struct fastrpc_ioctl_mem_map mem_map;
+	struct fastrpc_ioctl_mem_unmap mem_unmap;
+	struct fastrpc_ioctl_mmap mmap;
+	struct fastrpc_ioctl_mmap_64 mmap64;
+	struct fastrpc_ioctl_munmap munmap;
+	struct fastrpc_ioctl_munmap_64 munmap64;
+	struct fastrpc_ioctl_munmap_fd munmap_fd;
+	struct fastrpc_ioctl_init_attrs init;
+	struct fastrpc_ioctl_control cp;
+	struct fastrpc_ioctl_capability cap;
+	struct fastrpc_ioctl_invoke2 inv2;
+	struct fastrpc_ioctl_dspsignal_signal sig;
+	struct fastrpc_ioctl_dspsignal_wait wait;
+	struct fastrpc_ioctl_dspsignal_create cre;
+	struct fastrpc_ioctl_dspsignal_destroy des;
+	struct fastrpc_ioctl_dspsignal_cancel_wait canc;
+};
+
+#endif