From nobody Wed May 22 16:06:54 2024 X-Original-To: dev-commits-src-main@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 4Vkx5B27T6z5LxbB; Wed, 22 May 2024 16:06:54 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vkx5B1ShPz4Srx; Wed, 22 May 2024 16:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716394014; 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=30+sTgeLdmIeK/Q7Ss3XUcmVMUWQXL5K+i7WJfkd2CI=; b=yXDJPZScrvzXWN3r2aOnQyDqXrHmA7rAjSxLLxPqFFNVVUDtaNygjvfcevfC89h18F2nNd WKbG/Gwhm//eOv6N13sP3MDrXxztGVVZsub6A++o/qZTHbwhOnPKGKA57LXW+Rndh1HLxX OnlqhLmRWR11YPijU3JXSij7PkZMznNiKFnkmLAX5x67xQhMklX+CwEGePD/XSL/XhF7tw KVOdnVVAE/d4ldc9awxB8836rcgXUDs/9sX3TlOUxH0g52IhL+e+9vs2Iep/cwk/WJV5sb Ot3/9sHMZf/I6LYF/ogt/gERdWsIg9sIILmzuQsUa7qzRpOPVZlnRy1BKKp0gA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716394014; a=rsa-sha256; cv=none; b=r1U6ZyQmtS6VVnlmxeXU4E10855ZMiq2IDielC4/e+FYhOnJ9uLyvjH0eAE72Z4HJxlRNE smspxWYoKQK/iJEodfgoyes+CSBgJeuPVIngj8c8d8ezXarkYrk+ho7euyeTjetNcYD7R7 IrmE9uE7JFU2m9hN1n8b0lPeiNltTGWu+c9IxmOScB9ohmq4HsWpuP/S6y1ZmPurNBEiox XmvfYyx7oHDmNKlhb0voLicEZ/WRgYqchqn/HiNo1uxKv8YEi5ivZI4aQGLaIogHbZXLJn +Qt1ZizskyS3vD87vFykkdTBbIqSEFTVY01HcWQK2qIMtuMHNGd/Iv6iiyl6QA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716394014; 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=30+sTgeLdmIeK/Q7Ss3XUcmVMUWQXL5K+i7WJfkd2CI=; b=KNuIzGMX+mv5MXOUx6za44Zbiv8S/HOUIQYd6gHSRfDHMAkifIERk0oleK7eAVcLQNl2i7 lnDYddktoecmy+0C5FD3cpg3V8G14lRZIJ4BgOE2ZOar0V8uolWz4WG/H2c4bMw7hcOyxm xzfD3cpafrqgEZhgWs/rASeHpWGT9EZiBuisHo3IaIWulQq5yN5Jm7M0pbLxwUhPlxsJqO XC8x7tPj33EJHv8XPOepB3Qm2SgW+tCdATWmaRWps5PaNEZArinRl2hdYvJQgC//AJMvZA ef1TEpV4KurNJj3j67Q5Ia/TadkEBuv+D+CZXGdv5SAHCg4Y9LKIOYxLzn/2rA== 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 4Vkx5B0zCcz1BR4; Wed, 22 May 2024 16:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44MG6sIU072568; Wed, 22 May 2024 16:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44MG6st5072565; Wed, 22 May 2024 16:06:54 GMT (envelope-from git) Date: Wed, 22 May 2024 16:06:54 GMT Message-Id: <202405221606.44MG6st5072565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ruslan Bukin Subject: git: 2183004e14a8 - main - riscv: Implement atomic operations List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: br X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2183004e14a863d65ca9192df1bea2625e3fdfb3 Auto-Submitted: auto-generated The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=2183004e14a863d65ca9192df1bea2625e3fdfb3 commit 2183004e14a863d65ca9192df1bea2625e3fdfb3 Author: Ruslan Bukin AuthorDate: 2024-05-22 15:07:27 +0000 Commit: Ruslan Bukin CommitDate: 2024-05-22 15:45:11 +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 --- 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 ef9aa5ef057d..03c1327d74da 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)