Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp175282pxp; Wed, 9 Mar 2022 00:03:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJySAC4eg6fbYkSXT7KHZ88rcUtkbwuU9be4FfI/JunlSxuBATrXh1pId3iadiVP4Y+HG8jT X-Received: by 2002:aa7:d5d9:0:b0:416:1dd3:7714 with SMTP id d25-20020aa7d5d9000000b004161dd37714mr19586177eds.256.1646813022572; Wed, 09 Mar 2022 00:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646813022; cv=none; d=google.com; s=arc-20160816; b=d3v+j8iEBxZ9RQsC3jQJ3v9C7qAvXMfouJoY0yd1c/8bx9KhxoizGeKPHxF6ZOhdCu OCBbPSlAPJVRtqNTVF+qnjFejIdEDP8itO0HWHWX1TgEXLht3Hw609uEuHVxZoxncR+r U41mt+DEkn2UlXNpR4S+xmIYjxsjxiQ0yK72dto+i4gwzWMH/joXpkQDAwsSDkkikqeP 0+eV/8IhyVHfTRo4kbPToTLRxpliOHlLddbn+ZsvOM4O2StMXJDYtHgZFfG39DqsSO1N ZJMPYFwoigB0m/alN/N7ROjakEn0jalIcBWNcSyDDwvGGk8lWiJVlItR9qWhACzqTrc5 MPug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hZeVVDP+BrYMPQbeMkd4bGILUynTsqM/HYaRj9FTlw4=; b=Vu2OC+16JC+AsyDT3MAUij3+RboqLeoieAqDZMz5YzJilJMhzCn6isD3VZ4g2yzimb ssJpa+WqP8El3OtuHqAS3ZK+IMwalLo92HVNewU+TfymBIc32NhDp7y6YLQnVR0XgQjO i6dhQxenSy3ZniC6aP0ZEr34cPRtKZMhFNYpgRidjO1e6NQT665X4sCSLHUCN7UEA1XN 2o00aYhCpVn7iS8TkUhv1FMe27f5pPSP7a09pY5hhaqzlv0tJwPzTdBvQX9CSO//gniM BGueid3wi4aQTLiC3ko1pVPG5H54k+Zwks9jJExaTQ8OSSYZuB1zSQ0fBkcxDMzYsIqq fRSA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq17-20020a170906abd100b006db71f1fc19si272684ejb.829.2022.03.09.00.03.15; Wed, 09 Mar 2022 00:03:42 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbiCIH7v (ORCPT + 99 others); Wed, 9 Mar 2022 02:59:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbiCIH6D (ORCPT ); Wed, 9 Mar 2022 02:58:03 -0500 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4F2166E0E for ; Tue, 8 Mar 2022 23:56:33 -0800 (PST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4KD4Jv4lzXz9sSV; Wed, 9 Mar 2022 08:56:31 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qLx4faVm02P8; Wed, 9 Mar 2022 08:56:31 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4KD4Jv40v5z9sSR; Wed, 9 Mar 2022 08:56:31 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 76C848B77D; Wed, 9 Mar 2022 08:56:31 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id WlMku7kl4AUb; Wed, 9 Mar 2022 08:56:31 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.202.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2A0278B763; Wed, 9 Mar 2022 08:56:31 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 2297uI323593930 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 9 Mar 2022 08:56:18 +0100 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 2297uGok3593929; Wed, 9 Mar 2022 08:56:16 +0100 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc: Use rol32() instead of opencoding in csum_fold() Date: Wed, 9 Mar 2022 08:56:14 +0100 Message-Id: <794337eff7bb803d2c4e67d9eee635390c4c48fe.1646812553.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1646812573; l=1384; s=20211009; h=from:subject:message-id; bh=KDkVF9PqMt4cDBy6twCvMX/grto3ncphU+ZUsJSR6IA=; b=RHvXwbEHlO+1j8HBQrsBzcN7RyHmiKhQDWO+jKCyUQ/MU9Oq0s9c9mzE5EhM8Q2UNfaAumg9TIt1 ZkNP1gIcC713W+IjC+xio7Ol4Twoiz712ZOMJiiCO3/N1T8fa48g X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 rol32(x, 16) will do the rotate using rlwinm. No need to open code using inline assembly. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/checksum.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h index 8321f6053a67..4b573a3b7e17 100644 --- a/arch/powerpc/include/asm/checksum.h +++ b/arch/powerpc/include/asm/checksum.h @@ -38,14 +38,15 @@ extern __wsum csum_and_copy_to_user(const void *src, void __user *dst, */ static inline __sum16 csum_fold(__wsum sum) { - unsigned int tmp; - - /* swap the two 16-bit halves of sum */ - __asm__("rlwinm %0,%1,16,0,31" : "=r" (tmp) : "r" (sum)); - /* if there is a carry from adding the two 16-bit halves, - it will carry from the lower half into the upper half, - giving us the correct sum in the upper half. */ - return (__force __sum16)(~((__force u32)sum + tmp) >> 16); + u32 tmp = (__force u32)sum; + + /* + * swap the two 16-bit halves of sum + * if there is a carry from adding the two 16-bit halves, + * it will carry from the lower half into the upper half, + * giving us the correct sum in the upper half. + */ + return (__force __sum16)(~(tmp + rol32(tmp, 16)) >> 16); } static inline u32 from64to32(u64 x) -- 2.34.1