On 23-09-2026 14:09, Vinayak Katoch wrote:
> For ADSP, only a limited number of FastRPC context banks (CBs) are
> available. Each CB supports a single session, which means only a few
> processes can run on ADSP simultaneously. If all sessions are consumed
> by fastrpc daemons, no session remains available when a user application
> starts, causing the application to fail.
> 
> To work around this, qcom,nsessions = <5> was set in DT to duplicate
> sessions inline during fastrpc_cb_init(). This policy does not belong
> in DT and should be handled at the driver level instead.
> 
> Remove the qcom,nsessions DT property read and the per-CB duplication
> logic from fastrpc_cb_init(). After all context banks have been
> initialised in fastrpc_rpmsg_probe(), append FASTRPC_DUP_SESSIONS (4)
> copies of the last session for the ADSP domain.
> 
> Signed-off-by: Vinayak Katoch <[email protected]>
> ---
>  drivers/misc/fastrpc.c | 29 +++++++++++++++++------------
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index f20d3e5ecc81..b29c1fd00de2 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -34,6 +34,7 @@
>  #define CDSP_DOMAIN_ID (3)
>  #define GDSP_DOMAIN_ID (4)
>  #define FASTRPC_MAX_SESSIONS 14
> +#define FASTRPC_DUP_SESSIONS 4
add some comment here>  #define FASTRPC_MAX_VMIDS       16
>  #define FASTRPC_ALIGN                128
>  #define FASTRPC_MAX_FDLIST   16
> @@ -2338,7 +2339,6 @@ static int fastrpc_cb_init(struct platform_device *pdev)
>       struct fastrpc_channel_ctx *cctx;
>       struct fastrpc_session_ctx *sess;
>       struct device *dev = &pdev->dev;
> -     int i, sessions = 0;
>       unsigned long flags;
>       u32 dma_bits;
>       u32 sid = 0;
> @@ -2348,7 +2348,6 @@ static int fastrpc_cb_init(struct platform_device *pdev)
>       if (!cctx)
>               return -EINVAL;
>  
> -     of_property_read_u32(dev->of_node, "qcom,nsessions", &sessions);
>       if (of_property_read_u32(dev->of_node, "reg", &sid))
>               dev_info(dev, "FastRPC Session ID not specified in DT\n");
>  
> @@ -2369,16 +2368,6 @@ static int fastrpc_cb_init(struct platform_device 
> *pdev)
>       if (cctx->domain_id == CDSP_DOMAIN_ID)
>               dma_bits = cctx->soc_data->dma_addr_bits_cdsp;
>  
> -     if (sessions > 0) {
> -             struct fastrpc_session_ctx *dup_sess;
> -
> -             for (i = 1; i < sessions; i++) {
> -                     if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
> -                             break;
> -                     dup_sess = &cctx->session[cctx->sesscount++];
> -                     memcpy(dup_sess, sess, sizeof(*dup_sess));
> -             }
> -     }
>       spin_unlock_irqrestore(&cctx->lock, flags);
>       rc = dma_set_mask(dev, DMA_BIT_MASK(dma_bits));
>       if (rc) {
> @@ -2669,6 +2658,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device 
> *rpdev)
>       if (err)
>               goto err_deregister_fdev;
>  
> +     if (data->domain_id == ADSP_DOMAIN_ID && data->sesscount > 0) {
> +             struct fastrpc_session_ctx *last_sess;
> +             struct fastrpc_session_ctx *dup_sess;
> +             unsigned long flags;
> +
> +             spin_lock_irqsave(&data->lock, flags);
> +             last_sess = &data->session[data->sesscount - 1];
> +             for (i = 0; i < FASTRPC_DUP_SESSIONS; i++) {
> +                     if (data->sesscount >= FASTRPC_MAX_SESSIONS)
> +                             break;
> +                     dup_sess = &data->session[data->sesscount++];
> +                     memcpy(dup_sess, last_sess, sizeof(*dup_sess));
> +             }
> +             spin_unlock_irqrestore(&data->lock, flags);
> +     }
> +
>       return 0;
>  
>  err_deregister_fdev:
> 

Reply via email to