Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net v1] i40e: fix rtnl locking when setting up pf switch
@ 2021-03-12 11:21 Mateusz Palczewski
  2021-03-16  1:27 ` Nguyen, Anthony L
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Palczewski @ 2021-03-12 11:21 UTC (permalink / raw)
  To: intel-wired-lan

From: Jan Sokolowski <jan.sokolowski@intel.com>

A recent change that made i40e use new udp_tunnel infrastructure
uses a method that expects to be called under rtnl_lock.

Not all codepaths however made that lock when calling
i40e_setup_pf_switch.

Fix a stacktrace by adding additional rtnl locking and unlocking.

Fixes: 40a98cb6f01f ("i40e: convert to new udp_tunnel infrastructure")
Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 71f14c4..8c2072c 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -31,7 +31,7 @@ static void i40e_vsi_reinit_locked(struct i40e_vsi *vsi);
 static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
 static int i40e_add_vsi(struct i40e_vsi *vsi);
 static int i40e_add_veb(struct i40e_veb *veb, struct i40e_vsi *vsi);
-static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit);
+static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
 static int i40e_setup_misc_vector(struct i40e_pf *pf);
 static void i40e_determine_queue_usage(struct i40e_pf *pf);
 static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
@@ -10576,7 +10576,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
 
 	if (!lock_acquired)
 		rtnl_lock();
-	ret = i40e_setup_pf_switch(pf, reinit);
+	ret = i40e_setup_pf_switch(pf, reinit, true);
 	if (ret)
 		goto end_unlock;
 
@@ -14659,7 +14659,7 @@ int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig)
  *
  * Returns 0 on success, negative value on failure
  **/
-static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
+static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired)
 {
 	u16 flags = 0;
 	int ret;
@@ -14761,9 +14761,14 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
 
 	i40e_ptp_init(pf);
 
+	if (!lock_acquired)
+		rtnl_lock();
 	/* repopulate tunnel port filters */
 	udp_tunnel_nic_reset_ntf(pf->vsi[pf->lan_vsi]->netdev);
 
+	if (!lock_acquired)
+		rtnl_unlock();
+
 	return ret;
 }
 
@@ -15556,7 +15561,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 			pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
 	}
 #endif
-	err = i40e_setup_pf_switch(pf, false);
+	err = i40e_setup_pf_switch(pf, false, false);
 	if (err) {
 		dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
 		goto err_vsis;
-- 
2.17.1


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

* [Intel-wired-lan] [PATCH net v1] i40e: fix rtnl locking when setting up pf switch
  2021-03-12 11:21 [Intel-wired-lan] [PATCH net v1] i40e: fix rtnl locking when setting up pf switch Mateusz Palczewski
@ 2021-03-16  1:27 ` Nguyen, Anthony L
  0 siblings, 0 replies; 2+ messages in thread
From: Nguyen, Anthony L @ 2021-03-16  1:27 UTC (permalink / raw)
  To: intel-wired-lan



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Mateusz Palczewski
> Sent: Friday, March 12, 2021 3:21 AM
> To: intel-wired-lan at lists.osuosl.org
> Cc: Palczewski, Mateusz <mateusz.palczewski@intel.com>
> Subject: [Intel-wired-lan] [PATCH net v1] i40e: fix rtnl locking when setting up pf
> switch
> 
> From: Jan Sokolowski <jan.sokolowski@intel.com>
> 
> A recent change that made i40e use new udp_tunnel infrastructure uses a
> method that expects to be called under rtnl_lock.
> 
> Not all codepaths however made that lock when calling i40e_setup_pf_switch.
> 
> Fix a stacktrace by adding additional rtnl locking and unlocking.
> 
> Fixes: 40a98cb6f01f ("i40e: convert to new udp_tunnel infrastructure")
> Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c
> b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 71f14c4..8c2072c 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -31,7 +31,7 @@ static void i40e_vsi_reinit_locked(struct i40e_vsi *vsi);
> static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
> static int i40e_add_vsi(struct i40e_vsi *vsi);  static int i40e_add_veb(struct
> i40e_veb *veb, struct i40e_vsi *vsi); -static int i40e_setup_pf_switch(struct
> i40e_pf *pf, bool reinit);
> +static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool
> +lock_acquired);
>  static int i40e_setup_misc_vector(struct i40e_pf *pf);  static void
> i40e_determine_queue_usage(struct i40e_pf *pf);  static int
> i40e_setup_pf_filter_control(struct i40e_pf *pf); @@ -10576,7 +10576,7 @@
> static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
> 
>  	if (!lock_acquired)
>  		rtnl_lock();
> -	ret = i40e_setup_pf_switch(pf, reinit);
> +	ret = i40e_setup_pf_switch(pf, reinit, true);
>  	if (ret)
>  		goto end_unlock;
> 
> @@ -14659,7 +14659,7 @@ int i40e_fetch_switch_configuration(struct i40e_pf
> *pf, bool printconfig)
>   *
>   * Returns 0 on success, negative value on failure
>   **/
> -static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
> +static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool
> +lock_acquired)

The new parameter needs to be documented:

drivers/net/ethernet/intel/i40e/i40e_main.c:14680: warning: Function parameter or member 'lock_acquired' not described in 'i40e_setup_pf_switch'  

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

end of thread, other threads:[~2021-03-16  1:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-12 11:21 [Intel-wired-lan] [PATCH net v1] i40e: fix rtnl locking when setting up pf switch Mateusz Palczewski
2021-03-16  1:27 ` Nguyen, Anthony L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox