ath12k_ahb_power_up() and ath12k_ahb_load_auth_shared_fw() call
qcom_mdt_load() for SCM-authenticated paths and then
qcom_pas_auth_and_reset() which skips the shmbridge prepare step
required before TrustZone authentication.

Replace `qcom_mdt_load()` with `devm_qcom_pas_context_alloc()` and
`qcom_mdt_pas_load()` in both call sites. In `ath12k_ahb_power_up()` the
PAS context was allocated inside the first `scm_auth_enabled` block; hoist
it to function scope so it remains visible at the authentication step in
the second `scm_auth_enabled` block, then replace
`qcom_pas_auth_and_reset()` with `qcom_pas_prepare_and_auth_reset()`.

The non-SCM-authenticated fw2 path and no-auth path retain their existing
qcom_mdt_load_no_init() calls with the persistent mem_region mapping.

Signed-off-by: Mukesh Ojha <[email protected]>
---
 drivers/net/wireless/ath/ath12k/ahb.c | 31 +++++++++++++++++++--------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/ahb.c 
b/drivers/net/wireless/ath/ath12k/ahb.c
index 85360365aa4b..6f0ad29a83f8 100644
--- a/drivers/net/wireless/ath/ath12k/ahb.c
+++ b/drivers/net/wireless/ath/ath12k/ahb.c
@@ -391,6 +391,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
        struct ath12k_ahb_rproc_info *rproc_info = ab_ahb->rproc_info;
        char fw_name[ATH12K_USERPD_FW_NAME_LEN];
        char fw2_name[ATH12K_USERPD_FW_NAME_LEN];
+       struct qcom_pas_context *ctx = NULL;
        struct device *dev = ab->dev;
        const struct firmware *fw, *fw2;
        unsigned long time_left;
@@ -424,14 +425,20 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
                ATH12K_AHB_UPD_SWID;
 
        /* Load FW image to a reserved memory location */
-       if (ab_ahb->scm_auth_enabled)
-               ret = qcom_mdt_load(dev, fw, fw_name, pasid, 
rproc_info->mem_region,
-                                   rproc_info->mem_phys, rproc_info->mem_size,
-                                   NULL);
-       else
+       if (ab_ahb->scm_auth_enabled) {
+               ctx = devm_qcom_pas_context_alloc(dev, pasid,
+                                                 rproc_info->mem_phys,
+                                                 rproc_info->mem_size);
+               if (IS_ERR(ctx)) {
+                       ret = PTR_ERR(ctx);
+                       goto err_fw;
+               }
+               ret = qcom_mdt_pas_load(ctx, fw, fw_name, NULL);
+       } else {
                ret = qcom_mdt_load_no_init(dev, fw, fw_name, 
rproc_info->mem_region,
                                            rproc_info->mem_phys, 
rproc_info->mem_size,
                                            NULL);
+       }
        if (ret) {
                ath12k_err(ab, "Failed to load MDT segments: %d\n", ret);
                goto err_fw;
@@ -465,7 +472,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
 
        if (ab_ahb->scm_auth_enabled) {
                /* Authenticate FW image using peripheral ID */
-               ret = qcom_pas_auth_and_reset(pasid);
+               ret = qcom_pas_prepare_and_auth_reset(ctx);
                if (ret) {
                        ath12k_err(ab, "failed to boot the remote processor 
%d\n", ret);
                        goto err_fw2;
@@ -994,6 +1001,7 @@ static int ath12k_ahb_load_auth_shared_fw(struct 
ath12k_base *ab,
                                          struct ath12k_ahb_rproc_info 
*rproc_info,
                                          const char *fw_name, u32 pasid)
 {
+       struct qcom_pas_context *ctx;
        int ret;
 
        const struct firmware *fw __free(firmware) = NULL;
@@ -1012,14 +1020,19 @@ static int ath12k_ahb_load_auth_shared_fw(struct 
ath12k_base *ab,
        ath12k_dbg(ab, ATH12K_DBG_AHB, "loading firmware %s, size %zd\n", 
fw_name,
                   fw->size);
 
-       ret = qcom_mdt_load(ab->dev, fw, fw_name, pasid, rproc_info->mem_region,
-                           rproc_info->mem_phys, rproc_info->mem_size, NULL);
+       ctx = devm_qcom_pas_context_alloc(ab->dev, pasid,
+                                         rproc_info->mem_phys,
+                                         rproc_info->mem_size);
+       if (IS_ERR(ctx))
+               return PTR_ERR(ctx);
+
+       ret = qcom_mdt_pas_load(ctx, fw, fw_name, NULL);
        if (ret) {
                ath12k_err(ab, "failed to load RO firmware %s: %d\n", fw_name, 
ret);
                return ret;
        }
 
-       ret = qcom_pas_auth_and_reset(pasid);
+       ret = qcom_pas_prepare_and_auth_reset(ctx);
        if (ret)
                ath12k_err(ab, "failed to authenticate and boot shared 
firmware: %d\n",
                           ret);
-- 
2.55.0


Reply via email to