From patchwork Fri Apr 4 13:50:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 878200 Delivered-To: patch@linaro.org Received: by 2002:a5d:6dae:0:b0:38f:210b:807b with SMTP id u14csp3793638wrs; Fri, 4 Apr 2025 06:51:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzO+Y4JPp08a33pzb/dkxIDGrzyzgKnpgFmtp7MF169GHM+pAw/0jZ7jyCgH51qgecSv5mkA==@linaro.org X-Google-Smtp-Source: AGHT+IGYSe1mtvInMoc4ak2Ty7c1H/009zil5M0vhfoVxRER0pKsPgiPxtUyGTU19BcHJiiewzMG X-Received: by 2002:a05:6102:3f42:b0:4c1:9328:107d with SMTP id ada2fe7eead31-4c856a8bbeamr2070902137.24.1743774673743; Fri, 04 Apr 2025 06:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1743774673; cv=none; d=google.com; s=arc-20240605; b=lWZiMOkGuovER0bqvlJvEt41zHatk71XEavYDvPk7YDXHknkZxsOBrt742W3+KkETB 8ohBV7OlR04bN5Z6L/qg5wy1n2+SFb8Ov8Hs2t9IByd/Kd4lfo9YsR3BhzAgQeTlUwtt ovkqkwDNGYZwXOfex/ZUHC3uIPpM3A26y+vlQ8v5Fr1kXw8H4fKFR0WvfzX2DjQC1RkZ L+4O+325fC294UpDTRZGgdyYUvKZ347gygSiteo4a4VXAvtgdZuQLTs9k4Ki4NEeIyuz iF5xbJQjHiYhK7xCzDoUhXfNUjugCaz+d4ms5TGgJUZaVAZs0BNRAg/TLnGgZindw2WL IZdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qi9by1MKh50q+7xZ6MMgeVvB3qppj0ZCwaLDnpWjMIk=; fh=WL6YvzUlN9JCc7YE1jg9wWIjV4NJ0RoausLPOPPiJjU=; b=ltrxcGCAo32T/KQ2BvVvqu7hqeDKy9lE3S7vQo/rJz0O8AcBNMOpK45pPF3ak8DRDi YvaokhQ0wH3TIefIouSrLIwB/3CGKxg25gLETavXMzXHafA9LC0ULJMqu0DflbfDNMru V5co7NHVEm6bvgGtvsJKwL9Fwvk41RYfm+hspcI9XGko/hkOJU065438dV/S/5kLTxb+ 9PvJhdosy4TWU29rWUeeP1MKdxCgkUrviFLlHxLZddN0i8XXu4p60dqnMPfEo0eWedlg Y08StacM3OYJYwfVorvVUONyKKxSjmBnVPBfwn7s3pSyymV4X2JIo8MvhyFdgU3oo8u0 9Sjg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dI5uZKCg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ada2fe7eead31-4c848fc911bsi1186160137.435.2025.04.04.06.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Apr 2025 06:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dI5uZKCg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5BAC829A0; Fri, 4 Apr 2025 15:51:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dI5uZKCg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 191D6829C7; Fri, 4 Apr 2025 15:50:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F278B829B8 for ; Fri, 4 Apr 2025 15:50:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43948021a45so19506045e9.1 for ; Fri, 04 Apr 2025 06:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743774656; x=1744379456; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qi9by1MKh50q+7xZ6MMgeVvB3qppj0ZCwaLDnpWjMIk=; b=dI5uZKCgXit0WQpvYpcqgwvQjB+IgCfBKAquNqDD21wnzW9By26vR8+825ZF/U5O7l q8+/qc8wnHJWJgG5RRTQfd11nNrazH6+ZmZVorEdYeh1cDeVHbz5YD/F74hbV8cTvVxI u9CnpFqaBmZ7+kTXwGRs5YaOmTK2hnJB/1eNuCJmvG0vDHNv21v7sjAQvDghYyXutOcj dXLSfF+FW2vRzV04hc/jIoXy4AZEnp0FFa1TFhrqoAmTk8d99NJuftBP/ZIKnT5sX2KJ r+pQ8MeL6g159sByGb9x/JjB8DeF+/UdoLziyRNk/PCx84wKbUNTuXjubxSF0aHbpbEw tmtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743774656; x=1744379456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qi9by1MKh50q+7xZ6MMgeVvB3qppj0ZCwaLDnpWjMIk=; b=B7auBIrcPVtjjAYmtoINr+2SRZYWBY4gq+57KjZI3urbF0o8TdqpmVOKz2BtkqdS4F /th0GpGxBmaKkf1TcVgE+xxUwNSxqUWvwfocMyo0Ev0Rq93zKAXq1qYXrOW5/KKqzdOF WQaWnUtTdG/zAYvUdlUG3RG+01cQTcH4FoSnl5OUtGO8SkbRFCUwon/P9rI7IjQsKSI/ VCLeg+wQhh26UkHbqEYFyLVAgmhdzmwQEY+L7EppSLdKDJ5OKhqZHPt+TotKcVYbICbU 55GDAXU/D5yVkmHHiAGHaK6AW/zcHm22+Vue8pi1YYlbLKUGj4bsRHvKUcqKZ6p1y+d5 P46Q== X-Gm-Message-State: AOJu0YwVljJZxM7oMixZVrBFpalA/HsAhMem8WtW3iccstPEdFTyUyaH jnqsqsmaN6eIQoRcmcixlNFO+e7kAkJa8XWFrHV0za4O1EEbdRMCaF1XxK66roUhp5SDDX39Inx wFWRBSw== X-Gm-Gg: ASbGncvv6yCd4G+/HzuEgFkKc5g9HR3VBxPFmTwByU7sepAdHCB/WjSXUyQNy++Jjoq 7ECtcjKgyDaTSgGV4TAM90vlp0YxPvXReAbh1LSlnJzrwmEOp8U/sSOBMnirZicrLx9zhh6Go3E mMsqBPnZLDHyzvVZtlbPeK968hF3b4339sa2xoYIhcTqf1alqRIheDLuQFKG3847Pf51klCqOie NSSPpsVy+5qKLbk3j9HUBHYML7t6gWO1/XmhGmISGf6JOSyQyK+jb6Hx5mHw1LF0zXAnq950obZ 5B6JZ5osAm8chXCA2DJyL8yzOfpKkPPJZdnWyBjToDdRzcvJ5FaOMA== X-Received: by 2002:a05:600c:500a:b0:43b:ce3c:19d0 with SMTP id 5b1f17b1804b1-43ed0da06f1mr25982425e9.29.1743774656234; Fri, 04 Apr 2025 06:50:56 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:70d5:66af:ee2d:db3a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c301a7064sm4531821f8f.34.2025.04.04.06.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Apr 2025 06:50:55 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Jerome Forissier , Tom Rini , Stefan Roese , Andre Przywara , Peter Hoyes , Sam Protsenko , Simon Glass , Patrick Rudolph , Marek Vasut , Caleb Connolly Subject: [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set Date: Fri, 4 Apr 2025 15:50:35 +0200 Message-ID: <20250404135038.2134570-2-jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250404135038.2134570-1-jerome.forissier@linaro.org> References: <20250404135038.2134570-1-jerome.forissier@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean The mcr and msr instructions are available in Thumb mode only if Thumb2 is supported. Therefore, if __thumb2__ is not set, make sure we switch to ARM mode by inserting a .arm directive in the inline assembly. Fixes LTO link errors with kirkwood platforms, triggered by a later commit: tools/buildman/buildman -o /tmp/build -eP sheevaplug [...] {standard input}:24085: Error: selected processor does not support `mrc p15,0,r3,c1,c0,0' in Thumb mode Signed-off-by: Jerome Forissier --- arch/arm/include/asm/system.h | 22 +++++++++++++++++----- arch/arm/lib/cache.c | 5 +++-- arch/arm/mach-kirkwood/include/mach/cpu.h | 9 +++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index 849b3d0efb7..4c1b81483c9 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -428,11 +428,21 @@ void switch_to_hypervisor_ret(void); #define wfi() #endif +#if !defined(__thumb2__) +/* + * We will need to switch to ARM mode (.arm) for some instructions such as + * mrc p15 etc. + */ +#define asm_arm_or_thumb2(insn) asm volatile(".arm\n\t" insn) +#else +#define asm_arm_or_thumb2(insn) asm volatile(insn) +#endif + static inline unsigned long read_mpidr(void) { unsigned long val; - asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r" (val)); + asm_arm_or_thumb2("mrc p15, 0, %0, c0, c0, 5" : "=r" (val)); return val; } @@ -461,11 +471,13 @@ static inline unsigned int get_cr(void) unsigned int val; if (is_hyp()) - asm volatile("mrc p15, 4, %0, c1, c0, 0 @ get CR" : "=r" (val) + asm_arm_or_thumb2("mrc p15, 4, %0, c1, c0, 0 @ get CR" + : "=r" (val) : : "cc"); else - asm volatile("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) + asm_arm_or_thumb2("mrc p15, 0, %0, c1, c0, 0 @ get CR" + : "=r" (val) : : "cc"); return val; @@ -474,11 +486,11 @@ static inline unsigned int get_cr(void) static inline void set_cr(unsigned int val) { if (is_hyp()) - asm volatile("mcr p15, 4, %0, c1, c0, 0 @ set CR" : + asm_arm_or_thumb2("mcr p15, 4, %0, c1, c0, 0 @ set CR" : : "r" (val) : "cc"); else - asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR" : + asm_arm_or_thumb2("mcr p15, 0, %0, c1, c0, 0 @ set CR" : : "r" (val) : "cc"); isb(); diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index dd19bd3e4fb..ed6f15cb570 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -10,6 +10,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -126,8 +127,8 @@ void invalidate_l2_cache(void) { unsigned int val = 0; - asm volatile("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache" - : : "r" (val) : "cc"); + asm_arm_or_thumb2("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache" + : : "r" (val) : "cc"); isb(); } #endif diff --git a/arch/arm/mach-kirkwood/include/mach/cpu.h b/arch/arm/mach-kirkwood/include/mach/cpu.h index 9eec786fe8f..dce190ddee2 100644 --- a/arch/arm/mach-kirkwood/include/mach/cpu.h +++ b/arch/arm/mach-kirkwood/include/mach/cpu.h @@ -85,8 +85,9 @@ struct mbus_win { static inline unsigned int readfr_extra_feature_reg(void) { unsigned int val; - asm volatile ("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r" - (val)::"cc"); + + asm_arm_or_thumb2("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r" + (val)::"cc"); return val; } @@ -96,8 +97,8 @@ static inline unsigned int readfr_extra_feature_reg(void) */ static inline void writefr_extra_feature_reg(unsigned int val) { - asm volatile ("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r" - (val):"cc"); + asm_arm_or_thumb2("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r" + (val):"cc"); isb(); }