Skip to content

Commit 35a82b8

Browse files
Vamsi Krishna Gattupalligregkh
authored andcommitted
misc: fastrpc: Add dma handle implementation
The remote arguments carry both remote buffers and dma handles. Add proper dma handle instructions to make it compatible with DSP implementation. Signed-off-by: Vamsi Krishna Gattupalli <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8f6c1d8 commit 35a82b8

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

drivers/misc/fastrpc.c

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,20 @@ struct fastrpc_invoke_buf {
101101
u32 pgidx; /* index to start of contiguous region */
102102
};
103103

104-
struct fastrpc_remote_arg {
105-
u64 pv;
106-
u64 len;
104+
struct fastrpc_remote_dmahandle {
105+
s32 fd; /* dma handle fd */
106+
u32 offset; /* dma handle offset */
107+
u32 len; /* dma handle length */
108+
};
109+
110+
struct fastrpc_remote_buf {
111+
u64 pv; /* buffer pointer */
112+
u64 len; /* length of buffer */
113+
};
114+
115+
union fastrpc_remote_arg {
116+
struct fastrpc_remote_buf buf;
117+
struct fastrpc_remote_dmahandle dma;
107118
};
108119

109120
struct fastrpc_mmap_rsp_msg {
@@ -217,7 +228,7 @@ struct fastrpc_invoke_ctx {
217228
struct work_struct put_work;
218229
struct fastrpc_msg msg;
219230
struct fastrpc_user *fl;
220-
struct fastrpc_remote_arg *rpra;
231+
union fastrpc_remote_arg *rpra;
221232
struct fastrpc_map **maps;
222233
struct fastrpc_buf *buf;
223234
struct fastrpc_invoke_args *args;
@@ -767,7 +778,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
767778
* >>>>>> START of METADATA <<<<<<<<<
768779
* +---------------------------------+
769780
* | Arguments |
770-
* | type:(struct fastrpc_remote_arg)|
781+
* | type:(union fastrpc_remote_arg)|
771782
* | (0 - N) |
772783
* +---------------------------------+
773784
* | Invoke Buffer list |
@@ -792,7 +803,7 @@ static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
792803
{
793804
int size = 0;
794805

795-
size = (sizeof(struct fastrpc_remote_arg) +
806+
size = (sizeof(struct fastrpc_remote_buf) +
796807
sizeof(struct fastrpc_invoke_buf) +
797808
sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
798809
sizeof(u64) * FASTRPC_MAX_FDLIST +
@@ -857,7 +868,7 @@ static struct fastrpc_phy_page *fastrpc_phy_page_start(struct fastrpc_invoke_buf
857868
static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
858869
{
859870
struct device *dev = ctx->fl->sctx->dev;
860-
struct fastrpc_remote_arg *rpra;
871+
union fastrpc_remote_arg *rpra;
861872
struct fastrpc_invoke_buf *list;
862873
struct fastrpc_phy_page *pages;
863874
int inbufs, i, oix, err = 0;
@@ -893,8 +904,8 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
893904
i = ctx->olaps[oix].raix;
894905
len = ctx->args[i].length;
895906

896-
rpra[i].pv = 0;
897-
rpra[i].len = len;
907+
rpra[i].buf.pv = 0;
908+
rpra[i].buf.len = len;
898909
list[i].num = len ? 1 : 0;
899910
list[i].pgidx = i;
900911

@@ -904,7 +915,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
904915
if (ctx->maps[i]) {
905916
struct vm_area_struct *vma = NULL;
906917

907-
rpra[i].pv = (u64) ctx->args[i].ptr;
918+
rpra[i].buf.pv = (u64) ctx->args[i].ptr;
908919
pages[i].addr = ctx->maps[i]->phys;
909920

910921
mmap_read_lock(current->mm);
@@ -931,7 +942,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
931942
if (rlen < mlen)
932943
goto bail;
933944

934-
rpra[i].pv = args - ctx->olaps[oix].offset;
945+
rpra[i].buf.pv = args - ctx->olaps[oix].offset;
935946
pages[i].addr = ctx->buf->phys -
936947
ctx->olaps[oix].offset +
937948
(pkt_size - rlen);
@@ -945,7 +956,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
945956
}
946957

947958
if (i < inbufs && !ctx->maps[i]) {
948-
void *dst = (void *)(uintptr_t)rpra[i].pv;
959+
void *dst = (void *)(uintptr_t)rpra[i].buf.pv;
949960
void *src = (void *)(uintptr_t)ctx->args[i].ptr;
950961

951962
if (!kernel) {
@@ -961,12 +972,15 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
961972
}
962973

963974
for (i = ctx->nbufs; i < ctx->nscalars; ++i) {
964-
rpra[i].pv = (u64) ctx->args[i].ptr;
965-
rpra[i].len = ctx->args[i].length;
966975
list[i].num = ctx->args[i].length ? 1 : 0;
967976
list[i].pgidx = i;
968-
pages[i].addr = ctx->maps[i]->phys;
969-
pages[i].size = ctx->maps[i]->size;
977+
if (ctx->maps[i]) {
978+
pages[i].addr = ctx->maps[i]->phys;
979+
pages[i].size = ctx->maps[i]->size;
980+
}
981+
rpra[i].dma.fd = ctx->args[i].fd;
982+
rpra[i].dma.len = ctx->args[i].length;
983+
rpra[i].dma.offset = (u64) ctx->args[i].ptr;
970984
}
971985

972986
bail:
@@ -979,7 +993,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
979993
static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
980994
u32 kernel)
981995
{
982-
struct fastrpc_remote_arg *rpra = ctx->rpra;
996+
union fastrpc_remote_arg *rpra = ctx->rpra;
983997
struct fastrpc_user *fl = ctx->fl;
984998
struct fastrpc_map *mmap = NULL;
985999
struct fastrpc_invoke_buf *list;
@@ -996,9 +1010,9 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
9961010

9971011
for (i = inbufs; i < ctx->nbufs; ++i) {
9981012
if (!ctx->maps[i]) {
999-
void *src = (void *)(uintptr_t)rpra[i].pv;
1013+
void *src = (void *)(uintptr_t)rpra[i].buf.pv;
10001014
void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
1001-
u64 len = rpra[i].len;
1015+
u64 len = rpra[i].buf.len;
10021016

10031017
if (!kernel) {
10041018
if (copy_to_user((void __user *)dst, src, len))

0 commit comments

Comments
 (0)