Skip to contentSkip to conversation

net/ice: fix memzone leak when firmware is missing

PATCH Superseded David Marchand 3 participants 10 messages Jul 6, 2021 – Jul 7, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix memzone leak when firmware is missing

Caught by our QE.
When the firmware is missing, memzones were not released.

$ dpdk-testpmd -c 0x1f -a 0:0:0.0 -- -i
...

testpmd> dump_memzone
...
Zone 6: name:<RTE_METRICS>, len:0x15040, virt:0x1661b24c0, socket_id:0, flags:0
physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

testpmd> port attach 0000:5e:00.0
Attaching a new port...
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0) ice_load_pkg(): failed to open file: /lib/firmware/intel/ice/ddp/ice.pkg

ice_dev_init(): Failed to load the DDP package,Use safe-mode-support=1 to
enter Safe Mode
EAL: Releasing PCI mapped resource for 0000:5e:00.0
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2200000000
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2202000000
EAL: Driver cannot attach the device (0000:5e:00.0)
EAL: Failed to attach device on primary process
testpmd: Failed to attach port 0000:5e:00.0

testpmd> dump_memzone
...
Zone 139: name:<ice_dma_17168374657430093156>, len:0x1000,
virt:0x1660ed800, socket_id:0, flags:0 physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

With 20 tries attaching a net/ice port, we would end up with:

EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
EAL: memzone_reserve_aligned_thread_unsafe(): Number of requested memzone
segments exceeds RTE_MAX_MEMZONE
ice_dev_init(): Failed to initialize HW

Fixes a4c8c48fe3f4 ("net/ice: load OS default package")
---
 drivers/net/ice/ice_ethdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +3 -1
index 09e38590e5..f85c7cc8da 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
 		if (ad->devargs.safe_mode_support == 0) {
 			PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
 					"Use safe-mode-support=1 to enter Safe Mode");
-			return ret;
+			goto err_init_fw;
 		}
 
 		PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
@@ -2175,6 +2175,8 @@ ice_dev_init(struct rte_eth_dev *dev)
 	rte_free(dev->data->mac_addrs);
 	dev->data->mac_addrs = NULL;
 err_init_mac:
+	ice_free_hw_tbls(hw);
+err_init_fw:
 	ice_sched_cleanup_all(hw);
 	rte_free(hw->port_info);
 	ice_shutdown_all_ctrlq(hw);
Signature · 1 line
2.23.0
#1 lore raw
Quoted 71 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 6, 2021 16:57
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: [PATCH] net/ice: fix memzone leak when firmware is missing

Caught by our QE.
When the firmware is missing, memzones were not released.

$ dpdk-testpmd -c 0x1f -a 0:0:0.0 -- -i
...

testpmd> dump_memzone
...
Zone 6: name:<RTE_METRICS>, len:0x15040, virt:0x1661b24c0, socket_id:0, flags:0
physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

testpmd> port attach 0000:5e:00.0
Attaching a new port...
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0) ice_load_pkg(): failed to open file: /lib/firmware/intel/ice/ddp/ice.pkg

ice_dev_init(): Failed to load the DDP package,Use safe-mode-support=1 to
enter Safe Mode
EAL: Releasing PCI mapped resource for 0000:5e:00.0
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2200000000
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2202000000
EAL: Driver cannot attach the device (0000:5e:00.0)
EAL: Failed to attach device on primary process
testpmd: Failed to attach port 0000:5e:00.0

testpmd> dump_memzone
...
Zone 139: name:<ice_dma_17168374657430093156>, len:0x1000,
virt:0x1660ed800, socket_id:0, flags:0 physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

With 20 tries attaching a net/ice port, we would end up with:

EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
EAL: memzone_reserve_aligned_thread_unsafe(): Number of requested memzone
segments exceeds RTE_MAX_MEMZONE
ice_dev_init(): Failed to initialize HW

Fixes a4c8c48fe3f4 ("net/ice: load OS default package")
---
 drivers/net/ice/ice_ethdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +1 -1
index 09e38590e5..f85c7cc8da 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
 		if (ad->devargs.safe_mode_support == 0) {
 			PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
 					"Use safe-mode-support=1 to enter Safe Mode");
