Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1293222pxb; Thu, 28 Oct 2021 00:38:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ0SQ/tEum8btJalB9GIPElgrAJrLd//0yF24glyRtVFyc7liMLhto2chERCsUkG6VLvmv X-Received: by 2002:a63:700f:: with SMTP id l15mr1911339pgc.437.1635406685136; Thu, 28 Oct 2021 00:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635406685; cv=none; d=google.com; s=arc-20160816; b=WPWjydw/Zzchc83foJqZkJToYdBl9e1/OcDE2vpsxcmweJ07HtTuiSUfUtkL+O/LaP 1wC6sZ1WSVoVOYacpjMyKDRyLoYBDmoq94cEZAAyW+rAJnNagANjCFIlCvz7HjrEueGX YDxXInr5wSzhXISCiQfdYgNE36fKilm2gwqDG/46fLWtHhMvHL3OfOl2Gv0BT36oWuEG ZUi/WfPXqPwuXeG1BsreKBYRyya1SIBo/gRX0QnxV8CTU3U20SdjLyViLl3bJVKT1F/H ECV2UxVMyECxx4LfEmss58fNqmQTgrXRD1CJCUbVgglbSXemOjJq++jACfc2AB9D9orl kNZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ppUAD27YLPJk3pp4jUF0iz8qhnq0mx1UXsDV8cLsQB8=; b=OoFfHOXvHKtCBfscRhzwHI+SGw8iZsNV6BjRbpuPbpIczzZKOs2bqWiiR1elhDUbSe JBWeU+K8VX/6FKEWKiKGVCwyYzjNj1cg3is0tlu38UPLGcl1Zt3UoWEFJKe/L2RwsgPr MP+EHblt0d5wNxQ15lEF7+b8gnFRxrjOmvi1r6gX6+1i9j9h0uDpXB34mTl/QXb0OIEP MAtzSleF0nxHo8hiSC5pp0f3zOjjgRMODa/4tCx9FnBe8yO1MOvI/RsnJqbEGzcSl/pC Ztl1G4/INo4iwi2w6t+3JRn4Ay3t4CBHk6eHv1Xp2zHZLdKdEAxawUPfiTjEA4N1KWAZ HVgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si3510197pjf.141.2021.10.28.00.37.56; Thu, 28 Oct 2021 00:38:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhJ1HkP (ORCPT + 67 others); Thu, 28 Oct 2021 03:40:15 -0400 Received: from mout-p-102.mailbox.org ([80.241.56.152]:18652 "EHLO mout-p-102.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbhJ1HkN (ORCPT ); Thu, 28 Oct 2021 03:40:13 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Hfy8820NFzQl1x; Thu, 28 Oct 2021 09:37:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= To: Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , Kalle Valo , "David S. Miller" , Jakub Kicinski Cc: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= , Tsuchiya Yuto , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maximilian Luz , Andy Shevchenko , Bjorn Helgaas , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH] mwifiex: Add quirk to disable deep sleep with certain hardware revision Date: Thu, 28 Oct 2021 09:37:29 +0200 Message-Id: <20211028073729.24408-1-verdre@v0yd.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6340818B8 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The 88W8897 PCIe+USB card in the hardware revision 20 apparently has a hardware issue where the card wakes up from deep sleep randomly and very often, somewhat depending on the card activity, maybe the hardware has a floating wakeup pin or something. Those continuous wakeups prevent the card from entering host sleep when the computer suspends. And because the host won't answer to events from the card anymore while it's suspended, the firmwares internal powersaving state machine seems to get confused and the card can't sleep anymore at all after that. Since we can't work around that hardware bug in the firmware, let's get the hardware revision string from the firmware and match it with known bad revisions. Then disable auto deep sleep for those revisions, which makes sure we no longer get those spurious wakeups. Signed-off-by: Jonas Dreßler --- drivers/net/wireless/marvell/mwifiex/main.c | 14 ++++++++++++++ drivers/net/wireless/marvell/mwifiex/main.h | 1 + .../net/wireless/marvell/mwifiex/sta_cmdresp.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 19b996c6a260..5ab2ad4c7006 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -226,6 +226,19 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter) return 0; } +static void maybe_quirk_fw_disable_ds(struct mwifiex_adapter *adapter) +{ + struct mwifiex_private *priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA); + struct mwifiex_ver_ext ver_ext; + + set_bit(MWIFIEX_IS_REQUESTING_FW_VEREXT, &adapter->work_flags); + + memset(&ver_ext, 0, sizeof(ver_ext)); + ver_ext.version_str_sel = 1; + mwifiex_send_cmd(priv, HostCmd_CMD_VERSION_EXT, + HostCmd_ACT_GEN_GET, 0, &ver_ext, false); +} + /* * The main process. * @@ -356,6 +369,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) { adapter->hw_status = MWIFIEX_HW_STATUS_READY; mwifiex_init_fw_complete(adapter); + maybe_quirk_fw_disable_ds(adapter); } } diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index 90012cbcfd15..1e829d84b1f6 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -524,6 +524,7 @@ enum mwifiex_adapter_work_flags { MWIFIEX_IS_SUSPENDED, MWIFIEX_IS_HS_CONFIGURED, MWIFIEX_IS_HS_ENABLING, + MWIFIEX_IS_REQUESTING_FW_VEREXT, }; struct mwifiex_band_config { diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c index 6b5d35d9e69f..8e49ebca1847 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c @@ -708,6 +708,22 @@ static int mwifiex_ret_ver_ext(struct mwifiex_private *priv, { struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext; + if (test_and_clear_bit(MWIFIEX_IS_REQUESTING_FW_VEREXT, &priv->adapter->work_flags)) { + if (strncmp(ver_ext->version_str, "ChipRev:20, BB:9b(10.00), RF:40(21)", 128) == 0) { + struct mwifiex_ds_auto_ds auto_ds = { + .auto_ds = DEEP_SLEEP_OFF, + }; + + mwifiex_dbg(priv->adapter, MSG, + "Bad HW revision detected, disabling deep sleep\n"); + + mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, + DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds, false); + } + + return 0; + } + if (version_ext) { version_ext->version_str_sel = ver_ext->version_str_sel; memcpy(version_ext->version_str, ver_ext->version_str, -- 2.31.1