<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>Does the community have any other ideas? Or I am wrong, and
      devm_iounmap is enough?<br>
    </p>
    <p>Regards,<br>
      Adrian<br>
    </p>
    <div class="moz-cite-prefix">On 6.12.2022 22:23, Adrian Fiergolski
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:c65c7e91-b1c5-f6aa-2082-470eca58bc41@fastree3d.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi Costa,</p>
      <p>Thank you for your reply.</p>
      <p>I saw 'devm_iounmap' , but, correct me if I am wrong, I think
        is not enough. <br>
      </p>
      <p>devm_ioremap_resource calls __devm_ioremap_resource (<a
          moz-do-not-send="true"
href="https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L117">link</a>)
        which calls eventually __devm_request_region (<a
          moz-do-not-send="true"
href="https://elixir.bootlin.com/linux/v5.10.157/source/kernel/resource.c#L1520">link</a>)
        and __devm_ioremap (<a moz-do-not-send="true"
href="https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L25">link</a>).
        Those two will allocate 2 devres: devm_region_release and
        devm_ioremap_release.</p>
      <p>The proposed devm_iounmap (<a moz-do-not-send="true"
href="https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L108">link</a>)
        seems to destroy only devm_ioremap_release devres.</p>
      <p>Regards,<br>
        Adrian<br>
      </p>
      <div class="moz-cite-prefix">On 2.12.2022 19:01, Constantine
        Shulyupin wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAE7jHC-Bik4nXqfv290WpRwNkcxwG60Z-tv2WfXa-X8dDuYEGw@mail.gmail.com">
        <pre class="moz-quote-pre" wrap="">Hi,

I suppose you are looking for `devm_iounmap`.
You can find example of usage in `drivers/fpga/dfl.c`:

...
                        feature->ioaddr =
                               devm_ioremap_resource(binfo->dev,
                                                     &finfo->mmio_res);
...

static void build_info_complete(struct build_feature_devs_info *binfo)
{
       devm_iounmap(binfo->dev, binfo->ioaddr);
       devm_release_mem_region(binfo->dev, binfo->start, binfo->len);
}

Regards,
Costa


On Fri, 2 Dec 2022 at 19:25, Adrian Fiergolski
<a class="moz-txt-link-rfc2396E" href="mailto:adrian.fiergolski@fastree3d.com" moz-do-not-send="true"><adrian.fiergolski@fastree3d.com></a> wrote:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">Hello,

I am extending xilinx-hls driver
(<a class="moz-txt-link-freetext" href="https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-hls.c" moz-do-not-send="true">https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-hls.c</a>)
to support of_overlay.

In order to reflect in the driver changes being applied by the overlay
to the device tree, I need to unmap first the memory mapped with
devm_ioremap_resource. How to do it properly?

I think it's uncommon, as normally kernel (devm_* functions) manages
those resources itself with devres, so I can't find inspiration in other
drivers.

Regards,
Adrian



_______________________________________________
Kernelnewbies mailing list
<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:Kernelnewbies@kernelnewbies.org" moz-do-not-send="true">Kernelnewbies@kernelnewbies.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" moz-do-not-send="true">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a>
</pre>
        </blockquote>
      </blockquote>
    </blockquote>
  </body>
</html>