From patchwork Thu Jun 29 02:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Miao" X-Patchwork-Id: 129089 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ACFD042D60; Thu, 29 Jun 2023 04:27:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A36541611; Thu, 29 Jun 2023 04:27:03 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 6A6AF406B7; Thu, 29 Jun 2023 04:27: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=1688005621; x=1719541621; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZ9pl07QvbPSByhxSeadRyErsYoXeb4vVdggm1LZP8Q=; b=fhQcqPGl5yhe2csMFFb9yGjIlEygkzFr/ikOMosZQIoU7Yji+laOrYHb CQk3L3++BbItkd1fTd41+1FtQJwj7NV06XW7jOM3KjQ4jSSVNHSNrwVBA n7bD1NUt00o3QMJiaxdUAl5MOAoxK7KJHHYNOyrOG/mX2a+ApXX9y93Xb blcHbiZBNRhlTb+Q/1sWXo7+RMNtZlSQNFc5+tyjDzSc7rdycvJE7MPRN 4u13i42I+7L92g6dVki4wXe+YSD6fnRNONHvjOEwDy9boQ/PUV6wcfNw1 fcBFVEOkRztCHbWlU2AVi4JMocoevWzrXsjfum/M6SZq+gsVmi1I+2aVY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="362047098" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="362047098" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 19:27:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="861747237" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="861747237" Received: from dpdk-limiao-icelake.sh.intel.com ([10.67.111.26]) by fmsmga001.fm.intel.com with ESMTP; 28 Jun 2023 19:26:58 -0700 From: Miao Li To: dev@dpdk.org Cc: stable@dpdk.org, Maxime Coquelin , Chenbo Xia , David Marchand Subject: [PATCH v2 1/2] net/virtio: fix legacy device IO port map in secondary process Date: Thu, 29 Jun 2023 02:26:52 +0000 Message-Id: <20230629022653.263046-1-miao.li@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230628063651.178604-1-miao.li@intel.com> References: <20230628063651.178604-1-miao.li@intel.com> MIME-Version: 1.0 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 When doing IO port map for legacy device in secondary process, vfio_cfg setup for legacy device like vfio_group_fd and vfio_dev_fd is missing. So, in secondary process, rte_pci_map_device is added for legacy device to setup vfio_cfg and fill in region info like in primary process. Fixes: 512e27eeb743 ("net/virtio: move PCI specific dev init to PCI ethdev init") Cc: stable@dpdk.org Signed-off-by: Miao Li Tested-by: Wei Ling --- drivers/net/virtio/virtio_pci_ethdev.c | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c index 9b4b846f8a..dc11a6e82f 100644 --- a/drivers/net/virtio/virtio_pci_ethdev.c +++ b/drivers/net/virtio/virtio_pci_ethdev.c @@ -44,23 +44,23 @@ virtio_remap_pci(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev) { struct virtio_hw *hw = &dev->hw; - if (dev->modern) { - /* - * We don't have to re-parse the PCI config space, since - * rte_pci_map_device() makes sure the mapped address - * in secondary process would equal to the one mapped in - * the primary process: error will be returned if that - * requirement is not met. - * - * That said, we could simply reuse all cap pointers - * (such as dev_cfg, common_cfg, etc.) parsed from the - * primary process, which is stored in shared memory. - */ - if (rte_pci_map_device(pci_dev)) { - PMD_INIT_LOG(DEBUG, "failed to map pci device!"); - return -1; - } - } else { + /* + * We don't have to re-parse the PCI config space, since + * rte_pci_map_device() makes sure the mapped address + * in secondary process would equal to the one mapped in + * the primary process: error will be returned if that + * requirement is not met. + * + * That said, we could simply reuse all cap pointers + * (such as dev_cfg, common_cfg, etc.) parsed from the + * primary process, which is stored in shared memory. + */ + if (rte_pci_map_device(pci_dev)) { + PMD_INIT_LOG(DEBUG, "failed to map pci device!"); + return -1; + } + + if (!dev->modern) { if (vtpci_legacy_ioport_map(hw) < 0) return -1; } From patchwork Thu Jun 29 02:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Miao" X-Patchwork-Id: 129090 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 787AD42D60; Thu, 29 Jun 2023 04:27:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D297F42D12; Thu, 29 Jun 2023 04:27:04 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 2AB90406B7; Thu, 29 Jun 2023 04:27:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688005623; x=1719541623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qp+WWECIcwwN89NkpLvVd8lRyRzRcX9/Z9CiIrGxAZI=; b=ZV39U/30nRghNo1QUBtgjWpioPGb63qdraibaWl642T7icSUv+PKy+Sh xISPdr/Uo5JhIRCe1G5TldMiao4OXtufF/padHpEMWJMYENKA3uAAnnnB RbrpcwP3UPoO1h74RfzVhHS/kHy60Njixrz8eFQc+gG1PgvdIWR7r622+ J7WzAQgAja13htFTEGt4YgrHK2qlDtm3rOf6ftzQ1wqG7Mb3TwfrLtFQJ 5JSKJOci8+9rAliExQo04d5Vaex9VazSUjj6gpSaQac0HxYuSoJCmfMGv Ol0pS11pwIjeDN2q7ErHcoDe5LD2Sjwyya74HB+UeHbg1QG0z6Ym9kiPO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="362047101" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="362047101" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 19:27:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="861747267" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="861747267" Received: from dpdk-limiao-icelake.sh.intel.com ([10.67.111.26]) by fmsmga001.fm.intel.com with ESMTP; 28 Jun 2023 19:27:01 -0700 From: Miao Li To: dev@dpdk.org Cc: stable@dpdk.org, Anatoly Burakov , Jonas Pfefferle Subject: [PATCH v2 2/2] bus/pci: add IO port region check before region map Date: Thu, 29 Jun 2023 02:26:53 +0000 Message-Id: <20230629022653.263046-2-miao.li@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230629022653.263046-1-miao.li@intel.com> References: <20230628063651.178604-1-miao.li@intel.com> <20230629022653.263046-1-miao.li@intel.com> MIME-Version: 1.0 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 This patch adds IO port region check to skip region map when doing IO port map for legacy device in secondary process. Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping") Cc: stable@dpdk.org Signed-off-by: Miao Li --- drivers/bus/pci/linux/pci_vfio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index e634de8322..dd4ca46120 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -1099,6 +1099,15 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev) maps = vfio_res->maps; for (i = 0; i < vfio_res->nb_maps; i++) { + /* chk for io port region */ + ret = pci_vfio_is_ioport_bar(dev, vfio_dev_fd, i); + if (ret < 0) { + goto err_vfio_dev_fd; + } else if (ret) { + RTE_LOG(INFO, EAL, "Ignore mapping IO port bar(%d)\n", i); + continue; + } + if (maps[i].nr_areas > 0) { ret = pci_vfio_sparse_mmap_bar(vfio_dev_fd, vfio_res, i, MAP_FIXED); if (ret < 0) {