public inbox for kernelnewbies@kernelnewbies.org
 help / color / mirror / Atom feed
From: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
To: Constantine Shulyupin <constantine.shulyupin@gmail.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: unmap memory mapped with devm_ioremap_resource
Date: Fri, 9 Dec 2022 17:14:14 +0100	[thread overview]
Message-ID: <2d7fddcd-6289-dc63-6cf2-a5880057d6aa@fastree3d.com> (raw)
In-Reply-To: <c65c7e91-b1c5-f6aa-2082-470eca58bc41@fastree3d.com>


[-- Attachment #1.1: Type: text/plain, Size: 2410 bytes --]

Hi,

Does the community have any other ideas? Or I am wrong, and devm_iounmap 
is enough?

Regards,
Adrian

On 6.12.2022 22:23, Adrian Fiergolski wrote:
>
> Hi Costa,
>
> Thank you for your reply.
>
> I saw 'devm_iounmap' , but, correct me if I am wrong, I think is not 
> enough.
>
> devm_ioremap_resource calls __devm_ioremap_resource (link 
> <https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L117>) 
> which calls eventually __devm_request_region (link 
> <https://elixir.bootlin.com/linux/v5.10.157/source/kernel/resource.c#L1520>) 
> and __devm_ioremap (link 
> <https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L25>). 
> Those two will allocate 2 devres: devm_region_release and 
> devm_ioremap_release.
>
> The proposed devm_iounmap (link 
> <https://elixir.bootlin.com/linux/v5.10.157/source/lib/devres.c#L108>) 
> seems to destroy only devm_ioremap_release devres.
>
> Regards,
> Adrian
>
> On 2.12.2022 19:01, Constantine Shulyupin wrote:
>> 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
>> <adrian.fiergolski@fastree3d.com>  wrote:
>>> Hello,
>>>
>>> I am extending xilinx-hls driver
>>> (https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-hls.c)
>>> 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
>>> Kernelnewbies@kernelnewbies.org
>>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[-- Attachment #1.2: Type: text/html, Size: 3855 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2022-12-09 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 17:24 unmap memory mapped with devm_ioremap_resource Adrian Fiergolski
2022-12-02 18:01 ` Constantine Shulyupin
2022-12-06 21:23   ` Adrian Fiergolski
2022-12-09 16:14     ` Adrian Fiergolski [this message]
2022-12-09 19:58       ` jim.cromie
2022-12-09 20:35         ` Valdis Klētnieks
2022-12-09 22:52           ` Adrian Fiergolski
2022-12-10  6:53             ` Constantine Shulyupin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2d7fddcd-6289-dc63-6cf2-a5880057d6aa@fastree3d.com \
    --to=adrian.fiergolski@fastree3d.com \
    --cc=constantine.shulyupin@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox