From patchwork Fri Jul 3 18:17:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 6716571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D17309F2F0 for ; Fri, 3 Jul 2015 18:19:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1E702063F for ; Fri, 3 Jul 2015 18:19:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81A5E20639 for ; Fri, 3 Jul 2015 18:19:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZB5Wz-0004wU-TU; Fri, 03 Jul 2015 18:17:45 +0000 Received: from cantor2.suse.de ([195.135.220.15] helo=mx2.suse.de) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZB5Wu-00044d-Id for linux-arm-kernel@lists.infradead.org; Fri, 03 Jul 2015 18:17:41 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3B821ADB7; Fri, 3 Jul 2015 18:17:13 +0000 (UTC) Date: Fri, 3 Jul 2015 20:17:09 +0200 From: "Luis R. Rodriguez" To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: RFC: default ioremap_*() variant defintions Message-ID: <20150703181709.GD7021@wotan.suse.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150703_111740_966283_AA433CA6 X-CRM114-Status: GOOD ( 22.81 ) X-Spam-Score: -7.5 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Toshi Kani , Arnd Bergmann , "Luis R. Rodriguez" , Benjamin Herrenschmidt , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Borislav Petkov , Ingo Molnar Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 0-day build bot detected a build issue on a patch not upstream yet that makes a driver use iorempa_uc(), this call is now upstream but we have no drivers yet using it, the patch in question makes the atyfb framebuffer driver use it. The build issue was the lack of the ioremap_uc() call being implemented on some non-x86 architectures. I *thought* I had added boiler plate code to map the ioremap_uc() call to ioremap_nocache() for archs that do not already define their own iorempa_uc() call, but upon further investigation it seems that was not the case but found that this may be a bit different issue altogether. The way include/asm-generic/io.h works for ioremap() calls and its variants is: #ifndef CONFIG_MMU #ifndef ioremap #define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t offset, size_t size) { return (void __iomem *)(unsigned long)offset; } #endif ... #define iounmap iounmap static inline void iounmap(void __iomem *addr) { } #endif #endif /* CONFIG_MMU */ That's the gist of it, but the catch here is the ioremap_*() variants and where they are defined. The first variant is ioremap_nocache() and then all other variants by default map to this one. We've been stuffing the variant definitions within the #ifndef CONFIG_MMU and I don't think we should be as otherwise each and everyone's archs will have to add their own variant default map to the default ioremap_nocache() or whatever. That's exaclty what we have to day, and from what I gather the purpose of the variant boiler plate is lost. I think we should keep the ioremap() and ioreunmap() tucked under the CONFIG_MMU but not the variants. For instance to address the build issue for ioremap_uc() we either define ioremap_uc() for all archs or do something like this: This builds on x86 and other archs now and I can verify that the default boilerplate code is not used on x86. One small caveat: I have no idea why its not picking up asm-generic ioremap_uc() for x86, although this is the right thing to do the guard should not work as we never define ioremap_uc() as a macro but we do as an exported symbol. The way archs do their ioremap calls is they define externs and then they include asm-generic to pick up the things they don't define. In the extern calls for ioremap_uc() we never add a define there. Adding a simple one line #define right after the extern declaration to itself should suffice to fix paranoia but curious why this does work as-is right now. I'd like review and consensus from other architecture folks if this is the Right Thing To Do (TM) and if it is decide how we want to fix this. For instance my preference would be to just add this fix as-is after we've figured out the guard thing above, and then define these variants in the documentation on the asm-generic file as safe to not have, and safe to map to the default ioremap call. If you don't have a safe call like this we should set out different expectations, for instance having it depend on Kconfig symbol and then drivers depend on it, archs then implement the symbols and can HAVE_ARCH_FOO. If everyone agrees with this then there is quite a bit of cleanup possible as tons of archs do tons of their own variant mapping definitions. Luis diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index f56094cfdeff..6e5e80d5dd0c 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -769,14 +769,6 @@ static inline void __iomem *ioremap_nocache(phys_addr_t offset, size_t size) } #endif -#ifndef ioremap_uc -#define ioremap_uc ioremap_uc -static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size) -{ - return ioremap_nocache(offset, size); -} -#endif - #ifndef ioremap_wc #define ioremap_wc ioremap_wc static inline void __iomem *ioremap_wc(phys_addr_t offset, size_t size) @@ -802,6 +794,14 @@ static inline void iounmap(void __iomem *addr) #endif #endif /* CONFIG_MMU */ +#ifndef ioremap_uc +#define ioremap_uc ioremap_uc +static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size) +{ + return ioremap_nocache(offset, size); +} +#endif + #ifdef CONFIG_HAS_IOPORT_MAP #ifndef CONFIG_GENERIC_IOMAP #ifndef ioport_map