All of lore.kernel.org
 help / color / mirror / Atom feed
* [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25
@ 2020-09-25 21:09 Tony Nguyen
  2020-09-25 21:09 ` [net v2 1/4] iavf: Fix incorrect adapter get in iavf_resume Tony Nguyen
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tony Nguyen @ 2020-09-25 21:09 UTC (permalink / raw)
  To: davem; +Cc: Tony Nguyen, netdev, nhorman, sassmann

This series contains updates to the iavf and ice driver.

Sylwester fixes a crash with iavf resume due to getting the wrong pointers.

Ani fixes a call trace in ice resume by calling pci_save_state().

Jakes fixes memory leaks in case of register_netdev() failure or
ice_cfg_vsi_lan() failure for the ice driver.

v2: Rebased; no other changes

The following are changes since commit ad2b9b0f8d0107602bdc1f3b1ab90719842ace11:
  tcp: skip DSACKs with dubious sequence ranges
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue 100GbE

Anirudh Venkataramanan (1):
  ice: Fix call trace on suspend

Jacob Keller (2):
  ice: fix memory leak if register_netdev_fails
  ice: fix memory leak in ice_vsi_setup

Sylwester Dziedziuch (1):
  iavf: Fix incorrect adapter get in iavf_resume

 drivers/net/ethernet/intel/iavf/iavf_main.c |  4 ++--
 drivers/net/ethernet/intel/ice/ice_lib.c    | 20 ++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_lib.h    |  6 ------
 drivers/net/ethernet/intel/ice/ice_main.c   | 14 ++++----------
 4 files changed, 22 insertions(+), 22 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [net v2 1/4] iavf: Fix incorrect adapter get in iavf_resume
  2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
@ 2020-09-25 21:09 ` Tony Nguyen
  2020-09-25 21:09 ` [net v2 2/4] ice: Fix call trace on suspend Tony Nguyen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2020-09-25 21:09 UTC (permalink / raw)
  To: davem
  Cc: Sylwester Dziedziuch, netdev, nhorman, sassmann,
	anthony.l.nguyen, Aleksandr Loktionov, Aaron Brown

From: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>

When calling iavf_resume there was a crash because wrong
function was used to get iavf_adapter and net_device pointers.
Changed how iavf_resume is getting iavf_adapter and net_device
pointers from pci_dev.

Fixes: 5eae00c57f5e ("i40evf: main driver core")
Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index d870343cf689..cf539db79af9 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -3806,8 +3806,8 @@ static int __maybe_unused iavf_suspend(struct device *dev_d)
 static int __maybe_unused iavf_resume(struct device *dev_d)
 {
 	struct pci_dev *pdev = to_pci_dev(dev_d);
-	struct iavf_adapter *adapter = pci_get_drvdata(pdev);
-	struct net_device *netdev = adapter->netdev;
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct iavf_adapter *adapter = netdev_priv(netdev);
 	u32 err;
 
 	pci_set_master(pdev);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net v2 2/4] ice: Fix call trace on suspend
  2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
  2020-09-25 21:09 ` [net v2 1/4] iavf: Fix incorrect adapter get in iavf_resume Tony Nguyen
@ 2020-09-25 21:09 ` Tony Nguyen
  2020-09-25 21:09 ` [net v2 3/4] ice: fix memory leak if register_netdev_fails Tony Nguyen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2020-09-25 21:09 UTC (permalink / raw)
  To: davem
  Cc: Anirudh Venkataramanan, netdev, nhorman, sassmann,
	anthony.l.nguyen, Aaron Brown

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

It appears that the ice_suspend flow is missing a call to pci_save_state
and this is triggering the message "State of device not saved by
ice_suspend" and a call trace. Fix it.

Fixes: 769c500dcc1e ("ice: Add advanced power mgmt for WoL")
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 4634b48949bb..954f11f86f50 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4522,6 +4522,7 @@ static int __maybe_unused ice_suspend(struct device *dev)
 	}
 	ice_clear_interrupt_scheme(pf);
 
