Commit 8a4fcffd authored by Mukesh Ojha's avatar Mukesh Ojha Committed by Bjorn Andersson
Browse files

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: default avatarKonrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: default avatarMukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260105-kvmrprocv10-v10-6-022e96815380@oss.qualcomm.com


Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
parent b13d8baf
Loading
Loading
Loading
Loading
+5 −19
Original line number Diff line number Diff line
@@ -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;

+31 −0
Original line number Diff line number Diff line
@@ -478,5 +478,36 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
}
EXPORT_SYMBOL_GPL(qcom_mdt_load);

/**
 * 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);
	if (ret)
		return ret;

	return qcom_mdt_load_no_init(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");
+10 −0
Original line number Diff line number Diff line
@@ -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,