Skip to content

Commit d90a3c2

Browse files
FROMLIST: firmware: qcom_scm: Introduce PAS context allocator helper function
When the Peripheral Authentication Service (PAS) method runs on a SoC where Linux operates at EL2 (i.e., without the Gunyah hypervisor), the reset sequences are handled by TrustZone. In such cases, Linux must perform additional steps before invoking PAS SMC calls, such as creating a SHM bridge. Therefore, PAS SMC calls require awareness and handling of these additional steps when Linux runs at EL2. To support this, there is a need for a data structure that can be initialized prior to invoking any SMC or MDT functions. This structure allows those functions to determine whether they are operating in the presence or absence of the Gunyah hypervisor and behave accordingly. Currently, remoteproc and non-remoteproc subsystems use different variants of the MDT loader helper API, primarily due to differences in metadata context handling. Remoteproc subsystems retain the metadata context until authentication and reset are completed, while non-remoteproc subsystems (e.g., video, graphics, IPA, etc.) do not retain the metadata context and can free it within the qcom_scm_pas_init() call by passing a NULL context parameter and due to these differences, it is not possible to extend metadata context handling to support remoteproc and non remoteproc subsystem use PAS operations, when Linux operates at EL2. Add PAS context data structure allocator helper function. Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260105-kvmrprocv10-v10-4-022e96815380@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 32ee583 commit d90a3c2

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

drivers/firmware/qcom/qcom_scm.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,40 @@ static void qcom_scm_set_download_mode(u32 dload_mode)
558558
dev_err(__scm->dev, "failed to set download mode: %d\n", ret);
559559
}
560560

561+
/**
562+
* devm_qcom_scm_pas_context_alloc() - Allocate peripheral authentication service
563+
* context for a given peripheral
564+
*
565+
* PAS context is device-resource managed, so the caller does not need
566+
* to worry about freeing the context memory.
567+
*
568+
* @dev: PAS firmware device
569+
* @pas_id: peripheral authentication service id
570+
* @mem_phys: Subsystem reserve memory start address
571+
* @mem_size: Subsystem reserve memory size
572+
*
573+
* Returns: The new PAS context, or ERR_PTR() on failure.
574+
*/
575+
struct qcom_scm_pas_context *devm_qcom_scm_pas_context_alloc(struct device *dev,
576+
u32 pas_id,
577+
phys_addr_t mem_phys,
578+
size_t mem_size)
579+
{
580+
struct qcom_scm_pas_context *ctx;
581+
582+
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
583+
if (!ctx)
584+
return ERR_PTR(-ENOMEM);
585+
586+
ctx->dev = dev;
587+
ctx->pas_id = pas_id;
588+
ctx->mem_phys = mem_phys;
589+
ctx->mem_size = mem_size;
590+
591+
return ctx;
592+
}
593+
EXPORT_SYMBOL_GPL(devm_qcom_scm_pas_context_alloc);
594+
561595
/**
562596
* qcom_scm_pas_init_image() - Initialize peripheral authentication service
563597
* state machine for a given peripheral, using the

include/linux/firmware/qcom/qcom_scm.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ struct qcom_scm_camera_qos {
8282
int qcom_scm_camera_update_camnoc_qos(uint32_t use_case_id,
8383
uint32_t qos_cnt, struct qcom_scm_camera_qos *scm_buf);
8484

85+
struct qcom_scm_pas_context {
86+
struct device *dev;
87+
u32 pas_id;
88+
phys_addr_t mem_phys;
89+
size_t mem_size;
90+
void *ptr;
91+
dma_addr_t phys;
92+
ssize_t size;
93+
};
94+
95+
struct qcom_scm_pas_context *devm_qcom_scm_pas_context_alloc(struct device *dev,
96+
u32 pas_id,
97+
phys_addr_t mem_phys,
98+
size_t mem_size);
8599
int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size,
86100
struct qcom_scm_pas_metadata *ctx);
87101
void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx);

0 commit comments

Comments
 (0)