-			return ret;
+			goto err_init_fw;
 		}
 
 		PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2182

Quoted 8 lines
drivers/net/ice/ice_ethdev.c +2 -0
@@ -2175,6 +2175,8 @@ ice_dev_init(struct rte_eth_dev *dev)
 	rte_free(dev->data->mac_addrs);
 	dev->data->mac_addrs = NULL;
 err_init_mac:
+	ice_free_hw_tbls(hw);
+err_init_fw:
 	ice_sched_cleanup_all(hw);
 	rte_free(hw->port_info);
 	ice_shutdown_all_ctrlq(hw);

The function 'ice_deinit_hw' should be used. ;-)

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/ice/ice_main.c#n4508

drivers/net/ice/ice_ethdev.c +3 -4
index 09e38590e5..c777474468 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
                if (ad->devargs.safe_mode_support == 0) {
                        PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                        "Use safe-mode-support=1 to enter Safe Mode");
-                       return ret;
+                       goto err_init_fw;
                }
 
                PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
@@ -2175,10 +2175,9 @@ ice_dev_init(struct rte_eth_dev *dev)
        rte_free(dev->data->mac_addrs);
        dev->data->mac_addrs = NULL;
 err_init_mac:
-       ice_sched_cleanup_all(hw);
-       rte_free(hw->port_info);
-       ice_shutdown_all_ctrlq(hw);
        rte_free(pf->proto_xtr);
+err_init_fw:
+       ice_deinit_hw(hw);
 
        return ret;
 }

====

Before attach:

testpmd> dump_memzone
Zone 0: name:<MP_mb_pool_1>, len:0x182100, virt:0x11ff954ec0, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 1: name:<RG_MP_mb_pool_1>, len:0x200180, virt:0x11ff754c00, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 2: name:<MP_mb_pool_1_0>, len:0x18333940, virt:0x11e7421240, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 3: name:<RTE_METRICS>, len:0x15040, virt:0x11e739f340, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
testpmd>

After attach:

testpmd> dump_memzone
Zone 0: name:<MP_mb_pool_1>, len:0x182100, virt:0x11ff954ec0, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 1: name:<RG_MP_mb_pool_1>, len:0x200180, virt:0x11ff754c00, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 2: name:<MP_mb_pool_1_0>, len:0x18333940, virt:0x11e7421240, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 3: name:<RTE_METRICS>, len:0x15040, virt:0x11e739f340, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000
Zone 4: name:<rte_eth_dev_data>, len:0x37040, virt:0x11e73670c0, socket_id:1, flags:0 physical segments used:
addr: 0x11c0000000 iova: 0x11c0000000 len: 0x40000000 pagesz: 0x40000000

Only the 'rte_eth_dev_data' is added.

Quoted 2 lines

--
2.23.0

#2 lore raw
Quoted 25 lines · Haiyue
Quoted 14 lines
drivers/net/ice/ice_ethdev.c +1 -1
index 09e38590e5..f85c7cc8da 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
              if (ad->devargs.safe_mode_support == 0) {
                      PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                      "Use safe-mode-support=1 to enter Safe Mode");
-                     return ret;
+                     goto err_init_fw;
              }
 
              PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2182

Quoted 8 lines
drivers/net/ice/ice_ethdev.c +2 -0
@@ -2175,6 +2175,8 @@ ice_dev_init(struct rte_eth_dev *dev)
      rte_free(dev->data->mac_addrs);
      dev->data->mac_addrs = NULL;
 err_init_mac:
+     ice_free_hw_tbls(hw);
+err_init_fw:
      ice_sched_cleanup_all(hw);
      rte_free(hw->port_info);
      ice_shutdown_all_ctrlq(hw);

The function 'ice_deinit_hw' should be used. ;-)

Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/ice/ice_main.c#n4508

Well I was inspired by ice_dev_close(), so I guess this code too could use some cleanup but I don't have the hw anymore to test this change. I'll trust you and simply update ice_dev_init.

Quoted 15 lines
drivers/net/ice/ice_ethdev.c +1 -1
index 09e38590e5..c777474468 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
                if (ad->devargs.safe_mode_support == 0) {
                        PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                        "Use safe-mode-support=1 to enter Safe Mode");
