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: Refactor qcom_scm_pas_init_image()

Refactor qcom_scm_pas_init_image() by moving the memory allocation,
copy, and free operations to a higher-level function, and isolate the
actual SMC call in a separate function. The main intention is to allow
flexibility for different allocators and to respect any constraints that
the allocator API may impose before invoking the actual SCM function.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
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-9-022e96815380@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Mukesh Ojha and committed by
Bjorn Andersson
223a8716 4a7d6a78

+33 -25
+33 -25
drivers/firmware/qcom/qcom_scm.c
··· 592 592 } 593 593 EXPORT_SYMBOL_GPL(devm_qcom_scm_pas_context_alloc); 594 594 595 + static int __qcom_scm_pas_init_image(u32 pas_id, dma_addr_t mdata_phys, 596 + struct qcom_scm_res *res) 597 + { 598 + struct qcom_scm_desc desc = { 599 + .svc = QCOM_SCM_SVC_PIL, 600 + .cmd = QCOM_SCM_PIL_PAS_INIT_IMAGE, 601 + .arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_VAL, QCOM_SCM_RW), 602 + .args[0] = pas_id, 603 + .owner = ARM_SMCCC_OWNER_SIP, 604 + }; 605 + int ret; 606 + 607 + ret = qcom_scm_clk_enable(); 608 + if (ret) 609 + return ret; 610 + 611 + ret = qcom_scm_bw_enable(); 612 + if (ret) 613 + goto disable_clk; 614 + 615 + desc.args[1] = mdata_phys; 616 + 617 + ret = qcom_scm_call(__scm->dev, &desc, res); 618 + qcom_scm_bw_disable(); 619 + 620 + disable_clk: 621 + qcom_scm_clk_disable(); 622 + 623 + return ret; 624 + } 625 + 595 626 /** 596 627 * qcom_scm_pas_init_image() - Initialize peripheral authentication service 597 628 * state machine for a given peripheral, using the ··· 643 612 int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size, 644 613 struct qcom_scm_pas_context *ctx) 645 614 { 615 + struct qcom_scm_res res; 646 616 dma_addr_t mdata_phys; 647 617 void *mdata_buf; 648 618 int ret; 649 - struct qcom_scm_desc desc = { 650 - .svc = QCOM_SCM_SVC_PIL, 651 - .cmd = QCOM_SCM_PIL_PAS_INIT_IMAGE, 652 - .arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_VAL, QCOM_SCM_RW), 653 - .args[0] = pas_id, 654 - .owner = ARM_SMCCC_OWNER_SIP, 655 - }; 656 - struct qcom_scm_res res; 657 619 658 620 /* 659 621 * During the scm call memory protection will be enabled for the meta ··· 667 643 668 644 memcpy(mdata_buf, metadata, size); 669 645 670 - ret = qcom_scm_clk_enable(); 671 - if (ret) 672 - goto out; 673 - 674 - ret = qcom_scm_bw_enable(); 675 - if (ret) 676 - goto disable_clk; 677 - 678 - desc.args[1] = mdata_phys; 679 - 680 - ret = qcom_scm_call(__scm->dev, &desc, &res); 681 - qcom_scm_bw_disable(); 682 - 683 - disable_clk: 684 - qcom_scm_clk_disable(); 685 - 686 - out: 646 + ret = __qcom_scm_pas_init_image(pas_id, mdata_phys, &res); 687 647 if (ret < 0 || !ctx) { 688 648 dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); 689 649 } else if (ctx) {