Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp246415lqb; Tue, 4 Jun 2024 10:05:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnOXsaUm2KKu24g0zbhld3HPzx/rOUGuxQ3A7CIZ4dhwpJJuttU3ODH5OW+meY9ViukyF9cxcCp2sI2QMjuJNWdj9n46UVmmDmO4TlQQ== X-Google-Smtp-Source: AGHT+IFHgWxsEV+eLoniKW2j71kW7D9+zLbJBgXYonvsKmWHfGv9fq/NTvQdOcguVOEQml2uSXzd X-Received: by 2002:a17:906:2852:b0:a68:baaa:b290 with SMTP id a640c23a62f3a-a699f6819ebmr9731866b.37.1717520710173; Tue, 04 Jun 2024 10:05:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717520710; cv=pass; d=google.com; s=arc-20160816; b=cjbzggC+UWz+WuzYEmKQ3Z/atK63zIMJCqJgm4eIDcdfGaQKjYXPEjwU4yHDrweAz6 sxDmPqYLnPsgFxTOA1ZTUVxOVKThL6aQuUwAd7QtNY9mext1MUiJZLdS7lCeN3b8N/GA jBZeX1ubJMuNy6GTgtJW8/IUgyWvlQ89skHL3OKkMO2axkTbm1jItW/9a+hKFJ/l9tvI XqfuCgYpHpH/zsP3vCer1MQq+Tkl3m88R7M2XKS+JYXmbEYbqE2YLr/l5kEMqrh8u+pX qmQzijL/lYsTkm7AvO4BVy8lT6tY4JciWkN08/e8vG3Qh2HrJd1dZDqpQKcvCBLA2RwC jTew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Mr3Sk7ozU6pG7vgvOVhl1Mssr5YnosBC1FdAyg8J308=; fh=7KGSApx0JZtJG4YsxxGAIiDkkJI8YZN13t5+Caz67Nc=; b=adr0m0ET9RNqwIPQE2SDznDyqmmRWdFfIa4v2C+7w/UgP6pCcePweEdZm5IM0Fwe6v r46sytf33nFzP3dentAIIBp+AhP8J5wkgbLW5FicP8ClH6acxtjbDtWAAPBwqoKYXIO1 c4w+5zDcKukGDdojznEUQOcjes/eZIrY4zF/nN+XoSchpOKVeUsBhtGafo3E1cRstbfG PDUTaTiulaRXF/5Na2w5OY4C8Rku6SSH63cP+1JpjIIwju4Yb78evzOQOsVy7eS9JLl5 NOSfBSBWU6Y20Ml3k87jBr7biW2D58pqAOsluDU4vODEllFZWvvobjr9YxhhrTklLOMW saQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VdcZuACD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a68a487a099si387378666b.527.2024.06.04.10.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 10:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VdcZuACD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DD22A1F23694 for ; Tue, 4 Jun 2024 17:05:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF01414A090; Tue, 4 Jun 2024 17:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VdcZuACD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF4F3149C65; Tue, 4 Jun 2024 17:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717520681; cv=none; b=HKcfgItt/pYiOu2OvgWzmr8lETuFX6zBDop+CEgg9dvJ3nGt+KSUxaqNaeBS0LV9QHEVA/pCg4XAa1w1/iU2OST9TyUn8yxXaR/OfHROOmXzb8JBHAZC4OnpedzKTH1zUBSfl2SzQdrsh4nSEtolBtBHJ3ix3S0dGOcsoKLNwYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717520681; c=relaxed/simple; bh=rrXhYcuvAzSeNxJsE5K8KoOIiHuhtq2k88GjikEXdAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GtL2SIIBCXYQdSe2lzeoKbfh/OJQu+hnjajlgEbjXgygP7ClFDL5G3yKZttNIJzaycdHEZSHaRKqEovXMmQvV4Ue/bUu83Uk/3Kjv7lOlfEv3k2H8x4zqsOnvkL7w27/QQ3+x7aCkLdkdiwYrQcrDlkxq5JocqcNDZgMQAhtjVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VdcZuACD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 700D4C4AF10; Tue, 4 Jun 2024 17:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717520681; bh=rrXhYcuvAzSeNxJsE5K8KoOIiHuhtq2k88GjikEXdAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VdcZuACD7jFzew8Y495MNxaKHldbX2iP8xvNHsI8eKkW0G2YxjlzAgxLkPd7oKKM1 FtjqK+2bGHncEj0v81ifGJ0r1L7ZaeN3jgpnYbPsQtUaR2olHVTXo6GYHoyQlp7GNg lrr00++8r7myhmm/i00hZZpUcCfL4Ownla+JxAO/Q4d0olbXWR0MP4nHS0YB9gJvE3 XePnoEf9Z/MPRz+i2o9/b5sLuE2MhaK9dkUcTM6fzv4abfZ5I+ocQY7i8OBhKvyNKK 5FnRl9DLBNMAlJLeTa/Bb+tRy8NAPr0DOV2trLtmxlMSAmfDNMo4z+dhOpLwS8qpzq d6nFjU1Iobj6w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 08360CE3F27; Tue, 4 Jun 2024 10:04:41 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, torvalds@linux-foundation.org, arnd@arndb.de, "Paul E. McKenney" , Mark Brown , Naresh Kamboju , Nathan Chancellor , "Russell King (Oracle)" , Andrew Davis , Linus Walleij , Eric DeVolder , Rob Herring , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg Date: Tue, 4 Jun 2024 10:04:37 -0700 Message-Id: <20240604170437.2362545-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <1dee481f-d584-41d6-a5f1-d84375be5fe8@paulmck-laptop> References: <1dee481f-d584-41d6-a5f1-d84375be5fe8@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on ARM systems with ARCH < ARMv6K. [ paulmck: Apply Arnd Bergmann and Nathan Chancellor feedback. ] Reported-by: Mark Brown Closes: https://lore.kernel.org/all/54798f68-48f7-4c65-9cba-47c0bf175143@sirena.org.uk/ Reported-by: Naresh Kamboju Closes: https://lore.kernel.org/all/CA+G9fYuZ+pf6p8AXMZWtdFtX-gbG8HMaBKp=XbxcdzA_QeLkxQ@mail.gmail.com/ Signed-off-by: Paul E. McKenney Tested-by: Nathan Chancellor Cc: "Russell King (Oracle)" Cc: Arnd Bergmann Cc: Andrew Davis Cc: Andrew Morton Cc: Linus Walleij Cc: Eric DeVolder Cc: Rob Herring Cc: --- arch/arm/Kconfig | 1 + arch/arm/include/asm/cmpxchg.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ee5115252aac4..a867a7d967aa5 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -34,6 +34,7 @@ config ARM select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 + select ARCH_NEED_CMPXCHG_1_EMU if CPU_V6 select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_CFI_CLANG select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h index 44667bdb4707a..a428e06fe94ee 100644 --- a/arch/arm/include/asm/cmpxchg.h +++ b/arch/arm/include/asm/cmpxchg.h @@ -5,6 +5,7 @@ #include #include #include +#include #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110) /* @@ -162,7 +163,11 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, prefetchw((const void *)ptr); switch (size) { -#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ +#ifdef CONFIG_CPU_V6 /* min ARCH < ARMv6K */ + case 1: + oldval = cmpxchg_emu_u8((volatile u8 *)ptr, old, new); + break; +#else /* min ARCH >= ARMv6K */ case 1: do { asm volatile("@ __cmpxchg1\n" -- 2.40.1