Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1510149lqe; Mon, 8 Apr 2024 10:52:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVAAsSZg9yxVaIy/ErvSQAbTs8NdtVCHHXcisAE7KR5uBLoiPI5CfNouaPU9QpJL49FUV5I8Yj07DE8K6XkZas8jXe3gHU2KlRIO3mrA== X-Google-Smtp-Source: AGHT+IH561kYXRQj09AEHDOb6Ug6w+WZXsKhv9FJUtiH4WhHtIZZV1ofhfPS22kf/ophyGJmpSGT X-Received: by 2002:a05:6808:19a4:b0:3c5:ea9c:8b2c with SMTP id bj36-20020a05680819a400b003c5ea9c8b2cmr7860090oib.29.1712598733908; Mon, 08 Apr 2024 10:52:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712598733; cv=pass; d=google.com; s=arc-20160816; b=SmGdqPcqKu2dFgyfruTnljPlmBFcOdUY/q9HHLZFuNb/KgElKYgSVEQKjzpob+dIun gSLEm+VivkP2BAjJKI+FX2KyGA1DWJlMOejkK5Am8KOZTm924YUEaYidEd6Esfc5HM0I 0KWoc3t5RmyxSk52A7cU1ogVdW7XjvBUxPxrruiIwxCfSESyK3XbhBo8hIamdomk7Ap+ RD+Kx66S/1M5R5KjNxTnQykZddF3OWF88Vo0frUg4vQs4eQUVe4lltwsvk+PChzgH0JY ZoXe8Y33oXeKKQhtiZutgIsSPKj634durCVsBBW/OxfoWyCx83iqIaB5uDpdXUr514dT Tr+A== 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=+f1d1IOF52k8+OMFOhfjZi7WOg9ki6QZFNKV0NGKk74=; b=IUSdS0fxnhTM6CIXdwXgyCshZH3VBFnrN1sQjo8lbk45m5M9IQy1a0CCYIwepolhVT SEqieU9XbO247dlTCi0z8w2OL+Yh18NcfnaWQk6oSpchdY6IbTQ7thmV8UK7Ay39nokj cEkBxwUmHEDa2XfsNsOmszfk0VoKueS7xGKyCYnx8huaGylQds7Tjg4p7tXo4oXCk0jR zOPpfqb7v4RSkuNmFUckAflOlQHtR52ysmtYK8c1+zKyfzA50yHno543ViH5jw4eL1/D QyF0oyyOx/8m02Y/i9SygizWr3JwJAW/KkHHHhyB+ju9AzCjemhfF2dZ+DhBl+y9G92D 1grQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uprUfyn1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135782-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g16-20020ac85810000000b00434a5361172si2444468qtg.698.2024.04.08.10.52.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:52:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135782-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uprUfyn1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135782-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135782-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A109D1C23B5A for ; Mon, 8 Apr 2024 17:52:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4996C14882C; Mon, 8 Apr 2024 17:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uprUfyn1" 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 6B25C1448E8; Mon, 8 Apr 2024 17:49:47 +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=1712598587; cv=none; b=UC70T/kcdxLLt5/JDCVj6OZRniFMZHzmTR8vfsjcbZBHBsNLq4hiSZGO7TpaEqABTq3Ztr5zf/4rwCDtqIe62jBhhRy3H/7ZsdQ4CJHrNMt0Wrvz5qlZ2FkZ9/su/+Ce3u0nMPs67y/TKAys9HNrFIxf/N1upxj7waQDjKbL/Pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712598587; c=relaxed/simple; bh=WKYKHYI+0R9pnBOWkWIHPz6LwRVJ8kFwJ9YA0/qhV2w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fP5ERcRQ0yjJE2Q56vTaMutjIZuXmhe5jQO8C4+ouEYsjtI8r26PnRbCALVGnG90tET6UU7YNO/drLOy2DF6o8AuoBSs46COCzBouyt7EY2eDSPwNJwRZL2tnOrMqECEpdxqW0vVodaqu5x3Kfy3/TjSjVWqWcPLdHCb9Td+VIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uprUfyn1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 149AFC4166A; Mon, 8 Apr 2024 17:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712598587; bh=WKYKHYI+0R9pnBOWkWIHPz6LwRVJ8kFwJ9YA0/qhV2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uprUfyn1HNN/C/FfKaccPjHjiW9rZEMZ07du2AWZmn3jNcVGXTOphZGqAlBSHzfIp 3FY/2a3zYF9th+NXgJ8k0iKX9TB2joR2FBuiLQ3QBeg0PhGaIOEzjwQRomSNaDkf70 nl7UHD8uqesvBXSyPGeR4E9+PLa3Zx55HS1h6c0MY6CBJDE7Ex5wwGg36R4XiSdeL7 g6ayH+lk38x9CgGoBr8jFHOT0Nl2zkKlDeJGDPkx2xhwh6LXvhFTOHkgp9qOiJw22t JU9i4AaLn0JwLDmZiSTqWsQszkxmm2zApvfO2xCeYcREMPGyrqN6DGkQbgI4RL7coq EU9VblDlNuCFQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 578B5CE2CD4; Mon, 8 Apr 2024 10:49:46 -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, torvalds@linux-foundation.org, Arnd Bergmann , "Paul E. McKenney" , Yujie Liu , Guo Ren , linux-csky@vger.kernel.org Subject: [PATCH cmpxchg 11/14] csky: Emulate one-byte cmpxchg Date: Mon, 8 Apr 2024 10:49:41 -0700 Message-Id: <20240408174944.907695-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> References: <7b3646e0-667c-48e2-8f09-e493c43c30cb@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 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