Received: by 10.213.65.68 with SMTP id h4csp869744imn; Thu, 22 Mar 2018 10:19:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELvAwOXgC4xpyaal/sluqxfaPFMkMArTbenv35mEBkP1uzTPJWiV2jaDR8jYqxPTcYw5P8rE X-Received: by 2002:a17:902:43e4:: with SMTP id j91-v6mr8034098pld.118.1521739196063; Thu, 22 Mar 2018 10:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521739196; cv=none; d=google.com; s=arc-20160816; b=qmmn586VZgv1H77F1dhuGqOsUIArxqHwyq+3/FTFedPMeCyNoZL/wyCBGfytzdErZP T2E0O4/qpgK/XpWts/mnZ82NB78KUdkJto7GQ0lCyjn5yHKktx81jaPSW8ATAUa2O9CW subdJjhyIhF3datuYE7k3ttINM4qwIWzddkKxXv2PxECVAbLcZDxUSiJ2TuaGSfzv2jX VsGjLKjJIvBmnrty3fHCx7xlubgNZClTlWWBt6aRP3KpkGFFS0sS9pWjx66shT1usYQ7 liSdQK/wyZu9OUoI2mL0VMrQd5539TrV2Tkw39063RuQvH0ZnR+LvJtqWf+hV1GZKixB WDag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=Sed5J4zur1LuGTTwBEWmz2VkNnKyo/0tvdcqPvCOv6Y=; b=qd/wGccKlohc0+DF4CxsIgk9qg+poN0sf5I3RjYS9Y89M/01mbeE03Ej+CO2wdW1jO 9qZWVJ8Y597XTSE3i1ZSpEuny0YaZ3KmvKrCAMwYKasPWjby4gvciWngdaYXdQeGzqCw tfuzBzL9skU3N/zxMXVoAOPj5GQL3UOYdKuib4M2qg18Y41AG/ndmBg8SDPjnEo5fEyQ gXt7UJc0K/xFh9aHmQryea/ueaw1pWKXGJcIVoeXP0RbJkqh74UqU4kEqHmYvUT5pkjm xDwo93BvpvdyyRUhvtBYcMITsQnayOUufQvMwLs3ZTnlZu9OUd2MJE4M/byDKUagfHBC lolw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si6031545pln.234.2018.03.22.10.19.40; Thu, 22 Mar 2018 10:19:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbeCVRRT (ORCPT + 99 others); Thu, 22 Mar 2018 13:17:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:35150 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751923AbeCVRRM (ORCPT ); Thu, 22 Mar 2018 13:17:12 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ez3ps-00073G-5B; Thu, 22 Mar 2018 11:17:10 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1ez3pq-00018I-Jc; Thu, 22 Mar 2018 11:17:06 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-ntb@googlegroups.com, linux-crypto@vger.kernel.org, Greg Kroah-Hartman Cc: Arnd Bergmann , Andy Shevchenko , =?UTF-8?q?Horia=20Geant=C4=83?= , Logan Gunthorpe , Thomas Gleixner , Philippe Ombredanne , Kate Stewart , Luc Van Oostenryck Date: Thu, 22 Mar 2018 11:16:55 -0600 Message-Id: <20180322171703.4300-3-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180322171703.4300-1-logang@deltatee.com> References: <20180322171703.4300-1-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, arnd@arndb.de, horia.geanta@nxp.com, logang@deltatee.com, tglx@linutronix.de, pombredanne@nexb.com, gregkh@linuxfoundation.org, kstewart@linuxfoundation.org, andy.shevchenko@gmail.com, luc.vanoostenryck@gmail.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH v14 02/10] iomap: Add big endian sparse annotations to mmio_{read|write}XXbe() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse produces a few warnings of the form: lib/iomap.c:84:9: warning: cast to restricted __be16 (The kbuild robot has recently started running such checks) The warning is not valid because the __raw_readX() and __raw_writeX() functions have an endianess determined by the semantics of whichever register they are operating on (which is intern dependant on the address passed to the function). In the iomap case, the register being operated on is known, semantically, to be Big Endian when an ioXXbe() function is used by the caller. These functions wrap a raw read or write function in an endianness conversion function. Sparse enforces that all values that aren't in CPU endianness be marked with types like __be16 and similar and said types cannot be mixed with other types. However, per above, the raw functions cannot be marked as such seeing the endianness is indeterminate. Thus, the output of __raw_readX() and the input of __raw_writeX() must be cast with the __force keyword to supress the invalid warning. Signed-off-by: Logan Gunthorpe Reviewed-by: Andy Shevchenko Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: Philippe Ombredanne Cc: Kate Stewart Cc: Luc Van Oostenryck --- lib/iomap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/iomap.c b/lib/iomap.c index be120c13d6cc..44645c4b516c 100644 --- a/lib/iomap.c +++ b/lib/iomap.c @@ -65,8 +65,8 @@ static void bad_io_access(unsigned long port, const char *access) #endif #ifndef mmio_read16be -#define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) -#define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) +#define mmio_read16be(addr) be16_to_cpu((__be16 __force)__raw_readw(addr)) +#define mmio_read32be(addr) be32_to_cpu((__be32 __force)__raw_readl(addr)) #endif unsigned int ioread8(void __iomem *addr) @@ -106,8 +106,8 @@ EXPORT_SYMBOL(ioread32be); #endif #ifndef mmio_write16be -#define mmio_write16be(val,port) __raw_writew(cpu_to_be16(val),port) -#define mmio_write32be(val,port) __raw_writel(cpu_to_be32(val),port) +#define mmio_write16be(val,port) __raw_writew((u16 __force)cpu_to_be16(val),port) +#define mmio_write32be(val,port) __raw_writel((u32 __force)cpu_to_be32(val),port) #endif void iowrite8(u8 val, void __iomem *addr) -- 2.11.0