From nobody Wed Jan 18 22:07:16 2023 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 4Ny0H84Lktz2t8mM; Wed, 18 Jan 2023 22:07:16 +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 4Ny0H83jjKz4CWF; Wed, 18 Jan 2023 22:07:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674079636; 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=z8EKZs65nn9BJljAEx8MxI/21hmwZ2rRKIls7YvsFe8=; b=jofMpkCcAvzVHvSwSUFDCICFrVyJ2QhiCX5tLQwTLvNkSNF7fBQb0tUEZuJRVOQXr+dBSa z7ghQWvDktHqW9MYjaYrQFauoZbm92o+YWKpa3I5T+TsjcvgCgbOlHeJYbM8wvZectbj8G AwG0PdgulWsLNXBke3bCuWeX2201SeE0NmxrS6pCRGQxyX5KNiCQSoVF2OIwiIhHs8R5VL EcRPGC9/PTXq+DcbhLy++OdtjOGBOPNZZQKNek+hqtVfFu43e6dl+LkwRsrUtIYBWgNmvH hBMZJ2Ho0DRqf8xISZZroq9vKELMFabDcQm4rv4eX/EkKamh2yKnOfgyjW31Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674079636; 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=z8EKZs65nn9BJljAEx8MxI/21hmwZ2rRKIls7YvsFe8=; b=dnnDcr46pGGyWwWqj/w0D6AY0BxFmjJur7S1ghGuct9Wy7cF2+wrtnjdddlABQ+UXU/I2R qgfrBBDnFPDmf2b9ZQ8sY4g5VEXDd470q60j+pFFuca+U73/0epeXmpHGTYQ3t6QRQAjLo 2zeInqBN8Kwml+jSSGSzWQTlT3sYguLIF61xdAIIkVrA3noh2+R1ng0QosWNqElMxV5Tbn Hh0v9bX+wvK4mTCnDhXFM4LwAT3XqQ2eZcXpv0CkkPgxAzTSFXvbOxZE8fySkFTwM+Jbi2 rXoFoinm7Lq6/PfAqCjUC5ne9Bd21bWaVGlhrJeMHTfhN79kPx2D07BbjBAkhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674079636; a=rsa-sha256; cv=none; b=A5MH6jOj9LXQE3KGdwHtbCJG62rZ9FqCyPmoPsaa8wNUqy+1kiRaKS5iUcQAE+2dgKh5eF Jiwyu3Ztos2cYsiARXiRztcItSwsdf/71w1ymyaydTLvWAW/5+ut/osPT0ool7EfA9sB34 s4fY29gr1cnO9a/mUyWWWH0j+r0fNAM+/WubJbEJYFybK6sLRKqA8P0OQYq0wmvpgda/j5 ZJKfhN17B9K52fvsntBRAFVmMyAqsWJ3j65vQx7/c6U1/OEMt5LT3KYvj6htE09kZXKTX9 wxljlJvyJiEcDWm2HNFWlXSfeDRAgZS7oSl7Hncl2Ru9POper8nJXtb9Kr3wsw== 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 4Ny0H82m8WzRj3; Wed, 18 Jan 2023 22:07:16 +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 30IM7Gea027365; Wed, 18 Jan 2023 22:07:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IM7Gvf027364; Wed, 18 Jan 2023 22:07:16 GMT (envelope-from git) Date: Wed, 18 Jan 2023 22:07:16 GMT Message-Id: <202301182207.30IM7Gvf027364@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: bb651c77f5f7 - main - linuxkpi: Define `hrtimer_try_to_cancel()` 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb651c77f5f71a38dd90b2eee214e7a2224421a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=bb651c77f5f71a38dd90b2eee214e7a2224421a7 commit bb651c77f5f71a38dd90b2eee214e7a2224421a7 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-11 01:00:57 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-01-18 22:02:24 +0000 linuxkpi: Define `hrtimer_try_to_cancel()` It is the same as callout_stop(9) but the return values are different. Reviewed by: hselasky Approved by: hselasky Differential Revision: https://reviews.freebsd.org/D38081 --- sys/compat/linuxkpi/common/include/linux/hrtimer.h | 2 ++ sys/compat/linuxkpi/common/src/linux_hrtimer.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/hrtimer.h b/sys/compat/linuxkpi/common/include/linux/hrtimer.h index 23e707d906b4..4a63db80cc12 100644 --- a/sys/compat/linuxkpi/common/include/linux/hrtimer.h +++ b/sys/compat/linuxkpi/common/include/linux/hrtimer.h @@ -53,6 +53,7 @@ struct hrtimer { }; #define hrtimer_active(hrtimer) linux_hrtimer_active(hrtimer) +#define hrtimer_try_to_cancel(hrtimer) linux_hrtimer_try_to_cancel(hrtimer) #define hrtimer_cancel(hrtimer) linux_hrtimer_cancel(hrtimer) #define hrtimer_init(hrtimer, clock, mode) do { \ @@ -79,6 +80,7 @@ struct hrtimer { } while (0) bool linux_hrtimer_active(struct hrtimer *); +int linux_hrtimer_try_to_cancel(struct hrtimer *); int linux_hrtimer_cancel(struct hrtimer *); void linux_hrtimer_init(struct hrtimer *); void linux_hrtimer_set_expires(struct hrtimer *, ktime_t); diff --git a/sys/compat/linuxkpi/common/src/linux_hrtimer.c b/sys/compat/linuxkpi/common/src/linux_hrtimer.c index a56485512a14..5d9b376f9561 100644 --- a/sys/compat/linuxkpi/common/src/linux_hrtimer.c +++ b/sys/compat/linuxkpi/common/src/linux_hrtimer.c @@ -65,6 +65,28 @@ linux_hrtimer_active(struct hrtimer *hrtimer) return (ret); } +/* + * Try to cancel active hrtimer. + * Return 1 if timer was active and cancellation succeeded, 0 if timer was + * inactive, or -1 if the timer is being serviced and can't be cancelled. + */ +int +linux_hrtimer_try_to_cancel(struct hrtimer *hrtimer) +{ + int ret; + + mtx_lock(&hrtimer->mtx); + ret = callout_stop(&hrtimer->callout); + mtx_unlock(&hrtimer->mtx); + if (ret > 0) { + return (1); + } else if (ret < 0) { + return (0); + } else { + return (-1); + } +} + /* * Cancel active hrtimer. * Return 1 if timer was active and cancellation succeeded, or 0 otherwise.