Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2526821imu; Thu, 29 Nov 2018 06:25:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1Bi32HJ8Z9Lev796lPFB3qnanDLL2PiyDymE457MwA5zwHOH2nTD7ghVvOTa9rLFBflpn X-Received: by 2002:a17:902:2867:: with SMTP id e94mr1699223plb.264.1543501549196; Thu, 29 Nov 2018 06:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501549; cv=none; d=google.com; s=arc-20160816; b=OqaF2u1VHkNd7TQVJRPQ0iGVuop14sy0K5hnR8+4iRsHxVQHu0pWg51ZEFmh+AW4+z Vb2CINZfCxfjD5r4PbKM0WiIMTLOOQBOmPGOXdAnqvOrE370Ar5R5LUEwzmLfcbgxCPq p98ErHN5L/AyVSW5xG9t7sAezckfPBRldAqbJVe6WtfLWevCDOs5BZn45fLfRiPTaOhk DTHnkD3MPrn/AMXbVmCQLZMXgBrF2pfcTM+iGgzVOdEPz1B6cf0q2sjuoz95lM0G4gJM SEnIlLv/3gXRbJayCj5+VQi2nDepu0UMUOXGGuC2wOP6Pd4JYXPD5ELjDQqbyAz0JSkf AJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ik0scVkYIRJHnT7gOWoIQLpZk5SAuV+v4VsPvvU0ATE=; b=ePw8FADBhmXuvIhJAQLAo5Kj1LIpzpXIua/SDmKNm0Le3vUYMex/rYBvNdopDc4BaH gHFlFY+Cg+Zx3IPfMJrmwUWH2xx/mY1ldazrNy9vub41inv0u0rULHjyf8e66vAt6Wss tz+1F5EXiKEGvglHR9TZEmDIVcbE7mgu36VvBGre/H9Sag/EndGtR+5vogY2oQ30UhfR Vq1KXtTmjhPvGNJqFEo6/G5vNIMB5GxVIfKOwDtjfCEybQ9SKNMrAgtaXBUAej1H8Mup kDcHC1LB8olVYpoYGl/MfPNoxIy3iqoPfmD20priiSwzabVO9keayn8C9vQriQkCVQrW juwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g7fpq+y5; 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 76si2360097pfw.66.2018.11.29.06.25.28; Thu, 29 Nov 2018 06:25:49 -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=@kernel.org header.s=default header.b=g7fpq+y5; 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 S1732222AbeK3B2m (ORCPT + 99 others); Thu, 29 Nov 2018 20:28:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:54484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731487AbeK3B2m (ORCPT ); Thu, 29 Nov 2018 20:28:42 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE160205C9; Thu, 29 Nov 2018 14:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501390; bh=zJZa2Yi7BQsntlcItmkv38lcyr86JVx+B3tZ5bOZqiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7fpq+y5vEUGNA0vAkDDX42/ARpQaZf1Pg5s20Af92pQiv6ZLogP8cOzhiPUnRHCB OVoLMw0z86l1v7ve7fcTcrx5LQu6nbFslKDoEWf546/8KFCVl1Nnx6Ed/Pggujuhkk 3XyLzUgQJXjuxDNXEFsF+NP58+4N5nE0ASVQmvyg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amitkumar Karwar , Brian Norris , Kalle Valo , Amit Pundir Subject: [PATCH 4.9 71/92] mwifiex: prevent register accesses after host is sleeping Date: Thu, 29 Nov 2018 15:12:40 +0100 Message-Id: <20181129140112.125124662@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140106.520639693@linuxfoundation.org> References: <20181129140106.520639693@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amitkumar Karwar commit ec815dd2a5f110f627d7955e0027a3a008f68166 upstream. Following is mwifiex driver-firmware host sleep handshake. It involves three threads. suspend handler, interrupt handler, interrupt processing in main work queue. 1) Enter suspend handler 2) Download HS_CFG command 3) Response from firmware for HS_CFG 4) Suspend thread waits until handshake completes(i.e hs_activate becomes true) 5) SLEEP from firmware 6) SLEEP confirm downloaded to firmware. 7) SLEEP confirm response from firmware 8) Driver processes SLEEP confirm response and set hs_activate to wake up suspend thread 9) Exit suspend handler 10) Read sleep cookie in loop and wait until it indicates firmware is sleep. 11) After processing SLEEP confirm response, we are at the end of interrupt processing routine. Recheck if there are interrupts received while we were processing them. During suspend-resume stress test, it's been observed that we may end up acessing PCIe hardware(in 10 and 11) when PCIe bus is closed which leads to a kernel crash. This patch solves the problem with below changes. a) action 10 above can be done before 8 b) Skip 11 if hs_activated is true. SLEEP confirm response is the last interrupt from firmware. No need to recheck for pending interrupts. c) Add flush_workqueue() in suspend handler. Signed-off-by: Amitkumar Karwar Reviewed-by: Brian Norris Tested-by: Brian Norris Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/marvell/mwifiex/pcie.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -118,6 +118,7 @@ static int mwifiex_pcie_suspend(struct d adapter = card->adapter; hs_actived = mwifiex_enable_hs(adapter); + flush_workqueue(adapter->workqueue); /* Indicate device suspended */ adapter->is_suspended = true; @@ -1676,9 +1677,6 @@ static int mwifiex_pcie_process_cmd_comp if (!adapter->curr_cmd) { if (adapter->ps_state == PS_STATE_SLEEP_CFM) { - mwifiex_process_sleep_confirm_resp(adapter, skb->data, - skb->len); - mwifiex_pcie_enable_host_int(adapter); if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_SLEEP_CFM_DONE)) { @@ -1691,6 +1689,9 @@ static int mwifiex_pcie_process_cmd_comp while (reg->sleep_cookie && (count++ < 10) && mwifiex_pcie_ok_to_access_hw(adapter)) usleep_range(50, 60); + mwifiex_pcie_enable_host_int(adapter); + mwifiex_process_sleep_confirm_resp(adapter, skb->data, + skb->len); } else { mwifiex_dbg(adapter, ERROR, "There is no command but got cmdrsp\n"); @@ -2329,6 +2330,8 @@ static int mwifiex_process_pcie_int(stru ret = mwifiex_pcie_process_cmd_complete(adapter); if (ret) return ret; + if (adapter->hs_activated) + return ret; } if (card->msi_enable) {