Lines Matching refs:fl
193 struct fastrpc_user *fl; member
215 struct fastrpc_user *fl; member
244 struct fastrpc_user *fl; member
317 int vmid = map->fl->cctx->vmperms[0].vmid; in fastrpc_free_map()
326 dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d\n", in fastrpc_free_map()
337 if (map->fl) { in fastrpc_free_map()
338 spin_lock(&map->fl->lock); in fastrpc_free_map()
340 spin_unlock(&map->fl->lock); in fastrpc_free_map()
341 map->fl = NULL; in fastrpc_free_map()
362 static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd, in fastrpc_map_lookup() argument
373 spin_lock(&fl->lock); in fastrpc_map_lookup()
374 list_for_each_entry(map, &fl->maps, node) { in fastrpc_map_lookup()
382 spin_unlock(&fl->lock); in fastrpc_map_lookup()
396 static int __fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, in __fastrpc_buf_alloc() argument
409 buf->fl = fl; in __fastrpc_buf_alloc()
429 static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, in fastrpc_buf_alloc() argument
435 ret = __fastrpc_buf_alloc(fl, dev, size, obuf); in fastrpc_buf_alloc()
441 if (fl->sctx && fl->sctx->sid) in fastrpc_buf_alloc()
442 buf->phys += ((u64)fl->sctx->sid << 32); in fastrpc_buf_alloc()
447 static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct device *dev, in fastrpc_remote_heap_alloc() argument
450 struct device *rdev = &fl->cctx->rpdev->dev; in fastrpc_remote_heap_alloc()
452 return __fastrpc_buf_alloc(fl, rdev, size, obuf); in fastrpc_remote_heap_alloc()
582 ctx->fl = user; in fastrpc_context_alloc()
749 static int fastrpc_map_attach(struct fastrpc_user *fl, int fd, in fastrpc_map_attach() argument
752 struct fastrpc_session_ctx *sess = fl->sctx; in fastrpc_map_attach()
765 map->fl = fl; in fastrpc_map_attach()
791 map->phys += ((u64)fl->sctx->sid << 32); in fastrpc_map_attach()
815 dst_perms[1].vmid = fl->cctx->vmperms[0].vmid; in fastrpc_map_attach()
825 spin_lock(&fl->lock); in fastrpc_map_attach()
826 list_add_tail(&map->node, &fl->maps); in fastrpc_map_attach()
827 spin_unlock(&fl->lock); in fastrpc_map_attach()
842 static int fastrpc_map_create(struct fastrpc_user *fl, int fd, in fastrpc_map_create() argument
845 struct fastrpc_session_ctx *sess = fl->sctx; in fastrpc_map_create()
848 if (!fastrpc_map_lookup(fl, fd, ppmap)) { in fastrpc_map_create()
855 err = fastrpc_map_attach(fl, fd, len, attr, ppmap); in fastrpc_map_create()
923 struct device *dev = ctx->fl->sctx->dev; in fastrpc_create_maps()
933 err = fastrpc_map_create(ctx->fl, ctx->args[i].fd, in fastrpc_create_maps()
936 err = fastrpc_map_attach(ctx->fl, ctx->args[i].fd, in fastrpc_create_maps()
959 struct device *dev = ctx->fl->sctx->dev; in fastrpc_get_args()
979 if (ctx->fl->sctx->sid) in fastrpc_get_args()
980 err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf); in fastrpc_get_args()
982 err = fastrpc_remote_heap_alloc(ctx->fl, dev, pkt_size, &ctx->buf); in fastrpc_get_args()
1090 struct fastrpc_user *fl = ctx->fl; in fastrpc_put_args() local
1127 if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap)) in fastrpc_put_args()
1139 struct fastrpc_user *fl = ctx->fl; in fastrpc_invoke_send() local
1143 cctx = fl->cctx; in fastrpc_invoke_send()
1144 msg->client_id = fl->client_id; in fastrpc_invoke_send()
1150 msg->ctx = ctx->ctxid | fl->pd; in fastrpc_invoke_send()
1166 static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, in fastrpc_internal_invoke() argument
1175 if (!fl->sctx) in fastrpc_internal_invoke()
1178 if (!fl->cctx->rpdev) in fastrpc_internal_invoke()
1182 …dev_warn_ratelimited(fl->sctx->dev, "user app trying to send a kernel RPC message (%d)\n", handle… in fastrpc_internal_invoke()
1186 ctx = fastrpc_context_alloc(fl, kernel, sc, args); in fastrpc_internal_invoke()
1197 err = fastrpc_invoke_send(fl->sctx, ctx, kernel, handle); in fastrpc_internal_invoke()
1226 spin_lock(&fl->lock); in fastrpc_internal_invoke()
1228 spin_unlock(&fl->lock); in fastrpc_internal_invoke()
1233 list_for_each_entry_safe(buf, b, &fl->mmaps, node) { in fastrpc_internal_invoke()
1235 list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps); in fastrpc_internal_invoke()
1240 dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); in fastrpc_internal_invoke()
1245 static bool is_session_rejected(struct fastrpc_user *fl, bool unsigned_pd_request) in is_session_rejected() argument
1248 if (!fl->is_secure_dev && fl->cctx->secure) { in is_session_rejected()
1254 if (!fl->cctx->unsigned_support || !unsigned_pd_request) { in is_session_rejected()
1255 dev_err(&fl->cctx->rpdev->dev, "Error: Untrusted application trying to offload to signed PD\n"); in is_session_rejected()
1263 static int fastrpc_init_create_static_process(struct fastrpc_user *fl, in fastrpc_init_create_static_process() argument
1299 if (!fl->cctx->remote_heap) { in fastrpc_init_create_static_process()
1300 err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, in fastrpc_init_create_static_process()
1301 &fl->cctx->remote_heap); in fastrpc_init_create_static_process()
1306 if (fl->cctx->vmcount) { in fastrpc_init_create_static_process()
1309 err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, in fastrpc_init_create_static_process()
1310 (u64)fl->cctx->remote_heap->size, in fastrpc_init_create_static_process()
1312 fl->cctx->vmperms, fl->cctx->vmcount); in fastrpc_init_create_static_process()
1314 dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d\n", in fastrpc_init_create_static_process()
1315 fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); in fastrpc_init_create_static_process()
1322 inbuf.client_id = fl->client_id; in fastrpc_init_create_static_process()
1325 fl->pd = USER_PD; in fastrpc_init_create_static_process()
1335 pages[0].addr = fl->cctx->remote_heap->phys; in fastrpc_init_create_static_process()
1336 pages[0].size = fl->cctx->remote_heap->size; in fastrpc_init_create_static_process()
1344 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, in fastrpc_init_create_static_process()
1354 if (fl->cctx->vmcount && scm_done) { in fastrpc_init_create_static_process()
1359 for (i = 0; i < fl->cctx->vmcount; i++) in fastrpc_init_create_static_process()
1360 src_perms |= BIT(fl->cctx->vmperms[i].vmid); in fastrpc_init_create_static_process()
1364 err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, in fastrpc_init_create_static_process()
1365 (u64)fl->cctx->remote_heap->size, in fastrpc_init_create_static_process()
1368 dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d\n", in fastrpc_init_create_static_process()
1369 fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); in fastrpc_init_create_static_process()
1372 fastrpc_buf_free(fl->cctx->remote_heap); in fastrpc_init_create_static_process()
1381 static int fastrpc_init_create_process(struct fastrpc_user *fl, in fastrpc_init_create_process() argument
1414 if (is_session_rejected(fl, unsigned_module)) { in fastrpc_init_create_process()
1424 inbuf.client_id = fl->client_id; in fastrpc_init_create_process()
1430 fl->pd = USER_PD; in fastrpc_init_create_process()
1433 err = fastrpc_map_create(fl, init.filefd, init.filelen, 0, &map); in fastrpc_init_create_process()
1440 err = fastrpc_buf_alloc(fl, fl->sctx->dev, memlen, in fastrpc_init_create_process()
1445 fl->init_mem = imem; in fastrpc_init_create_process()
1477 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, in fastrpc_init_create_process()
1487 fl->init_mem = NULL; in fastrpc_init_create_process()
1498 struct fastrpc_user *fl) in fastrpc_session_alloc() argument
1500 struct fastrpc_channel_ctx *cctx = fl->cctx; in fastrpc_session_alloc()
1511 fl->client_id = i + 1; in fastrpc_session_alloc()
1530 static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl) in fastrpc_release_current_dsp_process() argument
1536 client_id = fl->client_id; in fastrpc_release_current_dsp_process()
1542 return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, in fastrpc_release_current_dsp_process()
1548 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data; in fastrpc_device_release() local
1549 struct fastrpc_channel_ctx *cctx = fl->cctx; in fastrpc_device_release()
1555 fastrpc_release_current_dsp_process(fl); in fastrpc_device_release()
1558 list_del(&fl->user); in fastrpc_device_release()
1561 if (fl->init_mem) in fastrpc_device_release()
1562 fastrpc_buf_free(fl->init_mem); in fastrpc_device_release()
1564 list_for_each_entry_safe(ctx, n, &fl->pending, node) { in fastrpc_device_release()
1569 list_for_each_entry_safe(map, m, &fl->maps, node) in fastrpc_device_release()
1572 list_for_each_entry_safe(buf, b, &fl->mmaps, node) { in fastrpc_device_release()
1577 fastrpc_session_free(cctx, fl->sctx); in fastrpc_device_release()
1580 mutex_destroy(&fl->mutex); in fastrpc_device_release()
1581 kfree(fl); in fastrpc_device_release()
1591 struct fastrpc_user *fl = NULL; in fastrpc_device_open() local
1597 fl = kzalloc(sizeof(*fl), GFP_KERNEL); in fastrpc_device_open()
1598 if (!fl) in fastrpc_device_open()
1604 filp->private_data = fl; in fastrpc_device_open()
1605 spin_lock_init(&fl->lock); in fastrpc_device_open()
1606 mutex_init(&fl->mutex); in fastrpc_device_open()
1607 INIT_LIST_HEAD(&fl->pending); in fastrpc_device_open()
1608 INIT_LIST_HEAD(&fl->maps); in fastrpc_device_open()
1609 INIT_LIST_HEAD(&fl->mmaps); in fastrpc_device_open()
1610 INIT_LIST_HEAD(&fl->user); in fastrpc_device_open()
1611 fl->cctx = cctx; in fastrpc_device_open()
1612 fl->is_secure_dev = fdevice->secure; in fastrpc_device_open()
1614 fl->sctx = fastrpc_session_alloc(fl); in fastrpc_device_open()
1615 if (!fl->sctx) { in fastrpc_device_open()
1617 mutex_destroy(&fl->mutex); in fastrpc_device_open()
1618 kfree(fl); in fastrpc_device_open()
1624 list_add_tail(&fl->user, &cctx->users); in fastrpc_device_open()
1630 static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp) in fastrpc_dmabuf_alloc() argument
1640 err = fastrpc_buf_alloc(fl, fl->sctx->dev, bp.size, &buf); in fastrpc_dmabuf_alloc()
1675 static int fastrpc_init_attach(struct fastrpc_user *fl, int pd) in fastrpc_init_attach() argument
1678 int client_id = fl->client_id; in fastrpc_init_attach()
1685 fl->pd = pd; in fastrpc_init_attach()
1687 return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, in fastrpc_init_attach()
1691 static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp) in fastrpc_invoke() argument
1715 err = fastrpc_internal_invoke(fl, false, inv.handle, inv.sc, args); in fastrpc_invoke()
1721 static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr_buf, in fastrpc_get_info_from_dsp() argument
1741 return fastrpc_internal_invoke(fl, true, FASTRPC_DSP_UTILITIES_HANDLE, in fastrpc_get_info_from_dsp()
1746 struct fastrpc_user *fl) in fastrpc_get_info_from_kernel() argument
1748 struct fastrpc_channel_ctx *cctx = fl->cctx; in fastrpc_get_info_from_kernel()
1766 err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES); in fastrpc_get_info_from_kernel()
1788 static int fastrpc_get_dsp_info(struct fastrpc_user *fl, char __user *argp) in fastrpc_get_dsp_info() argument
1799 dev_err(&fl->cctx->rpdev->dev, "Error: invalid attribute: %d, err: %d\n", in fastrpc_get_dsp_info()
1804 err = fastrpc_get_info_from_kernel(&cap, fl); in fastrpc_get_dsp_info()
1814 static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, struct fastrpc_buf *buf) in fastrpc_req_munmap_impl() argument
1818 struct device *dev = fl->sctx->dev; in fastrpc_req_munmap_impl()
1822 req_msg.client_id = fl->client_id; in fastrpc_req_munmap_impl()
1830 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, in fastrpc_req_munmap_impl()
1834 spin_lock(&fl->lock); in fastrpc_req_munmap_impl()
1836 spin_unlock(&fl->lock); in fastrpc_req_munmap_impl()
1845 static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp) in fastrpc_req_munmap() argument
1849 struct device *dev = fl->sctx->dev; in fastrpc_req_munmap()
1854 spin_lock(&fl->lock); in fastrpc_req_munmap()
1855 list_for_each_entry_safe(iter, b, &fl->mmaps, node) { in fastrpc_req_munmap()
1861 spin_unlock(&fl->lock); in fastrpc_req_munmap()
1869 return fastrpc_req_munmap_impl(fl, buf); in fastrpc_req_munmap()
1872 static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) in fastrpc_req_mmap() argument
1880 struct device *dev = fl->sctx->dev; in fastrpc_req_mmap()
1899 err = fastrpc_remote_heap_alloc(fl, dev, req.size, &buf); in fastrpc_req_mmap()
1901 err = fastrpc_buf_alloc(fl, dev, req.size, &buf); in fastrpc_req_mmap()
1908 req_msg.client_id = fl->client_id; in fastrpc_req_mmap()
1926 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, in fastrpc_req_mmap()
1941 if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { in fastrpc_req_mmap()
1945 &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); in fastrpc_req_mmap()
1947 dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", in fastrpc_req_mmap()
1953 spin_lock(&fl->lock); in fastrpc_req_mmap()
1954 list_add_tail(&buf->node, &fl->mmaps); in fastrpc_req_mmap()
1955 spin_unlock(&fl->lock); in fastrpc_req_mmap()
1968 fastrpc_req_munmap_impl(fl, buf); in fastrpc_req_mmap()
1973 static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_mem_unmap *req) in fastrpc_req_mem_unmap_impl() argument
1980 struct device *dev = fl->sctx->dev; in fastrpc_req_mem_unmap_impl()
1982 spin_lock(&fl->lock); in fastrpc_req_mem_unmap_impl()
1983 list_for_each_entry_safe(iter, m, &fl->maps, node) { in fastrpc_req_mem_unmap_impl()
1990 spin_unlock(&fl->lock); in fastrpc_req_mem_unmap_impl()
1997 req_msg.client_id = fl->client_id; in fastrpc_req_mem_unmap_impl()
2006 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, in fastrpc_req_mem_unmap_impl()
2017 static int fastrpc_req_mem_unmap(struct fastrpc_user *fl, char __user *argp) in fastrpc_req_mem_unmap() argument
2024 return fastrpc_req_mem_unmap_impl(fl, &req); in fastrpc_req_mem_unmap()
2027 static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp) in fastrpc_req_mem_map() argument
2035 struct device *dev = fl->sctx->dev; in fastrpc_req_mem_map()
2044 err = fastrpc_map_create(fl, req.fd, req.length, 0, &map); in fastrpc_req_mem_map()
2050 req_msg.client_id = fl->client_id; in fastrpc_req_mem_map()
2075 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]); in fastrpc_req_mem_map()
2092 fastrpc_req_mem_unmap_impl(fl, &req_unmap); in fastrpc_req_mem_map()
2107 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data; in fastrpc_device_ioctl() local
2113 err = fastrpc_invoke(fl, argp); in fastrpc_device_ioctl()
2116 err = fastrpc_init_attach(fl, ROOT_PD); in fastrpc_device_ioctl()
2119 err = fastrpc_init_attach(fl, SENSORS_PD); in fastrpc_device_ioctl()
2122 err = fastrpc_init_create_static_process(fl, argp); in fastrpc_device_ioctl()
2125 err = fastrpc_init_create_process(fl, argp); in fastrpc_device_ioctl()
2128 err = fastrpc_dmabuf_alloc(fl, argp); in fastrpc_device_ioctl()
2131 err = fastrpc_req_mmap(fl, argp); in fastrpc_device_ioctl()
2134 err = fastrpc_req_munmap(fl, argp); in fastrpc_device_ioctl()
2137 err = fastrpc_req_mem_map(fl, argp); in fastrpc_device_ioctl()
2140 err = fastrpc_req_mem_unmap(fl, argp); in fastrpc_device_ioctl()
2143 err = fastrpc_get_dsp_info(fl, argp); in fastrpc_device_ioctl()