Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1941079pxj; Sat, 22 May 2021 06:24:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfc878ZCvcY8u8VfUJTpKfi1I0CSFwyCSgFh4p4PkUp7Azh09An9PCEx9/IHj1RoxjPiS8 X-Received: by 2002:a17:907:6288:: with SMTP id nd8mr15169124ejc.223.1621689842786; Sat, 22 May 2021 06:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621689842; cv=none; d=google.com; s=arc-20160816; b=1LMi2wKPLXbQQKUf0WoOUpUvYN6sY1MUw1vx0cOmxIyNh7O8Ru7+LRVHV7tjuyhHRi vebCo7oCBuL1P3NZsK0Gxm0AyhUrA7NEw3o/+nr5ZlL0zmP8XDSX1UgQbwqvPr2EzQyH eXh6E8rpTHtO/Z/je1YK6y70wVlr6dviwUA7wVgzyZ69sCmv5dLLYkoefEa7sME5qQv+ W3p7X6fuh7OsbRACA3Adcq3vtjeSxky4x5VgwmNATUf2Yu/RsWCUks877Ryi9x9f3cE7 HDsYB3NlLlNeHypSi/DbW+S3zi1jcNubM4e3+6EIYLvLozFTPP8k7rQ5KK7tM3KN20Jm FdtQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JauVDqKwqnR659j9/VbW/kd3HyRLK6Vx4ZDe0lGRCjM=; b=XWluXCh5wgsuqFaltzolZonwRo9hXA5fvpLWoY1qQGzbYmUTF6l0mZcsEEqhsS7Pnp nJsLYkYpLaP++g2Gm4RO4I+tvFGqi9roA27c2pOIwCECWiozigru9zfUdY6+8PSKohbi 3P/ai4CYw3Ye3UCZS00VOH7mfVDEHX6Vq6JHRm5rCLVoEvcchGDw/wxsDS0Kms3keM2l jzcO1uY34AJ0hSGGuQsEUwZclnz/37uu5dUdcCpjD+r5hzE3Ypxd+C7D/UdO8XucGmwX l4xvo7ZKZjCsXVRjsqYMewGpvmvg6XJZyITLKrcnUk9QZOeVBttH8jR9l3wxfqUreEuZ 7xUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 n15si8465369edy.29.2021.05.22.06.23.38; Sat, 22 May 2021 06:24:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbhEVNW5 (ORCPT + 99 others); Sat, 22 May 2021 09:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbhEVNWx (ORCPT ); Sat, 22 May 2021 09:22:53 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3630EC061574; Sat, 22 May 2021 06:21:28 -0700 (PDT) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (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-202.mailbox.org (Postfix) with ESMTPS id 4FnPJ63g4WzQjmx; Sat, 22 May 2021 15:21:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 5KQTvm_awH-q; Sat, 22 May 2021 15:21:22 +0200 (CEST) From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= To: Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , 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, linux-pci@vger.kernel.org, Maximilian Luz , Andy Shevchenko , Bjorn Helgaas , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [RFC PATCH 3/3] mwifiex: pcie: add reset_wsid quirk for Surface 3 Date: Sat, 22 May 2021 15:18:27 +0200 Message-Id: <20210522131827.67551-4-verdre@v0yd.nl> In-Reply-To: <20210522131827.67551-1-verdre@v0yd.nl> References: <20210522131827.67551-1-verdre@v0yd.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -3.16 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0D74B1802 X-Rspamd-UID: 56ddeb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tsuchiya Yuto This commit adds reset_wsid quirk and uses this quirk for Surface 3 on card reset. To reset mwifiex on Surface 3, it seems that calling the _DSM method exists in \_SB.WSID [1] device is required. On Surface 3, calling the _DSM method removes/re-probes the card by itself. So, need to place the reset function before performing FLR and skip performing any other reset-related works. Note that Surface Pro 3 also has the WSID device [2], but it seems to need more work. This commit only supports Surface 3 yet. [1] https://github.com/linux-surface/acpidumps/blob/05cba925f3a515f222acb5b3551a032ddde958fe/surface_3/dsdt.dsl#L11947-L12011 [2] https://github.com/linux-surface/acpidumps/blob/05cba925f3a515f222acb5b3551a032ddde958fe/surface_pro_3/dsdt.dsl#L12164-L12216 Signed-off-by: Tsuchiya Yuto Signed-off-by: Jonas Dreßler --- drivers/net/wireless/marvell/mwifiex/pcie.c | 10 ++ .../wireless/marvell/mwifiex/pcie_quirks.c | 91 +++++++++++++++++++ .../wireless/marvell/mwifiex/pcie_quirks.h | 6 ++ 3 files changed, 107 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index d9acfea395ad..6e049236ae1a 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -2969,6 +2969,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. */ diff --git a/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c index b5f214fc1212..f0a6fa0a7ae5 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.c @@ -9,10 +9,21 @@ * down, or causes NULL ptr deref). */ +#include #include #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[] = { { @@ -81,6 +92,22 @@ static const struct dmi_system_id mwifiex_quirk_table[] = { }, .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 Pro 3", + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 3"), + }, + .driver_data = 0, + }, {} }; @@ -97,6 +124,9 @@ void mwifiex_initialize_quirks(struct pcie_service_card *card) 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) @@ -153,3 +183,64 @@ int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev) 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 index 549093067813..d90ada3f2daa 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie_quirks.h +++ b/drivers/net/wireless/marvell/mwifiex/pcie_quirks.h @@ -7,5 +7,11 @@ #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); -- 2.31.1