From nobody Fri Jan 14 03:51:24 2022 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 2A8111952F34; Fri, 14 Jan 2022 03:51:25 +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 4JZnR10Kj8z3FPJ; Fri, 14 Jan 2022 03:51:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642132285; 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=t4fxv1mOsN+AvZDhf373XWSBp7LZoOx4Tg2+OCTvPFg=; b=sMEAnljoWhb0EDEMwXaeFAc8CoZFGzW1GhZEaC3MOTVsrGYLYPPDmKhpTvw37U+BBePF3C URH5ZmJlT3yhgWzDdhK+wq/4/FiCGdDmpTgmV0+Blt4uzic+rSUZgxaw3XD9fxfcoBcT+L CvwwpYHdw8EAzCYG8Vm7jEC2AoKrsj2MxfB9iEPchhgF1Iz1Icjbn3ZVetYqxo1q+M47Cx 7VzwD0lXvxOZw0zvU/Kg3aKpRhK+N74rLsz2LNvIAOV5ukNMDemVu5CO4LtY4uqaj+i6jA mXrgeA9apZ0chwqhsuqUUnFRTMApPmI/pL9wwzZxvFZGxqxvdn2B0Hjv76cjLg== 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 DFBA54EF1; Fri, 14 Jan 2022 03:51:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20E3pOdv048463; Fri, 14 Jan 2022 03:51:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20E3pOiU048462; Fri, 14 Jan 2022 03:51:24 GMT (envelope-from git) Date: Fri, 14 Jan 2022 03:51:24 GMT Message-Id: <202201140351.20E3pOiU048462@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: b5d227b0b27a - main - powerpc: Add atomic_testand_{set,clear}_{int,long} 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b5d227b0b27adbb7b4db9f8f27a14df342344c50 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642132285; 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=t4fxv1mOsN+AvZDhf373XWSBp7LZoOx4Tg2+OCTvPFg=; b=cV6Wozb4FpwEqa5A3wcuatyZCuD2UtVPpCc+qeblNd/OpIF+LtJ0BDKJnr4IZiueTL+uCb WAVja/dpUFBBbclEIRgG+3CDRV9ia9hmi1i+ff64QvfRlqSS/h1PKENRWJgFYKOyT+M5Pe 3hWI/dkcdryZ8798ua9jDqKrCFU1jGUPnTgb3KRhq1DOF77+q76n4+zdd8FcZBcMoRmHj2 cQuPI+1P9dX7B8uzcTvqGWT3CxoyBv0XHs8yQNizU88ehDtWL/cXo4/QWcWmDt9dSd5ce4 xOMJ36p1xt05asYisZ1he/85mkYWBfUQqyE8kgPmuLh+w2tziitdUsrAWKBf8g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642132285; a=rsa-sha256; cv=none; b=noWf4IGVTa72MJ97NKsqHbtMK3+vuIXBuxnatxbIbsJu/aqEyWuda07QISkfFBKwkdUl7J OpkErde7FmtrvV9bNOA22ExOJ7cHSFKEsnwnaFOvSHPJYdry+8rbiBtg04lWlInRBDCQfs Pvi3nHndxmvD4PQN4auSA08xC7o80qnB+CBIde/H1gq12b6N0ilJuir1jVX1aMldbPHUGn sSQIg2Z2+MkMA8kdE01t34tzGJ5zuBiYC9YOL3m+55bOzVGILhnkYq7gsF04vyvehHaXpU Icu2GiN2hnoyTT2NmBRBB2Tlj+rJJkLIgFQa5ikHRw7VViQLehl0/lPfudQNPg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=b5d227b0b27adbb7b4db9f8f27a14df342344c50 commit b5d227b0b27adbb7b4db9f8f27a14df342344c50 Author: Justin Hibbits AuthorDate: 2022-01-14 03:46:29 +0000 Commit: Justin Hibbits CommitDate: 2022-01-14 03:46:52 +0000 powerpc: Add atomic_testand_{set,clear}_{int,long} Add machine-optimized implementations for the following: * atomic_testandset_int * atomic_testandclear_int * atomic_testandset_long * atomic_testandclear_long This fixes the build with ISA_206_ATOMICS enabled. Add the associated atomic_testandset_32, atomic_testandclear_32, so that ice(4) can potentially build. --- sys/powerpc/include/atomic.h | 111 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index 0b383a4ebdf6..0d54ba4115c7 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -994,6 +994,117 @@ atomic_swap_64(volatile u_long *p, u_long v) #define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v) #endif +static __inline int +atomic_testandset_int(volatile u_int *p, u_int v) +{ + u_int m = (1 << (v & 0x1f)); + u_int res; + u_int tmp; + + __asm __volatile( + "1: lwarx %0,0,%3\n" + " and. %1,%0,%4\n" + " or %0,%0,%4\n" + " stwcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +static __inline int +atomic_testandclear_int(volatile u_int *p, u_int v) +{ + u_int m = (1 << (v & 0x1f)); + u_int res; + u_int tmp; + + __asm __volatile( + "1: lwarx %0,0,%3\n" + " and. %1,%0,%4\n" + " andc %0,%0,%4\n" + " stwcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +#ifdef __powerpc64__ +static __inline int +atomic_testandset_long(volatile u_long *p, u_int v) +{ + u_long m = (1 << (v & 0x3f)); + u_long res; + u_long tmp; + + __asm __volatile( + "1: ldarx %0,0,%3\n" + " and. %1,%0,%4\n" + " or %0,%0,%4\n" + " stdcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +static __inline int +atomic_testandclear_long(volatile u_long *p, u_int v) +{ + u_long m = (1 << (v & 0x3f)); + u_long res; + u_long tmp; + + __asm __volatile( + "1: ldarx %0,0,%3\n" + " and. %1,%0,%4\n" + " andc %0,%0,%4\n" + " stdcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} +#else +static __inline int +atomic_testandset_long(volatile u_long *p, u_int v) +{ + return (atomic_testandset_int((volatile u_int *)p, v); +} + +static __inline int +atomic_testandclear_long(volatile u_long *p, u_int v) +{ + return (atomic_testandclear_int((volatile u_int *)p, v); +} +#endif + +#define atomic_testandclear_32 atomic_testandclear_int +#define atomic_testandset_32 atomic_testandset_int + +static __inline int +atomic_testandset_acq_long(volatile u_long *p, u_int v) +{ + u_int a = atomic_testandset_long(p, v); + __ATOMIC_ACQ(); + return (a); +} + +#define atomic_testandclear_int atomic_testandclear_int +#define atomic_testandset_int atomic_testandset_int +#define atomic_testandclear_long atomic_testandclear_long +#define atomic_testandset_long atomic_testandset_long +#define atomic_testandset_acq_long atomic_testandset_acq_long + static __inline void atomic_thread_fence_acq(void) {