Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47D84C4338F for ; Wed, 11 Aug 2021 14:03:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3475560551 for ; Wed, 11 Aug 2021 14:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3475560551 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B74482DD8; Wed, 11 Aug 2021 16:03:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1628690583; bh=JoHtQ0fiHAPFuOhlP2Jup1rEd6t6r9sRUXaLCqYoW0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OxC7nbtz6Xt/kfFulJxq/1FedriRpmeyzOxCM6+7YjFEL2S0fk0io1cy7XQ5gaRMq rkqKOFQ21qZYNfUPociVgvMexfBlbCAU1UzAt06IYwr7NdYzSAQkMqHuz0gSEcYrNj o1nV/h662erq6nUl23jB74+oq0W1t/LT4nQ+7RZGJNgwLtji6BOcgegCtCackMEBUz Z4Il+M8T/WGb0jcbDj2ogD+j3tZI6vWklhkdoNo1SqCIwvhx30pKwbQDkumQtBjj42 E1f/dNu2OoFtxaetnNgWoZjKQsmjzbMNIAUvn3Wy7hDgP0rz0k9P5H9/4pAt+N4cay r4AVegZGhcuOQ== Received: by phobos.denx.de (Postfix, from userid 109) id 3463F82D97; Wed, 11 Aug 2021 16:02:57 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1BBC682DCE for ; Wed, 11 Aug 2021 16:02:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4GlBNV5mZKzQk3R; Wed, 11 Aug 2021 16:02:50 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id TEZYy6dnipTh; Wed, 11 Aug 2021 16:02:43 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: trini@konsulko.com, Rasmus Villemoes , sjg@chromium.org, Wolfgang Denk Subject: [PATCH v3 2/3] arm64: memset-arm64: Use simple memset when cache is disabled Date: Wed, 11 Aug 2021 16:02:41 +0200 Message-Id: <20210811140242.1942483-3-sr@denx.de> In-Reply-To: <20210811140242.1942483-1-sr@denx.de> References: <20210811140242.1942483-1-sr@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 049D418CA X-Rspamd-UID: a87554 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The optimized memset uses the dc opcode, which causes problems when the cache is disabled. This patch adds a check if the cache is disabled and uses a very simple memset implementation in this case. Otherwise the optimized version is used. Signed-off-by: Stefan Roese --- (no changes since v2) Changes in v2: - New patch arch/arm/lib/memset-arm64.S | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/lib/memset-arm64.S b/arch/arm/lib/memset-arm64.S index 710f6f582cad..a474dcb53c83 100644 --- a/arch/arm/lib/memset-arm64.S +++ b/arch/arm/lib/memset-arm64.S @@ -11,6 +11,7 @@ * */ +#include #include "asmdefs.h" #define dstin x0 @@ -25,6 +26,35 @@ ENTRY (memset) PTR_ARG (0) SIZE_ARG (2) + /* + * The optimized memset uses the dc opcode, which causes problems + * when the cache is disabled. Let's check if the cache is disabled + * and use a very simple memset implementation in this case. Otherwise + * jump to the optimized version. + */ + switch_el x6, 3f, 2f, 1f +3: mrs x6, sctlr_el3 + b 0f +2: mrs x6, sctlr_el2 + b 0f +1: mrs x6, sctlr_el1 +0: + tst x6, #CR_C + bne 9f + + /* + * A very "simple" memset implementation without the use of the + * dc opcode. Can be run with caches disabled. + */ + mov x3, #0x0 +4: strb w1, [x0, x3] + add x3, x3, #0x1 + cmp x2, x3 + bne 4b + ret +9: + + /* Here the optimized memset version starts */ dup v0.16B, valw add dstend, dstin, count -- 2.32.0