Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Mukesh Ojha and committed by
Bjorn Andersson
ccb7bde5 69054348

+48
+34
drivers/firmware/qcom/qcom_scm.c
··· 559 559 } 560 560 561 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 + 595 + /** 562 596 * qcom_scm_pas_init_image() - Initialize peripheral authentication service 563 597 * state machine for a given peripheral, using the 564 598 * metadata
+14
include/linux/firmware/qcom/qcom_scm.h
··· 72 72 ssize_t size; 73 73 }; 74 74 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); 75 89 int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size, 76 90 struct qcom_scm_pas_metadata *ctx); 77 91 void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx);