Merge tag 'drm-misc-next-2020-10-27' of git://anongit.freedesktop.org/drm/drm-misc...
[platform/kernel/linux-starfive.git] / drivers / misc / fastrpc.c
index b39e198..70eb5ed 100644 (file)
 #define FASTRPC_RMID_INIT_CREATE_ATTR  7
 #define FASTRPC_RMID_INIT_CREATE_STATIC        8
 
+/* Protection Domain(PD) ids */
+#define AUDIO_PD       (0) /* also GUEST_OS PD? */
+#define USER_PD                (1)
+#define SENSORS_PD     (2)
+
 #define miscdev_to_cctx(d) container_of(d, struct fastrpc_channel_ctx, miscdev)
 
 static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
@@ -518,7 +523,7 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
 
        table = &a->sgt;
 
-       if (!dma_map_sg(attachment->dev, table->sgl, table->nents, dir))
+       if (!dma_map_sgtable(attachment->dev, table, dir, 0))
                return ERR_PTR(-ENOMEM);
 
        return table;
@@ -528,7 +533,7 @@ static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,
                                  struct sg_table *table,
                                  enum dma_data_direction dir)
 {
-       dma_unmap_sg(attach->dev, table->sgl, table->nents, dir);
+       dma_unmap_sgtable(attach->dev, table, dir, 0);
 }
 
 static void fastrpc_release(struct dma_buf *dmabuf)
@@ -1039,7 +1044,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
        inbuf.pageslen = 1;
        inbuf.attrs = init.attrs;
        inbuf.siglen = init.siglen;
-       fl->pd = 1;
+       fl->pd = USER_PD;
 
        if (init.filelen && init.filefd) {
                err = fastrpc_map_create(fl, init.filefd, init.filelen, &map);
@@ -1278,7 +1283,7 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
        return 0;
 }
 
-static int fastrpc_init_attach(struct fastrpc_user *fl)
+static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
 {
        struct fastrpc_invoke_args args[1];
        int tgid = fl->tgid;
@@ -1289,7 +1294,7 @@ static int fastrpc_init_attach(struct fastrpc_user *fl)
        args[0].fd = -1;
        args[0].reserved = 0;
        sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
-       fl->pd = 0;
+       fl->pd = pd;
 
        return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
                                       sc, &args[0]);
@@ -1479,7 +1484,10 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
                err = fastrpc_invoke(fl, argp);
                break;
        case FASTRPC_IOCTL_INIT_ATTACH:
-               err = fastrpc_init_attach(fl);
+               err = fastrpc_init_attach(fl, AUDIO_PD);
+               break;
+       case FASTRPC_IOCTL_INIT_ATTACH_SNS:
+               err = fastrpc_init_attach(fl, SENSORS_PD);
                break;
        case FASTRPC_IOCTL_INIT_CREATE:
                err = fastrpc_init_create_process(fl, argp);