+	pci_save_state(pdev);
 	pci_wake_from_d3(pdev, pf->wol_ena);
 	pci_set_power_state(pdev, PCI_D3hot);
 	return 0;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net v2 3/4] ice: fix memory leak if register_netdev_fails
  2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
  2020-09-25 21:09 ` [net v2 1/4] iavf: Fix incorrect adapter get in iavf_resume Tony Nguyen
  2020-09-25 21:09 ` [net v2 2/4] ice: Fix call trace on suspend Tony Nguyen
@ 2020-09-25 21:09 ` Tony Nguyen
  2020-09-25 21:09 ` [net v2 4/4] ice: fix memory leak in ice_vsi_setup Tony Nguyen
  2020-09-25 23:24 ` [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2020-09-25 21:09 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, anthony.l.nguyen, Aaron Brown

From: Jacob Keller <jacob.e.keller@intel.com>

The ice_setup_pf_sw function can cause a memory leak if register_netdev
fails, due to accidentally failing to free the VSI rings. Fix the memory
leak by using ice_vsi_release, ensuring we actually go through the full
teardown process.

This should be safe even if the netdevice is not registered because we
will have set the netdev pointer to NULL, ensuring ice_vsi_release won't
call unregister_netdev.

An alternative fix would be moving management of the PF VSI netdev into
the main VSI setup code. This is complicated and likely requires
significant refactor in how we manage VSIs

Fixes: 3a858ba392c3 ("ice: Add support for VSI allocation and deallocation")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c  |  6 +++---
 drivers/net/ethernet/intel/ice/ice_lib.h  |  6 ------
 drivers/net/ethernet/intel/ice/ice_main.c | 13 +++----------
 3 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index f2682776f8c8..65cc78279501 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -246,7 +246,7 @@ static int ice_get_free_slot(void *array, int size, int curr)
  * ice_vsi_delete - delete a VSI from the switch
  * @vsi: pointer to VSI being removed
  */
-void ice_vsi_delete(struct ice_vsi *vsi)
+static void ice_vsi_delete(struct ice_vsi *vsi)
 {
 	struct ice_pf *pf = vsi->back;
 	struct ice_vsi_ctx *ctxt;
@@ -313,7 +313,7 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi)
  *
  * Returns 0 on success, negative on failure
  */
-int ice_vsi_clear(struct ice_vsi *vsi)
+static int ice_vsi_clear(struct ice_vsi *vsi)
 {
 	struct ice_pf *pf = NULL;
 	struct device *dev;
@@ -563,7 +563,7 @@ static int ice_vsi_get_qs(struct ice_vsi *vsi)
  * ice_vsi_put_qs - Release queues from VSI to PF
  * @vsi: the VSI that is going to release queues
  */
-void ice_vsi_put_qs(struct ice_vsi *vsi)
+static void ice_vsi_put_qs(struct ice_vsi *vsi)
 {
 	struct ice_pf *pf = vsi->back;
 	int i;
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h
index 981f3a156c24..3da17895a2b1 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_lib.h
@@ -45,10 +45,6 @@ int ice_cfg_vlan_pruning(struct ice_vsi *vsi, bool ena, bool vlan_promisc);
 
 void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create);
 
-void ice_vsi_delete(struct ice_vsi *vsi);
-
-int ice_vsi_clear(struct ice_vsi *vsi);
-
 #ifdef CONFIG_DCB
 int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);
 #endif /* CONFIG_DCB */
@@ -79,8 +75,6 @@ bool ice_is_reset_in_progress(unsigned long *state);
 void
 ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio);
 
-void ice_vsi_put_qs(struct ice_vsi *vsi);
-
 void ice_vsi_dis_irq(struct ice_vsi *vsi);
 
 void ice_vsi_free_irq(struct ice_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 954f11f86f50..54a7f55eb8c1 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3169,10 +3169,8 @@ static int ice_setup_pf_sw(struct ice_pf *pf)
 		return -EBUSY;
 
 	vsi = ice_pf_vsi_setup(pf, pf->hw.port_info);
-	if (!vsi) {
-		status = -ENOMEM;
-		goto unroll_vsi_setup;
-	}
+	if (!vsi)
+		return -ENOMEM;
 
 	status = ice_cfg_netdev(vsi);
 	if (status) {
@@ -3219,12 +3217,7 @@ static int ice_setup_pf_sw(struct ice_pf *pf)
 	}
 
 unroll_vsi_setup:
-	if (vsi) {
-		ice_vsi_free_q_vectors(vsi);
-		ice_vsi_delete(vsi);
-		ice_vsi_put_qs(vsi);
-		ice_vsi_clear(vsi);
-	}
+	ice_vsi_release(vsi);
 	return status;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net v2 4/4] ice: fix memory leak in ice_vsi_setup
  2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
                   ` (2 preceding siblings ...)
  2020-09-25 21:09 ` [net v2 3/4] ice: fix memory leak if register_netdev_fails Tony Nguyen
@ 2020-09-25 21:09 ` Tony Nguyen
  2020-09-25 23:24 ` [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2020-09-25 21:09 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, anthony.l.nguyen, Aaron Brown

From: Jacob Keller <jacob.e.keller@intel.com>

During ice_vsi_setup, if ice_cfg_vsi_lan fails, it does not properly
release memory associated with the VSI rings. If we had used devres
allocations for the rings, this would be ok. However, we use kzalloc and
kfree_rcu for these ring structures.

Using the correct label to cleanup the rings during ice_vsi_setup
highlights an issue in the ice_vsi_clear_rings function: it can leave
behind stale ring pointers in the q_vectors structure.

When releasing rings, we must also ensure that no q_vector associated
with the VSI will point to this ring again. To resolve this, loop over
all q_vectors and release their ring mapping. Because we are about to
free all rings, no q_vector should remain pointing to any of the rings
in this VSI.

Fixes: 5513b920a4f7 ("ice: Update Tx scheduler tree for VSI multi-Tx queue support")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 65cc78279501..ebbb8f54871c 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1196,6 +1196,18 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi)
 {
 	int i;
 
+	/* Avoid stale references by clearing map from vector to ring */
+	if (vsi->q_vectors) {
+		ice_for_each_q_vector(vsi, i) {
+			struct ice_q_vector *q_vector = vsi->q_vectors[i];
+
+			if (q_vector) {
+				q_vector->tx.ring = NULL;
+				q_vector->rx.ring = NULL;
+			}
+		}
+	}
+
 	if (vsi->tx_rings) {
 		for (i = 0; i < vsi->alloc_txq; i++) {
 			if (vsi->tx_rings[i]) {
@@ -2291,7 +2303,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
 	if (status) {
 		dev_err(dev, "VSI %d failed lan queue config, error %s\n",
 			vsi->vsi_num, ice_stat_str(status));
-		goto unroll_vector_base;
+		goto unroll_clear_rings;
 	}
 
 	/* Add switch rule to drop all Tx Flow Control Frames, of look up
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25
  2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
                   ` (3 preceding siblings ...)
  2020-09-25 21:09 ` [net v2 4/4] ice: fix memory leak in ice_vsi_setup Tony Nguyen
@ 2020-09-25 23:24 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-09-25 23:24 UTC (permalink / raw)
  To: anthony.l.nguyen; +Cc: netdev, nhorman, sassmann

From: Tony Nguyen <anthony.l.nguyen@intel.com>
Date: Fri, 25 Sep 2020 14:09:26 -0700

> This series contains updates to the iavf and ice driver.
> 
> Sylwester fixes a crash with iavf resume due to getting the wrong pointers.
> 
> Ani fixes a call trace in ice resume by calling pci_save_state().
> 
> Jakes fixes memory leaks in case of register_netdev() failure or
> ice_cfg_vsi_lan() failure for the ice driver.
> 
> v2: Rebased; no other changes

Pulled, thanks Tony.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-25 23:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 21:09 [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 Tony Nguyen
2020-09-25 21:09 ` [net v2 1/4] iavf: Fix incorrect adapter get in iavf_resume Tony Nguyen
2020-09-25 21:09 ` [net v2 2/4] ice: Fix call trace on suspend Tony Nguyen
2020-09-25 21:09 ` [net v2 3/4] ice: fix memory leak if register_netdev_fails Tony Nguyen
2020-09-25 21:09 ` [net v2 4/4] ice: fix memory leak in ice_vsi_setup Tony Nguyen
2020-09-25 23:24 ` [net v2 0/4][pull request] Intel Wired LAN Driver Updates 2020-09-25 David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.