Received: by 10.223.176.46 with SMTP id f43csp271756wra; Tue, 23 Jan 2018 20:45:54 -0800 (PST) X-Google-Smtp-Source: AH8x224Sqo/i6rVdleTk+6m6K2Y1AfrM7cPG7037INlUCaSvuZSQ57AzMqBPKSbbh6vBDzOKfhj6 X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr7036974plg.245.1516769154294; Tue, 23 Jan 2018 20:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769154; cv=none; d=google.com; s=arc-20160816; b=u43OU2RxmVkH0HArMpGcbqUAoNiasNqnNMVInTMC4FCttBFG2J/Bocs73guN4BVezg usi9BdsWYRdMv/pqJhOr47jAtnE0eR/vnwJqnWEttXUqfN5DmAh1LSuzatT73JaVgdKz zS1UuM1DPGTzCQ2m6XVFO8u7XVSNj0RDR9kNnaoVuBJ6/yfQ9bTgHbINnfo51ivWZUNH xASISl1W4TKW9RFpAO4uBXh3SVdevmv49On1AvhxhCtHctaRrPpaXVtcPIMPJgjW71cF kbKDrzCdsfcuK+TdKkuaELEma6rEFeSwc9kP/2HYzesqTtpgFwqbDGYNSmQzVLv8I0vL Halg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=/kg0KkK6cGW5HFvWa1kagkH2kLBnKcJqrAixE87AQDU=; b=Ed5p8v9QGrdTJmRNNQH1mIfDY5fRfgwhXypPLrLtWAG3xPLRGlPup0oSATd8DB3Fie WjRjMbGoOjxPjyVbIkyhXLYPRMHfFNfoRZT1a+ZMBTl0pJ6SZdJqjxVJOY3um6P9N9s6 NGN+nLiqtu42mRV2C+FKjFMhcK7PJx1FrOJZ7UgAxCKNFGB/cIaq57lsZofslGl7fRWr 7tC/ad2cL2OTbf24fMsBZb79xg7BaFOjXCMypwkXO/40BzhWXMyU+mmDvFCNuH5LaH40 6pGAIzXhQZTmvNpZ5leFT8V8lsJamuZ2xEgWpiLqH1I7syiUgGUBk1XdRmJ4ww9Q1/fD kTRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nLITYF2q; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si5506409ply.824.2018.01.23.20.45.40; Tue, 23 Jan 2018 20:45:54 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nLITYF2q; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932642AbeAXEQr (ORCPT + 99 others); Tue, 23 Jan 2018 23:16:47 -0500 Received: from mail-sn1nam01on0139.outbound.protection.outlook.com ([104.47.32.139]:26809 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932611AbeAXEQm (ORCPT ); Tue, 23 Jan 2018 23:16:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/kg0KkK6cGW5HFvWa1kagkH2kLBnKcJqrAixE87AQDU=; b=nLITYF2q3kraLTx5MfVAXuGjygep0FTC5Nq9fgtB2Mj2Cx5RQSM9piDYzEMdjc1Kpf+JORdmngaUkO+JWHAH8uxmmzgtyOr41PmrpyDG8a+0n5etPutpwRNhpg6lYh3Kk///Jpapd2JUHZxfA5/Tg/dTknx6rFaiQTq5TwQN0VY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0727.namprd21.prod.outlook.com (10.167.110.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.1; Wed, 24 Jan 2018 04:16:39 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:16:39 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Sara Sharon , Luca Coelho , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 094/100] iwlwifi: fix access to prph when transport is stopped Thread-Topic: [PATCH AUTOSEL for 4.14 094/100] iwlwifi: fix access to prph when transport is stopped Thread-Index: AQHTlMnvU6FHiNrrvkCj8svFVpvqjg== Date: Wed, 24 Jan 2018 04:15:14 +0000 Message-ID: <20180124041414.32065-94-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0727;6:oaBySXKdTD6Uj1UH68cH8R7DzgAdTPpTbr/HZwg5+FfuPGqC3MFt3oVFY/0LrNeD5JNuwLkx5H0tljzgJIFhF8yI70WWZ9m6bjED6sS0awgTU6V04o0uFhlkQ8Q2Afk4QxNm6jxxMgN6yA+YhhjhYdeUtKuQbCKLNstbkmoy6j+zwB72+q6/AsDR1aSn7w4phmN1N5HtXAN7AILUEgSpgSYigYuOLL3gTPeLIdplfXY+HU6/VO55CohOGJPDWnUOSdG0pqAYwT2r8JgaMRpuEbIFbpAFW//WYbGQf5zn/16awKlkoLGxid2Y2+WM2imuph6lRdfAyOmdqRn5RYNlR3fpY9EFMbj6RBy5XwM4tBNM+peEd37dXCXJno5hCRpS;5:jwjFaaTJJyeEPYv6GhRGepk3WmZu3KR0ck2zLvNGeqVUUndUI3P0/vB/sa8gd6JpxlhCR+okWWe43mpcMs8hNWFz8xgPbKuPJtVta2gHFnPAragmR01BmVGQuLvS5sEqtRnNB56+VDmfZrYgCt59RHez9Ivap5H28DFn2fLg5W8=;24:Ca2najeEnpGC5g74JXU58BBDyoYm4ynZtImpwSs8zOH8MOO57sqxun1gKyzAGYJGPOVp1gKvO90v7bEnHntnSV38METDJ7+SfcBNjNkgsDQ=;7:SZObUpcy9t/rc46pvWahMipftMoN8UtIcY+uv/M9v7l6Je1VyJGZNojXzshTxfAnDalHl2Swy1iQT1JpVZMMYTdipY9oHstfCJyKBQnaIDgilEyqBQ92spycSFJE2CD3sNQ/7j1MLZ/TSbUWd67cKgVhc84lXI90wBIo9kvd7lKYgcH3tWHjrOReBAjGdlY/FlBk3jTS2kUKXCDN5QqFvFW4l48FsXK/L33TkfM28cCGVDLCHorDea20GolLcTyq x-ms-office365-filtering-correlation-id: 9942aa66-7709-4ad9-3f1c-08d562e14400 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0727; x-ms-traffictypediagnostic: DM5PR2101MB0727: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3231046)(2400081)(944501161)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0727;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0727; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(366004)(39380400002)(39860400002)(376002)(189003)(199004)(86612001)(6506007)(106356001)(76176011)(59450400001)(6346003)(54906003)(575784001)(86362001)(2501003)(110136005)(1076002)(7736002)(5250100002)(3660700001)(316002)(26005)(102836004)(2950100002)(6666003)(99286004)(97736004)(22452003)(107886003)(6436002)(53936002)(478600001)(66066001)(14454004)(2900100001)(6512007)(2906002)(5660300001)(8936002)(4326008)(10290500003)(305945005)(10090500001)(68736007)(25786009)(81166006)(72206003)(36756003)(8676002)(81156014)(3846002)(6116002)(3280700002)(105586002)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0727;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: CGQUuXuhiCpympWg9MqYSupsysixBEqsse1Kl+iijQogiWeDI65Pm5mJaqQVa/dNMddRSWzqBQ5DYFca7P9FXQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9942aa66-7709-4ad9-3f1c-08d562e14400 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:15:14.6274 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0727 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h b/drivers/net/wire= less/intel/iwlwifi/fw/dbg.h index 9c889a32fe24..223fb77a3aa9 100644 --- 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_recording(struct iwl= _fw_runtime *fwrt) =20 static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt) { - iwl_fw_dbg_stop_recording(fwrt); - fwrt->dump.conf =3D FW_DBG_INVALID; } =20 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers= /net/wireless/intel/iwlwifi/pcie/trans-gen2.c index c59f4581e972..ac05fd1e74c4 100644 --- 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" =20 @@ -156,6 +157,11 @@ void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans= *trans, bool low_power) =20 trans_pcie->is_down =3D true; =20 + /* 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); =20 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/= wireless/intel/iwlwifi/pcie/trans.c index 2e3e013ec95a..12a9b86d71ea 100644 --- 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(struct iwl_t= rans *trans, bool low_power) =20 trans_pcie->is_down =3D true; =20 + /* Stop dbgc before stopping device */ + if (trans->cfg->device_family =3D=3D 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); =20 --=20 2.11.0