On Tue, Oct 27, 2026 at 03:01:41PM +0530, Gourav Kumar wrote:
> 
> 
> On 9/25/2026 9:27 PM, Mukesh Ojha wrote:
> > iris_load_fw_to_memory() calls qcom_mdt_load() which bundles metadata
> > init, memory setup, and segment loading with no PAS context, and
> > iris_fw_load() calls qcom_pas_auth_and_reset() which skips the shmbridge
> > prepare step required before TrustZone authentication.
> > 
> > Since the auth call is in a different function from where the PAS context
> > is allocated, add a pas_ctx pointer to struct iris_core so it can be
> > threaded between the two call sites.  Replace qcom_mdt_load() with
> > devm_qcom_pas_context_alloc() and qcom_mdt_pas_load() in
> > iris_load_fw_to_memory(), storing the context in core->pas_ctx, then
> > pass it to qcom_pas_prepare_and_auth_reset() in iris_fw_load().
> > 
> > Signed-off-by: Mukesh Ojha <[email protected]>
> > ---
> >  drivers/media/platform/qcom/iris/iris_core.h  |  2 ++
> >  .../media/platform/qcom/iris/iris_firmware.c  | 20 ++++++++-----------
> >  2 files changed, 10 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/media/platform/qcom/iris/iris_core.h 
> > b/drivers/media/platform/qcom/iris/iris_core.h
> > index 24da60448cf2..68e6adcc1dfd 100644
> > --- a/drivers/media/platform/qcom/iris/iris_core.h
> > +++ b/drivers/media/platform/qcom/iris/iris_core.h
> > @@ -8,6 +8,7 @@
> >  
> >  #include <linux/types.h>
> >  #include <linux/pm_domain.h>
> > +#include <linux/firmware/qcom/qcom_pas.h>
> >  #include <media/v4l2-device.h>
> >  
> >  #include "iris_hfi_common.h"
> > @@ -123,6 +124,7 @@ struct iris_core {
> >     /* encoder and decoder have overlapping caps, so two different arrays 
> > are required */
> >     struct platform_inst_fw_cap             
> > inst_fw_caps_dec[INST_FW_CAP_MAX];
> >     struct platform_inst_fw_cap             
> > inst_fw_caps_enc[INST_FW_CAP_MAX];
> > +   struct qcom_pas_context                 *pas_ctx;
> >  };
> >  
> >  int iris_core_init(struct iris_core *core);
> > diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c 
> > b/drivers/media/platform/qcom/iris/iris_firmware.c
> > index 21cdf1c39835..e73a5dd98b88 100644
> > --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> > +++ b/drivers/media/platform/qcom/iris/iris_firmware.c
> > @@ -115,9 +115,7 @@ static int iris_load_fw_to_memory(struct iris_core 
> > *core)
> >     struct resource res;
> >     phys_addr_t mem_phys;
> >     const char *fw_name;
> > -   size_t res_size;
> >     ssize_t fw_size;
> > -   void *mem_virt;
> >     int ret;
> >  
> >     ret = of_reserved_mem_region_to_resource(dev->of_node, 0, &res);
> > @@ -125,7 +123,6 @@ static int iris_load_fw_to_memory(struct iris_core 
> > *core)
> >             return ret;
> >  
> >     mem_phys = res.start;
> > -   res_size = resource_size(&res);
> >  
> >     firmware = iris_detect_firmware(core, &fw_name);
> >     if (IS_ERR(firmware))
> > @@ -134,21 +131,20 @@ static int iris_load_fw_to_memory(struct iris_core 
> > *core)
> >     core->iris_firmware_data = core->iris_firmware_desc->firmware_data;
> >  
> >     fw_size = qcom_mdt_get_size(firmware);
> > -   if (fw_size < 0 || res_size < (size_t)fw_size) {
> > +   if (fw_size < 0 || resource_size(&res) < (size_t)fw_size) {
> >             ret = -EINVAL;
> >             goto err_release_fw;
> >     }
> >  
> > -   mem_virt = memremap(mem_phys, res_size, MEMREMAP_WC);
> > -   if (!mem_virt) {
> > -           ret = -ENOMEM;
> > +   core->pas_ctx = devm_qcom_pas_context_alloc(dev, IRIS_PAS_ID, mem_phys,
> > +                                               resource_size(&res));
> > +   if (IS_ERR(core->pas_ctx)) {
> > +           ret = PTR_ERR(core->pas_ctx);
> > +           core->pas_ctx = NULL;
> >             goto err_release_fw;
> >     }
> >  
> > -   ret = qcom_mdt_load(dev, firmware, fw_name,
> > -                       IRIS_PAS_ID, mem_virt, mem_phys, res_size, NULL);
> > -
> > -   memunmap(mem_virt);
> > +   ret = qcom_mdt_pas_load(core->pas_ctx, firmware, fw_name, NULL);
> 
> qcom_mdt_pas_load() passes the ctx to qcom_pas_init_image(), which keeps
> the metadata buffer in ctx->ptr, and qcom_pas_prepare_and_auth_reset()
> does not free it. Who is expected to call qcom_pas_metadata_release()
> for iris? I don't see it called after authentication (or on its
> failure), unlike in qcom_q6v5_pas.c.
> 
Below change is merged, so buffer will be freed in the call itself, no need
to call qcom_pas_metadata_release() explicitly for clients who are not
interested in saving their metadata context.


https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2aa8fafc08e777e9da356307c1a0117e7f4277cf


> Gourav Kumar
> 
> >  err_release_fw:
> >     release_firmware(firmware);
> >  
> > @@ -166,7 +162,7 @@ int iris_fw_load(struct iris_core *core)
> >             return ret;
> >     }
> >  
> > -   ret = qcom_pas_auth_and_reset(IRIS_PAS_ID);
> > +   ret = qcom_pas_prepare_and_auth_reset(core->pas_ctx);
> 
> ctx->use_tzmem is not set for iris, so the shmbridge creation in
> qcom_scm_pas_prepare_and_auth_reset() is skipped and the behaviour is
> the same as the old qcom_pas_auth_and_reset(). Please reword the commit
> message accordingly, since it currently implies that the prepare step is
> now performed by the new API as a fix.

Sure.

> 
> Gourav Kumar
> 
> >     if (ret)  {
> >             dev_err(core->dev, "auth and reset failed: %d\n", ret);
> >             return ret;
> 

-- 
-Mukesh Ojha

Reply via email to