From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C318C4332F for ; Fri, 9 Dec 2022 16:14:43 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.96) (envelope-from ) id 1p3g11-0006h8-0o; Fri, 09 Dec 2022 11:14:23 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1p3g0x-0006gf-01 for kernelnewbies@kernelnewbies.org; Fri, 09 Dec 2022 11:14:19 -0500 Received: by mail-ej1-x629.google.com with SMTP id gh17so12628716ejb.6 for ; Fri, 09 Dec 2022 08:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastree3d-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=l+WzXktGokkvdo34zbDxfNzuELPTTQ36VagjYGexuPI=; b=zMAztE88sE8pwGQITyYRhPBke93l6exv68ep4XuMEuALZeJcDcgQ/cfgYvPnqtmsMd IrSD4swU3B6EYVf353Gn5hMzH9hxO28CQnwkmZXN7rV7L/lHgBB+w9KwCd9DRlXfn11V e5qNTxsymJXDikujyx++AyL01VIuHMkCVAGURjohk4oFd+PyTegZto53Pic9CXcs3ULK uc//Znu2ZFXKQJTUkX4TeMV4vXOL00KEAbBCMiVrOB1h/9SebBRizjN3m2tVJYPmu69W ffoX36qYCZdZ1k86oDW+41JEd+5+SC2+Re1PDSRXfreg/c0Ks1bq7GovDOKaMaKNWFc9 NkGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l+WzXktGokkvdo34zbDxfNzuELPTTQ36VagjYGexuPI=; b=M64rxrzFVCv4dzK3IwQyFA1HSV+oaqSOSO03oSeeAHCI72lRS3ltBdLeJzYqz77AeD 85vwN8tFYaPJ3hHHORTPqiFQrMwcXdNBfTs6R8khcYDYGKLhpzHysouXbsp1ov0Hn1DS NoJZ3WPAgPkvGOmD0dnqR4ylfnIl446g4+5alavQAD+39aPRd8SMDRPffSplweBRLbHC swCPqufEIsoUAK+QQW/KS39JUkFo2VmUz5F5WqPfWNqkEOVncoyqGkcacRrojhZA9JLP 5YqQeGUmkeQ8roQ4XLWK/eeb9/F2yDQTfURtGgAtvHqXvII7xALIa30xwwIFzu73ZtEY wW5w== X-Gm-Message-State: ANoB5pnPR4nfpLJIFffggZSJQAUynVIG/rrHmjBue1VmRjkGPOgoyghD v0ABhERT/ueFKz5hCmz694c94u+C1lpxjPwTSf+h X-Google-Smtp-Source: AA0mqf7FXwp4DR0e13fEhbOZimXE6aKiClwK1JyDj5NPCief8vHl0SD4o6MUU+famKWJcdek2TCuCQ== X-Received: by 2002:a17:906:524f:b0:7bf:f0e9:4edc with SMTP id y15-20020a170906524f00b007bff0e94edcmr5622821ejm.31.1670602455637; Fri, 09 Dec 2022 08:14:15 -0800 (PST) Received: from [192.168.33.195] (fastree1.epfl.ch. [192.26.37.52]) by smtp.gmail.com with ESMTPSA id b27-20020a1709062b5b00b0078db18d7972sm73064ejg.117.2022.12.09.08.14.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 08:14:15 -0800 (PST) From: Adrian Fiergolski X-Google-Original-From: Adrian Fiergolski Message-ID: <2d7fddcd-6289-dc63-6cf2-a5880057d6aa@fastree3d.com> Date: Fri, 9 Dec 2022 17:14:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.5.0 Subject: Re: unmap memory mapped with devm_ioremap_resource Content-Language: en-GB To: Constantine Shulyupin References: <518b1ec9-6d01-022e-de49-feb1f42c113c@fastree3d.com> In-Reply-To: Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0679070935012268101==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multi-part message in MIME format. --===============0679070935012268101== Content-Type: multipart/alternative; boundary="------------PE5bdrKTrkd72mNa91fEWXCS" Content-Language: en-GB This is a multi-part message in MIME format. --------------PE5bdrKTrkd72mNa91fEWXCS Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > ) > which calls eventually __devm_request_region (link > ) > and __devm_ioremap (link > ). > Those two will allocate 2 devres: devm_region_release and > devm_ioremap_release. > > The proposed devm_iounmap (link > ) > 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 >> 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 --------------PE5bdrKTrkd72mNa91fEWXCS Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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) which calls eventually __devm_request_region (link) and __devm_ioremap (link). Those two will allocate 2 devres: devm_region_release and devm_ioremap_release.

The proposed devm_iounmap (link) 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
--------------PE5bdrKTrkd72mNa91fEWXCS-- --===============0679070935012268101== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============0679070935012268101==--