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 940E2C433F5 for ; Wed, 27 Apr 2022 18:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244781AbiD0SYO (ORCPT ); Wed, 27 Apr 2022 14:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244782AbiD0SYF (ORCPT ); Wed, 27 Apr 2022 14:24:05 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A7C5AA4E for ; Wed, 27 Apr 2022 11:20:49 -0700 (PDT) Received: from mail-yw1-f174.google.com ([209.85.128.174]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Mspy4-1nz6Ep3T1k-00t8Zv for ; Wed, 27 Apr 2022 20:20:48 +0200 Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-2ef5380669cso28336387b3.9 for ; Wed, 27 Apr 2022 11:20:47 -0700 (PDT) X-Gm-Message-State: AOAM533JQw/gKkymZv4K96LKPX/UFEo5u67tJ++oO0BvKJgPGA94M1oc jpNu8wHFzHPHXHWtQ830FuaDI6i4QWdK2ZXqT8Y= X-Google-Smtp-Source: ABdhPJwvEoSUguhdRwTP+lohWXQtYJ9DDg1Zn7qIjSsaEiGfg1kkd2iKF2q7oFkNsz/JpP2X/5Hv5gVbR3gnWZxOUM4= X-Received: by 2002:a81:2305:0:b0:2f7:dadb:2162 with SMTP id j5-20020a812305000000b002f7dadb2162mr17396473ywj.42.1651083646618; Wed, 27 Apr 2022 11:20:46 -0700 (PDT) MIME-Version: 1.0 References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> <20220427121413.168468-3-wangkefeng.wang@huawei.com> In-Reply-To: <20220427121413.168468-3-wangkefeng.wang@huawei.com> From: Arnd Bergmann Date: Wed, 27 Apr 2022 20:20:30 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] mm: ioremap: Add arch_ioremap/iounmap_check() To: Kefeng Wang Cc: Catalin Marinas , Will Deacon , Andrew Morton , Linux ARM , Linux Kernel Mailing List , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:Py9c6L8yk4Q+u/Ah/U4yqNG58vF9Vui/iwrdfbE1xO+IcAxVelg WfkrrCffOdx2DTbqy59soc4/tCN3xmG1SPp5ACwCCx4ppq+CoTLMvNlkY+MHXm0pH1JFtJ4 4K2hMrERDwyBThIlOMPSonMr47Kq+C037LICDMMcGVmdKS28BXKkgFtwVN5gChkhN6rnw02 ncDaL0Pq8ZZvkCQOHusNw== X-UI-Out-Filterresults: notjunk:1;V03:K0:X4H1rwttH/k=:Gi7FBhMS0HESqzXcIydzOy OSg3pSWdg97bTqWTKHP9Biuzf+6xNpzVH7CLVNmwzmFH97QEi/qpvdSdKTuoWDHD15EZ4rjCw igScqUIdXj2oC6uavt1GTL+VqShDV9lEfrMTetXkRnhJBA6u2pbs78HRfN1CH6ME6nDuR/0Lq HRxmXDFR64kHpzyCyOZA0sZUEFeEtL6WFdjHINrk6EHwC1lIRmI/bSf1ZOE3C9eoEz9AA3K1n oe21c9TFyxK9puxDBaMxwbNXgiqS5cROyYDFm6wc0lVs2sc+4RUh3GrJP2g7x0GJoZ+Ydns8Y Y3uKoeL1Z/+jJ9vhH4QoB7lpiH7sZuACns63jkGCGBKYcJCPnKsJLAuz5/SRGRzQf/Zk8hao/ sMv7I3IDdCk/jrFk69fRnOQS8OHRcGc5X4OOASkhCMd5kJwwQ3y1wkAKOjFoTLpIrc1T8zlC4 CXXnYmNgitlT+H8alsr9FHmDjWRLq1gGpLPd6wlRzWNtjK1NFH5uBTtYW9jNq+B1pNlBwLjUU VUxrDQNdIzJM6i8WjfgLR+wc3ks5LHIUyQRB4/l+L+0Ak6Gdi8zcojGrnZ1nDb2V+G2uT/pFm B8aM5nfopwCK4jtk/3BsYA0P/jCXpbZXsp2hWzBNd5jHmjz1Y88JrOx+lxWm83CginrmdDr/9 I51mPe42LT7k0JqVFM4oXRxIo8fz1cU7DyB4CGl20ABJ9btUlnhuo+crbWiqSjVhVMN/YIzUk HYdLayU4k9ftezAdSJJfqx8jiN9FpLWWxazLcVV7F6whbWrgTa6hvloEE0RG8ChMDyU7NOUED dzkGpo9td+UxqlXDoF/NmSknvJoGkcJ8r+79Ok9Otb1OfwoGKs= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 (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. 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 8091CC433EF for ; Wed, 27 Apr 2022 18:23:43 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kf/EnhWxOKcfbNnByDP0t8T1SfCcC9iRss3D8a+6jGo=; b=mtwPbo84kwp1tr iO1neNkCSzpr6QrXoyRPlBxcKmaAc2YkFMN3uQokNjmG1injzOn1qvF5kMKX1KDWC95biMaUGsedZ ThYF+wHNCv1PRFe8B0WfeXIir61pyfvk0UjTz3q0rcGjcOJxA51QZvm3i0LKL0KeXlEt2c1W+Kefv ctSJOdbNSRtSvJ1DAfrgCtycbVuVyoWuZM13ZDu49T0obGp+47IIA3MpfF155Vr3dktS99LgMNFcN RPZlrZDheNI/D/zIbbz7f32SD++3MCJzojGaoR5G+f6j17ORWSIdex32czRgWA2lpDDqNM1Qi+q23 BL1Jwz45x7gFpkJYKDrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njmJ9-002yIf-Uj; Wed, 27 Apr 2022 18:22:36 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njmHT-002xVy-6F for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 18:20:53 +0000 Received: from mail-yw1-f180.google.com ([209.85.128.180]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N6JtR-1nuTWY3MiH-016fEs for ; Wed, 27 Apr 2022 20:20:48 +0200 Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-2f7d19cac0bso28173767b3.13 for ; Wed, 27 Apr 2022 11:20:47 -0700 (PDT) X-Gm-Message-State: AOAM530W16Wj6QoCixzrL5A9DmfgLWPSDVwfBpOmTZe602/J/KdK5iZ9 Tc+qmOHPrdRcLkiUZIpDLGrmm4b/ckxOP+B68K4= X-Google-Smtp-Source: ABdhPJwvEoSUguhdRwTP+lohWXQtYJ9DDg1Zn7qIjSsaEiGfg1kkd2iKF2q7oFkNsz/JpP2X/5Hv5gVbR3gnWZxOUM4= X-Received: by 2002:a81:2305:0:b0:2f7:dadb:2162 with SMTP id j5-20020a812305000000b002f7dadb2162mr17396473ywj.42.1651083646618; Wed, 27 Apr 2022 11:20:46 -0700 (PDT) MIME-Version: 1.0 References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> <20220427121413.168468-3-wangkefeng.wang@huawei.com> In-Reply-To: <20220427121413.168468-3-wangkefeng.wang@huawei.com> From: Arnd Bergmann Date: Wed, 27 Apr 2022 20:20:30 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] mm: ioremap: Add arch_ioremap/iounmap_check() To: Kefeng Wang Cc: Catalin Marinas , Will Deacon , Andrew Morton , Linux ARM , Linux Kernel Mailing List , Linux-MM X-Provags-ID: V03:K1:9pxXB5ktY4TN+CQTCHFL+y20veIrwKhqt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FayY/tf1iEd6Q8WS+3cf4n0Jy/nfiahAhGHtbOk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_112051_582114_6D7B78D1 X-CRM114-Status: GOOD ( 16.48 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 (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. Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel