Skip to content

Commit ccb7bde

Browse files
mukeshojha-linuxandersson
authored andcommitted
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 6905434 commit ccb7bde

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
@@ -72,6 +72,20 @@ struct qcom_scm_pas_metadata {
7272
ssize_t size;
7373
};
7474

75+
struct qcom_scm_pas_context {
76+
struct device *dev;
77+
u32 pas_id;
78+
phys_addr_t mem_phys;
79+
size_t mem_size;
80+
void *ptr;
81+
dma_addr_t phys;
82+
ssize_t size;
83+
};
84+
85+
struct qcom_scm_pas_context *devm_qcom_scm_pas_context_alloc(struct device *dev,
86+
u32 pas_id,
87+
phys_addr_t mem_phys,
88+
size_t mem_size);
7589
int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size,
7690
struct qcom_scm_pas_metadata *ctx);
7791
void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx);

0 commit comments

Comments
 (0)