diff mbox series

[net] iavf: Move netdev_update_features() into watchdog task

Message ID 20230103164227.33546-1-marcin.szycik@linux.intel.com
State Accepted
Delegated to: Anthony Nguyen
Headers show
Series [net] iavf: Move netdev_update_features() into watchdog task | expand

Commit Message

Marcin Szycik Jan. 3, 2023, 4:42 p.m. UTC
Remove netdev_update_features() from iavf_adminq_task(), as it can cause
deadlocks due to needing rtnl_lock. Instead use the
IAVF_FLAG_SETUP_NETDEV_FEATURES flag to indicate that netdev features need
to be updated in the watchdog task. iavf_set_vlan_offload_features()
and iavf_set_queue_vlan_tag_loc() can be called directly from
iavf_virtchnl_completion().

Suggested-by: Phani Burra <phani.r.burra@intel.com>
Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>
---
This patch is a suggested replacement for patch [1], and as such will
currently not apply to dev-queue. It solves the same issue, but does not
increase code complexity by introducing a new task.
[1] https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20221215225049.508812-3-mschmidt@redhat.com/

 drivers/net/ethernet/intel/iavf/iavf_main.c   | 27 +++++++------------
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  8 ++++++
 2 files changed, 17 insertions(+), 18 deletions(-)

Comments

Szlosek, Marek Jan. 20, 2023, 2:18 p.m. UTC | #1
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Marcin Szycik
> Sent: wtorek, 3 stycznia 2023 17:42
> To: intel-wired-lan@lists.osuosl.org
> Cc: Wesierski, DawidX <dawidx.wesierski@intel.com>; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>; Burra, Phani R <phani.r.burra@intel.com>
> Subject: [Intel-wired-lan] [PATCH net] iavf: Move netdev_update_features()
> into watchdog task
> 
> Remove netdev_update_features() from iavf_adminq_task(), as it can cause
> deadlocks due to needing rtnl_lock. Instead use the
> IAVF_FLAG_SETUP_NETDEV_FEATURES flag to indicate that netdev features
> need to be updated in the watchdog task. iavf_set_vlan_offload_features()
> and iavf_set_queue_vlan_tag_loc() can be called directly from
> iavf_virtchnl_completion().
> 
> Suggested-by: Phani Burra <phani.r.burra@intel.com>
> Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>
> ---
> This patch is a suggested replacement for patch [1], and as such will currently
> not apply to dev-queue. It solves the same issue, but does not increase code
> complexity by introducing a new task.
> [1] https://patchwork.ozlabs.org/project/intel-wired-
> lan/patch/20221215225049.508812-3-mschmidt@redhat.com/
> 
>  drivers/net/ethernet/intel/iavf/iavf_main.c   | 27 +++++++------------
>  .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  8 ++++++
>  2 files changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 931422485074..92ae7137584c 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c

Tested-by: Marek Szlosek <marek.szlosek@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 931422485074..92ae7137584c 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -2692,6 +2692,15 @@  static void iavf_watchdog_task(struct work_struct *work)
 		goto restart_watchdog;
 	}
 
+	if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) &&
+	    adapter->netdev_registered &&
+	    !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section) &&
+	    rtnl_trylock()) {
+		netdev_update_features(adapter->netdev);
+		rtnl_unlock();
+		adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES;
+	}
+
 	if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
 		iavf_change_state(adapter, __IAVF_COMM_FAILED);
 
@@ -3233,24 +3242,6 @@  static void iavf_adminq_task(struct work_struct *work)
 	} while (pending);
 	mutex_unlock(&adapter->crit_lock);
 
-	if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES)) {
-		if (adapter->netdev_registered ||
-		    !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
-			struct net_device *netdev = adapter->netdev;
-
-			rtnl_lock();
-			netdev_update_features(netdev);
-			rtnl_unlock();
-			/* Request VLAN offload settings */
-			if (VLAN_V2_ALLOWED(adapter))
-				iavf_set_vlan_offload_features
-					(adapter, 0, netdev->features);
-
-			iavf_set_queue_vlan_tag_loc(adapter);
-		}
-
-		adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES;
-	}
 	if ((adapter->flags &
 	     (IAVF_FLAG_RESET_PENDING | IAVF_FLAG_RESET_NEEDED)) ||
 	    adapter->state == __IAVF_RESETTING)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 0752fd67c96e..365ca0c710c4 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -2226,6 +2226,14 @@  void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 
 		iavf_process_config(adapter);
 		adapter->flags |= IAVF_FLAG_SETUP_NETDEV_FEATURES;
+
+		/* Request VLAN offload settings */
+		if (VLAN_V2_ALLOWED(adapter))
+			iavf_set_vlan_offload_features(adapter, 0,
+						       netdev->features);
+
+		iavf_set_queue_vlan_tag_loc(adapter);
+
 		was_mac_changed = !ether_addr_equal(netdev->dev_addr,
 						    adapter->hw.mac.addr);