linux/drivers/net/ethernet/intel
Jacob Keller 5c91ecfda5 ice: separate out control queue lock creation
The ice_init_all_ctrlq and ice_shutdown_all_ctrlq functions create and
destroy the locks used to protect the send and receive process of each
control queue.

This is problematic, as the driver may use these functions to shutdown
and re-initialize the control queues at run time. For example, it may do
this in response to a device reset.

If the driver failed to recover from a reset, it might leave the control
queues offline. In this case, the locks will no longer be initialized.
A later call to ice_sq_send_cmd will then attempt to acquire a lock that
has been destroyed.

It is incorrect behavior to access a lock that has been destroyed.

Indeed, ice_aq_send_cmd already tries to avoid accessing an offline
control queue, but the check occurs inside the lock.

The root of the problem is that the locks are destroyed at run time.

Modify ice_init_all_ctrlq and ice_shutdown_all_ctrlq such that they no
longer create or destroy the locks.

Introduce new functions, ice_create_all_ctrlq and ice_destroy_all_ctrlq.
Call these functions in ice_init_hw and ice_deinit_hw.

Now, the control queue locks will remain valid for the life of the
driver, and will not be destroyed until the driver unloads.

This also allows removing a duplicate check of the sq.count and
rq.count values when shutting down the controlqs. The ice_shutdown_ctrlq
function already checks this value under the lock. Previously
commit dec64ff10e ("ice: use [sr]q.count when checking if queue is
initialized") needed this check to happen outside the lock, because it
prevented duplicate attempts at destroying the locks.

The driver may now safely use ice_init_all_ctrlq and
ice_shutdown_all_ctrlq while handling reset events, without causing the
locks to be invalid.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-07-31 10:23:04 -07:00
..
e1000 net: Use skb accessors in network drivers 2019-07-22 20:47:56 -07:00
e1000e e1000e: add workaround for possible stalled packet 2019-07-24 13:55:09 -07:00
fm10k fm10k: Use dev_get_drvdata 2019-07-23 13:02:41 -07:00
i40e net: Use skb_frag_off accessors 2019-07-30 14:21:32 -07:00
iavf net: Use skb_frag_off accessors 2019-07-30 14:21:32 -07:00
ice ice: separate out control queue lock creation 2019-07-31 10:23:04 -07:00
igb igb: Use dev_get_drvdata where possible 2019-07-23 13:02:42 -07:00
igbvf net: Use skb accessors in network drivers 2019-07-22 20:47:56 -07:00
igc igc: Add more SKUs for i225 device 2019-07-24 13:55:09 -07:00
ixgb net: Use skb accessors in network drivers 2019-07-22 20:47:56 -07:00
ixgbe net: Use skb_frag_off accessors 2019-07-30 14:21:32 -07:00
ixgbevf net/ixgbevf: fix a compilation error of skb_frag_t 2019-07-24 15:28:43 -07:00
e100.c intel: correct return from set features callback 2019-03-19 14:18:49 -07:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller support 2018-10-17 12:14:54 -07:00