@@ -320,15 +320,15 @@ static void fastrpc_map_get(struct fastrpc_map *map)
320
320
kref_get (& map -> refcount );
321
321
}
322
322
323
- static int fastrpc_map_find (struct fastrpc_user * fl , int fd ,
323
+
324
+ static int fastrpc_map_lookup (struct fastrpc_user * fl , int fd ,
324
325
struct fastrpc_map * * ppmap )
325
326
{
326
327
struct fastrpc_map * map = NULL ;
327
328
328
329
mutex_lock (& fl -> mutex );
329
330
list_for_each_entry (map , & fl -> maps , node ) {
330
331
if (map -> fd == fd ) {
331
- fastrpc_map_get (map );
332
332
* ppmap = map ;
333
333
mutex_unlock (& fl -> mutex );
334
334
return 0 ;
@@ -339,6 +339,17 @@ static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
339
339
return - ENOENT ;
340
340
}
341
341
342
+ static int fastrpc_map_find (struct fastrpc_user * fl , int fd ,
343
+ struct fastrpc_map * * ppmap )
344
+ {
345
+ int ret = fastrpc_map_lookup (fl , fd , ppmap );
346
+
347
+ if (!ret )
348
+ fastrpc_map_get (* ppmap );
349
+
350
+ return ret ;
351
+ }
352
+
342
353
static void fastrpc_buf_free (struct fastrpc_buf * buf )
343
354
{
344
355
dma_free_coherent (buf -> dev , buf -> size , buf -> virt ,
@@ -411,7 +422,7 @@ static void fastrpc_context_free(struct kref *ref)
411
422
ctx = container_of (ref , struct fastrpc_invoke_ctx , refcount );
412
423
cctx = ctx -> cctx ;
413
424
414
- for (i = 0 ; i < ctx -> nscalars ; i ++ )
425
+ for (i = 0 ; i < ctx -> nbufs ; i ++ )
415
426
fastrpc_map_put (ctx -> maps [i ]);
416
427
417
428
if (ctx -> buf )
@@ -969,9 +980,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
969
980
u32 kernel )
970
981
{
971
982
struct fastrpc_remote_arg * rpra = ctx -> rpra ;
972
- int i , inbufs ;
983
+ struct fastrpc_user * fl = ctx -> fl ;
984
+ struct fastrpc_map * mmap = NULL ;
985
+ struct fastrpc_invoke_buf * list ;
986
+ struct fastrpc_phy_page * pages ;
987
+ u64 * fdlist ;
988
+ int i , inbufs , outbufs , handles ;
973
989
974
990
inbufs = REMOTE_SCALARS_INBUFS (ctx -> sc );
991
+ outbufs = REMOTE_SCALARS_OUTBUFS (ctx -> sc );
992
+ handles = REMOTE_SCALARS_INHANDLES (ctx -> sc ) + REMOTE_SCALARS_OUTHANDLES (ctx -> sc );
993
+ list = fastrpc_invoke_buf_start (rpra , ctx -> nscalars );
994
+ pages = fastrpc_phy_page_start (list , ctx -> nscalars );
995
+ fdlist = (uint64_t * )(pages + inbufs + outbufs + handles );
975
996
976
997
for (i = inbufs ; i < ctx -> nbufs ; ++ i ) {
977
998
if (!ctx -> maps [i ]) {
@@ -988,6 +1009,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
988
1009
}
989
1010
}
990
1011
1012
+ for (i = 0 ; i < FASTRPC_MAX_FDLIST ; i ++ ) {
1013
+ if (!fdlist [i ])
1014
+ break ;
1015
+ if (!fastrpc_map_lookup (fl , (int )fdlist [i ], & mmap ))
1016
+ fastrpc_map_put (mmap );
1017
+ }
1018
+
991
1019
return 0 ;
992
1020
}
993
1021
0 commit comments