-                       return ret;
+                       goto err_init_fw;
                }
 
                PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2179

Quoted 8 lines
drivers/net/ice/ice_ethdev.c +1 -3
@@ -2175,10 +2175,9 @@ ice_dev_init(struct rte_eth_dev *dev)
        rte_free(dev->data->mac_addrs);
        dev->data->mac_addrs = NULL;
 err_init_mac:
-       ice_sched_cleanup_all(hw);
-       rte_free(hw->port_info);
-       ice_shutdown_all_ctrlq(hw);
        rte_free(pf->proto_xtr);
+err_init_fw:

In such a case a single label should be enough, right?

Quoted 4 lines
drivers/net/ice/ice_ethdev.c +1 -0
+       ice_deinit_hw(hw);
 
        return ret;
 }
Signature · 1 line
David Marchand
#3 lore raw
Quoted 56 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 6, 2021 20:47
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: Re: [PATCH] net/ice: fix memzone leak when firmware is missing

Quoted 12 lines · Haiyue
Quoted 12 lines
drivers/net/ice/ice_ethdev.c +1 -1
index 09e38590e5..f85c7cc8da 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
              if (ad->devargs.safe_mode_support == 0) {
                      PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                      "Use safe-mode-support=1 to enter Safe Mode");
-                     return ret;
+                     goto err_init_fw;
              }
 
Quoted 14 lines

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2182

Quoted 10 lines
drivers/net/ice/ice_ethdev.c +2 -0
              PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
@@ -2175,6 +2175,8 @@ ice_dev_init(struct rte_eth_dev *dev)
      rte_free(dev->data->mac_addrs);
      dev->data->mac_addrs = NULL;
 err_init_mac:
+     ice_free_hw_tbls(hw);
+err_init_fw:
      ice_sched_cleanup_all(hw);
      rte_free(hw->port_info);
      ice_shutdown_all_ctrlq(hw);

The function 'ice_deinit_hw' should be used. ;-)

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/ice
/ice_main.c#n4508

Well I was inspired by ice_dev_close(), so I guess this code too could use some cleanup but I don't have the hw anymore to test this change. I'll trust you and simply update ice_dev_init.

Quoted 13 lines
drivers/net/ice/ice_ethdev.c +1 -1
index 09e38590e5..c777474468 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
                if (ad->devargs.safe_mode_support == 0) {
                        PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
                                        "Use safe-mode-support=1 to enter Safe Mode");
-                       return ret;
+                       goto err_init_fw;
                }
 
Quoted 12 lines

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2179

Quoted 10 lines
drivers/net/ice/ice_ethdev.c +1 -3
                PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
@@ -2175,10 +2175,9 @@ ice_dev_init(struct rte_eth_dev *dev)
        rte_free(dev->data->mac_addrs);
        dev->data->mac_addrs = NULL;
 err_init_mac:
-       ice_sched_cleanup_all(hw);
-       rte_free(hw->port_info);
-       ice_shutdown_all_ctrlq(hw);
        rte_free(pf->proto_xtr);
+err_init_fw:

In such a case a single label should be enough, right?

Yes, since pf->proto_xtr = NULL can be 'freed' safely.

Quoted 10 lines

drivers/net/ice/ice_ethdev.c ice_dev_init(struct rte_eth_dev *dev) · line 2183

Quoted 6 lines
drivers/net/ice/ice_ethdev.c +1 -0
+       ice_deinit_hw(hw);
 
        return ret;
 }

--
David Marchand

#4 lore raw
Quoted 9 lines · Haiyue
Quoted 9 lines
Quoted 3 lines

The function 'ice_deinit_hw' should be used. ;-)

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/ice
/ice_main.c#n4508

Well I was inspired by ice_dev_close(), so I guess this code too could use some cleanup but I don't have the hw anymore to test this change. I'll trust you and simply update ice_dev_init.

Adding to this, there are other potential leaks if ice_flow_init() or ice_reset_fxp_resource() fails.
Probably worth opening a bz for later processing.
WDYT?

