From patchwork Fri Dec 16 23:17:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9478663 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 C81EC607EE for ; Fri, 16 Dec 2016 23:19:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9952285DC for ; Fri, 16 Dec 2016 23:19:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE5EE28658; Fri, 16 Dec 2016 23:19:37 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67A47285DC for ; Fri, 16 Dec 2016 23:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762294AbcLPXSX (ORCPT ); Fri, 16 Dec 2016 18:18:23 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35353 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761773AbcLPXSK (ORCPT ); Fri, 16 Dec 2016 18:18:10 -0500 Received: by mail-pg0-f68.google.com with SMTP id p66so11046357pga.2; Fri, 16 Dec 2016 15:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=9/Zdd+GjhHOwYTU2fjiWZdiqyds7xQxNT3222LOJpfQ=; b=Qiqu4MHqdLOYKRUd0FIiabmPSgegXSn+7IsZis0PFtXTohMsboYBMAljtxIiRvRL9Z UDI16/gOTYOcXcylJmWyzdu+fYDoZiBO5h9czLEciNQfyILtm7VLRKl0m1vKiFTUybtD +cqJKqlW55iX0Eg3/AHZCK298nlE2+oE4sv3LzeW/R9FKHsXrFzMh7xBinm0OaLmnHOV jgjRIjpYBDM2INcawdno+RQ/5McRleXSPI8DgDrLBzU0qfBUxriuvx7D2HfN2kkSrl0y PT5dNz1jqNpBzsuDY5b6HN93hE2gulYJw+bgdofvWoFbGBVinPArXEXy8H4OU4MkGvSn jF9A== 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:in-reply-to :references:in-reply-to:references; bh=9/Zdd+GjhHOwYTU2fjiWZdiqyds7xQxNT3222LOJpfQ=; b=gUw0voraMiprydpfVKCTDwrwDvVV3aY2lWLjc1paQd1FXVr+VfXmy6OXO1nd/A7vqv g9wL289QvU2x8UaHmuzeUqyuTPI+lE7zQ/rWhwv0ClY3X7zehhcZYwRpkF547GWEbcyM yUWLWwyaseeh6cvqIrkFiqZ4svS+cmc91ZE4m2oTejXFxzwiEcvGdd+p4VjXd5/9xvhO tdjgaiYR4FQtjr58KRzqKln5x/sQWzrll4MKwRK5LE2qeCc8yrkNbtnMQCR1yJ5x/j4X pq2Sd0eJf+TtYd/GtTME7QVlcqgTdnP5fr1DvHcwHP0fx5tdK7UKPP0jH5MjpLzW77hK oNNw== X-Gm-Message-State: AKaTC03prg+OQ69Izgz2rOREsinytMPyTTbC3zzNH8MLGbxmJONwqULMNTNolrHPJ36QaA== X-Received: by 10.98.41.3 with SMTP id p3mr5539380pfp.22.1481930287863; Fri, 16 Dec 2016 15:18:07 -0800 (PST) Received: from jclayton-pc.columbia.uniwest.com (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by smtp.gmail.com with ESMTPSA id e11sm14280165pgp.10.2016.12.16.15.18.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 15:18:06 -0800 (PST) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Russell King , Catalin Marinas , Will Deacon , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Mark Rutland , Rob Herring , Anatolij Gustschin , Joshua Clayton , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fpga@vger.kernel.org Subject: [PATCH v6 2/5] lib: implement __arch_bitrev8x4() Date: Fri, 16 Dec 2016 15:17:51 -0800 Message-Id: <6c1c052d3c1d0c02a791aaaf8e114360ab1cb4e7.1481918884.git.stillcompiling@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement faster bitrev8x4() for arm, arm64 and mips, all the platforms with CONFIG_HAVE_ARCH_BITREVERSE. ARM platforms just need a byteswap added to the existing __arch_bitrev32() Amusingly, the mips implementation is exactly the opposite, requiring removal of the byteswap from its __arch_bitrev32() Signed-off-by: Joshua Clayton --- arch/arm/include/asm/bitrev.h | 6 ++++++ arch/arm64/include/asm/bitrev.h | 6 ++++++ arch/mips/include/asm/bitrev.h | 6 ++++++ include/linux/bitrev.h | 1 + 4 files changed, 19 insertions(+) diff --git a/arch/arm/include/asm/bitrev.h b/arch/arm/include/asm/bitrev.h index ec291c3..9482f78 100644 --- a/arch/arm/include/asm/bitrev.h +++ b/arch/arm/include/asm/bitrev.h @@ -17,4 +17,10 @@ static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) return __arch_bitrev32((u32)x) >> 24; } +static __always_inline __attribute_const__ u32 __arch_bitrev8x4(u32 x) +{ + __asm__ ("rbit %0, %1; rev %0, %0" : "=r" (x) : "r" (x)); + return x; +} + #endif diff --git a/arch/arm64/include/asm/bitrev.h b/arch/arm64/include/asm/bitrev.h index a5a0c36..1801078 100644 --- a/arch/arm64/include/asm/bitrev.h +++ b/arch/arm64/include/asm/bitrev.h @@ -16,4 +16,10 @@ static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) return __arch_bitrev32((u32)x) >> 24; } +static __always_inline __attribute_const__ u32 __arch_bitrev8x4(u32 x) +{ + __asm__ ("rbit %0, %1; rev %0, %0" : "=r" (x) : "r" (x)); + return x; +} + #endif diff --git a/arch/mips/include/asm/bitrev.h b/arch/mips/include/asm/bitrev.h index bc739a4..9ac6439 100644 --- a/arch/mips/include/asm/bitrev.h +++ b/arch/mips/include/asm/bitrev.h @@ -27,4 +27,10 @@ static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) return ret; } +static __always_inline __attribute_const__ u32 __arch_bitrev8x4(u32 x) +{ + u32 ret; + asm("bitswap %0, %1" : "=r"(ret) : "r"(x)); + return ret; +} #endif /* __MIPS_ASM_BITREV_H__ */ diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h index 868dcb6..b1cfa1a 100644 --- a/include/linux/bitrev.h +++ b/include/linux/bitrev.h @@ -9,6 +9,7 @@ #define __bitrev32 __arch_bitrev32 #define __bitrev16 __arch_bitrev16 #define __bitrev8 __arch_bitrev8 +#define __bitrev8x4 __arch_bitrev8x4 #else extern u8 const byte_rev_table[256];