linux/drivers/net/ethernet/intel/ice
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
..
ice_adminq_cmd.h ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_common.c ice: separate out control queue lock creation 2019-07-31 10:23:04 -07:00
ice_common.h ice: separate out control queue lock creation 2019-07-31 10:23:04 -07:00
ice_controlq.c ice: separate out control queue lock creation 2019-07-31 10:23:04 -07:00
ice_controlq.h ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_dcb_lib.c ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_dcb_lib.h ice: Fix hang when ethtool disables FW LLDP 2019-05-23 10:51:53 -07:00
ice_dcb.c ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_dcb.h ice: Refactor the LLDP MIB change event handling 2019-05-23 10:51:53 -07:00
ice_devids.h ice: Change device ID define names to align with branding string 2018-10-24 13:53:30 -07:00
ice_ethtool.c ice: add lp_advertising flow control support 2019-07-31 10:23:04 -07:00
ice_hw_autogen.h ice: track hardware stat registers past rollover 2019-07-31 10:23:04 -07:00
ice_lan_tx_rx.h ice: Always set prefena when configuring an Rx queue 2019-07-31 10:23:04 -07:00
ice_lib.c ice: Move vector base setup to PF VSI 2019-07-31 10:23:04 -07:00
ice_lib.h ice: Add switch rules to handle LLDP packets 2019-05-30 10:31:42 -07:00
ice_main.c ice: track hardware stat registers past rollover 2019-07-31 10:23:04 -07:00
ice_nvm.c ice: Add handler for ethtool selftest 2019-05-29 02:44:12 -07:00
ice_osdep.h ice: Start hardware initialization 2018-03-26 09:59:08 -07:00
ice_sched.c ice: Use struct_size() helper 2019-06-28 14:54:11 -07:00
ice_sched.h ice: Add code for DCB initialization part 3/4 2019-04-18 08:38:47 -07:00
ice_sriov.c ice: Add support for new PHY types 2019-01-15 12:38:44 -08:00
ice_sriov.h ice: Add handlers for VF netdevice operations 2018-10-03 07:42:30 -07:00
ice_status.h ice: Add handler for ethtool selftest 2019-05-29 02:44:12 -07:00
ice_switch.c ice: Add switch rules to handle LLDP packets 2019-05-30 10:31:42 -07:00
ice_switch.h ice: Minor cleanup in ice_switch.h 2019-05-29 02:55:34 -07:00
ice_txrx.c net: Use skb accessors in network drivers 2019-07-22 20:47:56 -07:00
ice_txrx.h ice: Use bitfields when possible 2019-05-23 10:51:54 -07:00
ice_type.h ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_virtchnl_pf.c ice: Trivial cosmetic changes 2019-05-30 10:57:55 -07:00
ice_virtchnl_pf.h ice: Refactor interrupt tracking 2019-05-29 02:48:49 -07:00
ice.h ice: Change minimum descriptor count value for Tx/Rx rings 2019-05-30 10:37:26 -07:00
Makefile ice: Add code for DCB initialization part 1/4 2019-04-18 08:38:47 -07:00