From nobody Thu Jan 16 18:08:00 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YYrSd0DB3z5kkpK; Thu, 16 Jan 2025 18:08:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYrSc4qLtz3RK8; Thu, 16 Jan 2025 18:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737050880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qGTA4cNG5FMyw6uGuLHY+qGL763939l/w/S+JCDZwxo=; b=UVS4RyhApQYkR8lQ8pw+x8nCXqqGcfAn0oNS9IeHlx36XLYxNYHbxxwj/nuw4s5SbR0da/ hEcSGGeVYBt7xfbuvhJV9ngfyQ1Bxeh68MlscTOOoz9RyOM84+5dSc1xKMIWlkCkpt4o9/ wpSw/tjjbbwhveIT8IXNRGmCLvBvwLFi9+bSWvzlzcq27gIA9bq+EspSxTOxd+yeg18uDy Z1pUEqOUjUFIDTHEXmYaUZXz2JY3kZYZdOCGb00hwi7bcMHQMvugGmdPNHMaKOEs9uxZFa e6ITh14kiErOrdZtzGFzIyDaNGGuxxLtjkLeP3Ho6XuJ150NZ49pWS0rlckzJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737050880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qGTA4cNG5FMyw6uGuLHY+qGL763939l/w/S+JCDZwxo=; b=s7HS/lhx873dAmz+vyFcTgWDumVRgWQJxd0OIR+98nXKzf0kV4l+41F99p1QcwMAgOkasa LwMfS3mts7M9ebsLMEMtBPmjOUcGELMArJyNEbo7O/M8DQtvywEfir9owDiU/av6cg9+TL 7X0jXW59CcqVnm3AHORNBZnAFchBbOZxNkhvRuedO5CLby03krXsmjE6hQiV+zP++gU7yw 9P+57oP0rJL7bo02meR+Hw7xhy0lCQIZOQZ4MPGhZxM/4UNmO8IkblC/oF1965D/7hNvI6 mbQ4B4R5LaxwuWMoMyq1Nb5bC6qMBH5ic+FLAxK1MqVywqHgEEqsrv87v76b0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737050880; a=rsa-sha256; cv=none; b=irfikmIVPLeGILYfT+JCV9sch2EoIZ4+nDLwVlil3JfypcbV5bIgdzQUQ1Pwy5nodjNfeT BOh8VFSmCIpwtFU4gBF3jRnhNdZvvPzCiqOyHYDJThIa519DzORstSxxr/w9Y6Rtl7a344 CC09OGFGY+rPgX2v14agSSIEijSyB+oDvygAAA+BxVE2fV1OHZaxqfJL2NFvkGLTpDqjVM 4eoH0Bq80skrA3MtSpey9stQzxHGL7Ak0toHYZOluLED01Vjqb36oinsnQVrStFYBXhl66 ccbCKYLBimSS8ydQEkUCh+CVx2b0LheiWCIJ/3jBITgQBAO1OrdXLYVdPtkR8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YYrSc3xPZzjs0; Thu, 16 Jan 2025 18:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50GI80Ku091068; Thu, 16 Jan 2025 18:08:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50GI80aZ091065; Thu, 16 Jan 2025 18:08:00 GMT (envelope-from git) Date: Thu, 16 Jan 2025 18:08:00 GMT Message-Id: <202501161808.50GI80aZ091065@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 0635f5eeacbf - stable/14 - riscv: Implement atomic operations List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0635f5eeacbfccff227dc5722cad62ca11abd47b Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=0635f5eeacbfccff227dc5722cad62ca11abd47b commit 0635f5eeacbfccff227dc5722cad62ca11abd47b Author: Ruslan Bukin AuthorDate: 2024-05-22 15:07:27 +0000 Commit: Olivier Certner CommitDate: 2025-01-16 18:06:52 +0000 riscv: Implement atomic operations Implement atomic_load_acq_16, atomic_store_rel_16. These are needed by bhyve(8) PCIe bus emulation code. Group 16-bit atomic functions similarly to 32 and 64-bit. Reviewed by: mhorne Differential Revision: https://reviews.freebsd.org/D45228 (cherry picked from commit 2183004e14a863d65ca9192df1bea2625e3fdfb3) --- sys/riscv/include/atomic.h | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/sys/riscv/include/atomic.h b/sys/riscv/include/atomic.h index fee82e6a6bc9..aaa7add6894b 100644 --- a/sys/riscv/include/atomic.h +++ b/sys/riscv/include/atomic.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Ruslan Bukin + * Copyright (c) 2015-2024 Ruslan Bukin * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -105,8 +105,6 @@ atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \ ATOMIC_CMPSET_ACQ_REL(8); ATOMIC_FCMPSET_ACQ_REL(8); -ATOMIC_CMPSET_ACQ_REL(16); -ATOMIC_FCMPSET_ACQ_REL(16); #define atomic_cmpset_char atomic_cmpset_8 #define atomic_cmpset_acq_char atomic_cmpset_acq_8 @@ -116,11 +114,40 @@ ATOMIC_FCMPSET_ACQ_REL(16); #define atomic_fcmpset_rel_char atomic_fcmpset_rel_8 #define atomic_cmpset_short atomic_cmpset_16 -#define atomic_cmpset_acq_short atomic_cmpset_acq_16 -#define atomic_cmpset_rel_short atomic_cmpset_rel_16 #define atomic_fcmpset_short atomic_fcmpset_16 + +ATOMIC_CMPSET_ACQ_REL(16); +ATOMIC_FCMPSET_ACQ_REL(16); + +#define atomic_load_acq_16 atomic_load_acq_16 +static __inline uint16_t +atomic_load_acq_16(volatile uint16_t *p) +{ + uint16_t ret; + + ret = *p; + + fence(); + + return (ret); +} + +static __inline void +atomic_store_rel_16(volatile uint16_t *p, uint16_t val) +{ + + fence(); + + *p = val; +} + +#define atomic_cmpset_acq_short atomic_cmpset_acq_16 #define atomic_fcmpset_acq_short atomic_fcmpset_acq_16 +#define atomic_load_acq_short atomic_load_acq_16 + +#define atomic_cmpset_rel_short atomic_cmpset_rel_16 #define atomic_fcmpset_rel_short atomic_fcmpset_rel_16 +#define atomic_store_rel_short atomic_store_rel_16 static __inline void atomic_add_32(volatile uint32_t *p, uint32_t val)