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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D70ADC433F5 for ; Thu, 28 Apr 2022 06:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243749AbiD1GXt (ORCPT ); Thu, 28 Apr 2022 02:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239165AbiD1GXo (ORCPT ); Thu, 28 Apr 2022 02:23:44 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4A160062 for ; Wed, 27 Apr 2022 23:20:28 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Kplnv2QVFz1JBk4; Thu, 28 Apr 2022 14:19:31 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 14:20:26 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 14:20:25 +0800 Message-ID: Date: Thu, 28 Apr 2022 14:20:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 2/4] mm: ioremap: Add arch_ioremap/iounmap_check() Content-Language: en-US To: Arnd Bergmann CC: Catalin Marinas , Will Deacon , Andrew Morton , Linux ARM , Linux Kernel Mailing List , Linux-MM References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> <20220427121413.168468-3-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/4/28 2:20, Arnd Bergmann wrote: > On Wed, Apr 27, 2022 at 2:14 PM Kefeng Wang wrote: >> @@ -964,6 +964,9 @@ static inline void iounmap(volatile void __iomem *addr) >> #elif defined(CONFIG_GENERIC_IOREMAP) >> #include >> >> +bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot); >> +bool arch_iounmap_check(void __iomem *addr); >> + >> void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); >> void iounmap(volatile void __iomem *addr); >> >> diff --git a/mm/ioremap.c b/mm/ioremap.c >> index 522ef899c35f..d1117005dcc7 100644 >> --- a/mm/ioremap.c >> +++ b/mm/ioremap.c >> @@ -11,6 +11,16 @@ >> #include >> #include >> >> +bool __weak arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot) >> +{ >> + return true; >> +} >> + >> +bool __weak arch_iounmap_check(void __iomem *addr) >> +{ >> + return true; >> +} >> + > I don't really like the weak functions. The normal way to do this in > asm-generic headers > is to have something like > > #ifndef arch_ioremap_check > static inline bool arch_ioremap_check(phys_addr_t addr, size_t size, > unsigned long prot) > { > return true; > } > #endif > > and then in architectures that actually do some checking, have these > bits in asm/io.h > > bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot); > #define arch_ioremap_check arch_ioremap_check Ok, I could use this way, and keep consistent with others definitions in asm/io.h > (or alternatively an extern declaration, if the implementation is nontrivial) > > It may be worth pointing out that either way requires including > asm-generic/io.h, > which most architectures don't. This is probably fine, as only csky, riscv and > now arm64 use CONFIG_GENERIC_IOREMAP, and we can probably require > that any further architectures using this symbol also have to use > asm-generic/io.h. It looks the arch is already include it, $ git grep "asm-generic/io.h" arch/ arch/arc/include/asm/io.h:#include arch/arm/include/asm/io.h:#include arch/arm64/include/asm/io.h:#include arch/csky/include/asm/io.h:#include arch/h8300/include/asm/io.h:#include arch/ia64/include/asm/io.h:#include arch/m68k/include/asm/io.h:#include arch/m68k/include/asm/io_no.h: * that behavior here first before we include asm-generic/io.h. arch/microblaze/include/asm/io.h:#include arch/nios2/include/asm/io.h:#include arch/openrisc/include/asm/io.h:#include arch/powerpc/include/asm/io.h:#include arch/riscv/include/asm/io.h:#include arch/s390/include/asm/io.h:#include arch/sparc/include/asm/io_32.h:#include arch/um/include/asm/io.h:#include arch/x86/include/asm/io.h:#include arch/xtensa/include/asm/io.h:#include > Arnd > > . 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 212B4C433F5 for ; Thu, 28 Apr 2022 06:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QWVrEvweHnROc/zxyGR5h3m/8UiWYfI36cLN0yZuyxE=; b=I/rWUpPMZPoMeZ N1/kXAWdRd/pm+GGub0UsR16XvtAqmiPmYNFm2qJgTqN2rdmX6mWjpdjlUihpEh4ILWniIqUV6Fc+ 6IgDiKaCLvWUgs8DAGMB/pboHaGmis+VlMLsxjKCuivDZRYS3ZDf9ffxZjB1DXedXezy2WYI+EUDL c7OVnJjXtjKIo2bXGlP2vLFN/sjZhYVzjG1txb7rTYgM58tTxzlATDxPNON0pycZC6f683ps2f95p h7nqdtFBIGcIfQgzwWWrwgU2+R95i66nBWMXI397XYzTM/uE98BkVhx7fBk68pafCihpyuruNLzQ3 ptOtIBnMDNhOGR+wQuug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njxVy-004rrl-4s; Thu, 28 Apr 2022 06:20:34 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njxVt-004rpY-M3 for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2022 06:20:31 +0000 Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Kplnv2QVFz1JBk4; Thu, 28 Apr 2022 14:19:31 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 14:20:26 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 14:20:25 +0800 Message-ID: Date: Thu, 28 Apr 2022 14:20:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 2/4] mm: ioremap: Add arch_ioremap/iounmap_check() Content-Language: en-US To: Arnd Bergmann CC: Catalin Marinas , Will Deacon , Andrew Morton , Linux ARM , Linux Kernel Mailing List , Linux-MM References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> <20220427121413.168468-3-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_232030_136455_74BC756F X-CRM114-Status: GOOD ( 15.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022/4/28 2:20, Arnd Bergmann wrote: > On Wed, Apr 27, 2022 at 2:14 PM Kefeng Wang wrote: >> @@ -964,6 +964,9 @@ static inline void iounmap(volatile void __iomem *addr) >> #elif defined(CONFIG_GENERIC_IOREMAP) >> #include >> >> +bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot); >> +bool arch_iounmap_check(void __iomem *addr); >> + >> void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); >> void iounmap(volatile void __iomem *addr); >> >> diff --git a/mm/ioremap.c b/mm/ioremap.c >> index 522ef899c35f..d1117005dcc7 100644 >> --- a/mm/ioremap.c >> +++ b/mm/ioremap.c >> @@ -11,6 +11,16 @@ >> #include >> #include >> >> +bool __weak arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot) >> +{ >> + return true; >> +} >> + >> +bool __weak arch_iounmap_check(void __iomem *addr) >> +{ >> + return true; >> +} >> + > I don't really like the weak functions. The normal way to do this in > asm-generic headers > is to have something like > > #ifndef arch_ioremap_check > static inline bool arch_ioremap_check(phys_addr_t addr, size_t size, > unsigned long prot) > { > return true; > } > #endif > > and then in architectures that actually do some checking, have these > bits in asm/io.h > > bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot); > #define arch_ioremap_check arch_ioremap_check Ok, I could use this way, and keep consistent with others definitions in asm/io.h > (or alternatively an extern declaration, if the implementation is nontrivial) > > It may be worth pointing out that either way requires including > asm-generic/io.h, > which most architectures don't. This is probably fine, as only csky, riscv and > now arm64 use CONFIG_GENERIC_IOREMAP, and we can probably require > that any further architectures using this symbol also have to use > asm-generic/io.h. It looks the arch is already include it, $ git grep "asm-generic/io.h" arch/ arch/arc/include/asm/io.h:#include arch/arm/include/asm/io.h:#include arch/arm64/include/asm/io.h:#include arch/csky/include/asm/io.h:#include arch/h8300/include/asm/io.h:#include arch/ia64/include/asm/io.h:#include arch/m68k/include/asm/io.h:#include arch/m68k/include/asm/io_no.h: * that behavior here first before we include asm-generic/io.h. arch/microblaze/include/asm/io.h:#include arch/nios2/include/asm/io.h:#include arch/openrisc/include/asm/io.h:#include arch/powerpc/include/asm/io.h:#include arch/riscv/include/asm/io.h:#include arch/s390/include/asm/io.h:#include arch/sparc/include/asm/io_32.h:#include arch/um/include/asm/io.h:#include arch/x86/include/asm/io.h:#include arch/xtensa/include/asm/io.h:#include > Arnd > > . _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel