On Mon, Oct 13, 2025 at 03:33:09PM +0530, Mukesh Ojha wrote:
> Introduce a new PAS context-aware function, qcom_mdt_pas_load(), for
> remote processor drivers. This function utilizes the PAS context
> pointer returned from qcom_scm_pas_ctx_init() to perform firmware
> metadata verification and memory setup via SMC calls.
> 
> The qcom_mdt_pas_load() and qcom_mdt_load() functions are largely
> similar, but the former is designed for clients using the PAS
> context-based data structure. Over time, all users of qcom_mdt_load()
> can be migrated to use qcom_mdt_pas_load() for consistency and
> improved abstraction.
> 
> As the remoteproc PAS driver (qcom_q6v5_pas) has already adopted the
> PAS context-based approach, update it to use qcom_mdt_pas_load().
> 
> Signed-off-by: Mukesh Ojha <[email protected]>
> ---
>  drivers/remoteproc/qcom_q6v5_pas.c  | 24 +++++-------------------
>  drivers/soc/qcom/mdt_loader.c       | 32 ++++++++++++++++++++++++++++++++
>  include/linux/soc/qcom/mdt_loader.h | 10 ++++++++++
>  3 files changed, 47 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c 
> b/drivers/remoteproc/qcom_q6v5_pas.c
> index e9dcab94ea0c..ee0ea35803c6 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -239,15 +239,9 @@ static int qcom_pas_load(struct rproc *rproc, const 
> struct firmware *fw)
>                       return ret;
>               }
>  
> -             ret = qcom_mdt_pas_init(pas->dev, pas->dtb_firmware, 
> pas->dtb_firmware_name,
> -                                     pas->dtb_pas_id, pas->dtb_mem_phys,
> -                                     pas->dtb_pas_ctx);
> -             if (ret)
> -                     goto release_dtb_firmware;
> -
> -             ret = qcom_mdt_load_no_init(pas->dev, pas->dtb_firmware, 
> pas->dtb_firmware_name,
> -                                         pas->dtb_mem_region, 
> pas->dtb_mem_phys,
> -                                         pas->dtb_mem_size, 
> &pas->dtb_mem_reloc);
> +             ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
> +                                     pas->dtb_firmware_name, 
> pas->dtb_mem_region,
> +                                     &pas->dtb_mem_reloc);
>               if (ret)
>                       goto release_dtb_metadata;
>       }
> @@ -256,8 +250,6 @@ static int qcom_pas_load(struct rproc *rproc, const 
> struct firmware *fw)
>  
>  release_dtb_metadata:
>       qcom_scm_pas_metadata_release(pas->dtb_pas_ctx);
> -
> -release_dtb_firmware:
>       release_firmware(pas->dtb_firmware);
>  
>       return ret;
> @@ -305,14 +297,8 @@ static int qcom_pas_start(struct rproc *rproc)
>               }
>       }
>  
> -     ret = qcom_mdt_pas_init(pas->dev, pas->firmware, rproc->firmware, 
> pas->pas_id,
> -                             pas->mem_phys, pas->pas_ctx);
> -     if (ret)
> -             goto disable_px_supply;
> -
> -     ret = qcom_mdt_load_no_init(pas->dev, pas->firmware, rproc->firmware,
> -                                 pas->mem_region, pas->mem_phys, 
> pas->mem_size,
> -                                 &pas->mem_reloc);
> +     ret = qcom_mdt_pas_load(pas->pas_ctx, pas->firmware, rproc->firmware,
> +                             pas->mem_region, &pas->mem_reloc);
>       if (ret)
>               goto release_pas_metadata;
>  
> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> index fe35038c5342..52de8adcc4f2 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -486,5 +486,37 @@ int qcom_mdt_load_no_init(struct device *dev, const 
> struct firmware *fw,
>  }
>  EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init);
>  
> +/**
> + * qcom_mdt_pas_load - Loads and authenticates the metadata of the firmware
> + * (typically contained in the .mdt file), followed by loading the actual
> + * firmware segments (e.g., .bXX files). Authentication of the segments done
> + * by a separate call.
> + *
> + * The PAS context must be initialized using qcom_scm_pas_context_init()
> + * prior to invoking this function.
> + *
> + * @ctx:        Pointer to the PAS (Peripheral Authentication Service) 
> context
> + * @fw:         Firmware object representing the .mdt file
> + * @firmware:   Name of the firmware used to construct segment file names
> + * @mem_region: Memory region allocated for loading the firmware
> + * @reloc_base: Physical address adjusted after relocation
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct 
> firmware *fw,
> +                   const char *firmware, void *mem_region, phys_addr_t 
> *reloc_base)
> +{
> +     int ret;
> +
> +     ret = qcom_mdt_pas_init(ctx->dev, fw, firmware, ctx->pas_id, 
> ctx->mem_phys,
> +                             ctx->metadata);

s/ctx->metadata/ctx

This has been done 6/13, missed here in patch reordering.

> +     if (ret)
> +             return ret;
> +
> +     return __qcom_mdt_load(ctx->dev, fw, firmware, mem_region, 
> ctx->mem_phys,
> +                            ctx->mem_size, reloc_base);
> +}
> +EXPORT_SYMBOL_GPL(qcom_mdt_pas_load);
> +
>  MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format");
>  MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/soc/qcom/mdt_loader.h 
> b/include/linux/soc/qcom/mdt_loader.h
> index 07c278841816..7d57746fbbfa 100644
> --- a/include/linux/soc/qcom/mdt_loader.h
> +++ b/include/linux/soc/qcom/mdt_loader.h
> @@ -23,6 +23,9 @@ int qcom_mdt_load(struct device *dev, const struct firmware 
> *fw,
>                 phys_addr_t mem_phys, size_t mem_size,
>                 phys_addr_t *reloc_base);
>  
> +int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct 
> firmware *fw,
> +                   const char *firmware, void *mem_region, phys_addr_t 
> *reloc_base);
> +
>  int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
>                         const char *fw_name, void *mem_region,
>                         phys_addr_t mem_phys, size_t mem_size,
> @@ -52,6 +55,13 @@ static inline int qcom_mdt_load(struct device *dev, const 
> struct firmware *fw,
>       return -ENODEV;
>  }
>  
> +static inline int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx,
> +                                 const struct firmware *fw, const char 
> *firmware,
> +                                 void *mem_region, phys_addr_t *reloc_base)
> +{
> +     return -ENODEV;
> +}
> +
>  static inline int qcom_mdt_load_no_init(struct device *dev,
>                                       const struct firmware *fw,
>                                       const char *fw_name, void *mem_region,
> 
> -- 
> 2.50.1
> 

-- 
-Mukesh Ojha

Reply via email to