i40e: fix: do not sleep in netdev_ops
Subsystems (2)
PATCH 1/2 i40e: fix: do not sleep in netdev_ops
The driver was being called by vlan, bonding, teaming operations that expected to be able to hold locks like rcu_read_lock().
This causes the driver to be held to the requirement to not sleep, and was found by the kernel debug options for checking sleep inside critical section, and the locking validator.
---
Testing Hints (required if no HSD): add and remove vlan, over and under bonding and teaming driver, add and delete mac address, run debug kernel with lock validator.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 44 +++++++++++++---------------- 1 file changed, 20 insertions(+), 24 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +20 -24
@@ -1552,9 +1552,11 @@ static int i40e_set_mac(struct net_device *netdev, void *p)spin_unlock_bh (&vsi->mac_filter_list_lock); } -i40e_sync_vsi_filters (vsi, false);ether_addr_copy (netdev->dev_addr, addr->sa_data); - +/* schedule our worker thread which will take care of +* applying the new filter changes +*/ +i40e_service_event_schedule (vsi->back);return 0 ; }
@@ -2118,12 +2120,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl)*/ if (pf->cur_promisc != cur_promisc) { pf->cur_promisc = cur_promisc; -if (grab_rtnl) -i40e_do_reset_safe (pf, -BIT (__I40E_PF_RESET_REQUESTED)); -else -i40e_do_reset (pf, -BIT (__I40E_PF_RESET_REQUESTED)); +set_bit (__I40E_PF_RESET_REQUESTED, &pf->state); } }else { ret = i40e_aq_set_vsi_unicast_promiscuous(
@@ -2383,16 +2380,13 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid) } } -/* Make sure to release before sync_vsi_filter because that -* function will lock/unlock as necessary -*/ spin_unlock_bh (&vsi->mac_filter_list_lock); -if (test_bit (__I40E_DOWN, &vsi->back->state) || -test_bit (__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) -return 0 ; - -return i40e_sync_vsi_filters (vsi, false); +/* schedule our worker thread which will take care of +* applying the new filter changes +*/ +i40e_service_event_schedule (vsi->back); +return 0 ; }/**
@@ -2465,16 +2459,13 @@ int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid) } } -/* Make sure to release before sync_vsi_filter because that -* function with lock/unlock as necessary -*/ spin_unlock_bh (&vsi->mac_filter_list_lock); -if (test_bit (__I40E_DOWN, &vsi->back->state) || -test_bit (__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) -return 0 ; - -return i40e_sync_vsi_filters (vsi, false); +/* schedule our worker thread which will take care of +* applying the new filter changes +*/ +i40e_service_event_schedule (vsi->back); +return 0 ; }/**
@@ -2717,6 +2708,11 @@ static void i40e_config_xps_tx_ring(struct i40e_ring *ring)netif_set_xps_queue (ring->netdev, mask, ring->queue_index);free_cpumask_var (mask); } + +/* schedule our worker thread which will take care of +* applying the new filter changes +*/ +i40e_service_event_schedule (vsi->back); }/**
Signature · 1 line
1.8.3.1
PATCH 2/2 i40e: remove unused argument
With the final edition of the patches to remove sleeps from the driver's entry points, the grab_rtnl argument is no longer needed, so partially revert the commit that added it.
---
Testing Hints (required if no HSD): add and remove vlan, over and under bonding and teaming driver, add and delete mac address, run debug kernel with lock validator. The test that originally failed was with vlan add/remove while running a vlan as part of a bridge with dhclient over the top of it.
--- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 16 +++++++++++----- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 ++++---- 4 files changed, 18 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -1
@@ -697,7 +697,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi, bool is_vf, bool is_netdev);void i40e_del_filter (struct i40e_vsi *vsi,u8 *macaddr,s16 vlan,bool is_vf,bool is_netdev); -int i40e_sync_vsi_filters (struct i40e_vsi *vsi,bool grab_rtnl); +int i40e_sync_vsi_filters (struct i40e_vsi *vsi);struct i40e_vsi *i40e_vsi_setup (struct i40e_pf *pf,u8 type,u16 uplink,u32 param1);int i40e_vsi_release (struct i40e_vsi *vsi);
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +2 -2
@@ -1138,7 +1138,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,spin_lock_bh (&vsi->mac_filter_list_lock); f =i40e_add_filter (vsi, ma, vlan, false, false);spin_unlock_bh (&vsi->mac_filter_list_lock); - ret =i40e_sync_vsi_filters (vsi, true); + ret =i40e_sync_vsi_filters (vsi);if (f && !ret) dev_info(&pf->pdev->dev, "add macaddr: %pM vlan=%d added to VSI %d\n",
@@ -1177,7 +1177,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,spin_lock_bh (&vsi->mac_filter_list_lock);i40e_del_filter (vsi, ma, vlan, false, false);spin_unlock_bh (&vsi->mac_filter_list_lock); - ret =i40e_sync_vsi_filters (vsi, true); + ret =i40e_sync_vsi_filters (vsi);if (!ret) dev_info(&pf->pdev->dev, "del macaddr: %pM vlan=%d removed from VSI %d\n",
drivers/net/ethernet/intel/i40e/i40e_main.c +11 -5
@@ -1859,13 +1859,12 @@ static void i40e_cleanup_add_list(struct list_head *add_list)/** * i40e_sync_vsi_filters - Update the VSI filter list to the HW * @vsi: ptr to the VSI -* @grab_rtnl: whether RTNL needs to be grabbed * * Push any outstanding VSI filter changes through the AdminQ. * * Returns 0 or error value **/ -int i40e_sync_vsi_filters (struct i40e_vsi *vsi,bool grab_rtnl) +int i40e_sync_vsi_filters (struct i40e_vsi *vsi) {struct list_head tmp_del_list, tmp_add_list;struct i40e_mac_filter *f, *ftmp, *fclone;
@@ -2169,8 +2168,15 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)for (v =0 ; v < pf->num_alloc_vsi; v++) {if (pf->vsi[v] && - (pf->vsi[v]->flags &I40E_VSI_FLAG_FILTER_CHANGED )) -i40e_sync_vsi_filters (pf->vsi[v], true); + (pf->vsi[v]->flags &I40E_VSI_FLAG_FILTER_CHANGED )) { +int ret =i40e_sync_vsi_filters (pf->vsi[v]); + +if (ret) { +/* come back and try again later */ + pf->flags |=I40E_FLAG_FILTER_SYNC ; +break ; + } + } } }
@@ -9219,7 +9225,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi) f->is_vf, f->is_netdev);spin_unlock_bh (&vsi->mac_filter_list_lock); -i40e_sync_vsi_filters (vsi, false); +i40e_sync_vsi_filters (vsi);i40e_vsi_delete (vsi);i40e_vsi_free_q_vectors (vsi);
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +4 -4
@@ -565,7 +565,7 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type) }/* program mac filter */ - ret =i40e_sync_vsi_filters (vsi, false); + ret =i40e_sync_vsi_filters (vsi);if (ret)dev_err (&pf->pdev->dev,"Unable to program ucast filters\n" );
@@ -1633,7 +1633,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)spin_unlock_bh (&vsi->mac_filter_list_lock);/* program the updated filter list */ -if (i40e_sync_vsi_filters (vsi, false)) +if (i40e_sync_vsi_filters (vsi))dev_err (&pf->pdev->dev,"Unable to program VF %d MAC filters\n" , vf->vf_id);
@@ -1687,7 +1687,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)spin_unlock_bh (&vsi->mac_filter_list_lock);/* program the updated filter list */ -if (i40e_sync_vsi_filters (vsi, false)) +if (i40e_sync_vsi_filters (vsi))dev_err (&pf->pdev->dev,"Unable to program VF %d MAC filters\n" , vf->vf_id);
@@ -2102,7 +2102,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)dev_info (&pf->pdev->dev,"Setting MAC %pM on VF %d\n" , mac, vf_id);/* program mac filter */ -if (i40e_sync_vsi_filters (vsi, false)) { +if (i40e_sync_vsi_filters (vsi)) {dev_err (&pf->pdev->dev,"Unable to program ucast filters\n" ); ret = -EIO ; goto error_param;
Signature · 1 line
1.8.3.1
Bowers
PATCH 2/2 i40e: remove unused argument
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jesse Brandeburg
Sent: Thursday, November 05, 2015 5:01 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 2/2] i40e: remove unused argumentWith the final edition of the patches to remove sleeps from the driver's entry points, the
grab_rtnlargument is no longer needed, so partially revert the commit that added it.Signed-off-by Jesse Brandeburg <[email protected]>Change-ID Ib9778476242586cc9e58b670f5f48d415cb59003---
Testing Hints (required if no HSD): add and remove vlan, over and under bonding and teaming driver, add and delete mac address, run debug kernel with lock validator. The test that originally failed was with vlan add/remove while running a vlan as part of a bridge with dhclient over the top of it.
Quoted 6 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 16 +++++++++++----- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 ++++---- 4 files changed, 18 insertions(+), 12 deletions(-)
Patch code changes correctly applied, add/delete mac/vlan operations lock and unlock normally
Bowers
PATCH 1/2 i40e: fix: do not sleep in netdev_ops
In reply to Jesse BrandeburgQuoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jesse Brandeburg
Sent: Thursday, November 05, 2015 5:01 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 1/2] i40e: fix: do not sleep innetdev_opsThe driver was being called by vlan, bonding, teaming operations that expected to be able to hold locks like
rcu_read_lock().This causes the driver to be held to the requirement to not sleep, and was found by the kernel debug options for checking sleep inside critical section, and the locking validator.
Signed-off-by Jesse Brandeburg <[email protected]>Change-ID Ibc68c835f5ffa8ffe0638ffe910a66fc5649a7f7---
Quoted 7 lines
Testing Hints (required if no HSD): add and remove vlan, over and under bonding and teaming driver, add and delete mac address, run debug kernel with lock validator.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 44 +++++++++++++------------ ---- 1 file changed, 20 insertions(+), 24 deletions(-)
Patch code changes correctly applied, add/delete mac/vlan operations lock and unlock normally