Skip to content

Commit 7e60e1e

Browse files
Anandu Krishnan Eekanshibu
authored andcommitted
Revert "FROMLIST: misc: fastrpc: Add reference counting for fastrpc_user structure"
This reverts commit 94b182f. This change corresponds to the initial (v1) version shared with the upstream community. Revert it to apply the complete v4 revision, which includes additional fixes and updates not present in the earlier version. v4 version contains this changes as well. Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
1 parent c18d1af commit 7e60e1e

1 file changed

Lines changed: 4 additions & 31 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ struct fastrpc_user {
332332
spinlock_t lock;
333333
/* lock for allocations */
334334
struct mutex mutex;
335-
/* Reference count */
336-
struct kref refcount;
337335
};
338336

339337
/* Extract SMMU PA from consolidated IOVA */
@@ -551,36 +549,15 @@ static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx)
551549
kref_put(&cctx->refcount, fastrpc_channel_ctx_free);
552550
}
553551

554-
static void fastrpc_user_free(struct kref *ref)
555-
{
556-
struct fastrpc_user *fl = container_of(ref, struct fastrpc_user, refcount);
557-
558-
fastrpc_channel_ctx_put(fl->cctx);
559-
mutex_destroy(&fl->mutex);
560-
kfree(fl);
561-
}
562-
563-
static void fastrpc_user_get(struct fastrpc_user *fl)
564-
{
565-
kref_get(&fl->refcount);
566-
}
567-
568-
static void fastrpc_user_put(struct fastrpc_user *fl)
569-
{
570-
kref_put(&fl->refcount, fastrpc_user_free);
571-
}
572-
573552
static void fastrpc_context_free(struct kref *ref)
574553
{
575554
struct fastrpc_invoke_ctx *ctx;
576555
struct fastrpc_channel_ctx *cctx;
577-
struct fastrpc_user *fl;
578556
unsigned long flags;
579557
int i;
580558

581559
ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
582560
cctx = ctx->cctx;
583-
fl = ctx->fl;
584561

585562
for (i = 0; i < ctx->nbufs; i++)
586563
fastrpc_map_put(ctx->maps[i]);
@@ -595,8 +572,6 @@ static void fastrpc_context_free(struct kref *ref)
595572
kfree(ctx->olaps);
596573
kfree(ctx);
597574

598-
/* Release the reference taken in fastrpc_context_alloc() */
599-
fastrpc_user_put(fl);
600575
fastrpc_channel_ctx_put(cctx);
601576
}
602577

@@ -704,8 +679,6 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
704679

705680
/* Released in fastrpc_context_put() */
706681
fastrpc_channel_ctx_get(cctx);
707-
/* Take a reference to user, released in fastrpc_context_free() */
708-
fastrpc_user_get(user);
709682

710683
ctx->sc = sc;
711684
ctx->retval = -1;
@@ -736,7 +709,6 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
736709
spin_lock(&user->lock);
737710
list_del(&ctx->node);
738711
spin_unlock(&user->lock);
739-
fastrpc_user_put(user);
740712
fastrpc_channel_ctx_put(cctx);
741713
kfree(ctx->maps);
742714
kfree(ctx->olaps);
@@ -1744,9 +1716,11 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
17441716
}
17451717

17461718
fastrpc_session_free(cctx, fl->sctx);
1719+
fastrpc_channel_ctx_put(cctx);
1720+
1721+
mutex_destroy(&fl->mutex);
1722+
kfree(fl);
17471723
file->private_data = NULL;
1748-
/* Release the reference taken in fastrpc_device_open */
1749-
fastrpc_user_put(fl);
17501724

17511725
return 0;
17521726
}
@@ -1790,7 +1764,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
17901764
spin_lock_irqsave(&cctx->lock, flags);
17911765
list_add_tail(&fl->user, &cctx->users);
17921766
spin_unlock_irqrestore(&cctx->lock, flags);
1793-
kref_init(&fl->refcount);
17941767

17951768
return 0;
17961769
}

0 commit comments

Comments
 (0)