From patchwork Tue Nov 21 14:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 13463243 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="lK8s4WR4" Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BB9197 for ; Tue, 21 Nov 2023 06:24:54 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6cb7951d713so1802431b3a.1 for ; Tue, 21 Nov 2023 06:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700576694; x=1701181494; darn=vger.kernel.org; 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=KQzQ3hctuM1DrYXT+jmSwlcI1w3CAnf53zL9eOZco7c=; b=lK8s4WR4D8qSeSl/wIndq3Y/ygX+TN/NIiGvIInZYS4yLgqoazrLYb8VAsi94YZzBI Ewym/spIimpGTmNWO7w2DqPAQtRk0t8uGS52aH9pk/e/RSSPg1qPA0gv2iH456fXHf2N ZXK1lnI6HFlp3OWOdl3g6XN8WYUSY3bAAdc0YJ4gN/FM4U+/ThowxrCYqtt3tszLtix3 WN7go69/Fj1hDOdBr+s/K9yYhCiYll4EMUahkrElleQ9rr0BwlPgUhSNNWEGXydRVBUK Bu0F/GyJBqfWo6ozXYgA4xusqzgvnUHsanLlnxodjTMBnIVRIWOqkjX22HUiu1BXvR6Q Anpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700576694; x=1701181494; 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=KQzQ3hctuM1DrYXT+jmSwlcI1w3CAnf53zL9eOZco7c=; b=mma2SQh8WHhQ0XHLDoWsLkA0LtPyQEWNBbUSQLmQAeTaxTjDruTRtLTf3mHtT6g7sb es1iKYvPotx8ZfV0yeJ4/1UUiunMjCMu5Ex5C5ywLfGUCzr2yV5p3TUeVunvl5n08302 5KwnURM6br/NO+E5lf7yg+2uR09kjaaf/iCsIJMhU62hF/V0hWLU97PP8CZtN4R2xAi2 yJJTaEp3QrQsCDIMjohX8hGz1q4ZwhoWNpQ6Z165+AYgs7kqhbvRcJyUYAKVDVregaLN GOHelTpWVltVBYgo7rnHahvBXnWZkdhhAvFtNA5/CWPW2L6BMNJtkWXCdHxh5i4pIHuw zbmw== X-Gm-Message-State: AOJu0Yw84Yqo3sNhRQvbSwKB6NI84XCIhI62ALsoQSzPNLoQHQKybrBo +rkMtk8FGOFwlQRwMUdVTL50mQ== X-Google-Smtp-Source: AGHT+IHbYu2jqbF7t8/wu/0pojkQUebMfIzAqIQeTS1oR0oKU5ESn/XV9iR5u5ULhgBjAJ/tpgr/hw== X-Received: by 2002:a05:6a00:228f:b0:6cb:8abd:39b5 with SMTP id f15-20020a056a00228f00b006cb8abd39b5mr4000172pfe.1.1700576693727; Tue, 21 Nov 2023 06:24:53 -0800 (PST) Received: from devz1.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id d13-20020a056a00244d00b0068842ebfd10sm7923193pfj.160.2023.11.21.06.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:24:53 -0800 (PST) From: "wuqiang.matt" To: ubizjak@gmail.com, mark.rutland@arm.com, vgupta@kernel.org, bcain@quicinc.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, chris@zankel.net, jcmvbkbc@gmail.com, geert@linux-m68k.org, andi.shyti@linux.intel.com, mingo@kernel.org, palmer@rivosinc.com, andrzej.hajda@intel.com, arnd@arndb.de, peterz@infradead.org, mhiramat@kernel.org Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mattwu@163.com, linux@roeck-us.net, "wuqiang.matt" , kernel test robot Subject: [PATCH v3 2/5] arch,locking/atomic: arc: add arch_cmpxchg[64]_local Date: Tue, 21 Nov 2023 22:23:44 +0800 Message-Id: <20231121142347.241356-3-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121142347.241356-1-wuqiang.matt@bytedance.com> References: <20231121142347.241356-1-wuqiang.matt@bytedance.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 arc doesn't have arch_cmpxhg_local implemented, which causes building failures for any references of try_cmpxchg_local, reported by the kernel test robot. This patch implements arch_cmpxchg[64]_local with the native cmpxchg variant if the corresponding data size is supported, otherwise generci_cmpxchg[64]_local is to be used. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310272207.tLPflya4-lkp@intel.com/ Signed-off-by: wuqiang.matt Reviewed-by: Masami Hiramatsu (Google) --- arch/arc/include/asm/cmpxchg.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h index bf46514f6f12..91429f2350df 100644 --- a/arch/arc/include/asm/cmpxchg.h +++ b/arch/arc/include/asm/cmpxchg.h @@ -80,6 +80,34 @@ #endif +/* + * always make arch_cmpxchg[64]_local available, native cmpxchg + * will be used if available, then generic_cmpxchg[64]_local + */ +#include +static inline unsigned long __cmpxchg_local(volatile void *ptr, + unsigned long old, + unsigned long new, int size) +{ + switch (size) { +#ifdef CONFIG_ARC_HAS_LLSC + case 4: + return __cmpxchg_32((int32_t *)ptr, old, new); +#endif + default: + return __generic_cmpxchg_local(ptr, old, new, size); + } + + return old; +} +#define arch_cmpxchg_local(ptr, o, n) ({ \ + (__typeof__(*ptr))__cmpxchg_local((ptr), \ + (unsigned long)(o), \ + (unsigned long)(n), \ + sizeof(*(ptr))); \ +}) +#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n)) + /* * xchg */