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 A3347A0544; Tue, 7 Jun 2022 11:00:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E3E94282A; Tue, 7 Jun 2022 11:00:04 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id E50334282D; Tue, 7 Jun 2022 11:00:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654592402; x=1686128402; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Tu7CnW9QZNKq6lCopF7WamlfoOu5jS1gFXAAVQaijiU=; b=nljgSqyQChifdD+J0rbSurOqmI+rMN+HL75ddgIW+LpNu73FRHdajFIv OOiDB4qV3G8+j6aHsP3Ys7xMR+Ob++QvLLRafq31qkkf/SUPR3VstMlG7 5u3bKz1sSB2GoR0j1akZN0pUxEwCl7RX4A9N2Sl5mVT9C+8v7nNtdoMXN fmXZP1BkCaZ4YLEhC8Z957yWyTdgRM/PenHOVPFsVxSR5OqurluGxDOux dk8+STNIT7zRc1Uffz9CzkGo1e0lPhDxcyARvKiJsakx6FAn5tVXwIv9+ xfCMjYXx8sOx/iHVtWSrz7v0XDOLJMAhRZORY+nKLjtgAeLgss455J4GO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="363057006" X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="363057006" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 02:00:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="669888756" Received: from unknown (HELO zj-fpga-amt.sh.intel.com) ([10.238.175.102]) by FMSMGA003.fm.intel.com with ESMTP; 07 Jun 2022 01:59:59 -0700 From: Wei Huang To: dev@dpdk.org, thomas@monjalon.net, nipun.gupta@nxp.com, hemant.agrawal@nxp.com Cc: stable@dpdk.org, rosen.xu@intel.com, tianfei.zhang@intel.com, qi.z.zhang@intel.com, Wei Huang Subject: [PATCH v5 3/5] raw/ifpga: unregister interrupt in ifpga close function Date: Tue, 7 Jun 2022 05:07:22 -0400 Message-Id: <1654592844-1824-4-git-send-email-wei.huang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1654592844-1824-1-git-send-email-wei.huang@intel.com> References: <1653640433-5066-1-git-send-email-wei.huang@intel.com> <1654592844-1824-1-git-send-email-wei.huang@intel.com> 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 There is an API rte_pmd_ifpga_cleanup provided by ifpga driver to free the software resource used by ifpga card. The function call of rte_pmd_ifpga_cleanup is list below. rte_pmd_ifpga_cleanup() ifpga_rawdev_cleanup() rte_rawdev_pmd_release() rte_rawdev_close() ifpga_rawdev_close() The interrupts are unregistered in ifpga_rawdev_destroy instead of ifpga_rawdev_close function, so rte_pmd_ifpga_cleanup cannot free interrupt resource as expected. To fix such issue, interrupt unregistration is moved from ifpga_rawdev_destroy to ifpga_rawdev_close function. The change of function call of ifpga_rawdev_destroy is as below. ifpga_rawdev_destroy() ifpga_unregister_msix_irq() // removed rte_rawdev_pmd_release() rte_rawdev_close() ifpga_rawdev_close() Fixes: e0a1aafe2af9 ("raw/ifpga: introduce IRQ functions") Cc: stable@dpdk.org Signed-off-by: Wei Huang Acked-by: Tianfei Zhang Reviewed-by: Rosen Xu --- v2: update commit log with Tianfei's comment --- v3: update commit log with more explanations about the function call --- drivers/raw/ifpga/ifpga_rawdev.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index fe3fc43..94df56c 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -78,6 +78,7 @@ static int set_surprise_link_check_aer( static int ifpga_pci_find_next_ext_capability(unsigned int fd, int start, uint32_t cap); static int ifpga_pci_find_ext_capability(unsigned int fd, uint32_t cap); +static void fme_interrupt_handler(void *param); struct ifpga_rawdev * ifpga_rawdev_get(const struct rte_rawdev *rawdev) @@ -740,8 +741,9 @@ static int set_surprise_link_check_aer( { struct ifpga_rawdev *ifpga_rdev = NULL; struct opae_adapter *adapter; + struct opae_manager *mgr; char *vdev_name = NULL; - int i = 0; + int i, ret = 0; if (dev) { ifpga_rdev = ifpga_rawdev_get(dev); @@ -756,12 +758,19 @@ static int set_surprise_link_check_aer( } adapter = ifpga_rawdev_get_priv(dev); if (adapter) { + mgr = opae_adapter_get_mgr(adapter); + if (ifpga_rdev && mgr) { + if (ifpga_unregister_msix_irq(ifpga_rdev, + IFPGA_FME_IRQ, 0, + fme_interrupt_handler, mgr) < 0) + ret = -EINVAL; + } opae_adapter_destroy(adapter); opae_adapter_data_free(adapter->data); } } - return dev ? 0:1; + return ret; } static int @@ -1629,9 +1638,6 @@ static int fme_clean_fme_error(struct opae_manager *mgr) int ret; struct rte_rawdev *rawdev; char name[RTE_RAWDEV_NAME_MAX_LEN]; - struct opae_adapter *adapter; - struct opae_manager *mgr; - struct ifpga_rawdev *dev; if (!pci_dev) { IFPGA_RAWDEV_PMD_ERR("Invalid pci_dev of the device!"); @@ -1651,19 +1657,6 @@ static int fme_clean_fme_error(struct opae_manager *mgr) IFPGA_RAWDEV_PMD_ERR("Invalid device name (%s)", name); return -EINVAL; } - dev = ifpga_rawdev_get(rawdev); - - adapter = ifpga_rawdev_get_priv(rawdev); - if (!adapter) - return -ENODEV; - - mgr = opae_adapter_get_mgr(adapter); - if (!mgr) - return -ENODEV; - - if (ifpga_unregister_msix_irq(dev, IFPGA_FME_IRQ, 0, - fme_interrupt_handler, mgr) < 0) - return -EINVAL; /* rte_rawdev_close is called by pmd_release */ ret = rte_rawdev_pmd_release(rawdev); -- 1.8.3.1