Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1703779lqz; Mon, 1 Apr 2024 14:40:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQ0uya9XAPy4YQdm6bTm/pT2+b/leqUyiMskgmrIg6ZLNjZBERGz6UHv7IpMfidqvtoWixBMFAIdvNqgMkdAuGZeic7qehknJ+JxwmxQ== X-Google-Smtp-Source: AGHT+IHUSFRKJIe9l/0lgwJhEd4G86dzOPEgj6OxAzT4DCNAxOXsN4jBJRh0lDok1/+UzRzujRso X-Received: by 2002:a17:90a:fc87:b0:29b:c1c8:8c1d with SMTP id ci7-20020a17090afc8700b0029bc1c88c1dmr9174992pjb.40.1712007630437; Mon, 01 Apr 2024 14:40:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712007630; cv=pass; d=google.com; s=arc-20160816; b=i4e/3mG2/jjvVHS5YH/lb5DJI/ijrc6vxCokKxzWffl+WynTuoLMAw/6jeA+9swHME uAIlj2268wZ0p7PApFnn2iHsM3pK1l4OsOI7p6anFzfC7MiHzPMzk+AKhOuJdWOMT0V/ WXnDMjELuxp9cjh4zi+ICwRoBEC5wRMCyu9N0c7XPgcufOnmpFkz4nt7smqd0UWQHoC1 TvH5NzT9IMvFt2qRBRmdmi5kDXUDHfnibIkz1qcUhHuKdhHRxqxuLD5dSRAdiKzHUGRQ FbhfuWzX2tSHG1mylc42bSPMWLOj+A9XXp8EKScVqqitdoulRbbqoQ3BrcvYI9DJK47p C7lg== 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=xIjiQavzxfezOmcH9hcVM/xB7++rnjzWi6+Xfr+NLSU=; fh=/RdyPwUSo3YNb2Ld9aYVrW/rralOnX/49qkKED1Gk9E=; b=K6BkySKZ/R2dSICJmm0PWp+6P1WRVPsXOkZ/imQbeG/koZwRAVzpu6Mkz7KCj1qMaY Z5IhBDqxiZASZh86SS8oWshddNPBXrDEfX4mJJUcI/0m36eAEXFZXVKR9RniNqhSH58M V9NBS5PPjTuSQ9FvSvHs3XVKVnScbQiKRIEiatX0VGE3+TRO8fM56eZfTOONX24iUFCQ pK+F/yy4CIuNGaytH+1Zmbpgmd76AhfgFjDng0v1J+5emS7I/LIfST+lMMux87uUa0iK 9SgXewPi8W2nVrTCUrfmMZEUOBd+x9WJ+Dyd1+66yLK00tNvQt6601RAjKd0QOQGl1vW Qopw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ALYUYhl+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127096-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l15-20020a17090aec0f00b002a204a2667dsi9532288pjy.42.2024.04.01.14.40.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 14:40:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ALYUYhl+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127096-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E4A45B22E3D for ; Mon, 1 Apr 2024 21:40:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55CB656B7B; Mon, 1 Apr 2024 21:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ALYUYhl+" 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 745B955E72; Mon, 1 Apr 2024 21:39:55 +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=1712007595; cv=none; b=ungtlxZyvHacu++csu1pdGWk/Z8WfbJG4isW1LYDkBGvYgbVN3WYL4SSnVJhn2YqpnVRocpBwCnTixmvVKKY6+xh9BOSgC1HJV9Y1vah8cW7x4O1wtktkKzdan3BFeXevtKyVjiViBAWpOSEoOfktSa6+W6URgl0K4ucSNIlVBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712007595; c=relaxed/simple; bh=ZGz86/tSVAGS9mMQah03h/TzE5FSFLZz3YJL1al/ZP0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WhgMA4EWJvtTfFi7h3ayCFykUPbIMaVASAuuNdU9/+kqmM2IxZJ2aQN77yDq369S14HA2EU3IBcU2m81z5ZIFj9xUZ6U1+HAAYqlmYF6/xisRjztYIJag5FN2YJ8FI5WiKR9xSf3hwy/yPI/NfR4QvlJkENrEbEbLTf5hiDYWE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ALYUYhl+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2699BC433C7; Mon, 1 Apr 2024 21:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712007595; bh=ZGz86/tSVAGS9mMQah03h/TzE5FSFLZz3YJL1al/ZP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ALYUYhl+t4DM33sILtMlLhGEKvST/UP5cm8J0LAwDf9/Bkm6xQWIE8iwoktinrOLb iOY4BQXBBAc7rw68xS39P9s0VZqb1gn6Sbt/cle5KzcIslH938LBjGiI5gudH6VeqN OozUjpH+jmiWYx3FRtKGYZhB46AAIsK+K29ePAFrWWpX9ACBCXRHUfDnXbxL60+1re b6S0LI3KQDxmRqJFxFvQiFZvUcUEcRiHAGK8OcUeQSJ85joaso9fT5ZfBMhgI9mz84 R5kXXKaBktQmgMebBiD6EXkWq7rsNfl5TpPg6wqVywJLZA13bEwkRhwX0xKNm8P9mV Cej7pK0/yQ74g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C2BACCE0B64; Mon, 1 Apr 2024 14:39:54 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: kernel-team@meta.com, "Paul E. McKenney" , Guo Ren , linux-csky@vger.kernel.org Subject: [PATCH RFC cmpxchg 4/8] csky: Emulate one-byte and two-byte cmpxchg Date: Mon, 1 Apr 2024 14:39:46 -0700 Message-Id: <20240401213950.3910531-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <31c82dcc-e203-48a9-aadd-f2fcd57d94c1@paulmck-laptop> References: <31c82dcc-e203-48a9-aadd-f2fcd57d94c1@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() and cmpxchg_emu_u16() to emulate one-byte and two-byte cmpxchg() on csky. Signed-off-by: Paul E. McKenney Cc: Guo Ren Cc: --- arch/csky/Kconfig | 1 + arch/csky/include/asm/cmpxchg.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index d3ac36751ad1f..860d4e02d6295 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_2_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..848a8691c5a2a 100644 --- a/arch/csky/include/asm/cmpxchg.h +++ b/arch/csky/include/asm/cmpxchg.h @@ -61,6 +61,12 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = cmpxchg_emu_u8((volatile u8 *)__ptr, __old, __new); \ + break; \ + case 2: \ + __ret = cmpxchg_emu_u16((volatile u16 *)__ptr, __old, __new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -91,6 +97,12 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = cmpxchg_emu_u8((volatile u8 *)__ptr, __old, __new); \ + break; \ + case 2: \ + __ret = cmpxchg_emu_u16((volatile u16 *)__ptr, __old, __new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -122,6 +134,12 @@ __typeof__(old) __old = (old); \ __typeof__(*(ptr)) __ret; \ switch (size) { \ + case 1: \ + __ret = cmpxchg_emu_u8((volatile u8 *)__ptr, __old, __new); \ + break; \ + case 2: \ + __ret = cmpxchg_emu_u16((volatile u16 *)__ptr, __old, __new); \ + break; \ case 4: \ asm volatile ( \ RELEASE_FENCE \ -- 2.40.1