Skip to content

Commit 8a4fcff

Browse files
mukeshojha-linuxandersson
authored andcommitted
soc: qcom: mdtloader: Add PAS context aware qcom_mdt_pas_load() function
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(). Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260105-kvmrprocv10-v10-6-022e96815380@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent b13d8ba commit 8a4fcff

3 files changed

Lines changed: 46 additions & 19 deletions

File tree

drivers/remoteproc/qcom_q6v5_pas.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,9 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
239239
return ret;
240240
}
241241

242-
ret = qcom_mdt_pas_init(pas->dev, pas->dtb_firmware, pas->dtb_firmware_name,
243-
pas->dtb_pas_id, pas->dtb_mem_phys,
244-
pas->dtb_pas_ctx);
245-
if (ret)
246-
goto release_dtb_firmware;
247-
248-
ret = qcom_mdt_load_no_init(pas->dev, pas->dtb_firmware, pas->dtb_firmware_name,
249-
pas->dtb_mem_region, pas->dtb_mem_phys,
250-
pas->dtb_mem_size, &pas->dtb_mem_reloc);
242+
ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
243+
pas->dtb_firmware_name, pas->dtb_mem_region,
244+
&pas->dtb_mem_reloc);
251245
if (ret)
252246
goto release_dtb_metadata;
253247
}
@@ -256,8 +250,6 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
256250

257251
release_dtb_metadata:
258252
qcom_scm_pas_metadata_release(pas->dtb_pas_ctx);
259-
260-
release_dtb_firmware:
261253
release_firmware(pas->dtb_firmware);
262254

263255
return ret;
@@ -305,14 +297,8 @@ static int qcom_pas_start(struct rproc *rproc)
305297
}
306298
}
307299

308-
ret = qcom_mdt_pas_init(pas->dev, pas->firmware, rproc->firmware, pas->pas_id,
309-
pas->mem_phys, pas->pas_ctx);
310-
if (ret)
311-
goto disable_px_supply;
312-
313-
ret = qcom_mdt_load_no_init(pas->dev, pas->firmware, rproc->firmware,
314-
pas->mem_region, pas->mem_phys, pas->mem_size,
315-
&pas->mem_reloc);
300+
ret = qcom_mdt_pas_load(pas->pas_ctx, pas->firmware, rproc->firmware,
301+
pas->mem_region, &pas->mem_reloc);
316302
if (ret)
317303
goto release_pas_metadata;
318304

drivers/soc/qcom/mdt_loader.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,5 +478,36 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
478478
}
479479
EXPORT_SYMBOL_GPL(qcom_mdt_load);
480480

481+
/**
482+
* qcom_mdt_pas_load - Loads and authenticates the metadata of the firmware
483+
* (typically contained in the .mdt file), followed by loading the actual
484+
* firmware segments (e.g., .bXX files). Authentication of the segments done
485+
* by a separate call.
486+
*
487+
* The PAS context must be initialized using qcom_scm_pas_context_init()
488+
* prior to invoking this function.
489+
*
490+
* @ctx: Pointer to the PAS (Peripheral Authentication Service) context
491+
* @fw: Firmware object representing the .mdt file
492+
* @firmware: Name of the firmware used to construct segment file names
493+
* @mem_region: Memory region allocated for loading the firmware
494+
* @reloc_base: Physical address adjusted after relocation
495+
*
496+
* Return: 0 on success or a negative error code on failure.
497+
*/
498+
int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct firmware *fw,
499+
const char *firmware, void *mem_region, phys_addr_t *reloc_base)
500+
{
501+
int ret;
502+
503+
ret = qcom_mdt_pas_init(ctx->dev, fw, firmware, ctx->pas_id, ctx->mem_phys, ctx);
504+
if (ret)
505+
return ret;
506+
507+
return qcom_mdt_load_no_init(ctx->dev, fw, firmware, mem_region, ctx->mem_phys,
508+
ctx->mem_size, reloc_base);
509+
}
510+
EXPORT_SYMBOL_GPL(qcom_mdt_pas_load);
511+
481512
MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format");
482513
MODULE_LICENSE("GPL v2");

include/linux/soc/qcom/mdt_loader.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
2323
phys_addr_t mem_phys, size_t mem_size,
2424
phys_addr_t *reloc_base);
2525

26+
int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx, const struct firmware *fw,
27+
const char *firmware, void *mem_region, phys_addr_t *reloc_base);
28+
2629
int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
2730
const char *fw_name, void *mem_region,
2831
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,
5255
return -ENODEV;
5356
}
5457

58+
static inline int qcom_mdt_pas_load(struct qcom_scm_pas_context *ctx,
59+
const struct firmware *fw, const char *firmware,
60+
void *mem_region, phys_addr_t *reloc_base)
61+
{
62+
return -ENODEV;
63+
}
64+
5565
static inline int qcom_mdt_load_no_init(struct device *dev,
5666
const struct firmware *fw,
5767
const char *fw_name, void *mem_region,

0 commit comments

Comments
 (0)