fastrpc.c (ead5d1f4d877e92c051e1a1ade623d0d30e71619) fastrpc.c (84195d206e1fbd6309ee172ddfbe1673c1254488)
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
3// Copyright (c) 2018, Linaro Limited
4
5#include <linux/completion.h>
6#include <linux/device.h>
7#include <linux/dma-buf.h>
8#include <linux/dma-mapping.h>

--- 59 unchanged lines hidden (view full) ---

68#define FASTRPC_RMID_INIT_ATTACH 0
69#define FASTRPC_RMID_INIT_RELEASE 1
70#define FASTRPC_RMID_INIT_MMAP 4
71#define FASTRPC_RMID_INIT_MUNMAP 5
72#define FASTRPC_RMID_INIT_CREATE 6
73#define FASTRPC_RMID_INIT_CREATE_ATTR 7
74#define FASTRPC_RMID_INIT_CREATE_STATIC 8
75
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
3// Copyright (c) 2018, Linaro Limited
4
5#include <linux/completion.h>
6#include <linux/device.h>
7#include <linux/dma-buf.h>
8#include <linux/dma-mapping.h>

--- 59 unchanged lines hidden (view full) ---

68#define FASTRPC_RMID_INIT_ATTACH 0
69#define FASTRPC_RMID_INIT_RELEASE 1
70#define FASTRPC_RMID_INIT_MMAP 4
71#define FASTRPC_RMID_INIT_MUNMAP 5
72#define FASTRPC_RMID_INIT_CREATE 6
73#define FASTRPC_RMID_INIT_CREATE_ATTR 7
74#define FASTRPC_RMID_INIT_CREATE_STATIC 8
75
76/* Protection Domain(PD) ids */
77#define AUDIO_PD (0) /* also GUEST_OS PD? */
78#define USER_PD (1)
79#define SENSORS_PD (2)
80
76#define miscdev_to_cctx(d) container_of(d, struct fastrpc_channel_ctx, miscdev)
77
78static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
79 "sdsp", "cdsp"};
80struct fastrpc_phy_page {
81 u64 addr; /* physical address */
82 u64 size; /* size of contiguous region */
83};

--- 429 unchanged lines hidden (view full) ---

513fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
514 enum dma_data_direction dir)
515{
516 struct fastrpc_dma_buf_attachment *a = attachment->priv;
517 struct sg_table *table;
518
519 table = &a->sgt;
520
81#define miscdev_to_cctx(d) container_of(d, struct fastrpc_channel_ctx, miscdev)
82
83static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
84 "sdsp", "cdsp"};
85struct fastrpc_phy_page {
86 u64 addr; /* physical address */
87 u64 size; /* size of contiguous region */
88};

--- 429 unchanged lines hidden (view full) ---

518fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
519 enum dma_data_direction dir)
520{
521 struct fastrpc_dma_buf_attachment *a = attachment->priv;
522 struct sg_table *table;
523
524 table = &a->sgt;
525
521 if (!dma_map_sg(attachment->dev, table->sgl, table->nents, dir))
526 if (!dma_map_sgtable(attachment->dev, table, dir, 0))
522 return ERR_PTR(-ENOMEM);
523
524 return table;
525}
526
527static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,
528 struct sg_table *table,
529 enum dma_data_direction dir)
530{
527 return ERR_PTR(-ENOMEM);
528
529 return table;
530}
531
532static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,
533 struct sg_table *table,
534 enum dma_data_direction dir)
535{
531 dma_unmap_sg(attach->dev, table->sgl, table->nents, dir);
536 dma_unmap_sgtable(attach->dev, table, dir, 0);
532}
533
534static void fastrpc_release(struct dma_buf *dmabuf)
535{
536 struct fastrpc_buf *buffer = dmabuf->priv;
537
538 fastrpc_buf_free(buffer);
539}

--- 492 unchanged lines hidden (view full) ---

1032 }
1033
1034 inbuf.pgid = fl->tgid;
1035 inbuf.namelen = strlen(current->comm) + 1;
1036 inbuf.filelen = init.filelen;
1037 inbuf.pageslen = 1;
1038 inbuf.attrs = init.attrs;
1039 inbuf.siglen = init.siglen;
537}
538
539static void fastrpc_release(struct dma_buf *dmabuf)
540{
541 struct fastrpc_buf *buffer = dmabuf->priv;
542
543 fastrpc_buf_free(buffer);
544}

--- 492 unchanged lines hidden (view full) ---

1037 }
1038
1039 inbuf.pgid = fl->tgid;
1040 inbuf.namelen = strlen(current->comm) + 1;
1041 inbuf.filelen = init.filelen;
1042 inbuf.pageslen = 1;
1043 inbuf.attrs = init.attrs;
1044 inbuf.siglen = init.siglen;
1040 fl->pd = 1;
1045 fl->pd = USER_PD;
1041
1042 if (init.filelen && init.filefd) {
1043 err = fastrpc_map_create(fl, init.filefd, init.filelen, &map);
1044 if (err)
1045 goto err;
1046 }
1047
1048 memlen = ALIGN(max(INIT_FILELEN_MAX, (int)init.filelen * 4),

--- 233 unchanged lines hidden (view full) ---

1282 int tgid = fl->tgid;
1283 u32 sc;
1284
1285 args[0].ptr = (u64)(uintptr_t) &tgid;
1286 args[0].length = sizeof(tgid);
1287 args[0].fd = -1;
1288 args[0].reserved = 0;
1289 sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
1046
1047 if (init.filelen && init.filefd) {
1048 err = fastrpc_map_create(fl, init.filefd, init.filelen, &map);
1049 if (err)
1050 goto err;
1051 }
1052
1053 memlen = ALIGN(max(INIT_FILELEN_MAX, (int)init.filelen * 4),

--- 233 unchanged lines hidden (view full) ---

1287 int tgid = fl->tgid;
1288 u32 sc;
1289
1290 args[0].ptr = (u64)(uintptr_t) &tgid;
1291 args[0].length = sizeof(tgid);
1292 args[0].fd = -1;
1293 args[0].reserved = 0;
1294 sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
1290 fl->pd = 0;
1295 fl->pd = AUDIO_PD;
1291
1292 return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
1293 sc, &args[0]);
1294}
1295
1296static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
1297{
1298 struct fastrpc_invoke_args *args = NULL;

--- 451 unchanged lines hidden ---
1296
1297 return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
1298 sc, &args[0]);
1299}
1300
1301static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
1302{
1303 struct fastrpc_invoke_args *args = NULL;

--- 451 unchanged lines hidden ---