The nic_error op must be atomic, but dumping the FW error logs reads the error tables from the device, which may sleep on some transports. Dump them from dump_error instead, which can sleep. Reading the tables later is fine: the FW is halted after the error, and dump_error always runs before the device is reset or stopped, so the tables are still intact. This also fixes a race: do_not_dump_once shares a bitfield with other fw_status flags that are modified under the wiphy lock, but nic_error cleared it without holding that lock. dump_error holds it. Assisted-by: LLM Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mld/mld.c | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mld.c b/drivers/net/wireless/intel/iwlwifi/mld/mld.c index 71832d92024d..57ff811964bd 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/mld.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/mld.c @@ -671,14 +671,9 @@ iwl_mld_nic_error(struct iwl_op_mode *op_mode, enum iwl_fw_error_type type) { struct iwl_mld *mld = IWL_OP_MODE_GET_MLD(op_mode); - bool trans_dead = iwl_trans_is_dead(mld->trans); if (type == IWL_ERR_TYPE_CMD_QUEUE_FULL) IWL_ERR(mld, "Command queue full!\n"); - else if (!trans_dead && !mld->fw_status.do_not_dump_once) - iwl_fwrt_dump_error_logs(&mld->fwrt); - - mld->fw_status.do_not_dump_once = false; /* It is necessary to abort any os scan here because mac80211 requires * having the scan cleared before restarting. @@ -709,6 +704,17 @@ iwl_mld_nic_error(struct iwl_op_mode *op_mode, iwl_mld_cancel_async_notifications(mld); } +static void iwl_mld_dump_error_logs(struct iwl_mld *mld, + enum iwl_fw_error_type type) +{ + if (type != IWL_ERR_TYPE_CMD_QUEUE_FULL && + !iwl_trans_is_dead(mld->trans) && + !mld->fw_status.do_not_dump_once) + iwl_fwrt_dump_error_logs(&mld->fwrt); + + mld->fw_status.do_not_dump_once = false; +} + static void iwl_mld_dump_error(struct iwl_op_mode *op_mode, struct iwl_fw_error_dump_mode *mode) { @@ -717,11 +723,14 @@ static void iwl_mld_dump_error(struct iwl_op_mode *op_mode, /* if we come in from opmode we have the mutex held */ if (mode->context == IWL_ERR_CONTEXT_FROM_OPMODE) { lockdep_assert_wiphy(mld->wiphy); + iwl_mld_dump_error_logs(mld, mode->type); iwl_fw_error_collect(&mld->fwrt); } else { wiphy_lock(mld->wiphy); - if (mode->context != IWL_ERR_CONTEXT_ABORT) + if (mode->context != IWL_ERR_CONTEXT_ABORT) { + iwl_mld_dump_error_logs(mld, mode->type); iwl_fw_error_collect(&mld->fwrt); + } wiphy_unlock(mld->wiphy); } } -- 2.34.1