Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp177811imd; Wed, 31 Oct 2018 16:53:22 -0700 (PDT) X-Google-Smtp-Source: AJdET5fsS6olE6vdWItZVDxQcj8G9cpCNX160gH3yg4kQTlri7t8JYgKydDbY4tsQHY6zf30fWYp X-Received: by 2002:a17:902:b709:: with SMTP id d9-v6mr5254296pls.199.1541030002730; Wed, 31 Oct 2018 16:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030002; cv=none; d=google.com; s=arc-20160816; b=ERN5HpJs7rRXEMok9+QPr3S6mqlP2+WEPBbRSVJBc1lBCet9yksXVQT/Tgh1aRgzok JSQ5J8PehwjXVBwWOJ4cu+T/Tnn5Av0LDOH6oo88S+vpSqIsoR6UjwY9OKN69gHfyda9 5Ff0gfDisda8iN6pa5OXwYT96L1fF88fr/xbFDsSyO736+HzeusiyAYhEcYbdTK9kxhS dB/xPYhgGoqJFBLVPIH71PF7l1KRY+jrS2pj68aMiwqwTjo0nuCAJVLfZZ7FJorvIaFM ZvHUs1LHNcaFhJ/oWsyjxsRPxBnfC5yUt/pbqYBrm7HkwUBgjyLgjVMOvjz8qTo6EZcB nu6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FP6ekoUndt+Cm4HxgB1VfCAFiV8Isk3MwDosONw3hNE=; b=bNI9jvURD7NQNtxlCr2Bk/3TcA+U9EXM0gvDk8K+wseDSnAG93JvBhkNh9BZxNqJc1 M7DtOD+5YE5/8BaxxyRYd+sZ4kjGfBW0ZF5+ZuZTFDR6K2jnLH9xE7jOrXsaeQNVAuc6 lEjQYSpgpAbzRwHIK6ygAochQc/NT1TBwSdsNisSeCeEKUO7UqxTM3tgX1BXJzqOhIzs Sb56zSUmsc+G6O+fB95SrG+8IpeOWNPMVSd4tu3EjarlaAKhheUVcXVwNpCLD9+AbGdo OOcq7TnhRo1JLoKJxIwjxyvk7Vft6LlDdwmwrBdyzrPViq8nSHGQsr+kTqWr8173Nglk 4MMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="cu2Q/km0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n81-v6si20397540pfj.30.2018.10.31.16.53.08; Wed, 31 Oct 2018 16:53:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="cu2Q/km0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbeKAIxH (ORCPT + 99 others); Thu, 1 Nov 2018 04:53:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727774AbeKAIGT (ORCPT ); Thu, 1 Nov 2018 04:06:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91CC420830; Wed, 31 Oct 2018 23:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027168; bh=Abeb/3xh2K6r5HmarrDpF17xN8h08gxUkz0UTITx8dU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cu2Q/km0oHOXGd/ijlaMc3yE++CunhSOdTT9n8bwmwQli0XGZy7mfgv/8F+opanj1 6j5HXZS+81jPC93iFeOPI8XkI9kusmETx6aibYR1Spa5JoVTpncRaThW+vGo+qgrBb qZgDsyoOh/yflACOIhF5cNpmks3fnMhPR9Qqw3KM= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Emmanuel Grumbach , Luca Coelho , Sasha Levin Subject: [PATCH AUTOSEL 4.19 028/146] iwlwifi: mvm: clear HW_RESTART_REQUESTED when stopping the interface Date: Wed, 31 Oct 2018 19:03:43 -0400 Message-Id: <20181031230541.28822-28-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Emmanuel Grumbach [ Upstream commit 155f7e0441cd121b1e673d465a35e99f4b9b2f0b ] Fix a bug that happens in the following scenario: 1) suspend without WoWLAN 2) mac80211 calls drv_stop because of the suspend 3) __iwl_mvm_mac_stop deallocates the aux station 4) during drv_stop the firmware crashes 5) iwlmvm: * sets IWL_MVM_STATUS_HW_RESTART_REQUESTED * asks mac80211 to kick the restart flow 6) mac80211 puts the restart worker into a freezable queue which means that the worker will not run for now since the workqueue is already frozen 7) ... 8) resume 9) mac80211 runs ieee80211_reconfig as part of the resume 10) mac80211 detects that a restart flow has been requested and that we are now resuming from suspend and cancels the restart worker 11) mac80211 calls drv_start() 12) __iwl_mvm_mac_start checks that IWL_MVM_STATUS_HW_RESTART_REQUESTED clears it, sets IWL_MVM_STATUS_IN_HW_RESTART and calls iwl_mvm_restart_cleanup() 13) iwl_fw_error_dump gets called and accesses the device to get debug data 14) iwl_mvm_up adds the aux station 15) iwl_mvm_add_aux_sta() allocates an internal station for the aux station 16) iwl_mvm_allocate_int_sta() tests IWL_MVM_STATUS_IN_HW_RESTART and doesn't really allocate a station ID for the aux station 17) a new queue is added for the aux station Note that steps from 5 to 9 aren't really part of the problem but were described for the sake of completeness. Once the iwl_mvm_mac_stop() is called, the device is not accessible, meaning that step 12) can't succeed and we'll see the following: drivers/net/wireless/intel/iwlwifi/pcie/trans.c:2122 iwl_trans_pcie_grab_nic_access+0xc0/0x1d6 [iwlwifi]() Timeout waiting for hardware access (CSR_GP_CNTRL 0x080403d8) Call Trace: [] iwl_trans_pcie_grab_nic_access+0xc0/0x1d6 [iwlwifi] [] iwl_trans_pcie_dump_regs+0x3fd/0x3fd [iwlwifi] [] iwl_fw_error_dump+0x4f5/0xe8b [iwlwifi] [] __iwl_mvm_mac_start+0x5a/0x21a [iwlmvm] [] iwl_mvm_mac_start+0xd4/0x103 [iwlmvm] [] drv_start+0xa1/0xc5 [iwl7000_mac80211] [] ieee80211_reconfig+0x145/0xf50 [mac80211] [] ieee80211_resume+0x62/0x66 [mac80211] [] wiphy_resume+0xa9/0xc6 [cfg80211] The station id of the aux station is set to 0xff in step 3 and because we don't really allocate a new station id for the auxliary station (as explained in 16), we end up sending a command to the firmware asking to connect the queue to station id 0xff. This makes the firmware crash with the following information: 0x00002093 | ADVANCED_SYSASSERT 0x000002F0 | trm_hw_status0 0x00000000 | trm_hw_status1 0x00000B38 | branchlink2 0x0001978C | interruptlink1 0x00000000 | interruptlink2 0xFF080501 | data1 0xDEADBEEF | data2 0xDEADBEEF | data3 Firmware error during reconfiguration - reprobe! FW error in SYNC CMD SCD_QUEUE_CFG Fix this by clearing IWL_MVM_STATUS_HW_RESTART_REQUESTED in iwl_mvm_mac_stop(). We won't be able to collect debug data anyway and when we will brought up again, we will have a clean state from the firmware perspective. Since we won't have IWL_MVM_STATUS_IN_HW_RESTART set in step 12) we won't get to the 2093 ASSERT either. Fixes: bf8b286f86fc ("iwlwifi: mvm: defer setting IWL_MVM_STATUS_IN_HW_RESTART") Signed-off-by: Emmanuel Grumbach Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index b15b0d84bb7e..155cc2ac0120 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -1233,12 +1233,15 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm) iwl_mvm_del_aux_sta(mvm); /* - * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete() - * won't be called in this case). + * Clear IN_HW_RESTART and HW_RESTART_REQUESTED flag when stopping the + * hw (as restart_complete() won't be called in this case) and mac80211 + * won't execute the restart. * But make sure to cleanup interfaces that have gone down before/during * HW restart was requested. */ - if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) + if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) || + test_and_clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, + &mvm->status)) ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm); -- 2.17.1