On Tue, Oct 27, 2026 at 07:49:03AM -0500, Alex Elder wrote:
> On 9/25/26 10:57 AM, Mukesh Ojha wrote:
> > ipa_firmware_load() calls qcom_mdt_load() which bundles metadata init,
> > memory setup, and segment loading with no PAS context, then calls
> > qcom_pas_auth_and_reset() which skips the shmbridge prepare step required
> > before TrustZone authentication.
> > 
> > Replace the open-coded memremap()/qcom_mdt_load()/memunmap() sequence
> > with devm_qcom_pas_context_alloc() and qcom_mdt_pas_load(), then pass
> > the same context to qcom_pas_prepare_and_auth_reset().
> > 
> > Signed-off-by: Mukesh Ojha <[email protected]>
> 
> I think this does the right thing, however the IPA driver does
> not use resource-managed (devm) interfaces, and this would be
> a first.
> 
> Why does "qcom_pas.c" not offer an interface that can be used
> without devm_kzalloc()?  What if someone wanted to pass in a
> preallocated structure to be initialized with the (publicly
> defined) PAS context?
> 
> I was going to suggest that you just rework the code to use
> gotos and the cleanup path as used everywhere else in this
> driver, but it looks like that's not easy.
> 
> I'm willing to ack this but I would have preferred to preserve
> consistency.

Ok, let me fix this by introducing a new API to initialize the context,
which will only initialize and not allocate. This will also fix the leak
problem if the earlier API is called multiple times.

> 
> Reluctantly:
> 
> Acked-by: Alex Elder <[email protected]>
> 
> 
> > ---
> >   drivers/net/ipa/ipa_main.c | 24 +++++++++++-------------
> >   1 file changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
> > index 14ac2d2faf7c..6964395caedd 100644
> > --- a/drivers/net/ipa/ipa_main.c
> > +++ b/drivers/net/ipa/ipa_main.c
> > @@ -585,12 +585,11 @@ static void ipa_deconfig(struct ipa *ipa)
> >   static int ipa_firmware_load(struct device *dev)
> >   {
> > +   struct qcom_pas_context *ctx;
> >     const struct firmware *fw;
> >     struct resource res;
> >     phys_addr_t phys;
> >     const char *path;
> > -   ssize_t size;
> > -   void *virt;
> >     int ret;
> >     ret = of_reserved_mem_region_to_resource(dev->of_node, 0, &res);
> > @@ -615,24 +614,23 @@ static int ipa_firmware_load(struct device *dev)
> >     }
> >     phys = res.start;
> > -   size = (size_t)resource_size(&res);
> > -   virt = memremap(phys, size, MEMREMAP_WC);
> > -   if (!virt) {
> > -           dev_err(dev, "unable to remap firmware memory\n");
> > -           ret = -ENOMEM;
> > +   ctx = devm_qcom_pas_context_alloc(dev, IPA_PAS_ID, phys,
> > +                                     resource_size(&res));
> > +   if (IS_ERR(ctx)) {
> > +           ret = PTR_ERR(ctx);
> >             goto out_release_firmware;
> >     }
> > -   ret = qcom_mdt_load(dev, fw, path, IPA_PAS_ID, virt, phys, size, NULL);
> > +   ret = qcom_mdt_pas_load(ctx, fw, path, NULL);
> >     if (ret) {
> >             dev_err(dev, "error %d loading \"%s\"\n", ret, path);
> > -   } else {
> > -           ret = qcom_pas_auth_and_reset(IPA_PAS_ID);
> > -           if (ret)
> > -                   dev_err(dev, "error %d authenticating \"%s\"\n", ret, 
> > path);
> > +           goto out_release_firmware;
> >     }
> > -   memunmap(virt);
> > +   ret = qcom_pas_prepare_and_auth_reset(ctx);
> > +   if (ret)
> > +           dev_err(dev, "error %d authenticating \"%s\"\n", ret, path);
> > +
> >   out_release_firmware:
> >     release_firmware(fw);
> 

-- 
-Mukesh Ojha

Reply via email to