From nobody Fri Jan 17 12:26:54 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 4YZJrb0dWnz5kvHd; Fri, 17 Jan 2025 12:26:55 +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 4YZJrZ3ggyz3TFr; Fri, 17 Jan 2025 12:26:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737116814; 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=vrJzSouAnyHt6iIhKeqjXZv01Zy1F6r9MKeCIXQkv6Q=; b=ID8MxSLrIMUqhW8ZuepR0QWZLljDi7dEs8PsXphiWzUtwpgJOKDLZzqjZb9tsBKkzFmwSP ut/UziK/30nfuKq5EL60vouGg0hue4UhSBmdiBMjEzw2ceHYhGJFAcX3+DcZLa0vGh3uYO yGcA7uBLgb5PRuU7TqFkj9zmxZUhIusTzNyRyz76OybvFl/kde3IpOzDtUvK9TR6BEAy/k uxwxRKalyyQKC6ZLd+kkRZ46/ZKKLK6CX7hi0bg8GuiFJGt++gYmWE8G4dCdZ0cDAp5iE8 dWSTzwAxSFseAtq1Rys3UIvtYf/nTOBTxsOlHn4DDawX0QCBO8ON6v0tZsYKYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737116814; 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=vrJzSouAnyHt6iIhKeqjXZv01Zy1F6r9MKeCIXQkv6Q=; b=V/ENgWnc6VZkQu9zGaoQugmogfgKCvmjc0Ikbjdj17tB5x8GCHFsKZhCMGo280rBvzGE6l pDeIfjq76vcySlVxz7at+B0d7D35UOpReCIrJONAZeqZ1ZkfDfMgRjZwKqrOg1+2pNyGO+ AHDHOucdYh50HUrbi1Y5lVdLfUM00VA8U6p7/gkzLdi5V8dgA8nuh3+OsX5BZxVsj6uyEF ldXpzbjEGe+9+XDWgnQ3UrvOfjmqGkWtaWzXB/WRaYkeKWkBqmG7B3Tw+si5rJa4oP2Whf /h+5tib7pb59ZGIxFpfrO7rF0YmWHtS90hWOGifZlscZHyOgg17iZh1XuG50wQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737116814; a=rsa-sha256; cv=none; b=Rp8a0AFv83fOPdma6obWEbkd84ZtEMnezwwN9gORBAC0K0Md/mZMnS2QSUWwHnoirqzfqj bstTyt1N0DXzCLnmAEJIuLBWbYJ54NNpw6lQXfiUkVIU/OS3BUbYOvnq3apfBWPPt6piOa PAaumbOEUbQwuj1lrzYm+baGzmsEotidqqQqBQD3XkjO2nN19ptDmSUi/ElODnSg0ZqSpZ XYEpMH+jZtH8Y1RVfjncFrPy11Cqwb/6Zcdq6giRt+4gRbTNtEinVMlrm9Ib1Mk8T2Hc9f jRmE+wVUvQclDwl2az+zcZUUNRChwcaxmQ44kbp25pXNRVuWYpM1OshaUzkWHg== 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 4YZJrZ3HhKz3BW; Fri, 17 Jan 2025 12:26:54 +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 50HCQsT7051635; Fri, 17 Jan 2025 12:26:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50HCQsKN051632; Fri, 17 Jan 2025 12:26:54 GMT (envelope-from git) Date: Fri, 17 Jan 2025 12:26:54 GMT Message-Id: <202501171226.50HCQsKN051632@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: 1c22ba23b015 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 1c22ba23b015024fc473d5fd8ab45d29dd72a580 Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=1c22ba23b015024fc473d5fd8ab45d29dd72a580 commit 1c22ba23b015024fc473d5fd8ab45d29dd72a580 Author: Ruslan Bukin AuthorDate: 2024-05-22 15:07:27 +0000 Commit: Olivier Certner CommitDate: 2025-01-17 12:24:48 +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 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)