From nobody Wed Mar 02 22:08:55 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 98F9E19E6EBD; Wed, 2 Mar 2022 22:08:56 +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 4K87Yh04SKz3jZx; Wed, 2 Mar 2022 22:08:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258936; 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=qEm2/vxeVgck80049p9Pk4b1ZNfKqXW2sH2QdZ4CGUc=; b=eJjqbelWIg5L9kXxtqfpcVAWdrlnlxIoa1+B9GQUPC/tUI3iv6cT+lB4uhJXLwvUkcvc0n WBpWWe+VvRCRCuFr70odRlQ0KEZD8PPI+Cq0aLxXRcCz+4Z/SL8eYrFw/zdVgCl/sIYt3o LnhF7nYo/U6YYfo+tEoNt7+DIl9peliYED4mOXE8kpQVpKfyzi7EK936CWWSvOsWPYCz1s JUMeA5D3FgSkAQzxRlJuFJav1HrteAQcbJA1rl0xTNLd8K9q0Q4qrtgYZvPz1rxbRptiox D9WtJ+qUmG1BMpMr5LNyFhS6cC5pCaZ8KZi3qkTcUFVusURpaPXPLeWliSVzOA== 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 58B7A387D; Wed, 2 Mar 2022 22:08:55 +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 222M8t7G080048; Wed, 2 Mar 2022 22:08:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222M8t9S080047; Wed, 2 Mar 2022 22:08:55 GMT (envelope-from git) Date: Wed, 2 Mar 2022 22:08:55 GMT Message-Id: <202203022208.222M8t9S080047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 8af771a0b3c5 - stable/13 - 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: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8af771a0b3c5da5de5dad65307b90ed25b383d66 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258936; 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=qEm2/vxeVgck80049p9Pk4b1ZNfKqXW2sH2QdZ4CGUc=; b=vpHyAKwRY1w0KN0hNs9o52uUilV4OWeOZg7xzvIu0B142yQFpWj8YZrQ1PDlVYS4zf5ReR km/HqjQRYFwkideRNAfZMoKGGHQf5RzPZA1xA4AHh9PMVxBv2J8gG/DZvxUp/MguUeMRyq UoylAeX3X1gVQGAbAR19xbAMGexkmR8S/J2hcoro/AKY/ix7aBE3seEmXojF69GrzxWGZn X1p+616MRdEkfo44ybilYvYqyPfMzAksUqkp22Zprz1+V4fjMrn7Kq8DwHNJI+tKbUFksM CpGUteKIl3e3fC3+Jbb6Fy+rJDdUtz7k5vfbYfcN+Qv3h5Bgh9OwocIoa4YIZA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646258936; a=rsa-sha256; cv=none; b=wnsq8UAgIF2lyH7zK385vCv/CuTb/rvrvoh7Iyn0i6EndKMSZyqgMaraKDkx0ufekc7Yyv p4g5Wx5mVqFH4gCwWSLH+SW1vSgNfAJzG/t8PKZ/hZFYBFS98MKx46lAMUepfXf46Vcvxf NIZ/DAZpux7UNzLA5vZcvb+cWqIe6uHIdvR3FVxiZTksgOMhsCRIw8gGt+VgSBbt4oV8xZ s1nW9IJb//Ns1M8SnEZn7prkzTI9jbjAx8Ss4JCotfA9pu8wsZQRuA/tcWFGTXFyFAaZlZ CkKO0b6NISdsb2sDyt9wi9v1AIzxc/AWfqKD2NmO0tKgojRVI9HSCH3uyn86Uw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=8af771a0b3c5da5de5dad65307b90ed25b383d66 commit 8af771a0b3c5da5de5dad65307b90ed25b383d66 Author: Justin Hibbits AuthorDate: 2022-01-14 03:46:29 +0000 Commit: Navdeep Parhar CommitDate: 2022-03-02 22:08:33 +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. (cherry picked from commit b5d227b0b27adbb7b4db9f8f27a14df342344c50) --- 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 aa03165de46c..c3d353cba3d3 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) {