From patchwork Wed Jun 28 14:58:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9814555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76082603F2 for ; Wed, 28 Jun 2017 15:10:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68758285C8 for ; Wed, 28 Jun 2017 15:10:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CF11285E3; Wed, 28 Jun 2017 15:10:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D918B285C8 for ; Wed, 28 Jun 2017 15:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Kg4+leUeqJVAooEvbk327nQMNjtGVQlFNCfrUe4wzWg=; b=V8Y LWIDzb/niRuMWS/4+cKRIq8t/Z+CuBEoAhen8gcKOonvrTdjMCinwt7fJwvBGbIRUmWWojQsbpOj/ eEVuxkzetPoMr48mYB43FzRSnxR5r4Mg+Y1Z1f0r3FkPQwauxItHUAdbyVpalvUxznYnpbQUPTsO9 87pDC/yf6taVqpws/q0cS2Dsi7ZECjBLsYgy60ukwWalcyPQKLbZsM4aLc0zm42nq85zvOVYqDmZ8 7XlcKoDD/EojFALEM6CKI2+GdW3ZSQxixKojP3BzHDPkk09S+AxrjP8ThqcC/JXZW1C6GrTF0KZ8v zVXEwKBC3QcFJKeKbswFJDHCoqEoSzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQEc0-0000AR-GO; Wed, 28 Jun 2017 15:10:36 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQEQM-0004tD-3P for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 14:58:37 +0000 Received: by mail-wm0-x241.google.com with SMTP id p204so7191661wmg.1 for ; Wed, 28 Jun 2017 07:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+/mfarE9Bz/nCnjbz/PtprdBEnrhIeVcz3sYnwt1IrI=; b=qn5KpTK+D2wfDIBj5AYeuiV2lQF84+Qq2RcjTBP/kgZQuAJcqSjdkf0W8SMQD+xCgh OyVIdVBWfUcvdiZhciEXyMWzcLUAKhkFjz8wR/Z168ltfZ2PxMGEVlLXfCzk3BJcgjft L2fFlbC6D4GE9RKiJIIGroByMj63h17m3SsP3bgTnes472HRbJSpiUGdJJNIKF6paUZo q0zgiBR67LJdtdWctlzSED9YP9Km8+ivqgroGVoBcRuuyvDxVthvJeGXVn13kJi9S80t saZ3InrsrfRcAHHhsCB5mbu5DfYONnM2icEfHU6XNoG5NL8k/vVc3iCIOfUOvE3R1Gc7 StEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+/mfarE9Bz/nCnjbz/PtprdBEnrhIeVcz3sYnwt1IrI=; b=k/ZokgC8wHhAAekIP2Vj/dsZj7JjoJ1HwGM+kmQTBqcVaJSz1ChvTHOEZhzWTlPaYF +ow/Ocw34mpGViDCt4X5SdOSX/9Cz1LAQfKQOh+ugR51oBADgsElr6YSRSYm8gfJwNMF Zvjgt0bTNPWNpHUmqDGXFZwHyQBtN4lsGdEkkCJkRw+86eQvr8/Im6GVov5D1Jk4WjsD n4zu0xt6aKC/4uEfuHOMq6kaXb2e3Mwncrf7brWJJWleJBz6r9qqfvlUe0Q3O6dBezxb W+B3LdFLDO0ZNY37Gs3CidAVG3IZvuAwROFHYj0Nd+T6pyneaO4DQzrDw9tovU6YnIGL 4eyw== X-Gm-Message-State: AKS2vOy1iHiAyq3CZh9wS51mZto1Ufu2TDl73ZuFgSZZXI2BU4kEPpCz TqzL1hPEVL8pCA== X-Received: by 10.80.160.231 with SMTP id 94mr7996658edo.173.1498661895939; Wed, 28 Jun 2017 07:58:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:837:f300:dc41:f6b3:4608:d7c8]) by smtp.gmail.com with ESMTPSA id f2sm1714720edf.30.2017.06.28.07.58.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:58:15 -0700 (PDT) From: Luc Van Oostenryck To: Will Deacon Subject: [PATCH] arm64: add missing conversion to __wsum in ip_fast_csum() Date: Wed, 28 Jun 2017 16:58:14 +0200 Message-Id: <20170628145814.24763-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_075835_243443_19E814B2 X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Luc Van Oostenryck , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ARM64 implementation of ip_fast_csum() do most of the work in 128 or 64 bit and call csum_fold() to finalize. csum_fold() itself take a __wsum argument, to insure that this value is always a 32bit native-order value. Fix this by using an helper __csum_fold() taking the native 32 bit value and doing the needed folding to 16 bit (and reuse this helper for csum_fold() itself). Note: a simpler patch would to use something like: return csum_fold((__wsum __force)(sum >> 32)); but using an helper __csum_fold() allow to avoid a forced cast. Signed-off-by: Luc Van Oostenryck --- arch/arm64/include/asm/checksum.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/checksum.h b/arch/arm64/include/asm/checksum.h index 09f65339d..dcc655137 100644 --- a/arch/arm64/include/asm/checksum.h +++ b/arch/arm64/include/asm/checksum.h @@ -18,12 +18,16 @@ #include -static inline __sum16 csum_fold(__wsum csum) +static inline __sum16 __csum_fold(u32 sum) { - u32 sum = (__force u32)csum; sum += (sum >> 16) | (sum << 16); return ~(__force __sum16)(sum >> 16); } + +static inline __sum16 csum_fold(__wsum csum) +{ + return __csum_fold((__force u32)csum); +} #define csum_fold csum_fold static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) @@ -42,7 +46,7 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) } while (--ihl); sum += ((sum >> 32) | (sum << 32)); - return csum_fold(sum >> 32); + return __csum_fold(sum >> 32); } #define ip_fast_csum ip_fast_csum