Loading drivers/char/adsprpc.c +43 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ #define TZ_PIL_AUTH_QDSP6_PROC 1 #define ADSP_MMAP_HEAP_ADDR 4 #define ADSP_MMAP_REMOTE_HEAP_ADDR 8 #define FASTRPC_DMAHANDLE_NOMAP (16) #define FASTRPC_ENOSUCH 39 #define VMID_SSC_Q6 5 #define VMID_ADSP_Q6 6 Loading Loading @@ -624,6 +626,14 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags) dma_free_coherent(me->dev, map->size, (void *)map->va, (dma_addr_t)map->phys); } } else if (map->flags == FASTRPC_DMAHANDLE_NOMAP) { if (!IS_ERR_OR_NULL(map->table)) dma_buf_unmap_attachment(map->attach, map->table, DMA_BIDIRECTIONAL); if (!IS_ERR_OR_NULL(map->attach)) dma_buf_detach(map->buf, map->attach); if (!IS_ERR_OR_NULL(map->buf)) dma_buf_put(map->buf); } else { int destVM[1] = {VMID_HLOS}; int destVMperm[1] = {PERM_READ | PERM_WRITE | PERM_EXEC}; Loading Loading @@ -694,6 +704,33 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, map->phys = (uintptr_t)region_phys; map->size = len; map->va = (uintptr_t)region_vaddr; } else if (mflags == FASTRPC_DMAHANDLE_NOMAP) { VERIFY(err, !IS_ERR_OR_NULL(map->buf = dma_buf_get(fd))); if (err) goto bail; VERIFY(err, !dma_buf_get_flags(map->buf, &flags)); if (err) goto bail; map->secure = flags & ION_FLAG_SECURE; map->uncached = 1; map->va = 0; map->phys = 0; VERIFY(err, !IS_ERR_OR_NULL(map->attach = dma_buf_attach(map->buf, me->dev))); if (err) goto bail; map->attach->dma_map_attrs |= DMA_ATTR_SKIP_CPU_SYNC; VERIFY(err, !IS_ERR_OR_NULL(map->table = dma_buf_map_attachment(map->attach, DMA_BIDIRECTIONAL))); if (err) goto bail; VERIFY(err, map->table->nents == 1); if (err) goto bail; map->phys = sg_dma_address(map->table->sgl); } else { if (map->attr && (map->attr & FASTRPC_ATTR_KEEP_MAP)) { pr_info("adsprpc: buffer mapped with persist attr %x\n", Loading Loading @@ -1222,8 +1259,13 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx) PERF_END); handles = REMOTE_SCALARS_INHANDLES(sc) + REMOTE_SCALARS_OUTHANDLES(sc); for (i = bufs; i < bufs + handles; i++) { int dmaflags = 0; if (ctx->attrs && (ctx->attrs[i] & FASTRPC_ATTR_NOMAP)) dmaflags = FASTRPC_DMAHANDLE_NOMAP; VERIFY(err, !fastrpc_mmap_create(ctx->fl, ctx->fds[i], FASTRPC_ATTR_NOVA, 0, 0, 0, &ctx->maps[i])); FASTRPC_ATTR_NOVA, 0, 0, dmaflags, &ctx->maps[i])); if (err) goto bail; ipage += 1; Loading drivers/char/adsprpc_shared.h +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ /* Fastrpc attribute for keeping the map persistent */ #define FASTRPC_ATTR_KEEP_MAP 0x8 /* Fastrpc attribute for no mapping of fd */ #define FASTRPC_ATTR_NOMAP (16) /* Driver should operate in parallel with the co-processor */ #define FASTRPC_MODE_PARALLEL 0 Loading Loading
drivers/char/adsprpc.c +43 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ #define TZ_PIL_AUTH_QDSP6_PROC 1 #define ADSP_MMAP_HEAP_ADDR 4 #define ADSP_MMAP_REMOTE_HEAP_ADDR 8 #define FASTRPC_DMAHANDLE_NOMAP (16) #define FASTRPC_ENOSUCH 39 #define VMID_SSC_Q6 5 #define VMID_ADSP_Q6 6 Loading Loading @@ -624,6 +626,14 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags) dma_free_coherent(me->dev, map->size, (void *)map->va, (dma_addr_t)map->phys); } } else if (map->flags == FASTRPC_DMAHANDLE_NOMAP) { if (!IS_ERR_OR_NULL(map->table)) dma_buf_unmap_attachment(map->attach, map->table, DMA_BIDIRECTIONAL); if (!IS_ERR_OR_NULL(map->attach)) dma_buf_detach(map->buf, map->attach); if (!IS_ERR_OR_NULL(map->buf)) dma_buf_put(map->buf); } else { int destVM[1] = {VMID_HLOS}; int destVMperm[1] = {PERM_READ | PERM_WRITE | PERM_EXEC}; Loading Loading @@ -694,6 +704,33 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, map->phys = (uintptr_t)region_phys; map->size = len; map->va = (uintptr_t)region_vaddr; } else if (mflags == FASTRPC_DMAHANDLE_NOMAP) { VERIFY(err, !IS_ERR_OR_NULL(map->buf = dma_buf_get(fd))); if (err) goto bail; VERIFY(err, !dma_buf_get_flags(map->buf, &flags)); if (err) goto bail; map->secure = flags & ION_FLAG_SECURE; map->uncached = 1; map->va = 0; map->phys = 0; VERIFY(err, !IS_ERR_OR_NULL(map->attach = dma_buf_attach(map->buf, me->dev))); if (err) goto bail; map->attach->dma_map_attrs |= DMA_ATTR_SKIP_CPU_SYNC; VERIFY(err, !IS_ERR_OR_NULL(map->table = dma_buf_map_attachment(map->attach, DMA_BIDIRECTIONAL))); if (err) goto bail; VERIFY(err, map->table->nents == 1); if (err) goto bail; map->phys = sg_dma_address(map->table->sgl); } else { if (map->attr && (map->attr & FASTRPC_ATTR_KEEP_MAP)) { pr_info("adsprpc: buffer mapped with persist attr %x\n", Loading Loading @@ -1222,8 +1259,13 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx) PERF_END); handles = REMOTE_SCALARS_INHANDLES(sc) + REMOTE_SCALARS_OUTHANDLES(sc); for (i = bufs; i < bufs + handles; i++) { int dmaflags = 0; if (ctx->attrs && (ctx->attrs[i] & FASTRPC_ATTR_NOMAP)) dmaflags = FASTRPC_DMAHANDLE_NOMAP; VERIFY(err, !fastrpc_mmap_create(ctx->fl, ctx->fds[i], FASTRPC_ATTR_NOVA, 0, 0, 0, &ctx->maps[i])); FASTRPC_ATTR_NOVA, 0, 0, dmaflags, &ctx->maps[i])); if (err) goto bail; ipage += 1; Loading
drivers/char/adsprpc_shared.h +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ /* Fastrpc attribute for keeping the map persistent */ #define FASTRPC_ATTR_KEEP_MAP 0x8 /* Fastrpc attribute for no mapping of fd */ #define FASTRPC_ATTR_NOMAP (16) /* Driver should operate in parallel with the co-processor */ #define FASTRPC_MODE_PARALLEL 0 Loading