Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp780274lqm; Wed, 1 May 2024 16:03:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgORXXNBs8uXlBiEyZgYUK4ApGd2/jI9yy+w+KphaqNBD581iSh23F28oiU0ZC3ubZHZ72CDPmReUGkxwre8j2kalSjR/8HY/9fBuGPA== X-Google-Smtp-Source: AGHT+IHK/PkYIhPH6LqeDfsSwnC/0DyFDR0i3wdUTeeSeVpholjeGVj+0m8backE3TFepVeMpZ5b X-Received: by 2002:a05:6a00:180d:b0:6ee:1b6e:662a with SMTP id y13-20020a056a00180d00b006ee1b6e662amr4864936pfa.32.1714604588503; Wed, 01 May 2024 16:03:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604588; cv=pass; d=google.com; s=arc-20160816; b=kg3MZ/6Y7DwdcMN/cKErxf6vB+kGZzpVAKT1bUjW1yTtuB3Q5mZpV2wooFMJN3XMks /sfFH/xjqu5h23sC6Nafo0M1b1vpTpW4PYFaBRRbZBqygfwM1sTpmBGyZOCDBmUSm0Tm r4R9r5GCynGRWrrr4hFQFEli7rRV/f7UsjfF5R+EDhCiOwf95+UWmmYGiO4QOQ2xFbXq lVB+TMnRkgA3GjpD7XnW0i0MzDu2O88xhF+AsGTRiy4zw4o7Lu2IiAJXHwnARjT+BTZw mCnYRyDDroPksRyuaAsOjrcso3DP/hn9+lVkllF9pyfXGhsxg5TZHtgQim6Q2Vm7H1WA F+1g== 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=kDht9+R6sBiIEnux/uvnQIWQGGkyYw4jGXqbN5xYAzc=; fh=ywgBtMX9RvdQgb/csQd+HG7sixvbPakAfzLevUrco9Q=; b=YPFSpuPRr7cR062J+YS6LfjZhQPwpfdJwydoI9+KgQSCWftUHve60V2mSRDpB7VFO0 9P/Lo4FKMP3Wd4oAUJz0XoJNMpK2F3s9CmzJEQQ71xkoaWYEGyQbH9PKu5e1hBLXwI20 +/nJaqqLmThAeT7pDQF3UTmgsApi2iMPyyICTL+uEuhc8hcDU/ZbsiA1k/e304kXIkZr GT6Mgo7Rq2VH5MT6IpOZNGPdArOt7Kc7f3ZkvrCViej3AIPYsn9erhIc6GZhGv+AaTTJ D46X8P+pSweDhVky7uKZANrBw5c17e/b6w32Vv3j/M4Qks/5YWRLDZkZ06wiB4Tx3Xn0 akzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dkWvtQ6I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165809-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165809-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m11-20020a63fd4b000000b005dc8280f3b1si25390116pgj.303.2024.05.01.16.03.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165809-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dkWvtQ6I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165809-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165809-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E5858282972 for ; Wed, 1 May 2024 23:03:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9BA616DEB2; Wed, 1 May 2024 23:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dkWvtQ6I" 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 F208D168AEE; Wed, 1 May 2024 23:01:32 +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=1714604493; cv=none; b=F3EJAG2MJqDhE68IcXYIYxH8IFQbOMLg6rCGfn/bZATs+rksJqRBoqg971iyLmXq1FtJnuzjmPwP8CQEWgG4UQpW3XRhqqMc74wda7+HP6kg8Cg+7zIrsw5QyJ9QkBxvpUnxe8ztWnI6ihc2e1CABi+Hwuj3/XrEFxc8AfAfpLI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604493; c=relaxed/simple; bh=WKYKHYI+0R9pnBOWkWIHPz6LwRVJ8kFwJ9YA0/qhV2w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V3q8zQEmnvfAaflKN4vRdalhuRr4zHYSrvI6X6G97j4Fwx6aUlIudmfKcUMMqYqUCmAiGcERsGg/Q3eRIhMOU+kYczVmmuvgkWdHSk8x8a/1x+nBBgqf0xVceEFDorWjrXfoEcMUQJatz2H+vrjFFNCzPxJ59RNrqCF8uEvJCbc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dkWvtQ6I; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98781C4AF53; Wed, 1 May 2024 23:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714604492; bh=WKYKHYI+0R9pnBOWkWIHPz6LwRVJ8kFwJ9YA0/qhV2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dkWvtQ6ImaDQCpaRW/GM9Kxzl0aMNvM9bdSFLU8tjP3IWqGR94n9mzXRMHpo/vVOg mRUw4scDFHfgYIlsKRdUSg6sInyTZ5IaA9+LDGZUtQev4+wh4bkZ7zPARSE3KsOIwh fN0WTi/qhrENELvVALKC3tNx1KI/JlCvBW268k8W+O5v1UbuLrOoySYEpEExLn0+iP 4a6kepf53caGhWEzeqvAaAH+azO6u6lF45KeQ/BcJzJsbKnkdTGoaW2uaS0oDpGrBb J6AJFvndPWBPuOFmc2GFTGW4wZks5AWHN+kPL9lsT8tPCs5aWon5m62Qh6k8zrv5T7 nAMNrZzVCuA2w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D9D84CE28A8; Wed, 1 May 2024 16:01:31 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, arnd@arndb.de, torvalds@linux-foundation.org, kernel-team@meta.com, "Paul E. McKenney" , Yujie Liu , Guo Ren , linux-csky@vger.kernel.org Subject: [PATCH v2 cmpxchg 11/13] csky: Emulate one-byte cmpxchg Date: Wed, 1 May 2024 16:01:28 -0700 Message-Id: <20240501230130.1111603-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 csky. [ paulmck: Apply kernel test robot feedback. ] [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] Co-developed-by: Yujie Liu Signed-off-by: Yujie Liu Signed-off-by: Paul E. McKenney Tested-by: Yujie Liu Cc: Guo Ren Cc: Arnd Bergmann Cc: --- arch/csky/Kconfig | 1 + arch/csky/include/asm/cmpxchg.h | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index d3ac36751ad1f..5479707eb5d10 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -37,6 +37,7 @@ config CSKY select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION + select ARCH_NEED_CMPXCHG_1_EMU select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace) select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT select COMMON_CLK diff --git a/arch/csky/include/asm/cmpxchg.h b/arch/csky/include/asm/cmpxchg.h index 916043b845f14..db6dda47184e4 100644 --- a/arch/csky/include/asm/cmpxchg.h +++ b/arch/csky/include/asm/cmpxchg.h @@ -6,6 +6,7 @@ #ifdef CONFIG_SMP #include #include +#include #define __xchg_relaxed(new, ptr, size) \ ({ \ @@ -61,6 +62,9 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -91,6 +95,9 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -122,6 +129,9 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ RELEASE_FENCE \ -- 2.40.1