Received: by 10.223.176.5 with SMTP id f5csp1023572wra; Fri, 2 Feb 2018 09:53:23 -0800 (PST) X-Google-Smtp-Source: AH8x226rt3hL94DPHz7/Rto374jE0Lc7nk3jXwwYyk6AV2KET6syYrzsuFhdj5kWukbu2NFLtH4f X-Received: by 10.99.60.28 with SMTP id j28mr4150337pga.207.1517594003503; Fri, 02 Feb 2018 09:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594003; cv=none; d=google.com; s=arc-20160816; b=un2CHCRoGK97+pwAWQJT9La8gp/OyP4IU4YEr3Gmd0zclwI639FnSc4QyTT5+sQ71o zSxtfI6iajfMhL3y0DWK71iU1l/Hy2W3JieKCJdKWRIPSp1yvswgkj5Qj46VezUs7k8p O5BXAS2RQyToEJXXDmrxdwDnyWBfszy8EePj16CRiYTJX+hfbNrqgljuqIsWdlFsxuTU aFY3Abb9SHfv1RJtCMsWKjfl1RXJU2wjJnJCGdAUk5fXs0bl5z7v1M8sDOUQHoXYfbG8 IU2H3IvgT8kBmU+hJSfuAcgh8SIurh3echxrORfTnGOiQYYCez78krTZq/qtt4UeRfyr EESA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NUTQUYpVNJ4/jbRTdQBSztHwbcxPQoVbLIyzErPW6Ec=; b=fVGpMCs2g4BpycdBTJtXYciD21IbgfIH0OMV1QpV+/AT2vTn2W4hbcqWQmkDSNgf+Z ZVaumRab0csdYfLblnQbAoPWHZYR5Fs8PHOcjCGzIFPNe1DnH7A0VjOIdp+JNpVzckY2 MHrAYtaxmFeG8iKdmgGj5IkBR9Erqp+a9PEJ0/lgFhi4LODBAEYfGs8D4jUvSBL72yE2 7p82Gu2nOavXhk9MaUPvMnaif5Op526H74u1hLnePY9ED7yZVICscprM/5I82YblUO1U INaJYRQuF5lLYqAFEAwUFAxifJiHZoKMg4hAFGBcYI7VBGONcH/YHp+3LP8i1Yb1xgmr 4A1w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33-v6si2155627plb.477.2018.02.02.09.53.08; Fri, 02 Feb 2018 09:53:23 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753649AbeBBRwO (ORCPT + 99 others); Fri, 2 Feb 2018 12:52:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39052 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbeBBRMg (ORCPT ); Fri, 2 Feb 2018 12:12:36 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B58D9E27; Fri, 2 Feb 2018 17:12:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sara Sharon , Luca Coelho , Sasha Levin Subject: [PATCH 4.14 120/156] iwlwifi: fix access to prph when transport is stopped Date: Fri, 2 Feb 2018 17:58:21 +0100 Message-Id: <20180202140845.605790897@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sara Sharon [ Upstream commit 0232d2cd7aa8e1b810fe84fb4059a0bd1eabe2ba ] When getting HW rfkill we get stop_device being called from two paths. One path is the IRQ calling stop device, and updating op mode and stack. As a result, cfg80211 is running rfkill sync work that shuts down all devices (second path). In the second path, we eventually get to iwl_mvm_stop_device which calls iwl_fw_dump_conf_clear->iwl_fw_dbg_stop_recording, that access periphery registers. The device may be stopped at this point from the first path, which will result with a failure to access those registers. Simply checking for the trans status is insufficient, since the race will still exist, only minimized. Instead, move the stop from iwl_fw_dump_conf_clear (which is getting called only from stop path) to the transport stop device function, where the access is always safe. This has the added value, of actually stopping dbgc before stopping device even when the stop is initiated from the transport. Fixes: 1efc3843a4ee ("iwlwifi: stop dbgc recording before stopping DMA") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/fw/dbg.h | 2 -- drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 6 ++++++ drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h @@ -209,8 +209,6 @@ static inline void iwl_fw_dbg_stop_recor static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt) { - iwl_fw_dbg_stop_recording(fwrt); - fwrt->dump.conf = FW_DBG_INVALID; } --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c @@ -49,6 +49,7 @@ * *****************************************************************************/ #include "iwl-trans.h" +#include "iwl-prph.h" #include "iwl-context-info.h" #include "internal.h" @@ -156,6 +157,11 @@ void _iwl_trans_pcie_gen2_stop_device(st trans_pcie->is_down = true; + /* Stop dbgc before stopping device */ + iwl_write_prph(trans, DBGC_IN_SAMPLE, 0); + udelay(100); + iwl_write_prph(trans, DBGC_OUT_CTRL, 0); + /* tell the device to stop sending interrupts */ iwl_disable_interrupts(trans); --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -1138,6 +1138,15 @@ static void _iwl_trans_pcie_stop_device( trans_pcie->is_down = true; + /* Stop dbgc before stopping device */ + if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) { + iwl_set_bits_prph(trans, MON_BUFF_SAMPLE_CTL, 0x100); + } else { + iwl_write_prph(trans, DBGC_IN_SAMPLE, 0); + udelay(100); + iwl_write_prph(trans, DBGC_OUT_CTRL, 0); + } + /* tell the device to stop sending interrupts */ iwl_disable_interrupts(trans);