* [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments
@ 2023-08-31 6:23 Ekansh Gupta
2023-09-26 10:27 ` Srinivas Kandagatla
2023-09-28 13:05 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Ekansh Gupta @ 2023-08-31 6:23 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
The FDs for DMA handles to be freed is updated in fdlist by DSP over
a remote call. This holds true even for remote calls with no
arguments. To handle this, get_args and put_args are needed to
be called for remote calls with no arguments also as fdlist
is allocated in get_args and FDs updated in fdlist is freed
in put_args.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 9666d28..e6df66e 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1153,11 +1153,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (IS_ERR(ctx))
return PTR_ERR(ctx);
- if (ctx->nscalars) {
- err = fastrpc_get_args(kernel, ctx);
- if (err)
- goto bail;
- }
+ err = fastrpc_get_args(kernel, ctx);
+ if (err)
+ goto bail;
/* make sure that all CPU memory writes are seen by DSP */
dma_wmb();
@@ -1181,14 +1179,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (err)
goto bail;
- if (ctx->nscalars) {
- /* make sure that all memory writes by DSP are seen by CPU */
- dma_rmb();
- /* populate all the output buffers with results */
- err = fastrpc_put_args(ctx, kernel);
- if (err)
- goto bail;
- }
+ /* make sure that all memory writes by DSP are seen by CPU */
+ dma_rmb();
+ /* populate all the output buffers with results */
+ err = fastrpc_put_args(ctx, kernel);
+ if (err)
+ goto bail;
bail:
if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments
2023-08-31 6:23 [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments Ekansh Gupta
@ 2023-09-26 10:27 ` Srinivas Kandagatla
2023-09-26 11:44 ` Ekansh Gupta
2023-09-28 13:05 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Srinivas Kandagatla @ 2023-09-26 10:27 UTC (permalink / raw)
To: Ekansh Gupta, linux-arm-msm
Cc: ekangupt, gregkh, linux-kernel, fastrpc.upstream
Thanks Ekansh for this patch.
few comments below
On 31/08/2023 07:23, Ekansh Gupta wrote:
> The FDs for DMA handles to be freed is updated in fdlist by DSP over
So the dsp is updating the fd list after invoke?
> a remote call. This holds true even for remote calls with no
> arguments. To handle this, get_args and put_args are needed to
> be called for remote calls with no arguments also as fdlist
> is allocated in get_args and FDs updated in fdlist is freed
> in put_args.
>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> ---
> drivers/misc/fastrpc.c | 22 +++++++++-------------
> 1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 9666d28..e6df66e 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1153,11 +1153,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
> if (IS_ERR(ctx))
> return PTR_ERR(ctx);
>
> - if (ctx->nscalars) {
Why do we need to remove this check?
fastrpc_internal_invoke will have nscalars set before calling. and we
are not dealing with fdlist in fastrpc_get_args(), so am not sure what
this change is helping with.
> - err = fastrpc_get_args(kernel, ctx);
> - if (err)
> - goto bail;
> - }
> + err = fastrpc_get_args(kernel, ctx);
> + if (err)
> + goto bail;
>
> /* make sure that all CPU memory writes are seen by DSP */
> dma_wmb();
> @@ -1181,14 +1179,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
> if (err)
> goto bail;
>
> - if (ctx->nscalars) {
> - /* make sure that all memory writes by DSP are seen by CPU */
> - dma_rmb();
> - /* populate all the output buffers with results */
> - err = fastrpc_put_args(ctx, kernel);
> - if (err)
> - goto bail;
> - }
> + /* make sure that all memory writes by DSP are seen by CPU */
> + dma_rmb();
> + /* populate all the output buffers with results */
A comment about fdlist here would be really useful
> + err = fastrpc_put_args(ctx, kernel);
> + if (err)
> + goto bail;
>
> bail:
> if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments
2023-09-26 10:27 ` Srinivas Kandagatla
@ 2023-09-26 11:44 ` Ekansh Gupta
0 siblings, 0 replies; 5+ messages in thread
From: Ekansh Gupta @ 2023-09-26 11:44 UTC (permalink / raw)
To: Srinivas Kandagatla, linux-arm-msm
Cc: ekangupt, gregkh, linux-kernel, fastrpc.upstream
On 9/26/2023 3:57 PM, Srinivas Kandagatla wrote:
> Thanks Ekansh for this patch.
>
> few comments below
>
> On 31/08/2023 07:23, Ekansh Gupta wrote:
>> The FDs for DMA handles to be freed is updated in fdlist by DSP over
>
> So the dsp is updating the fd list after invoke?
>
Yes, correct. DSP updates this fd list when the buffer is no longer
needed by the user PD.
>
>> a remote call. This holds true even for remote calls with no
>> arguments. To handle this, get_args and put_args are needed to
>> be called for remote calls with no arguments also as fdlist
>> is allocated in get_args and FDs updated in fdlist is freed
>> in put_args.
>>
>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
>> ---
>> drivers/misc/fastrpc.c | 22 +++++++++-------------
>> 1 file changed, 9 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 9666d28..e6df66e 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -1153,11 +1153,9 @@ static int fastrpc_internal_invoke(struct
>> fastrpc_user *fl, u32 kernel,
>> if (IS_ERR(ctx))
>> return PTR_ERR(ctx);
>> - if (ctx->nscalars) {
>
> Why do we need to remove this check?
> fastrpc_internal_invoke will have nscalars set before calling. and we
> are not dealing with fdlist in fastrpc_get_args(), so am not sure what
> this change is helping with.
Memory for fdlist is allocated as part of fastrpc_get_args. The reason
to add this change is that fdlist can be updated by DSP over a call with
no remote arguments, for this call, there should be some fdlist
allocated so the DSP can update the list if needed. Same apply for
fastrpc_put_args also as when DSP updates fdlist for any remote call
with no arguments, the maps corresponding to the fdlist should be freed.
>
>
>> - err = fastrpc_get_args(kernel, ctx);
>> - if (err)
>> - goto bail;
>> - }
>> + err = fastrpc_get_args(kernel, ctx);
>> + if (err)
>> + goto bail;
>> /* make sure that all CPU memory writes are seen by DSP */
>> dma_wmb();
>> @@ -1181,14 +1179,12 @@ static int fastrpc_internal_invoke(struct
>> fastrpc_user *fl, u32 kernel,
>> if (err)
>> goto bail;
>> - if (ctx->nscalars) {
>> - /* make sure that all memory writes by DSP are seen by CPU */
>> - dma_rmb();
>> - /* populate all the output buffers with results */
>> - err = fastrpc_put_args(ctx, kernel);
>> - if (err)
>> - goto bail;
>> - }
>> + /* make sure that all memory writes by DSP are seen by CPU */
>> + dma_rmb();
>> + /* populate all the output buffers with results */
>
> A comment about fdlist here would be really useful
Sure, I will add a comment in the next patch. Do you suggest to add
comment here or inside fastrpc_put_args function:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/misc/fastrpc.c#n1092
>
>> + err = fastrpc_put_args(ctx, kernel);
>> + if (err)
>> + goto bail;
>> bail:
>> if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments
2023-08-31 6:23 [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments Ekansh Gupta
2023-09-26 10:27 ` Srinivas Kandagatla
@ 2023-09-28 13:05 ` Greg KH
2023-09-29 7:14 ` Ekansh Gupta
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2023-09-28 13:05 UTC (permalink / raw)
To: Ekansh Gupta
Cc: srinivas.kandagatla, linux-arm-msm, ekangupt, linux-kernel,
fastrpc.upstream
On Thu, Aug 31, 2023 at 11:53:49AM +0530, Ekansh Gupta wrote:
> The FDs for DMA handles to be freed is updated in fdlist by DSP over
> a remote call. This holds true even for remote calls with no
> arguments. To handle this, get_args and put_args are needed to
> be called for remote calls with no arguments also as fdlist
> is allocated in get_args and FDs updated in fdlist is freed
> in put_args.
>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
What commit id does this fix? Or is this new functionality?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments
2023-09-28 13:05 ` Greg KH
@ 2023-09-29 7:14 ` Ekansh Gupta
0 siblings, 0 replies; 5+ messages in thread
From: Ekansh Gupta @ 2023-09-29 7:14 UTC (permalink / raw)
To: Greg KH
Cc: srinivas.kandagatla, linux-arm-msm, ekangupt, linux-kernel,
fastrpc.upstream
On 9/28/2023 6:35 PM, Greg KH wrote:
> On Thu, Aug 31, 2023 at 11:53:49AM +0530, Ekansh Gupta wrote:
>> The FDs for DMA handles to be freed is updated in fdlist by DSP over
>> a remote call. This holds true even for remote calls with no
>> arguments. To handle this, get_args and put_args are needed to
>> be called for remote calls with no arguments also as fdlist
>> is allocated in get_args and FDs updated in fdlist is freed
>> in put_args.
>>
>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
>
> What commit id does this fix? Or is this new functionality?
>
I'll update the details in the next patch.
-ekansh
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-29 7:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31 6:23 [PATCH v1] misc: fastrpc: Free DMA handles for RPC calls with no arguments Ekansh Gupta
2023-09-26 10:27 ` Srinivas Kandagatla
2023-09-26 11:44 ` Ekansh Gupta
2023-09-28 13:05 ` Greg KH
2023-09-29 7:14 ` Ekansh Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox