diff mbox series

[v6,2/2] misc: fastrpc: Increase unsigned PD initmem size

Message ID 20240722080200.3530850-3-quic_ekangupt@quicinc.com (mailing list archive)
State New, archived
Headers show
Series Fix user PD inimem requirements | expand

Commit Message

Ekansh Gupta July 22, 2024, 8:02 a.m. UTC
For unsigned PD offloading requirement, additional memory is required
because of additional static heap initialization. Without this
additional memory, PD initialization would fail. Increase the initmem
size by 2MB for unsigned PD initmem buffer allocation. Any additional
memory sent to DSP during PD init is used as the PD heap.

Fixes: 7f1f481263c3 ("misc: fastrpc: check before loading process to the DSP")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
 drivers/misc/fastrpc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Dmitry Baryshkov July 22, 2024, 8:34 a.m. UTC | #1
On Mon, Jul 22, 2024 at 01:32:00PM GMT, Ekansh Gupta wrote:
> For unsigned PD offloading requirement, additional memory is required
> because of additional static heap initialization. Without this
> additional memory, PD initialization would fail. Increase the initmem
> size by 2MB for unsigned PD initmem buffer allocation. Any additional
> memory sent to DSP during PD init is used as the PD heap.

From the previous commit message I had the feeling that DSP can request
more memory if required. Currently you are stating that PD init would
fail if it doesn't have enough mem.

> 
> Fixes: 7f1f481263c3 ("misc: fastrpc: check before loading process to the DSP")
> Cc: stable <stable@kernel.org>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> ---
>  drivers/misc/fastrpc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
Ekansh Gupta July 23, 2024, 4:36 a.m. UTC | #2
On 7/22/2024 2:04 PM, Dmitry Baryshkov wrote:
> On Mon, Jul 22, 2024 at 01:32:00PM GMT, Ekansh Gupta wrote:
>> For unsigned PD offloading requirement, additional memory is required
>> because of additional static heap initialization. Without this
>> additional memory, PD initialization would fail. Increase the initmem
>> size by 2MB for unsigned PD initmem buffer allocation. Any additional
>> memory sent to DSP during PD init is used as the PD heap.
> From the previous commit message I had the feeling that DSP can request
> more memory if required. Currently you are stating that PD init would
> fail if it doesn't have enough mem.

DSP PD can request for memory only for PD heap and that too once the PD
initialization is complete.

>
>> Fixes: 7f1f481263c3 ("misc: fastrpc: check before loading process to the DSP")
>> Cc: stable <stable@kernel.org>
>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
>> ---
>>  drivers/misc/fastrpc.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
Dmitry Baryshkov July 23, 2024, 9:14 a.m. UTC | #3
On Tue, 23 Jul 2024 at 07:36, Ekansh Gupta <quic_ekangupt@quicinc.com> wrote:
>
>
>
> On 7/22/2024 2:04 PM, Dmitry Baryshkov wrote:
> > On Mon, Jul 22, 2024 at 01:32:00PM GMT, Ekansh Gupta wrote:
> >> For unsigned PD offloading requirement, additional memory is required
> >> because of additional static heap initialization. Without this
> >> additional memory, PD initialization would fail. Increase the initmem
> >> size by 2MB for unsigned PD initmem buffer allocation. Any additional
> >> memory sent to DSP during PD init is used as the PD heap.
> > From the previous commit message I had the feeling that DSP can request
> > more memory if required. Currently you are stating that PD init would
> > fail if it doesn't have enough mem.
>
> DSP PD can request for memory only for PD heap and that too once the PD
> initialization is complete.

This should be a part of the (previous?) commit message.  Also what is
the difference between static heap vs PD heap?

>
> >
> >> Fixes: 7f1f481263c3 ("misc: fastrpc: check before loading process to the DSP")
> >> Cc: stable <stable@kernel.org>
> >> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> >> ---
> >>  drivers/misc/fastrpc.c | 8 ++++++++
> >>  1 file changed, 8 insertions(+)
> >>
>
diff mbox series

Patch

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index a3a5b745936e..9daeb039c2a2 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -40,6 +40,7 @@ 
 #define FASTRPC_CTXID_MASK (0xFF0)
 #define INIT_FILELEN_MAX (2 * 1024 * 1024)
 #define FASTRPC_INITLEN_MIN (3 * 1024 * 1024)
+#define FASTRPC_UNSIGNED_EXTRA_LEN (2 * 1024 * 1024)
 #define INIT_FILE_NAMELEN_MAX (128)
 #define FASTRPC_DEVICE_NAME	"fastrpc"
 
@@ -1411,8 +1412,15 @@  static int fastrpc_init_create_process(struct fastrpc_user *fl,
 			goto err;
 	}
 
+	/*
+	 * Allocate buffer in kernel for donating to remote process.
+	 * Unsigned PD requires additional memory because of the
+	 * additional static heap initialized within the process.
+	 */
 	memlen = ALIGN(max(FASTRPC_INITLEN_MIN, (int)init.filelen * 4),
 		       1024 * 1024);
+	if (unsigned_module)
+		memlen += FASTRPC_UNSIGNED_EXTRA_LEN;
 	err = fastrpc_buf_alloc(fl, fl->sctx->dev, memlen,
 				&imem);
 	if (err)