diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 0032a5659bd2..1759027fa88c 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -206,6 +206,13 @@ enum fastrpc_buf_type { USERHEAP_BUF, }; +/* Types of RPC calls to DSP */ +enum fastrpc_msg_type { + USER_MSG = 0, + KERNEL_MSG_WITH_ZERO_PID, + KERNEL_MSG_WITH_NONZERO_PID, +}; + #define PERF_END (void)0 #define PERF(enb, cnt, ff) \ @@ -2686,7 +2693,7 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx, msg->tid = current->pid; if (fl->sessionid) msg->tid |= (1 << SESSION_ID_INDEX); - if (kernel) + if (kernel == KERNEL_MSG_WITH_ZERO_PID) msg->pid = 0; msg->invoke.header.ctx = ctx->ctxid | fl->pd; msg->invoke.header.handle = handle; @@ -3225,7 +3232,7 @@ static int fastrpc_internal_invoke2(struct fastrpc_file *fl, if (err) goto bail; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, fl->mode, - 0, &p.inv))); + USER_MSG, &p.inv))); if (err) goto bail; break; @@ -3332,7 +3339,7 @@ static int fastrpc_init_attach_process(struct fastrpc_file *fl, fl->pd = 2; } - err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl); + err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl); if (err) goto bail; bail: @@ -3503,7 +3510,7 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl, ioctl.attrs = NULL; ioctl.crc = NULL; ioctl.job = NULL; - err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl); + err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl); if (err) goto bail; bail: @@ -3648,7 +3655,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_file *fl, ioctl.attrs = NULL; ioctl.crc = NULL; ioctl.job = NULL; - err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl); + err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl); if (err) goto bail; bail: @@ -3749,7 +3756,7 @@ static int fastrpc_send_cpuinfo_to_dsp(struct fastrpc_file *fl) ioctl.job = NULL; fl->pd = 1; - err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl); + err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl); if (!err) me->channel[fl->cid].cpuinfo_status = true; bail: @@ -3788,7 +3795,7 @@ static int fastrpc_get_info_from_dsp(struct fastrpc_file *fl, ioctl.job = NULL; fl->pd = 1; - err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl); + err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl); bail: if (err) @@ -3899,8 +3906,13 @@ static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl) ioctl.attrs = NULL; ioctl.crc = NULL; ioctl.job = NULL; + /* + * Pass 2 for "kernel" arg to send kernel msg to DSP + * with non-zero msg PID for the DSP to directly use + * that info to kill the remote process. + */ VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_NONZERO_PID, &ioctl))); if (err && fl->dsp_proc_init) ADSPRPC_ERR( "releasing DSP process failed with %d (0x%x) for %s\n", @@ -3956,7 +3968,7 @@ static int fastrpc_mem_map_to_dsp(struct fastrpc_file *fl, int fd, int offset, ioctl.crc = NULL; ioctl.job = NULL; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl))); if (err) goto bail; if (raddr) @@ -3998,7 +4010,7 @@ static int fastrpc_mem_unmap_to_dsp(struct fastrpc_file *fl, int fd, ioctl.crc = NULL; ioctl.job = NULL; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl))); if (err) goto bail; bail: @@ -4038,7 +4050,7 @@ static int fastrpc_unmap_on_dsp(struct fastrpc_file *fl, ioctl.crc = NULL; ioctl.job = NULL; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl))); if (err) goto bail; bail: @@ -4090,7 +4102,7 @@ static int fastrpc_mmap_on_dsp(struct fastrpc_file *fl, uint32_t flags, ioctl.crc = NULL; ioctl.job = NULL; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl))); *raddr = (uintptr_t)routargs.vaddrout; if (err) goto bail; @@ -4154,7 +4166,7 @@ static int fastrpc_munmap_on_dsp_rh(struct fastrpc_file *fl, uint64_t phys, ioctl.job = NULL; VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, - FASTRPC_MODE_PARALLEL, 1, &ioctl))); + FASTRPC_MODE_PARALLEL, KERNEL_MSG_WITH_ZERO_PID, &ioctl))); if (err) goto bail; } else if (flags == ADSP_MMAP_REMOTE_HEAP_ADDR) { @@ -5814,7 +5826,7 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num, goto bail; } VERIFY(err, 0 == (err = fastrpc_internal_invoke(fl, fl->mode, - 0, &p.inv))); + USER_MSG, &p.inv))); if (err) goto bail; break;