Skip to contentSkip to conversation

net/virtio: unmap PCI device in secondary process

PATCH Superseded Yuan Wang 3 participants 8 messages Apr 21, 2022 – Jun 20, 2022 Network drivers

lore
Share & tools
lore

Yuan Wang

author
#0 lore raw

PATCH 1/1 net/virtio: unmap PCI device in secondary process

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")
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +11 -1
index 54645dc62e..1f6bdeddda 100644
@@ -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);
Signature · 1 line
2.25.1
#2 lore raw
In reply to Yuan Wang
Quoted 8 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, April 21, 2022 7:16 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH] net/virtio: unmap PCI device in secondary process

Quoted 6 lines

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

unmaps

Quoted 1 line

based on virtio_rempa_pci().

Virtio_remap_pci

Quoted 2 lines
Fixes 36a7a2e7a53 ("net/virtio: move PCI device init in dedicated file")

Miss cc-stable tag. Patch LGTM

Thanks,
Chenbo

Quoted 35 lines
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +11 -2
index 54645dc62e..1f6bdeddda 100644
@@ -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

#3 lore raw

Hi Chenbo,

Quoted 27 lines

-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, May 30, 2022 10:49 AM
To: Wang, YuanX <[email protected]>; [email protected]
Cc: [email protected]; Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>
Subject: RE: [PATCH] net/virtio: unmap PCI device in secondary process

Quoted 8 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, April 21, 2022 7:16 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH] net/virtio: unmap PCI device in secondary process

Quoted 6 lines

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

unmaps

Quoted 1 line

based on virtio_rempa_pci().

Quoted 7 lines

Virtio_remap_pci

Quoted 3 lines
Fixes 36a7a2e7a53 ("net/virtio: move PCI device init in dedicated

file")

Miss cc-stable tag. Patch LGTM

Thanks, will fix it in next version.

Regards,
Yuan

Quoted 39 lines

Thanks,
Chenbo

Quoted 15 lines
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +1 -0
index 54645dc62e..1f6bdeddda 100644
@@ -122,10 +122,20 @@ static int
 eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev)  {
 	int ret;
+	struct virtio_pci_dev *dev;

drivers/net/virtio/virtio_pci_ethdev.c static int · line 133

Quoted 10 lines
drivers/net/virtio/virtio_pci_ethdev.c +7 -1
+	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));
Quoted 9 lines
drivers/net/virtio/virtio_pci_ethdev.c +3 -1
+		else
+			vtpci_legacy_ioport_unmap(hw);
 		return 0;
+	}
 
 	ret = virtio_dev_stop(eth_dev);
 	virtio_dev_close(eth_dev);
--

2.25.1

author
#4 lore raw

PATCH v2 1/1 net/virtio: unmap PCI device in secondary process

In reply to Yuan Wang

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")
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +11 -1
index 54645dc62e..1f6bdeddda 100644
@@ -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);
Signature · 1 line
2.25.1
Tested-by on v2 1/1
#5 lore raw
Quoted 17 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Monday, June 6, 2022 11:56 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Ling, WeiX <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Subject: [PATCH v2] net/virtio: unmap PCI device in secondary process

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.

Quoted 6 lines
Fixes 36a7a2e7a53 ("net/virtio: move PCI device init in dedicated file")

---

Reviewed-by on v2 1/1
#6 lore raw
In reply to Yuan Wang
Quoted 15 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Monday, June 6, 2022 11:56 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Ling, WeiX <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Subject: [PATCH v2] net/virtio: unmap PCI device in secondary process

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.

Quoted 4 lines

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")

This should be 12 digits, not 11

With this fixed:

Quoted 37 lines
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +11 -2
index 54645dc62e..1f6bdeddda 100644
@@ -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

#7 lore raw

Hi Chenbo,

Quoted 25 lines

-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Monday, June 20, 2022 11:38 AM
To: Wang, YuanX <[email protected]>; [email protected]; [email protected]
Cc: Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Ling, WeiX <[email protected]>; [email protected]
Subject: RE: [PATCH v2] net/virtio: unmap PCI device in secondary process

Quoted 15 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Monday, June 6, 2022 11:56 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; He, Xingguang <[email protected]>; Ling, WeiX <[email protected]>; Wang, YuanX <[email protected]>; [email protected]
Subject: [PATCH v2] net/virtio: unmap PCI device in secondary process

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.

Quoted 7 lines
Quoted 5 lines

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")

This should be 12 digits, not 11

Thanks, will be fixed at the next version.

Thanks,
Yuan

Quoted 42 lines

With this fixed:

Quoted 17 lines
---
 drivers/net/virtio/virtio_pci_ethdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_pci_ethdev.c +1 -0
index 54645dc62e..1f6bdeddda 100644
@@ -122,10 +122,20 @@ static int
 eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev)  {
 	int ret;
+	struct virtio_pci_dev *dev;

drivers/net/virtio/virtio_pci_ethdev.c static int · line 133

Quoted 10 lines
drivers/net/virtio/virtio_pci_ethdev.c +7 -1
+	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));
Quoted 9 lines
drivers/net/virtio/virtio_pci_ethdev.c +3 -1
+		else
+			vtpci_legacy_ioport_unmap(hw);
 		return 0;
+	}
 
 	ret = virtio_dev_stop(eth_dev);
 	virtio_dev_close(eth_dev);
--

2.25.1