Re: [PATCH v3 00/27] kill devm_ioremap_nocache
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH v3 00/27] kill devm_ioremap_nocache
- From: Yisheng Xie <xieyisheng1@xxxxxxxxxx>
- Date: Mon, 25 Dec 2017 09:34:25 +0800
- Cc: <linux-kernel@xxxxxxxxxxxxxxx>, <ysxie@xxxxxxxxxxx>, <ulf.hansson@xxxxxxxxxx>, <linux-mmc@xxxxxxxxxxxxxxx>, <boris.brezillon@xxxxxxxxxxxxxxxxxx>, <richard@xxxxxx>, <marek.vasut@xxxxxxxxx>, <cyrille.pitchen@xxxxxxxxxx>, <linux-mtd@xxxxxxxxxxxxxxxxxxx>, <alsa-devel@xxxxxxxxxxxxxxxx>, <wim@xxxxxxxxx>, <linux@xxxxxxxxxxxx>, <linux-watchdog@xxxxxxxxxxxxxxx>, <b.zolnierkie@xxxxxxxxxxx>, <linux-fbdev@xxxxxxxxxxxxxxx>, <linus.walleij@xxxxxxxxxx>, <linux-gpio@xxxxxxxxxxxxxxx>, <ralf@xxxxxxxxxxxxxx>, <linux-mips@xxxxxxxxxxxxxx>, <lgirdwood@xxxxxxxxx>, <broonie@xxxxxxxxxx>, <tglx@xxxxxxxxxxxxx>, <jason@xxxxxxxxxxxxxx>, <marc.zyngier@xxxxxxx>, <arnd@xxxxxxxx>, <andriy.shevchenko@xxxxxxxxxxxxxxx>, <industrypack-devel@xxxxxxxxxxxxxxxxxxxxx>, <wg@xxxxxxxxxxxxxx>, <mkl@xxxxxxxxxxxxxx>, <linux-can@xxxxxxxxxxxxxxx>, <mchehab@xxxxxxxxxx>, <linux-media@xxxxxxxxxxxxxxx>, <a.zummo@xxxxxxxxxxxx>, <alexandre.belloni@xxxxxxxxxxxxxxxxxx>, <linux-rtc@xxxxxxxxxxxxxxx>, <daniel.vetter@xxxxxxxxx>, <jani.nikula@xxxxxxxxxxxxxxx>, <seanpaul@xxxxxxxxxxxx>, <airlied@xxxxxxxx>, <dri-devel@xxxxxxxxxxxxxxxxxxxxx>, <kvalo@xxxxxxxxxxxxxx>, <linux-wireless@xxxxxxxxxxxxxxx>, <linux-spi@xxxxxxxxxxxxxxx>, <tj@xxxxxxxxxx>, <linux-ide@xxxxxxxxxxxxxxx>, <bhelgaas@xxxxxxxxxx>, <linux-pci@xxxxxxxxxxxxxxx>, <devel@xxxxxxxxxxxxxxxxxxxx>, <dvhart@xxxxxxxxxxxxx>, <andy@xxxxxxxxxxxxx>, <platform-driver-x86@xxxxxxxxxxxxxxx>, <jakub.kicinski@xxxxxxxxxxxxx>, <davem@xxxxxxxxxxxxx>, <nios2-dev@xxxxxxxxxxxxxxxxxxxxxx>, <netdev@xxxxxxxxxxxxxxx>, <vinod.koul@xxxxxxxxx>, <dan.j.williams@xxxxxxxxx>, <dmaengine@xxxxxxxxxxxxxxx>, <jslaby@xxxxxxxx>
- In-reply-to: <b8ff7f17-7f2c-f220-9833-7ae5bd7343d5@c-s.fr>
- References: <1514026525-32538-1-git-send-email-xieyisheng1@huawei.com> <20171223134831.GB10103@kroah.com> <b8ff7f17-7f2c-f220-9833-7ae5bd7343d5@c-s.fr>
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
On 2017/12/24 17:05, christophe leroy wrote:
>
>
> Le 23/12/2017 à 14:48, Greg KH a écrit :
>> On Sat, Dec 23, 2017 at 06:55:25PM +0800, Yisheng Xie wrote:
>>> Hi all,
>>>
>>> When I tried to use devm_ioremap function and review related code, I found
>>> devm_ioremap and devm_ioremap_nocache is almost the same with each other,
>>> except one use ioremap while the other use ioremap_nocache.
>>
>> For all arches? Really? Look at MIPS, and x86, they have different
>> functions.
>>
>>> While ioremap's
>>> default function is ioremap_nocache, so devm_ioremap_nocache also have the
>>> same function with devm_ioremap, which can just be killed to reduce the size
>>> of devres.o(from 20304 bytes to 18992 bytes in my compile environment).
>>>
>>> I have posted two versions, which use macro instead of function for
>>> devm_ioremap_nocache[1] or devm_ioremap[2]. And Greg suggest me to kill
>>> devm_ioremap_nocache for no need to keep a macro around for the duplicate
>>> thing. So here comes v3 and please help to review.
>>
>> I don't think this can be done, what am I missing? These functions are
>> not identical, sorry for missing that before.
>
> devm_ioremap() and devm_ioremap_nocache() are quite similar, both use devm_ioremap_release() for the release, why not just defining:
>
> static void __iomem *__devm_ioremap(struct device *dev, resource_size_t offset,
> resource_size_t size, bool nocache)
> {
> [...]
> if (nocache)
> addr = ioremap_nocache(offset, size);
> else
> addr = ioremap(offset, size);
> [...]
> }
>
> then in include/linux/io.h
>
> static inline void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
> resource_size_t size)
> {return __devm_ioremap(dev, offset, size, false);}
>
> static inline void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
> resource_size_t size);
> {return __devm_ioremap(dev, offset, size, true);}
Yeah, this seems good to me, right now we have devm_ioremap, devm_ioremap_wc, devm_ioremap_nocache
May be we can use an enum like:
typedef enum {
DEVM_IOREMAP = 0,
DEVM_IOREMAP_NOCACHE,
DEVM_IOREMAP_WC,
} devm_ioremap_type;
static inline void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
resource_size_t size)
{return __devm_ioremap(dev, offset, size, DEVM_IOREMAP);}
static inline void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
resource_size_t size);
{return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_NOCACHE);}
static inline void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
resource_size_t size);
{return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_WC);}
static void __iomem *__devm_ioremap(struct device *dev, resource_size_t offset,
resource_size_t size, devm_ioremap_type type)
{
void __iomem **ptr, *addr = NULL;
[...]
switch (type){
case DEVM_IOREMAP:
addr = ioremap(offset, size);
break;
case DEVM_IOREMAP_NOCACHE:
addr = ioremap_nocache(offset, size);
break;
case DEVM_IOREMAP_WC:
addr = ioremap_wc(offset, size);
break;
}
[...]
}
Thanks
Yisheng
>
> Christophe
>
>>
>> thanks,
>>
>> greg k-h
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
>
> .
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Index of Archives]
[Linux Kernel]
[Linux ARM (vger)]
[Linux ARM MSM]
[Linux Omap]
[Linux Arm]
[Linux Tegra]
[Fedora ARM]
[Linux for Samsung SOC]
[eCos]
[Linux Fastboot]
[Gcc Help]
[Git]
[DCCP]
[IETF Announce]
[Security]
[Linux MIPS]
[Yosemite Campsites]
|