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 97EE3A00C3; Thu, 21 Apr 2022 05:25:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 707B6410FA; Thu, 21 Apr 2022 05:25:13 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id E4888410E1 for ; Thu, 21 Apr 2022 05:25:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650511512; x=1682047512; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wPK/DMB55JT3nMkDYeCYX9hx0HAeQ0pLM8+1dhmwkKw=; b=TZdYMvFmXXekbdvOM+P3h7DhTQDroTcw6yhQ6lDIRPZXKkTK4qnIQzNU yXfjBrodU8UfyaX0Hzjho1n5DC6qTTz4eoHlhHuWrzafktM2aV+7+nTvS 3mw+NrBh6mSK7+bk0y4KAIk/4k9yAq6s9d8pBRiSRb9nAE8FA3FF7q5nB 8N6nyzWqkrp2rp4PrJ+lEIJhFpQaVKvgYt5y4H1dMmAJNGo9hbNT5G5Sm VnUTjS3G5Z3gXUm9QGO5b+MMfI/ec5v89Ds2jm5VuTWTsgavu3bc1yLnF C7vomAQxeFcSJg4o0KiVOl9XtLev/ooL3WvZ9h0ELvfauORD/vEafeyo8 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10323"; a="264395429" X-IronPort-AV: E=Sophos;i="5.90,277,1643702400"; d="scan'208";a="264395429" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 20:24:53 -0700 X-IronPort-AV: E=Sophos;i="5.90,277,1643702400"; d="scan'208";a="576971697" Received: from unknown (HELO localhost.localdomain) ([10.239.251.55]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 20:24:50 -0700 From: Yuan Wang To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, jiayu.hu@intel.com, xingguang.he@intel.com, yuanx.wang@intel.com Subject: [PATCH] net/virtio: unmap PCI device in secondary process Date: Thu, 21 Apr 2022 19:15:37 +0800 Message-Id: <20220421111537.935333-1-yuanx.wang@intel.com> X-Mailer: git-send-email 2.25.1 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 unmap PCI device at secondary process uninitialization based on virtio_rempa_pci(). Fixes: 36a7a2e7a53 ("net/virtio: move PCI device init in dedicated file") Signed-off-by: Yuan Wang --- 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