Changes: - SAM: - Fix bug in SAN driver, triggered by thermal events. - Rename Surface Laptop / Book 3 HID input devices. - Implement Surface Laptop 1 and 2 caps-lock light. - Continued cleanup and misc. fixes. - Update docs. Links: - SAM:73ea41f1ec
- kernel:95c876cc05
631 lines
20 KiB
Diff
631 lines
20 KiB
Diff
From efb05978b88476658030f3df4bc4fccf5412d0a3 Mon Sep 17 00:00:00 2001
|
|
From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com>
|
|
Date: Thu, 20 Feb 2020 16:51:11 +0900
|
|
Subject: [PATCH 3/7] wifi
|
|
|
|
---
|
|
drivers/net/wireless/marvell/mwifiex/Makefile | 1 +
|
|
.../net/wireless/marvell/mwifiex/cfg80211.c | 26 ++
|
|
drivers/net/wireless/marvell/mwifiex/main.c | 6 +-
|
|
drivers/net/wireless/marvell/mwifiex/pcie.c | 84 ++++--
|
|
drivers/net/wireless/marvell/mwifiex/pcie.h | 3 +
|
|
.../wireless/marvell/mwifiex/pcie_quirks.c | 255 ++++++++++++++++++
|
|
.../wireless/marvell/mwifiex/pcie_quirks.h | 17 ++
|
|
.../net/wireless/marvell/mwifiex/sta_cmd.c | 14 +-
|
|
8 files changed, 374 insertions(+), 32 deletions(-)
|
|
create mode 100644 drivers/net/wireless/marvell/mwifiex/pcie_quirks.c
|
|
create mode 100644 drivers/net/wireless/marvell/mwifiex/pcie_quirks.h
|
|
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/Makefile b/drivers/net/wireless/marvell/mwifiex/Makefile
|
|
index fdfd9bf15ed4..8a1e7c5b9c6e 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/Makefile
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/Makefile
|
|
@@ -49,6 +49,7 @@ mwifiex_sdio-y += sdio.o
|
|
obj-$(CONFIG_MWIFIEX_SDIO) += mwifiex_sdio.o
|
|
|
|
mwifiex_pcie-y += pcie.o
|
|
+mwifiex_pcie-y += pcie_quirks.o
|
|
obj-$(CONFIG_MWIFIEX_PCIE) += mwifiex_pcie.o
|
|
|
|
mwifiex_usb-y += usb.o
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
|
|
index 9e6dc289ec3e..00b4bc446989 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
|
|
@@ -25,6 +25,11 @@
|
|
static char *reg_alpha2;
|
|
module_param(reg_alpha2, charp, 0);
|
|
|
|
+static bool allow_ps_mode;
|
|
+module_param(allow_ps_mode, bool, 0444);
|
|
+MODULE_PARM_DESC(allow_ps_mode,
|
|
+ "allow WiFi power management to be enabled. (default: disallowed)");
|
|
+
|
|
static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
|
|
{
|
|
.max = 3, .types = BIT(NL80211_IFTYPE_STATION) |
|
|
@@ -439,6 +444,27 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
|
|
|
|
ps_mode = enabled;
|
|
|
|
+ /* Allow ps_mode to be enabled only when allow_ps_mode is set
|
|
+ * (but always allow ps_mode to be disabled in case it gets enabled
|
|
+ * for unknown reason and you want to disable it) */
|
|
+ if (ps_mode && !allow_ps_mode) {
|
|
+ dev_info(priv->adapter->dev,
|
|
+ "Request to enable ps_mode received but it's disallowed "
|
|
+ "by module parameter. Rejecting the request.\n");
|
|
+
|
|
+ /* Return negative value to inform userspace tools that setting
|
|
+ * power_save to be enabled is not permitted. */
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (ps_mode)
|
|
+ dev_warn(priv->adapter->dev,
|
|
+ "WARN: Request to enable ps_mode received. Enabling it. "
|
|
+ "Disable it if you encounter connection instability.\n");
|
|
+ else
|
|
+ dev_info(priv->adapter->dev,
|
|
+ "Request to disable ps_mode received. Disabling it.\n");
|
|
+
|
|
return mwifiex_drv_set_power(priv, &ps_mode);
|
|
}
|
|
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
|
|
index d14e55e3c9da..99cc391e4afb 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/main.c
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
|
|
@@ -1453,7 +1453,7 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter)
|
|
}
|
|
|
|
/*
|
|
- * This function gets called during PCIe function level reset.
|
|
+ * This function can be used for shutting down the adapter SW.
|
|
*/
|
|
int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
|
|
{
|
|
@@ -1469,6 +1469,8 @@ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
|
|
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
|
|
mwifiex_deauthenticate(priv, NULL);
|
|
|
|
+ mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN);
|
|
+
|
|
mwifiex_uninit_sw(adapter);
|
|
adapter->is_up = false;
|
|
|
|
@@ -1479,7 +1481,7 @@ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
|
|
}
|
|
EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw);
|
|
|
|
-/* This function gets called during PCIe function level reset. Required
|
|
+/* This function can be used for reinitting the adapter SW. Required
|
|
* code is extracted from mwifiex_add_card()
|
|
*/
|
|
int
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
|
|
index fc1706d0647d..0b1fec807d28 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
|
|
@@ -27,12 +27,18 @@
|
|
#include "wmm.h"
|
|
#include "11n.h"
|
|
#include "pcie.h"
|
|
+#include "pcie_quirks.h"
|
|
|
|
#define PCIE_VERSION "1.0"
|
|
#define DRV_NAME "Marvell mwifiex PCIe"
|
|
|
|
static struct mwifiex_if_ops pcie_ops;
|
|
|
|
+static bool enable_device_dump;
|
|
+module_param(enable_device_dump, bool, 0644);
|
|
+MODULE_PARM_DESC(enable_device_dump,
|
|
+ "enable device_dump (default: disabled)");
|
|
+
|
|
static const struct of_device_id mwifiex_pcie_of_match_table[] = {
|
|
{ .compatible = "pci11ab,2b42" },
|
|
{ .compatible = "pci1b4b,2b42" },
|
|
@@ -144,8 +150,7 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
|
|
* registered functions must have drivers with suspend and resume
|
|
* methods. Failing that the kernel simply removes the whole card.
|
|
*
|
|
- * If already not suspended, this function allocates and sends a host
|
|
- * sleep activate request to the firmware and turns off the traffic.
|
|
+ * This function shuts down the adapter.
|
|
*/
|
|
static int mwifiex_pcie_suspend(struct device *dev)
|
|
{
|
|
@@ -153,31 +158,21 @@ static int mwifiex_pcie_suspend(struct device *dev)
|
|
struct pcie_service_card *card = dev_get_drvdata(dev);
|
|
|
|
|
|
- /* Might still be loading firmware */
|
|
- wait_for_completion(&card->fw_done);
|
|
-
|
|
adapter = card->adapter;
|
|
if (!adapter) {
|
|
dev_err(dev, "adapter is not valid\n");
|
|
return 0;
|
|
}
|
|
|
|
- mwifiex_enable_wake(adapter);
|
|
-
|
|
- /* Enable the Host Sleep */
|
|
- if (!mwifiex_enable_hs(adapter)) {
|
|
+ /* Shut down SW */
|
|
+ if (mwifiex_shutdown_sw(adapter)) {
|
|
mwifiex_dbg(adapter, ERROR,
|
|
"cmd: failed to suspend\n");
|
|
- clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
|
|
- mwifiex_disable_wake(adapter);
|
|
return -EFAULT;
|
|
}
|
|
|
|
- flush_workqueue(adapter->workqueue);
|
|
-
|
|
/* Indicate device suspended */
|
|
set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
|
|
- clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
|
|
|
|
return 0;
|
|
}
|
|
@@ -187,13 +182,13 @@ static int mwifiex_pcie_suspend(struct device *dev)
|
|
* registered functions must have drivers with suspend and resume
|
|
* methods. Failing that the kernel simply removes the whole card.
|
|
*
|
|
- * If already not resumed, this function turns on the traffic and
|
|
- * sends a host sleep cancel request to the firmware.
|
|
+ * If already not resumed, this function reinits the adapter.
|
|
*/
|
|
static int mwifiex_pcie_resume(struct device *dev)
|
|
{
|
|
struct mwifiex_adapter *adapter;
|
|
struct pcie_service_card *card = dev_get_drvdata(dev);
|
|
+ int ret;
|
|
|
|
|
|
if (!card->adapter) {
|
|
@@ -211,9 +206,11 @@ static int mwifiex_pcie_resume(struct device *dev)
|
|
|
|
clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
|
|
|
|
- mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
|
|
- MWIFIEX_ASYNC_CMD);
|
|
- mwifiex_disable_wake(adapter);
|
|
+ ret = mwifiex_reinit_sw(adapter);
|
|
+ if (ret)
|
|
+ dev_err(dev, "reinit failed: %d\n", ret);
|
|
+ else
|
|
+ mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
|
|
|
|
return 0;
|
|
}
|
|
@@ -229,8 +226,13 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
|
|
const struct pci_device_id *ent)
|
|
{
|
|
struct pcie_service_card *card;
|
|
+ struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
|
|
int ret;
|
|
|
|
+ /* disable bridge_d3 to fix driver crashing after suspend on gen4+
|
|
+ * Surface devices */
|
|
+ parent_pdev->bridge_d3 = false;
|
|
+
|
|
pr_debug("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n",
|
|
pdev->vendor, pdev->device, pdev->revision);
|
|
|
|
@@ -261,6 +263,9 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
|
|
return ret;
|
|
}
|
|
|
|
+ /* check quirks */
|
|
+ mwifiex_initialize_quirks(card);
|
|
+
|
|
if (mwifiex_add_card(card, &card->fw_done, &pcie_ops,
|
|
MWIFIEX_PCIE, &pdev->dev)) {
|
|
pr_err("%s failed\n", __func__);
|
|
@@ -376,7 +381,16 @@ static void mwifiex_pcie_reset_prepare(struct pci_dev *pdev)
|
|
mwifiex_shutdown_sw(adapter);
|
|
clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
|
|
clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags);
|
|
+
|
|
+ /* For Surface gen4+ devices, we need to put wifi into D3cold right
|
|
+ * before performing FLR
|
|
+ */
|
|
+ if (card->quirks & QUIRK_FW_RST_D3COLD)
|
|
+ mwifiex_pcie_reset_d3cold_quirk(pdev);
|
|
+
|
|
mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
|
|
+
|
|
+ card->pci_reset_ongoing = true;
|
|
}
|
|
|
|
/*
|
|
@@ -405,6 +419,8 @@ static void mwifiex_pcie_reset_done(struct pci_dev *pdev)
|
|
dev_err(&pdev->dev, "reinit failed: %d\n", ret);
|
|
else
|
|
mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
|
|
+
|
|
+ card->pci_reset_ongoing = false;
|
|
}
|
|
|
|
static const struct pci_error_handlers mwifiex_pcie_err_handler = {
|
|
@@ -2785,6 +2801,12 @@ static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter)
|
|
|
|
static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter)
|
|
{
|
|
+ if (!enable_device_dump) {
|
|
+ mwifiex_dbg(adapter, MSG,
|
|
+ "device_dump is disabled by module parameter\n");
|
|
+ return;
|
|
+ }
|
|
+
|
|
adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE);
|
|
if (!adapter->devdump_data) {
|
|
mwifiex_dbg(adapter, ERROR,
|
|
@@ -2802,6 +2824,16 @@ static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter)
|
|
{
|
|
struct pcie_service_card *card = adapter->card;
|
|
|
|
+ /* On Surface 3, reset_wsid method removes then re-probes card by
|
|
+ * itself. So, need to place it here and skip performing any other
|
|
+ * reset-related works.
|
|
+ */
|
|
+ if (card->quirks & QUIRK_FW_RST_WSID_S3) {
|
|
+ mwifiex_pcie_reset_wsid_quirk(card->dev);
|
|
+ /* skip performing any other reset-related works */
|
|
+ return;
|
|
+ }
|
|
+
|
|
/* We can't afford to wait here; remove() might be waiting on us. If we
|
|
* can't grab the device lock, maybe we'll get another chance later.
|
|
*/
|
|
@@ -2995,7 +3027,19 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter)
|
|
int ret;
|
|
u32 fw_status;
|
|
|
|
- cancel_work_sync(&card->work);
|
|
+ /* Perform the cancel_work_sync() only when we're not resetting
|
|
+ * the card. It's because that function never returns if we're
|
|
+ * in reset path. If we're here when resetting the card, it means
|
|
+ * that we failed to reset the card (reset failure path).
|
|
+ */
|
|
+ if (!card->pci_reset_ongoing) {
|
|
+ mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n");
|
|
+ cancel_work_sync(&card->work);
|
|
+ mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n");
|
|
+ } else {
|
|
+ mwifiex_dbg(adapter, MSG,
|
|
+ "skipped cancel_work_sync() because we're in card reset failure path\n");
|
|
+ }
|
|
|
|
ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status);
|
|
if (fw_status == FIRMWARE_READY_PCIE) {
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h
|
|
index f7ce9b6db6b4..f7e968306a0c 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
|
|
@@ -391,6 +391,9 @@ struct pcie_service_card {
|
|
struct mwifiex_msix_context share_irq_ctx;
|
|
struct work_struct work;
|
|
unsigned long work_flags;
|
|
+
|
|
+ bool pci_reset_ongoing;
|
|
+ unsigned long quirks;
|
|
};
|
|
|
|
static inline int
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c
|
|
new file mode 100644
|
|
index 000000000000..34dcd84f02a6
|
|
--- /dev/null
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c
|
|
@@ -0,0 +1,255 @@
|
|
+// SPDX-License-Identifier: GPL-2.0
|
|
+/*
|
|
+ * File for PCIe quirks.
|
|
+ */
|
|
+
|
|
+/* The low-level PCI operations will be performed in this file. Therefore,
|
|
+ * let's use dev_*() instead of mwifiex_dbg() here to avoid troubles (e.g.
|
|
+ * to avoid using mwifiex_adapter struct before init or wifi is powered
|
|
+ * down, or causes NULL ptr deref).
|
|
+ */
|
|
+
|
|
+#include <linux/acpi.h>
|
|
+#include <linux/dmi.h>
|
|
+
|
|
+#include "pcie_quirks.h"
|
|
+
|
|
+/* For reset_wsid quirk */
|
|
+#define ACPI_WSID_PATH "\\_SB.WSID"
|
|
+#define WSID_REV 0x0
|
|
+#define WSID_FUNC_WIFI_PWR_OFF 0x1
|
|
+#define WSID_FUNC_WIFI_PWR_ON 0x2
|
|
+/* WSID _DSM UUID: "534ea3bf-fcc2-4e7a-908f-a13978f0c7ef" */
|
|
+static const guid_t wsid_dsm_guid =
|
|
+ GUID_INIT(0x534ea3bf, 0xfcc2, 0x4e7a,
|
|
+ 0x90, 0x8f, 0xa1, 0x39, 0x78, 0xf0, 0xc7, 0xef);
|
|
+
|
|
+/* quirk table based on DMI matching */
|
|
+static const struct dmi_system_id mwifiex_quirk_table[] = {
|
|
+ {
|
|
+ .ident = "Surface Pro 4",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 4"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Pro 5",
|
|
+ .matches = {
|
|
+ /* match for SKU here due to generic product name "Surface Pro" */
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1796"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Pro 5 (LTE)",
|
|
+ .matches = {
|
|
+ /* match for SKU here due to generic product name "Surface Pro" */
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1807"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Pro 6",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 6"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Book 1",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Book 2",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 2"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Laptop 1",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Laptop 2",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop 2"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_D3COLD,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface 3",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_WSID_S3,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface 3",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "OEMB"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "OEMB"),
|
|
+ },
|
|
+ .driver_data = (void *)QUIRK_FW_RST_WSID_S3,
|
|
+ },
|
|
+ {
|
|
+ .ident = "Surface Pro 3",
|
|
+ .matches = {
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 3"),
|
|
+ },
|
|
+ .driver_data = 0,
|
|
+ },
|
|
+ {}
|
|
+};
|
|
+
|
|
+void mwifiex_initialize_quirks(struct pcie_service_card *card)
|
|
+{
|
|
+ struct pci_dev *pdev = card->dev;
|
|
+ const struct dmi_system_id *dmi_id;
|
|
+
|
|
+ dmi_id = dmi_first_match(mwifiex_quirk_table);
|
|
+ if (dmi_id)
|
|
+ card->quirks = (uintptr_t)dmi_id->driver_data;
|
|
+
|
|
+ if (!card->quirks)
|
|
+ dev_info(&pdev->dev, "no quirks enabled\n");
|
|
+ if (card->quirks & QUIRK_FW_RST_D3COLD)
|
|
+ dev_info(&pdev->dev, "quirk reset_d3cold enabled\n");
|
|
+ if (card->quirks & QUIRK_FW_RST_WSID_S3)
|
|
+ dev_info(&pdev->dev,
|
|
+ "quirk reset_wsid for Surface 3 enabled\n");
|
|
+}
|
|
+
|
|
+static void mwifiex_pcie_set_power_d3cold(struct pci_dev *pdev)
|
|
+{
|
|
+ dev_info(&pdev->dev, "putting into D3cold...\n");
|
|
+
|
|
+ pci_save_state(pdev);
|
|
+ if (pci_is_enabled(pdev))
|
|
+ pci_disable_device(pdev);
|
|
+ pci_set_power_state(pdev, PCI_D3cold);
|
|
+}
|
|
+
|
|
+static int mwifiex_pcie_set_power_d0(struct pci_dev *pdev)
|
|
+{
|
|
+ int ret;
|
|
+
|
|
+ dev_info(&pdev->dev, "putting into D0...\n");
|
|
+
|
|
+ pci_set_power_state(pdev, PCI_D0);
|
|
+ ret = pci_enable_device(pdev);
|
|
+ if (ret) {
|
|
+ dev_err(&pdev->dev, "pci_enable_device failed\n");
|
|
+ return ret;
|
|
+ }
|
|
+ pci_restore_state(pdev);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev)
|
|
+{
|
|
+ struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
|
|
+ int ret;
|
|
+
|
|
+ /* Power-cycle (put into D3cold then D0) */
|
|
+ dev_info(&pdev->dev, "Using reset_d3cold quirk to perform FW reset\n");
|
|
+
|
|
+ /* We need to perform power-cycle also for bridge of wifi because
|
|
+ * on some devices (e.g. Surface Book 1), the OS for some reasons
|
|
+ * can't know the real power state of the bridge.
|
|
+ * When tried to power-cycle only wifi, the reset failed with the
|
|
+ * following dmesg log:
|
|
+ * "Cannot transition to power state D0 for parent in D3hot".
|
|
+ */
|
|
+ mwifiex_pcie_set_power_d3cold(pdev);
|
|
+ mwifiex_pcie_set_power_d3cold(parent_pdev);
|
|
+
|
|
+ ret = mwifiex_pcie_set_power_d0(parent_pdev);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ ret = mwifiex_pcie_set_power_d0(pdev);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int mwifiex_pcie_reset_wsid_quirk(struct pci_dev *pdev)
|
|
+{
|
|
+ acpi_handle handle;
|
|
+ union acpi_object *obj;
|
|
+ acpi_status status;
|
|
+
|
|
+ dev_info(&pdev->dev, "Using reset_wsid quirk to perform FW reset\n");
|
|
+
|
|
+ status = acpi_get_handle(NULL, ACPI_WSID_PATH, &handle);
|
|
+ if (ACPI_FAILURE(status)) {
|
|
+ dev_err(&pdev->dev, "No ACPI handle for path %s\n",
|
|
+ ACPI_WSID_PATH);
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ if (!acpi_has_method(handle, "_DSM")) {
|
|
+ dev_err(&pdev->dev, "_DSM method not found\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ if (!acpi_check_dsm(handle, &wsid_dsm_guid,
|
|
+ WSID_REV, WSID_FUNC_WIFI_PWR_OFF)) {
|
|
+ dev_err(&pdev->dev,
|
|
+ "_DSM method doesn't support wifi power off func\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ if (!acpi_check_dsm(handle, &wsid_dsm_guid,
|
|
+ WSID_REV, WSID_FUNC_WIFI_PWR_ON)) {
|
|
+ dev_err(&pdev->dev,
|
|
+ "_DSM method doesn't support wifi power on func\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ /* card will be removed immediately after this call on Surface 3 */
|
|
+ dev_info(&pdev->dev, "turning wifi off...\n");
|
|
+ obj = acpi_evaluate_dsm(handle, &wsid_dsm_guid,
|
|
+ WSID_REV, WSID_FUNC_WIFI_PWR_OFF,
|
|
+ NULL);
|
|
+ if (!obj) {
|
|
+ dev_err(&pdev->dev,
|
|
+ "device _DSM execution failed for turning wifi off\n");
|
|
+ return -EIO;
|
|
+ }
|
|
+ ACPI_FREE(obj);
|
|
+
|
|
+ /* card will be re-probed immediately after this call on Surface 3 */
|
|
+ dev_info(&pdev->dev, "turning wifi on...\n");
|
|
+ obj = acpi_evaluate_dsm(handle, &wsid_dsm_guid,
|
|
+ WSID_REV, WSID_FUNC_WIFI_PWR_ON,
|
|
+ NULL);
|
|
+ if (!obj) {
|
|
+ dev_err(&pdev->dev,
|
|
+ "device _DSM execution failed for turning wifi on\n");
|
|
+ return -EIO;
|
|
+ }
|
|
+ ACPI_FREE(obj);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie_quirks.h b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.h
|
|
new file mode 100644
|
|
index 000000000000..3ef7440418e3
|
|
--- /dev/null
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.h
|
|
@@ -0,0 +1,17 @@
|
|
+/* SPDX-License-Identifier: GPL-2.0 */
|
|
+/*
|
|
+ * Header file for PCIe quirks.
|
|
+ */
|
|
+
|
|
+#include "pcie.h"
|
|
+
|
|
+/* quirks */
|
|
+#define QUIRK_FW_RST_D3COLD BIT(0)
|
|
+/* Surface 3 and Surface Pro 3 have the same _DSM method but need to
|
|
+ * be handled differently. Currently, only S3 is supported.
|
|
+ */
|
|
+#define QUIRK_FW_RST_WSID_S3 BIT(1)
|
|
+
|
|
+void mwifiex_initialize_quirks(struct pcie_service_card *card);
|
|
+int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev);
|
|
+int mwifiex_pcie_reset_wsid_quirk(struct pci_dev *pdev);
|
|
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
|
|
index 4ed10cf82f9a..bd735eb04981 100644
|
|
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
|
|
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
|
|
@@ -2339,16 +2339,10 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
|
|
if (ret)
|
|
return -1;
|
|
|
|
- if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
|
|
- /* Enable IEEE PS by default */
|
|
- priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
|
|
- ret = mwifiex_send_cmd(priv,
|
|
- HostCmd_CMD_802_11_PS_MODE_ENH,
|
|
- EN_AUTO_PS, BITMAP_STA_PS, NULL,
|
|
- true);
|
|
- if (ret)
|
|
- return -1;
|
|
- }
|
|
+ /* Not enabling ps_mode (IEEE power_save) by default. Enabling
|
|
+ * this causes connection instability, especially on 5GHz APs
|
|
+ * and eventually causes "firmware wakeup failed". Therefore,
|
|
+ * the relevant code was removed from here. */
|
|
|
|
if (drcs) {
|
|
adapter->drcs_enabled = true;
|
|
--
|
|
2.28.0
|
|
|