From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A428FA0C47; Tue, 5 Oct 2021 14:17:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6EFE3413B0; Tue, 5 Oct 2021 14:17:00 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 661AD413AD for ; Tue, 5 Oct 2021 14:16:58 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 195CEXgB028469; Tue, 5 Oct 2021 05:16:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=x2mvedNVJ6RazJ2d+mogzbzG2ycUVRCAuCLdM8cX7Qc=; b=XNOaF+Rwl2DNvtrGsaYnShA1T23A3DbpaPd7kllfzxnutduO45f3xUcVoGedpvNAZDXD pHSQPlsd4Tn4m6yp8smAu2ZuKIyDUNC9ELOYliz+dbHDCMO+1V9y1JmL5Rx+NykylHKU OH0GX+JBDY8or3LYp3Q0avyVUnvde2rfJp1RtbXKD+q+F7thxw8jjmYM5DvecWXrT7ut vCjbWpIkotRXQj2QF+sYk/KIYdP84Vt5vQzpNqywL+13XkF04h1mm8IUaPzNloG8+ayp uKVejt5igKpVA25weWNOR35LtBA3o2Ec7ZnSQmmCyCxzBxCPeiKCcV/4lnCRIwsrqolI hA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3bgmv5rara-20 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 05 Oct 2021 05:16:55 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 5 Oct 2021 05:16:18 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 5 Oct 2021 05:16:18 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 672D03F707D; Tue, 5 Oct 2021 05:16:16 -0700 (PDT) From: Harman Kalra To: , Bruce Richardson CC: , , , Harman Kalra Date: Tue, 5 Oct 2021 17:45:02 +0530 Message-ID: <20211005121502.66964-7-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20211005121502.66964-1-hkalra@marvell.com> References: <20210826145726.102081-1-hkalra@marvell.com> <20211005121502.66964-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 5zwE0fsp_NtUH8XXyg_INuWb9_sdzyHK X-Proofpoint-ORIG-GUID: 5zwE0fsp_NtUH8XXyg_INuWb9_sdzyHK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-05_01,2021-10-04_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH v2 6/6] eal/alarm: introduce alarm fini routine X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implementing alarm cleanup routine, where the memory allocated for interrupt instance can be freed. Signed-off-by: Harman Kalra --- lib/eal/common/eal_private.h | 11 +++++++++++ lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 10 +++++++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 86dab1f057..7fb9bc1324 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -163,6 +163,17 @@ int rte_eal_intr_init(void); */ int rte_eal_alarm_init(void); +/** + * Init alarm mechanism. This is to allow a callback be called after + * specific time. + * + * This function is private to EAL. + * + * @return + * 0 on success, negative on error + */ +void rte_eal_alarm_fini(void); + /** * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, * etc.) loaded. diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 6cee5ae369..7efead4f48 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -973,6 +973,7 @@ rte_eal_cleanup(void) rte_eal_memory_detach(); rte_trace_save(); eal_trace_fini(); + rte_eal_alarm_fini(); eal_cleanup_config(internal_conf); return 0; } diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c index 333dbd743b..0a5098efc0 100644 --- a/lib/eal/freebsd/eal_alarm.c +++ b/lib/eal/freebsd/eal_alarm.c @@ -46,6 +46,13 @@ static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER; static struct rte_intr_handle *intr_handle; static void eal_alarm_callback(void *arg); +void +rte_eal_alarm_fini(void) +{ + if (intr_handle) + rte_intr_instance_free(intr_handle); +} + int rte_eal_alarm_init(void) { diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 3577eaeaa4..5c8af85ad5 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_eal_memory_detach(); rte_trace_save(); eal_trace_fini(); + rte_eal_alarm_fini(); eal_cleanup_config(internal_conf); return 0; } diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c index 5856bc08ce..a236c639e8 100644 --- a/lib/eal/linux/eal_alarm.c +++ b/lib/eal/linux/eal_alarm.c @@ -58,6 +58,13 @@ static struct rte_intr_handle *intr_handle; static int handler_registered = 0; static void eal_alarm_callback(void *arg); +void +rte_eal_alarm_fini(void) +{ + if (intr_handle) + rte_intr_instance_free(intr_handle); +} + int rte_eal_alarm_init(void) { @@ -68,7 +75,8 @@ rte_eal_alarm_init(void) goto error; } - rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM); + if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM)) + goto error; /* create a timerfd file descriptor */ if (rte_intr_fd_set(intr_handle, -- 2.18.0