From nobody Thu Feb 16 11:55:38 2023 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 4PHYL30ysmz3q5WF; Thu, 16 Feb 2023 11:55:39 +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 4PHYL25SzFz47Q6; Thu, 16 Feb 2023 11:55:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548538; 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=S0p3ijj0U8XcifVnaOB8xWONuooowCIasfIebDott8Y=; b=W/WhSDhU1ci5FJxXL9MeGqvJlVm/AhdkGSJkokMB8k7YmDUpcuQgcmK4EbOpH8vC9TJThp oiVe47XlCMxCnDk6xP9bvZzYD2DxTrygaiz7t2O5fH9du/4AmPU2XVo+j4g7RwqcTCDhns wv8VUh8T7dPfpx7dhT1lNZYkO8Tnesg39koRQJg9bpFKmLSCPiBqDtfP0oFLnxYrShf+/v hoAL7rpuIZF8wSVTSRXNusmiC2rJVAtG7bEq5iEptOoWsDlHM0kKVLejERBQJG+8fgc3vZ vU4WOnazpNhFXGifEY+GTWBHj4rt6eRITNRWBKU0mnk4/fDzjMis5wGDCEwscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548538; 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=S0p3ijj0U8XcifVnaOB8xWONuooowCIasfIebDott8Y=; b=NnL/CbNUPB1LmupZv/HT/E4wcesbf6/RBotspM1ehSPlfNqNZEzKPb5Z3sMbCECbyfdRfw +KK/BdxmMvaVPbD2GgQog/BAHbQ5YXoHo5pH/Erqa687teyZQRER2s1eUNA7u4+n0zbTVv E2U8qJ9EnklK0u4Hpa9xfnCLVQLmIGksDNS9A9nfoAQ2e8d8eFOu6rSQD65/Yqrl2EnuCv yaxzNGEZ7jhJg/r+NYEsMcXCdyem7U5qY9z/kmC2aBaxxR6JNKUyXyKYWn2gSlMqdGfkyO f9251cV3k0VZFcTKUFph4YwbI6t9jv2/uNdosQBIxtE1a23GtjqXn+SJZEuGcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548538; a=rsa-sha256; cv=none; b=lyFL3kuRkuLLhbMMYx3vYG/OV/up/vuUATzHpK/GC438WswiAnO5R0PEYk5TEzyGfK5cQJ Im6Z4c4zUALyFNLO0yYCY+espzOe/xlqhGGXGQ49bZkJhpJyn1zoRICHo6RkyPRRh2UQUb eXw3wbPjARfSn39bArKPWiIyA+xzXa4pLRpt/mGUlxpOMmlk7M18Gr6GrcIOcWZytTw274 g/3DC3BOn66rxdArRFuWB5yfDFpb+qDVvyjQwq88oelTqXFffAGnU4FJ5azlalT5afPZ0B 66SKzG/Dpqx7edEsbDv2eY15D34JYI3JR1OpFOY/nUp6Q/A7bo1jLjkmycTJxQ== 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 4PHYL23bGjz13Gy; Thu, 16 Feb 2023 11:55:38 +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 31GBtcJ2054845; Thu, 16 Feb 2023 11:55:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBtcOM054844; Thu, 16 Feb 2023 11:55:38 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:55:38 GMT Message-Id: <202302161155.31GBtcOM054844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: ec8401ffaeb3 - stable/13 - linuxkpi: Define `hrtimer_try_to_cancel()` 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: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ec8401ffaeb399f8d02db237e6c2390c1e3f7bf5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=ec8401ffaeb399f8d02db237e6c2390c1e3f7bf5 commit ec8401ffaeb399f8d02db237e6c2390c1e3f7bf5 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-11 01:00:57 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-02-16 11:55:11 +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 (cherry picked from commit bb651c77f5f71a38dd90b2eee214e7a2224421a7) --- 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.