From patchwork Tue Jan 29 10:49:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1032663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NL5E1pqu"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="C/vu+DhV"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjtp0qHKz9sNQ for ; Tue, 29 Jan 2019 21:49:53 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=hrb0bG64aroV0wAT1kiX8avKzfG2w7aizn+NcpiOuzA=; b=NL5E1pqujATrvYCKAxL86MIFge jSi4BKIKQHokRjqrBaR79yhowexVlqdMOjW0oL6cTr68f5NvL1SgakdoekCldD7iZD2aW5nksPkOX 1SJA1DrcHYowqxzUnPeYrFrfPQqf9V0Z++WLxNXSCuOh9vEB2BcPBUcpBAalqYfWUG2DTzA1KDQ4V n8owj9j1kyA7sk6oOAgYFUErB9jqws2Thde+eBkvoL9224+Wy+q6LX4B6/9yfrzu243OoIFAdHRL8 RaBz0dUjyZQACchXZZntPBZSlmqWNNTkuqzPv0vsBTiQQxxch0DIvDHqjsCt4uNmRptoE9GbRgBoU vUNtCabA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxj-0003Gh-Q5; Tue, 29 Jan 2019 10:49:51 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxh-0003FG-CR for linux-snps-arc@lists.infradead.org; Tue, 29 Jan 2019 10:49:50 +0000 Received: from mailhost.synopsys.com (unknown [10.12.135.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 53EEB24E1EDF; Tue, 29 Jan 2019 02:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548758988; bh=mouU16pCIcH5sqT/DTD5iHNFBk1TiYPGBPqoc02eNy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C/vu+DhVumFDwX7dn3D4JgIldudgdoVA0pWuFVb8c8Dwgj/73n9Zzs9Kb1cq9GBhO +/1mjzlLquBmWRPUlo/I7bgtwX42Oee0WjIy5JQgrpud+ohPMkkJWyyv4d4ANoF9Lw 9zBJCC6xBOmvwNfcghRdhpByLGxO+kvbFHXyo7X+J8/nAneRiFJqj7xkZCP2muf7ZR w5G7h0N09G41WZ+2JQTi7Oke0sE2F58gJXcqTaLsjvray2s44FG7IzU7gfE6wU9l/K g3pS0a0QL3EQaVc8R/TYcNx1CG9ctQQdfLzZIpB0XKMUVRsaJNDKHQfhZXuEZFCAd1 gITnijuVaYe/w== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.46]) by mailhost.synopsys.com (Postfix) with ESMTP id F1818A00AA; Tue, 29 Jan 2019 10:49:46 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 1/5] ARCv2: lib: memcpy: fix doing prefetchw outside of buffer Date: Tue, 29 Jan 2019 13:49:38 +0300 Message-Id: <20190129104942.31705-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> References: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_024949_422601_5D274F48 X-CRM114-Status: UNSURE ( 8.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org ARCv2 optimized memcpy uses PREFETCHW instruction for prefetching the next cache line but doesn't ensure that the line is not past the end of the buffer. PRETECHW changes the line ownership and marks it dirty, which can cause data corruption if this area is used for DMA IO. Fix the issue by avoiding the PREFETCHW. This leads to performance degradation but it is OK as we'll introduce new memcpy implementation optimized for unaligned memory access using. We also cut off all PREFETCH instructions at they are quite useless according to benchmark. Signed-off-by: Eugeniy Paltsev --- arch/arc/lib/memcpy-archs.S | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/arch/arc/lib/memcpy-archs.S b/arch/arc/lib/memcpy-archs.S index d61044dd8b58..ea14b0bf3116 100644 --- a/arch/arc/lib/memcpy-archs.S +++ b/arch/arc/lib/memcpy-archs.S @@ -25,15 +25,11 @@ #endif #ifdef CONFIG_ARC_HAS_LL64 -# define PREFETCH_READ(RX) prefetch [RX, 56] -# define PREFETCH_WRITE(RX) prefetchw [RX, 64] # define LOADX(DST,RX) ldd.ab DST, [RX, 8] # define STOREX(SRC,RX) std.ab SRC, [RX, 8] # define ZOLSHFT 5 # define ZOLAND 0x1F #else -# define PREFETCH_READ(RX) prefetch [RX, 28] -# define PREFETCH_WRITE(RX) prefetchw [RX, 32] # define LOADX(DST,RX) ld.ab DST, [RX, 4] # define STOREX(SRC,RX) st.ab SRC, [RX, 4] # define ZOLSHFT 4 @@ -41,8 +37,6 @@ #endif ENTRY_CFI(memcpy) - prefetch [r1] ; Prefetch the read location - prefetchw [r0] ; Prefetch the write location mov.f 0, r2 ;;; if size is zero jz.d [blink] @@ -72,8 +66,6 @@ ENTRY_CFI(memcpy) lpnz @.Lcopy32_64bytes ;; LOOP START LOADX (r6, r1) - PREFETCH_READ (r1) - PREFETCH_WRITE (r3) LOADX (r8, r1) LOADX (r10, r1) LOADX (r4, r1) @@ -117,9 +109,7 @@ ENTRY_CFI(memcpy) lpnz @.Lcopy8bytes_1 ;; LOOP START ld.ab r6, [r1, 4] - prefetch [r1, 28] ;Prefetch the next read location ld.ab r8, [r1,4] - prefetchw [r3, 32] ;Prefetch the next write location SHIFT_1 (r7, r6, 24) or r7, r7, r5 @@ -162,9 +152,7 @@ ENTRY_CFI(memcpy) lpnz @.Lcopy8bytes_2 ;; LOOP START ld.ab r6, [r1, 4] - prefetch [r1, 28] ;Prefetch the next read location ld.ab r8, [r1,4] - prefetchw [r3, 32] ;Prefetch the next write location SHIFT_1 (r7, r6, 16) or r7, r7, r5 @@ -204,9 +192,7 @@ ENTRY_CFI(memcpy) lpnz @.Lcopy8bytes_3 ;; LOOP START ld.ab r6, [r1, 4] - prefetch [r1, 28] ;Prefetch the next read location ld.ab r8, [r1,4] - prefetchw [r3, 32] ;Prefetch the next write location SHIFT_1 (r7, r6, 8) or r7, r7, r5 From patchwork Tue Jan 29 10:49:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1032664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aX57gYOJ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="RwZmxNY/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjtp6xK1z9sNf for ; Tue, 29 Jan 2019 21:49:54 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=Dmj98TjZlfTnOm6SFQwaA4L98O0yhxgjuBf3H7xccPs=; b=aX57gYOJP+gKQUvsDI2K7x95f0 E8vy1CilolAt57ul2J7o8pLJD8PMVNhc1bZJBAH5zf33NOSk4PELTePCkQ8prnlXBkF/zniM6SeJn vNKJUeBPiuLsWlU6cVevNT77gUYDLAFnVOS9944+lfoopuO4uiZReB9uVyW/5Oz/jJd7GilM69Wt9 HEJSMB6OSUw02hNx33nttRuEYBGQpJiNHo+xrQ3RJjpHK4lxqnNtu6Mzg2UvUVXZYZ7aAj5s7AoMs aXj6BXK4rdgqwP77TFkUkro1yrQkvVHJaYAoqy0hLHMX9rdV+cf6/Y3VPBF0dNLdeIeIMIeLSnaDs gnF5yecA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxk-0003H7-UW; Tue, 29 Jan 2019 10:49:52 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxi-0003Fi-3w for linux-snps-arc@lists.infradead.org; Tue, 29 Jan 2019 10:49:51 +0000 Received: from mailhost.synopsys.com (unknown [10.12.135.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 0108824E1042; Tue, 29 Jan 2019 02:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548758990; bh=J0HaC3Vqy5ZDjyU8yn6oPWQX/qvRtFmGvycx9pwDCLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RwZmxNY/G2HxhrrNmuCzPeRVwsiCzrg9jW/8lca8FuZNGucN+ZrU8geeutFVQiv0t Mp4vVVzl4Ns/7CI4yrimgaHHrXA+i0CiozIQmnzqHhzjUmMrtlh3F6VkrE2i9Os0NL phQ62RHYQRA9X9811G7KnE8otIujygQTv/oBGcGAvtSit+R/AvNJ51A+oodMhhrSbp txuGYrOGN78jqcT4ymAf2X8LirliwSFADqFjSI8xj56zMxjMss43TAw5TYFQYrOlrP e+Hjz2rnNKd6DCDDL/jc9QQgj5TsGpOEANQ6wWxBgMod26Uqi6vttjoWd/czl0/zp+ /5ImpMPfOzi6A== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.46]) by mailhost.synopsys.com (Postfix) with ESMTP id A08ECA0096; Tue, 29 Jan 2019 10:49:48 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 2/5] ARCv2: introduce unaligned access under a Kconfig option Date: Tue, 29 Jan 2019 13:49:39 +0300 Message-Id: <20190129104942.31705-3-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> References: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_024950_158765_FAD86038 X-CRM114-Status: GOOD ( 11.87 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org As of today we enable unaligned access unconditionally on ARCv2. Lets move it under Kconfig option so we can disable it in case of using HW configuration which lacks of it. Signed-off-by: Eugeniy Paltsev --- arch/arc/Kconfig | 8 ++++++++ arch/arc/include/asm/irqflags-arcv2.h | 4 ++++ arch/arc/kernel/intc-arcv2.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 376366a7db81..37c8aeefa3a5 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -387,6 +387,14 @@ config ARC_HAS_SWAPE if ISA_ARCV2 +config ARC_USE_UNALIGNED_MEM_ACCESS + bool "Handle unaligned access in HW and use it" + default y + help + The ARC HS architecture supports unaligned memory access + which is disabled by default. Enable unaligned access in + hardware and use it in software. + config ARC_HAS_LL64 bool "Insn: 64bit LDD/STD" help diff --git a/arch/arc/include/asm/irqflags-arcv2.h b/arch/arc/include/asm/irqflags-arcv2.h index 8a4f77ea3238..9b911e2c6b31 100644 --- a/arch/arc/include/asm/irqflags-arcv2.h +++ b/arch/arc/include/asm/irqflags-arcv2.h @@ -44,8 +44,12 @@ #define ARCV2_IRQ_DEF_PRIO 1 /* seed value for status register */ +#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \ (ARCV2_IRQ_DEF_PRIO << 1)) +#else +#define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | (ARCV2_IRQ_DEF_PRIO << 1)) +#endif /* CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS */ #ifndef __ASSEMBLY__ diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c index 067ea362fb3e..84b1c7157d1b 100644 --- a/arch/arc/kernel/intc-arcv2.c +++ b/arch/arc/kernel/intc-arcv2.c @@ -93,7 +93,9 @@ void arc_init_IRQ(void) /* setup status32, don't enable intr yet as kernel doesn't want */ tmp = read_aux_reg(ARC_REG_STATUS32); - tmp |= STATUS_AD_MASK | (ARCV2_IRQ_DEF_PRIO << 1); + if (IS_ENABLED(ARC_USE_UNALIGNED_MEM_ACCESS)) + tmp |= STATUS_AD_MASK; + tmp |= ARCV2_IRQ_DEF_PRIO << 1; tmp &= ~STATUS_IE_MASK; asm volatile("kflag %0 \n"::"r"(tmp)); } From patchwork Tue Jan 29 10:49:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1032665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fCoFCGyK"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="i5URn9Si"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjtt1rdPz9sNg for ; Tue, 29 Jan 2019 21:49:58 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=8KCMbcETiE3GHM4CfjOcy9+2Sm5zfFtmZAU1fyf5yWE=; b=fCoFCGyKeQiLqqaQES1g71BUne mVmB47/Og5Z52k60y1M4C36gRv5p7HLLAUws9Rn5npd0rgX3M3IeYrWdti1H5yvGx1TUpNJ6e0Ud0 N2gDsZoF1yZo7JSFt7q2j6h386bv2c5rzuplDcxZ61xjdTh7ZDGOdVX8DnT+GiDuQa2nrnKr5JyIJ d49Fj6NacehjyGhVO2JfDu5sqjLOcZqE1l0na0iX+ylf+92regKeW9TdNxeLPek114e01vmq67r+J v7htP71K0TdYWt1DR6pCmrtevQP/XGGYq22qB2/YipXCdkKxFZ7TKas1MdhAuaa9rEbA/5K6qyjrS Td/8sEQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxo-0003J7-3w; Tue, 29 Jan 2019 10:49:56 +0000 Received: from smtprelay.synopsys.com ([198.182.60.111]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxl-0003H6-4q for linux-snps-arc@lists.infradead.org; Tue, 29 Jan 2019 10:49:54 +0000 Received: from mailhost.synopsys.com (dc2-mailhost1.synopsys.com [10.12.135.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id A0B6710C11FC; Tue, 29 Jan 2019 02:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548758991; bh=WSJDjd3/oVJABGK0l9Hp5QCULSLXnEApOGjWPqPwE3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5URn9Si6qh2AeflkpgQwV4ml/MenOQJ+py/OzLqjhYeGlDOBmWRCo5/EgVoOkS9X 4y9JGN7g+TC7Lx2HfWy9a8VS+BIdazt0ya3dY3Nc2fxZWk1XnXvFga5I8SLZOeKGID NrjxWFrxMt4LJtXBv/a2M9SnZfTyFLUuYltmNHRmdtLph5F0X/LOaBGjkvWZ7yMtAc 7pDnCC05mwswuDCBLQLxIsZAVGbkAteWdJfGNCZG8ZNrSFlosVdFiVmPAwquQgjJ9d d8PYsGl0SP3b5OpGTILqO5zPbyFJPa4eFElrnYsPQqIej0LN+v/+vUV5po0x38fzin UZK1e1VmkaFug== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.46]) by mailhost.synopsys.com (Postfix) with ESMTP id 4D6C4A0070; Tue, 29 Jan 2019 10:49:50 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 3/5] ARCv2: Enable unaligned access in early ASM code Date: Tue, 29 Jan 2019 13:49:40 +0300 Message-Id: <20190129104942.31705-4-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> References: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_024953_311299_C199A8CA X-CRM114-Status: GOOD ( 12.88 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Even though we do enable AD bit in arc_init_IRQ() we need to do it in early ASM code otherwise we may face unaligned data until we reach arc_init_IRQ() because GCC starting from v8.1.0 actively generates unaligned data as it assumes that: * ARCv2 always has support of unaliged data * This support is turned on in runtime Signed-off-by: Eugeniy Paltsev --- arch/arc/kernel/head.S | 14 ++++++++++++++ arch/arc/kernel/intc-arcv2.c | 2 -- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S index 8b90d25a15cc..ffe3d384fca5 100644 --- a/arch/arc/kernel/head.S +++ b/arch/arc/kernel/head.S @@ -17,6 +17,9 @@ #include #include #include +#ifdef CONFIG_ISA_ARCV2 +#include +#endif .macro CPU_EARLY_SETUP @@ -47,6 +50,17 @@ sr r5, [ARC_REG_DC_CTRL] 1: + + ; Enable / disable HW handling of unaligned access in the CPU. +#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS + kflag STATUS_AD_MASK +#else + ; Handling of unaligned access is disabled by default but we disable it + ; manually in case of any bootloader enabled it earlier. + lr r5, [ARC_REG_STATUS32] + bclr r5, r5, STATUS_AD_BIT + kflag r5 +#endif .endm .section .init.text, "ax",@progbits diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c index 84b1c7157d1b..6359896da1ea 100644 --- a/arch/arc/kernel/intc-arcv2.c +++ b/arch/arc/kernel/intc-arcv2.c @@ -93,8 +93,6 @@ void arc_init_IRQ(void) /* setup status32, don't enable intr yet as kernel doesn't want */ tmp = read_aux_reg(ARC_REG_STATUS32); - if (IS_ENABLED(ARC_USE_UNALIGNED_MEM_ACCESS)) - tmp |= STATUS_AD_MASK; tmp |= ARCV2_IRQ_DEF_PRIO << 1; tmp &= ~STATUS_IE_MASK; asm volatile("kflag %0 \n"::"r"(tmp)); From patchwork Tue Jan 29 10:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1032666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F+X0YM93"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="T/EA5xPX"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjtt4scrz9sNk for ; Tue, 29 Jan 2019 21:49:58 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=lcklgIAywF/jluCKi2NgulCS4tH2TqpzuI2/ILVXX6o=; b=F+X0YM93uLofJ3Bv+zLsE280t2 ZPLK3V91jcpf4L9bpv/6+j9k1enfH18BHucBYXgs+LIaxnpmWdYe98zvNzvcioKdAt0Z4F9pLeN8x BOtvP11M9vvdPWNDWt6N4bYt/dp8sGobWD326a9uXpsQD+tMj7ELNfj732RT1HFuIQ7z/BuYQ7Sbz tT9P5kBFQyV/qwMRDnQFIf/UuVm6Hhx2CWoLS5tPc9gjLxPpDmuxE14FK2imcXYrHyaM1hZIYEGFK pNLH/MNCf/npyye+OOiXzwM2NHRxlqiLTZXYtFF2u+mvycHK8RNKk+djQaTAQij/ty/hboFyAdgNc /MgBaLmA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxo-0003JE-8J; Tue, 29 Jan 2019 10:49:56 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxl-0003Hh-EQ for linux-snps-arc@lists.infradead.org; Tue, 29 Jan 2019 10:49:54 +0000 Received: from mailhost.synopsys.com (dc2-mailhost1.synopsys.com [10.12.135.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 579BC10C1493; Tue, 29 Jan 2019 02:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548758993; bh=w64iJvGv0yzHjpm3aGnApbOj/XSVxiTqqDo3AeNSwII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/EA5xPXWwaU+ME9vhv1a5ub61AO5Ik+T1iC3ke3MCaK/81QfJloBzPP6pXr54thz k3WE5BZN8hbndPGLVXnqrT9hsdr9u7kgIW8QwjOb71v9GpCnCqaUJC4gHXcrz4Myp1 rwb09mp/p9JZry+7zocFAukVRLfD+15Datqe36cvSqCGbZi9TzSvSgETcUh8jhpBts Z1j8ZVTBwBSWTvcFuMMJyF9DYTfq7xV+32q1LHa41/0080mU9q0ZMmOhlrvXis4vWY 7gV/APWo/Si3cgC/M6B6fUQaUhjua8TSnPlk+RuTNoCVqEv5wrzGmvFOHVof0kkogO K49mJoK1nycTA== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.46]) by mailhost.synopsys.com (Postfix) with ESMTP id EE25EA0070; Tue, 29 Jan 2019 10:49:51 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 4/5] ARCv2: use unaligned access in SW Date: Tue, 29 Jan 2019 13:49:41 +0300 Message-Id: <20190129104942.31705-5-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> References: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_024953_513653_DB26AE34 X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Select HAVE_EFFICIENT_UNALIGNED_ACCESS and allow GCC to generate unaligned data if we enable enable unaligned access in HW. Signed-off-by: Eugeniy Paltsev --- arch/arc/Kconfig | 1 + arch/arc/Makefile | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 37c8aeefa3a5..a1d976c612a6 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -390,6 +390,7 @@ if ISA_ARCV2 config ARC_USE_UNALIGNED_MEM_ACCESS bool "Handle unaligned access in HW and use it" default y + select HAVE_EFFICIENT_UNALIGNED_ACCESS help The ARC HS architecture supports unaligned memory access which is disabled by default. Enable unaligned access in diff --git a/arch/arc/Makefile b/arch/arc/Makefile index df00578c279d..e2b991f75bc5 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -28,6 +28,12 @@ cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape ifdef CONFIG_ISA_ARCV2 +ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS +cflags-y += -munaligned-access +else +cflags-y += -mno-unaligned-access +endif + ifndef CONFIG_ARC_HAS_LL64 cflags-y += -mno-ll64 endif From patchwork Tue Jan 29 10:49:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1032667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YbJ+onht"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="VpxmEqZi"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pjtw3mBDz9sNg for ; Tue, 29 Jan 2019 21:50:00 +1100 (AEDT) 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:References: In-Reply-To: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:List-Owner; bh=7f820VzIZ87W56yj5C9mPnWTOz/SGPQB5kZtwbD9p/E=; b=YbJ+onhtqVQQyeuNifoTqdnPfv ONTww9y+UVQKDgO/K454v+bVHwflCifvHbyyhEMlD7QvWD6w4n9fBqWhUdz6NXa6tQTweuolatdiY 5xZ6BZw6ra9IyumfAePGW9DDfU2N8aE+GHTU6HFCIJOetlzMv4XPCHqpQ/P6PsGldceKmPwdWf/Qf 94DHkYnCL2buyVslbkcEJmdM6jyaLzYVB5sxH1fijElvQnUb4o0uBPmNjRed/gg0n6rOYCOdkRLe8 Pb1utWLY8vi+Y7ImJX65doKlrx1Nph+hQkNSp1DbhPRd1D4No9xiVwj57wqhc44LyxP8d+jqSwg0p Q3X3D/xw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxq-0003Ka-GT; Tue, 29 Jan 2019 10:49:58 +0000 Received: from smtprelay.synopsys.com ([198.182.47.9]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goQxn-0003Ik-2n for linux-snps-arc@lists.infradead.org; Tue, 29 Jan 2019 10:49:56 +0000 Received: from mailhost.synopsys.com (unknown [10.12.135.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 0403124E1718; Tue, 29 Jan 2019 02:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1548758995; bh=gp9/AEoNo/BmClLhSdVvfGrL9375u+uThQLB9UExYDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VpxmEqZiG+jUJPydx/0Aa+URcJ86T+f5XU3KsB3Y1dYOshVmjgco/dc3Di4yVTA+i 1PBhvRyqRdUUTmi3y0qaD1L1Ec5SC2dxRKFkRZpl9I/Xq4o2zjbXUcWqEpWJ/Ec0wU Px2qmYGiEcoa201W6UmvHY73N/XIXAzN3tAayRKu0yJPts3DaVEK8vzZXat6KGNtvr 8lGjvWCa1Kt0FwxoEIDBXjFaZY/4qK5TENzHDUAPrTwMtYcaIYA9jOQpJAuw0PxeuW L9zMdJh08VpNl9zy5rJShoKobpF+RucZvE7B1A4rnfYDR3WjWQFvP/I/u482yTOidn 7WU7e92h3OoJw== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.46]) by mailhost.synopsys.com (Postfix) with ESMTP id A473FA0070; Tue, 29 Jan 2019 10:49:53 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 5/5] ARCv2: LIB: MEMCPY: fixed and optimised routine Date: Tue, 29 Jan 2019 13:49:42 +0300 Message-Id: <20190129104942.31705-6-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> References: <20190129104942.31705-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_024955_127471_8EEB336E X-CRM114-Status: GOOD ( 14.35 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Optimise code to use efficient unaligned memory access which is available on ARCv2. This allows us to really simplify memcpy code and speed up the code one and a half times (in case of unaligned source or destination). Signed-off-by: Eugeniy Paltsev --- arch/arc/Kconfig | 4 +++ arch/arc/lib/Makefile | 5 +++- arch/arc/lib/memcpy-archs-unaligned.S | 46 +++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 arch/arc/lib/memcpy-archs-unaligned.S diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index a1d976c612a6..88f1a3205b8f 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -396,6 +396,10 @@ config ARC_USE_UNALIGNED_MEM_ACCESS which is disabled by default. Enable unaligned access in hardware and use it in software. +#dummy symbol for using in makefile +config ARC_NO_UNALIGNED_MEM_ACCESS + def_bool !ARC_USE_UNALIGNED_MEM_ACCESS + config ARC_HAS_LL64 bool "Insn: 64bit LDD/STD" help diff --git a/arch/arc/lib/Makefile b/arch/arc/lib/Makefile index b1656d156097..59cc8b61342e 100644 --- a/arch/arc/lib/Makefile +++ b/arch/arc/lib/Makefile @@ -8,4 +8,7 @@ lib-y := strchr-700.o strcpy-700.o strlen.o memcmp.o lib-$(CONFIG_ISA_ARCOMPACT) += memcpy-700.o memset.o strcmp.o -lib-$(CONFIG_ISA_ARCV2) += memcpy-archs.o memset-archs.o strcmp-archs.o +lib-$(CONFIG_ISA_ARCV2) += memset-archs.o strcmp-archs.o + +lib-$(CONFIG_ARC_NO_UNALIGNED_MEM_ACCESS) += memcpy-archs.o +lib-$(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS) += memcpy-archs-unaligned.o diff --git a/arch/arc/lib/memcpy-archs-unaligned.S b/arch/arc/lib/memcpy-archs-unaligned.S new file mode 100644 index 000000000000..e09b51d4de70 --- /dev/null +++ b/arch/arc/lib/memcpy-archs-unaligned.S @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +// +// ARCv2 memcpy implementation optimized for unaligned memory access using. +// +// Copyright (C) 2019 Synopsys +// Author: Eugeniy Paltsev + +#include + +#ifdef CONFIG_ARC_HAS_LL64 +# define LOADX(DST,RX) ldd.ab DST, [RX, 8] +# define STOREX(SRC,RX) std.ab SRC, [RX, 8] +# define ZOLSHFT 5 +# define ZOLAND 0x1F +#else +# define LOADX(DST,RX) ld.ab DST, [RX, 4] +# define STOREX(SRC,RX) st.ab SRC, [RX, 4] +# define ZOLSHFT 4 +# define ZOLAND 0xF +#endif + +ENTRY_CFI(memcpy) + mov r3, r0 ; don;t clobber ret val + + lsr.f lp_count, r2, ZOLSHFT + lpnz @.Lcopy32_64bytes + ;; LOOP START + LOADX (r6, r1) + LOADX (r8, r1) + LOADX (r10, r1) + LOADX (r4, r1) + STOREX (r6, r3) + STOREX (r8, r3) + STOREX (r10, r3) + STOREX (r4, r3) +.Lcopy32_64bytes: + + and.f lp_count, r2, ZOLAND ;Last remaining 31 bytes + lpnz @.Lcopyremainingbytes + ;; LOOP START + ldb.ab r5, [r1, 1] + stb.ab r5, [r3, 1] +.Lcopyremainingbytes: + + j [blink] +END_CFI(memcpy)