Signature · 1 line
David Marchand
#5 lore raw
Quoted 16 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 6, 2021 21:28
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: Re: [PATCH] net/ice: fix memzone leak when firmware is missing

Quoted 4 lines · Haiyue
Quoted 4 lines
Quoted 3 lines

The function 'ice_deinit_hw' should be used. ;-)

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/ice

Quoted 2 lines
Quoted 2 lines

/ice_main.c#n4508

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Well I was inspired by ice_dev_close(), so I guess this code too could use some cleanup but I don't have the hw anymore to test this change. I'll trust you and simply update ice_dev_init.

Adding to this, there are other potential leaks if ice_flow_init() or ice_reset_fxp_resource() fails.
Probably worth opening a bz for later processing.
WDYT?

Yeah, make sense. ;-)

Quoted 4 lines

--
David Marchand

#6 lore raw
In reply to Wang, Haiyue
Quoted 3 lines · Haiyue
Quoted 1 line

In such a case a single label should be enough, right?

Yes, since pf->proto_xtr = NULL can be 'freed' safely.

Ah ok, I thought proto_xtr was initialised earlier and I had missed the ice_pf_sw_init() call.
I'll go with your suggestion.
Thanks.

Signature · 1 line
David Marchand
#7 lore raw

PATCH v2 1/1 net/ice: fix memzone leak when firmware is missing

In reply to David Marchand

Caught by our QE.
When the firmware is missing, memzones were not released.

$ dpdk-testpmd -c 0x1f -a 0:0:0.0 -- -i
...

testpmd> dump_memzone
...
Zone 6: name:<RTE_METRICS>, len:0x15040, virt:0x1661b24c0, socket_id:0, flags:0
physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

testpmd> port attach 0000:5e:00.0
Attaching a new port...
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0) ice_load_pkg(): failed to open file: /lib/firmware/intel/ice/ddp/ice.pkg

ice_dev_init(): Failed to load the DDP package,Use safe-mode-support=1 to
enter Safe Mode
EAL: Releasing PCI mapped resource for 0000:5e:00.0
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2200000000
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2202000000
EAL: Driver cannot attach the device (0000:5e:00.0)
EAL: Failed to attach device on primary process
testpmd: Failed to attach port 0000:5e:00.0

testpmd> dump_memzone
...
Zone 139: name:<ice_dma_17168374657430093156>, len:0x1000,
virt:0x1660ed800, socket_id:0, flags:0 physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

With 20 tries attaching a net/ice port, we would end up with:

EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
EAL: memzone_reserve_aligned_thread_unsafe(): Number of requested memzone
segments exceeds RTE_MAX_MEMZONE
ice_dev_init(): Failed to initialize HW

Fixes a4c8c48fe3f4 ("net/ice: load OS default package")

---
Changes since v1:
- switch to ice_deinit_hw() helper,
- fix build for Windows,

---
 drivers/net/ice/ice_ethdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/ice/ice_ethdev.c +5 -4
index 09e38590e5..2b5f406405 100644
@@ -2085,7 +2085,7 @@ ice_dev_init(struct rte_eth_dev *dev)
 		if (ad->devargs.safe_mode_support == 0) {
 			PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
 					"Use safe-mode-support=1 to enter Safe Mode");
-			return ret;
+			goto err_init_fw;
 		}
 
 		PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
@@ -2175,10 +2175,11 @@ ice_dev_init(struct rte_eth_dev *dev)
 	rte_free(dev->data->mac_addrs);
 	dev->data->mac_addrs = NULL;
 err_init_mac:
-	ice_sched_cleanup_all(hw);
-	rte_free(hw->port_info);
-	ice_shutdown_all_ctrlq(hw);
 	rte_free(pf->proto_xtr);
+#ifndef RTE_EXEC_ENV_WINDOWS
+err_init_fw:
+#endif
+	ice_deinit_hw(hw);
 
 	return ret;
 }
Signature · 1 line
2.23.0
Acked-by on v2 1/1
#8 lore raw
Quoted 53 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 6, 2021 22:13
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: [PATCH v2] net/ice: fix memzone leak when firmware is missing

Caught by our QE.
When the firmware is missing, memzones were not released.

