Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp303601iob; Thu, 28 Apr 2022 02:47:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlNQ50wEgjkrgQ4N6z0ehcxore6/Xhb0QvvjQTwzUeolQPYbTR2lq5+4EB7kVsnmVuWUEi X-Received: by 2002:a05:6a00:23c7:b0:50d:8f8e:ffac with SMTP id g7-20020a056a0023c700b0050d8f8effacmr4396438pfc.76.1651139239692; Thu, 28 Apr 2022 02:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651139239; cv=none; d=google.com; s=arc-20160816; b=INRvGsfaPHNF6zcoxAo/Js4UqAV/RtiYGuNKbp+tjbdpWnsXUFtRhjGe1kYCwg8Vwj 8V7urts8iDnYpGo60W8jAj3vAFpBVfC7cuxnIjp9OpaagwiC9EvWu7nQ9IuJT4e/El4S mxFjI//nDurNT3SeL9/WxZTNunktsA3oj0oP/jpeLijvyUxkCkL4t6975YK+wtzmZBC5 bWpbSL1XzdBgCbksPSaiTuVs4hkt34rmTXwiJklBCYLw4vmp5+iC6vMTLNEJWuJqmpW9 +EcLsHPQKM99A8SsG1obDMOD0liaQ9g4rQrTzZ8RPTtyOemNOCD38zfPsbLlcBjwacaB 63KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=yyPm48D0TaewRdFvBe5Vb3qT/y71/HNNrdBUI2ijpOE=; b=Ebc/iwpKnvANIEGnRaZ1h7cvLyJHqMNhYESDWs4rFIoHA++5re2RCGXDqDk3N/UEJs 2uQuyB42I4lmUtO+do+YVq6PbUJrM4iDvBI1RJWVZ7BjgO0zPmJi3iBkWmeJHvfVqwCi 2l4IDQGaMJ+Lhe+Imzwcx+YttmwiGvscToqmZWC/vukf5tJ52/+Rrc5huhMisCXl+h9D SRi4+lfGWutQ448k2775WlTKCXZLSi8AeRvZNopw3e6n4FohZrYZIpYqJfzKbLzOJ2NK EVORunmqhBpyt4Hcgs5tu5Sy/1NAk8rfonEhIeLVlzLw6lisMrbsRqr5dhXWRsswDB3w qV2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a170902ed0b00b00158d1f2d451si3665968pld.45.2022.04.28.02.47.04; Thu, 28 Apr 2022 02:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243545AbiD1GXs (ORCPT + 99 others); Thu, 28 Apr 2022 02:23:48 -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 X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 > > .