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 23851A0542; Mon, 6 Jun 2022 10:07:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD60940A7F; Mon, 6 Jun 2022 10:07:42 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 2C9F740150; Mon, 6 Jun 2022 10:07:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654502860; x=1686038860; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ft1VK3c6YkrSxedBQsiGDaqcxsLBUL41fzr5rMyHtjM=; b=GeX9kjT7yMEsQfAMPgKHsyxy5u901tKG2cKTxarMdOqZNsBKHXGR+8rA 7SgUXbRSwFoNopWQ4ObR7PB2vpHW8V0nY+BJugvMEA2HAB7kABKlNPY4T T8rS1gvNQ6ocgqrkUYvXhnAT5MZJfS3eFzW392wehjplXEFt5Vmjgp/oP HuVYnUhPbdhOnOxcf74dm5TFR97JElPBY2Q7CFjlc9IOlp2f1cMf2Wh+t rm5cEYTk9/45hHGj08aCL7aSj/GFYmW9hd1r/LAZvMv1tmdEAd+zblO4i LmT2lmj1vfvHbGvzIZrsfi9O622Lb6YyjW1JmdvDtHgucNNetQJT3TeTn g==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="339844123" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="339844123" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 01:07:17 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="682149236" Received: from unknown (HELO localhost.localdomain) ([10.239.251.55]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 01:07:14 -0700 From: Yuan Wang To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, dev@dpdk.org Cc: jiayu.hu@intel.com, xingguang.he@intel.com, weix.ling@intel.com, Yuan Wang , stable@dpdk.org Subject: [PATCH v2] net/virtio: unmap PCI device in secondary process Date: Mon, 6 Jun 2022 23:55:43 +0800 Message-Id: <20220606155543.1213665-1-yuanx.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220421111537.935333-1-yuanx.wang@intel.com> References: <20220421111537.935333-1-yuanx.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 In multi-process, the secondary process will remap PCI during initialization, but the mapping is not removed in the uninit path, the device is not closed, and the device busy error will be reported when the device is hotplugged. This patch unmaps PCI device at secondary process uninitialization based on virtio_rempa_pci. Fixes: 36a7a2e7a53 ("net/virtio: move PCI device init in dedicated file") Cc: stable@dpdk.org Signed-off-by: Yuan Wang Tested-by: Wei Ling --- drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c index 54645dc62e..1f6bdeddda 100644 --- a/drivers/net/virtio/virtio_pci_ethdev.c +++ b/drivers/net/virtio/virtio_pci_ethdev.c @@ -122,10 +122,20 @@ static int eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev) { int ret; + struct virtio_pci_dev *dev; + struct virtio_hw *hw; PMD_INIT_FUNC_TRACE(); - if (rte_eal_process_type() == RTE_PROC_SECONDARY) + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + dev = eth_dev->data->dev_private; + hw = &dev->hw; + + if (dev->modern) + rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev)); + else + vtpci_legacy_ioport_unmap(hw); return 0; + } ret = virtio_dev_stop(eth_dev); virtio_dev_close(eth_dev); -- 2.25.1