$ dpdk-testpmd -c 0x1f -a 0:0:0.0 -- -i
...

testpmd> dump_memzone
...
Zone 6: name:<RTE_METRICS>, len:0x15040, virt:0x1661b24c0, socket_id:0, flags:0
physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

testpmd> port attach 0000:5e:00.0
Attaching a new port...
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0) ice_load_pkg(): failed to open file: /lib/firmware/intel/ice/ddp/ice.pkg

ice_dev_init(): Failed to load the DDP package,Use safe-mode-support=1 to
enter Safe Mode
EAL: Releasing PCI mapped resource for 0000:5e:00.0
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2200000000
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2202000000
EAL: Driver cannot attach the device (0000:5e:00.0)
EAL: Failed to attach device on primary process
testpmd: Failed to attach port 0000:5e:00.0

testpmd> dump_memzone
...
Zone 139: name:<ice_dma_17168374657430093156>, len:0x1000,
virt:0x1660ed800, socket_id:0, flags:0 physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz: 0x40000000

With 20 tries attaching a net/ice port, we would end up with:

EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
EAL: memzone_reserve_aligned_thread_unsafe(): Number of requested memzone
segments exceeds RTE_MAX_MEMZONE
ice_dev_init(): Failed to initialize HW

Fixes a4c8c48fe3f4 ("net/ice: load OS default package")
Quoted 8 lines

---
Changes since v1:
- switch to ice_deinit_hw() helper,
- fix build for Windows,

---
 drivers/net/ice/ice_ethdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Quoted 2 lines

--
2.23.0

Applied
#9 lore raw
Quoted 75 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Tuesday, July 6, 2021 11:07 PM
To: David Marchand <[email protected]>; [email protected]
Cc: [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: RE: [PATCH v2] net/ice: fix memzone leak when firmware is missing

Quoted 47 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, July 6, 2021 22:13
To: [email protected]
Cc: Wang, Haiyue <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Stillwell Jr, Paul M <[email protected]>
Subject: [PATCH v2] net/ice: fix memzone leak when firmware is missing

Caught by our QE.
When the firmware is missing, memzones were not released.

$ dpdk-testpmd -c 0x1f -a 0:0:0.0 -- -i ...

testpmd> dump_memzone
...
Zone 6: name:<RTE_METRICS>, len:0x15040, virt:0x1661b24c0, socket_id:0,
flags:0
physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz:
0x40000000

testpmd> port attach 0000:5e:00.0
Attaching a new port...
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
ice_load_pkg(): failed to open file:
/lib/firmware/intel/ice/ddp/ice.pkg

ice_dev_init(): Failed to load the DDP package,Use safe-mode-support=1 to enter Safe Mode
EAL: Releasing PCI mapped resource for 0000:5e:00.0
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2200000000
EAL: Calling pci_unmap_resource for 0000:5e:00.0 at 0x2202000000
EAL: Driver cannot attach the device (0000:5e:00.0)
EAL: Failed to attach device on primary process
testpmd: Failed to attach port 0000:5e:00.0

testpmd> dump_memzone
...
Zone 139: name:<ice_dma_17168374657430093156>, len:0x1000,
virt:0x1660ed800, socket_id:0, flags:0 physical segments used:
addr: 0x140000000 iova: 0x140000000 len: 0x40000000 pagesz:
0x40000000

Quoted 5 lines

With 20 tries attaching a net/ice port, we would end up with:

EAL: Probe PCI driver: net_ice (8086:159b) device: 0000:5e:00.0 (socket 0)
EAL: memzone_reserve_aligned_thread_unsafe(): Number of requested

memzone

Quoted 12 lines

segments exceeds RTE_MAX_MEMZONE
ice_dev_init(): Failed to initialize HW

Fixes a4c8c48fe3f4 ("net/ice: load OS default package")

---
Changes since v1:
- switch to ice_deinit_hw() helper,
- fix build for Windows,

Quoted 5 lines
Quoted 3 lines
---
 drivers/net/ice/ice_ethdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Applied to dpdk-next-net-intel.

Thanks
Qi

Quoted 4 lines
Quoted 3 lines

--
2.23.0