diff mbox series

[v2] net/ice: fix memzone leak when firmware is missing

Message ID 20210706141237.30492-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers show
Series [v2] net/ice: fix memzone leak when firmware is missing | expand

Checks

Context Check Description
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

David Marchand July 6, 2021, 2:12 p.m. UTC
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")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
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(-)

Comments

Wang, Haiyue July 6, 2021, 3:07 p.m. UTC | #1
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Tuesday, July 6, 2021 22:13
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> Qi Z <qi.z.zhang@intel.com>; Stillwell Jr, Paul M <paul.m.stillwell.jr@intel.com>
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> 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(-)

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0
Zhang, Qi Z July 7, 2021, 12:35 a.m. UTC | #2
> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang@intel.com>
> Sent: Tuesday, July 6, 2021 11:07 PM
> To: David Marchand <david.marchand@redhat.com>; dev@dpdk.org
> Cc: stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Stillwell Jr, Paul M <paul.m.stillwell.jr@intel.com>
> Subject: RE: [PATCH v2] net/ice: fix memzone leak when firmware is missing
> 
> > -----Original Message-----
> > From: David Marchand <david.marchand@redhat.com>
> > Sent: Tuesday, July 6, 2021 22:13
> > To: dev@dpdk.org
> > Cc: Wang, Haiyue <haiyue.wang@intel.com>; stable@dpdk.org; Yang,
> > Qiming <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> > Stillwell Jr, Paul M <paul.m.stillwell.jr@intel.com>
> > 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")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > 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(-)
> 
> Acked-by: Haiyue Wang <haiyue.wang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> > --
> > 2.23.0
>
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 09e38590e5..2b5f406405 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -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;
 }