Răsfoiți Sursa

msm:ADSPRPC: configure signed userpd initial memory length

Currently the init memeory size allocated for user PD is fixed.
This may not be sufficent for some usecases. This change will
allow configuring initial memory size allocated for signed user PD.

Change-Id: I2b12cf98c96b1e11daaad7e1bbf1d3777f43c1b6
Acked-by: ANANDU E <[email protected]>
Signed-off-by: Vamsi Krishna Gattupalli <[email protected]>
Vamsi Krishna Gattupalli 2 ani în urmă
părinte
comite
b98c08f019
1 a modificat fișierele cu 29 adăugiri și 6 ștergeri
  1. 29 6
      dsp/adsprpc.c

+ 29 - 6
dsp/adsprpc.c

@@ -182,7 +182,9 @@
 #define FASTRPC_CPUINFO_EARLY_WAKEUP (1)
 
 #define INIT_FILELEN_MAX (2*1024*1024)
-#define INIT_MEMLEN_MAX  (8*1024*1024)
+#define INIT_MEMLEN_MAX_STATIC  (8*1024*1024)
+#define INIT_MEMLEN_MAX_DYNAMIC (200*1024*1024)
+#define INIT_MEMLEN_MIN_DYNAMIC (3*1024*1024)
 #define MAX_CACHE_BUF_SIZE (8*1024*1024)
 
 /* Maximum buffers cached in cached buffer list */
@@ -3622,7 +3624,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
 	remote_arg_t ra[6];
 	int fds[6];
 	unsigned int gid = 0, one_mb = 1024*1024;
-	unsigned int dsp_userpd_memlen = 3 * one_mb;
+	unsigned int dsp_userpd_memlen = 0;
 	struct fastrpc_buf *init_mem;
 
 	struct {
@@ -3642,6 +3644,20 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
 		return err;
 	}
 	fl->dsp_process_state = PROCESS_CREATE_IS_INPROGRESS;
+
+	if (init->memlen) {
+		if(init->memlen > INIT_MEMLEN_MAX_DYNAMIC || init->memlen < INIT_MEMLEN_MIN_DYNAMIC) {
+		    ADSPRPC_ERR(
+			    "init memory for process %d should be between %d and %d\n",
+			     init->memlen, INIT_MEMLEN_MIN_DYNAMIC, INIT_MEMLEN_MAX_DYNAMIC);
+		    err = -EINVAL;
+		    goto bail;
+		}
+		dsp_userpd_memlen = init->memlen;
+	} else {
+		dsp_userpd_memlen = 3*one_mb;
+	}
+
 	spin_unlock(&fl->hlock);
 
 	inbuf.pgid = fl->tgid;
@@ -3733,7 +3749,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
 	 * additional static heap initialized within the process.
 	 */
 	if (fl->is_unsigned_pd)
-		dsp_userpd_memlen += 2*one_mb;
+		dsp_userpd_memlen = 5*one_mb;
 	memlen = ALIGN(max(dsp_userpd_memlen, init->filelen * 4), one_mb);
 	imem_dma_attr = DMA_ATTR_DELAYED_UNMAP | DMA_ATTR_NO_KERNEL_MAPPING;
 	err = fastrpc_buf_alloc(fl, memlen, imem_dma_attr, 0,
@@ -3859,6 +3875,14 @@ static int fastrpc_init_create_static_process(struct fastrpc_file *fl,
 			"untrusted app trying to attach to audio PD\n");
 		return err;
 	}
+	VERIFY(err, init->memlen <= INIT_MEMLEN_MAX_STATIC);
+	if (err) {
+		ADSPRPC_ERR(
+			"init memory for static process %d is more than max allowed init len %d\n",
+			init->memlen, INIT_MEMLEN_MAX_STATIC);
+		err = -EFBIG;
+		goto bail;
+	}
 
 	if (!init->filelen)
 		goto bail;
@@ -4038,12 +4062,12 @@ int fastrpc_init_process(struct fastrpc_file *fl,
 	struct fastrpc_channel_ctx *chan = NULL;
 
 	VERIFY(err, init->filelen < INIT_FILELEN_MAX
-			&& init->memlen < INIT_MEMLEN_MAX);
+			&& init->memlen <= INIT_MEMLEN_MAX_DYNAMIC);
 	if (err) {
 		ADSPRPC_ERR(
 			"file size 0x%x or init memory 0x%x is more than max allowed file size 0x%x or init len 0x%x\n",
 			init->filelen, init->memlen,
-			INIT_FILELEN_MAX, INIT_MEMLEN_MAX);
+			INIT_FILELEN_MAX, INIT_MEMLEN_MAX_DYNAMIC);
 		err = -EFBIG;
 		goto bail;
 	}
@@ -6582,7 +6606,6 @@ bail:
 	return err;
 }
 
-
 static inline int fastrpc_mmap_device_ioctl(struct fastrpc_file *fl,
 		unsigned int ioctl_num,	union fastrpc_ioctl_param *p,
 		void *param)