From nobody Wed Sep 07 15:10:11 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 4MN5KH2MvZz4bPLX; Wed, 7 Sep 2022 15:10:11 +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 4MN5KH1gmCz3Y0r; Wed, 7 Sep 2022 15:10:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662563411; 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=ST+c3PS6nDKOvEhNEzo1M8vQl6HskFWfsSNIH6fMaZY=; b=KaeiZGnhEUN055+VN8kz6Ho7NrAjgXf3jULZrZIecUgKS6eE18opGlLfq1xmJOU2PaDxiv 6rMRzK1UaHyfSxu6iN6H6zo+TkTnIDxELnWd3M1f9EXqm0iifmf5cMWKgRrJ+OoxobtPp9 gHxu07f+j+KbHZ/q+ITbYZzaF+2/7tIf4lVpRZDsR5L0ckqs9+IpiiotSe32KBZ8hfAjOY uKFefpCLUdkEJmh2vWTPULWQSBP8ikKwujrs+8NfqoLRz11AC5VRt1MHgLrTapJd6WCwJH ljmxLfUP2sg/+3e/O0R6DA0azohfLAgKEVvea9NUKtoxX04YVWoNx9ZcUXkDRg== 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 4MN5KH0ncSzYxF; Wed, 7 Sep 2022 15:10:11 +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 287FABQs020913; Wed, 7 Sep 2022 15:10:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 287FABCA020911; Wed, 7 Sep 2022 15:10:11 GMT (envelope-from git) Date: Wed, 7 Sep 2022 15:10:11 GMT Message-Id: <202209071510.287FABCA020911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 56557fd4c43a - stable/13 - linuxkpi: Add try_cmpxchg and atomic_try_cmpxchg 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: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 56557fd4c43a9fb25200f2afff7a557eb2028845 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662563411; 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=ST+c3PS6nDKOvEhNEzo1M8vQl6HskFWfsSNIH6fMaZY=; b=ieL4zaW4VcMyawuH4MxJEG0FJOJaNdYd3c0T2e2poITIZzlQAQTS37RV3cO+bn5DtXZpcC 1NHWnYx0JI1AOHZyRfl5XLqMKByNvvtR6cSJKneCukl91wEF3h+P1qeay3XS2EVH1Q2Cjo p6x1QdDLGrqsdokWd32wHM+p0aGJm7MAqL2lpRUo8wORU9mwN4dDe1SlP6qcJo602+0XjY iUx1gQ2w3JUFIDUr/M5ghbmLSWqcmwNPaoUc94B77/60jj5U3rZD0HNHhpWMcNn97oHuin V+6M7V6i7fz6CvaDlm4RZk4acVO3k4wrxlIbYQ1saiO9apFLwVfRycS/WYES5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662563411; a=rsa-sha256; cv=none; b=uCuJuIUWsMxui2t7iKeFXXXoefDlSXmwa0hKqJJl4eN3SoqohBC0+0AuQb5dycd3QMVROc O0PEo6K1KoMlV91mirBKhiraBRBmasB77hEEEEItmNFNMeATL1Vd3taZyX8hjnjexI/+iz l1DWiysehJMdW7lQLK9b/42zMktfdjafPRk4/LeKbFtKi5yqVarFZxAGVSmGlmRArqVaOy HFuYIiZ8rJpEbUq6rZlKWt5Xit9U9U0v6LNiaOk4EQqs2y4Mw+IbwicsZB56+tfzVlFsuJ Qun4vHeZMht1IOMXK7XdT52mudjrxDK9umLngev3P29iaQZj4iL0KbL5Mi4zjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=56557fd4c43a9fb25200f2afff7a557eb2028845 commit 56557fd4c43a9fb25200f2afff7a557eb2028845 Author: Emmanuel Vadot AuthorDate: 2022-07-27 07:41:04 +0000 Commit: Emmanuel Vadot CommitDate: 2022-09-07 15:09:03 +0000 linuxkpi: Add try_cmpxchg and atomic_try_cmpxchg Needed by drm-kmod Obtain from: drm-kmod Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36015 (cherry picked from commit 39da3678b1ce2d4fac300e022e544b1db5c117c0) --- sys/compat/linuxkpi/common/include/asm/atomic.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/asm/atomic.h b/sys/compat/linuxkpi/common/include/asm/atomic.h index 7c7a2c4d4b92..d7e5338c0356 100644 --- a/sys/compat/linuxkpi/common/include/asm/atomic.h +++ b/sys/compat/linuxkpi/common/include/asm/atomic.h @@ -268,6 +268,28 @@ atomic_cmpxchg(atomic_t *v, int old, int new) __ret.val; \ }) +#define try_cmpxchg(p, op, n) \ +({ \ + __typeof(p) __op = (__typeof((p)))(op); \ + __typeof(*(p)) __o = *__op; \ + __typeof(*(p)) __p = __sync_val_compare_and_swap((p), (__o), (n)); \ + if (__p != __o) \ + *__op = __p; \ + (__p == __o); \ +}) + +#define __atomic_try_cmpxchg(type, _p, _po, _n) \ +({ \ + __typeof(_po) __po = (_po); \ + __typeof(*(_po)) __r, __o = *__po; \ + __r = atomic_cmpxchg##type((_p), __o, (_n)); \ + if (unlikely(__r != __o)) \ + *__po = __r; \ + likely(__r == __o); \ +}) + +#define atomic_try_cmpxchg(_p, _po, _n) __atomic_try_cmpxchg(, _p, _po, _n) + static inline int atomic_dec_if_positive(atomic_t *v) {