From patchwork Wed Dec 7 05:24:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13066625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD5B2C352A1 for ; Wed, 7 Dec 2022 05:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ELs4NC6PiIj6ouI8d5mNN0bzN7g1WKq2EiD/x98tu6M=; b=tyxaW7dOyIENl5DXd2UP91Agap xVCsMT4hH1r5feATcFHDBn2iYfUILvPp3CYA5cKv82WGK2/iSD9lOf61b7M72mazhBd/KGrDHdneW IYv5qZxIhn3Xp8M9lA39f1zRk0DLwn7rPseo+yPWpJHoXmRQ6n5tnarQ9ejchiDBt0yaeXcpmj3Ci L1I7CfWmbvU56P5H8JZMluOwE0607nzYEjXzY4UNVyw7ZSFwzQ5x+mrjTqI7xx5OUzPL6TnKjDEFQ xOeNbS0+itKtCWesicRMBFCu6UtyDmnUouBi9lPgJGGe6BhoaPTOeMxc+GQ8ATQHwTLqfXlKiJ7Gc oBta/Eww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwl-00BePR-8K; Wed, 07 Dec 2022 05:26:19 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwi-00BeBI-IL for linux-mediatek@lists.infradead.org; Wed, 07 Dec 2022 05:26:17 +0000 X-UUID: 7b47660cfcad493b9ba03026e42552c9-20221206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ELs4NC6PiIj6ouI8d5mNN0bzN7g1WKq2EiD/x98tu6M=; b=owCvSBm08W4lrMYXd85uT3ETGY+LoS5vSlIszuEUH4QML/8dFkJFcgYS1DC4efRUlPxNx2v+XygJPOJryrYKot5MUyFH6SRhtzyd2Xgi8ylTx7N3FmMPycX/K1JgFkz3ufkGBqGhW4rjuGVaMqFVMyqU2co3JCw9uWB8OcDXJGU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:09db9a05-5b10-410b-b706-1e3a1a934008,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:dcaaed0,CLOUDID:f080c516-b863-49f8-8228-cbdfeedd1fa4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 7b47660cfcad493b9ba03026e42552c9-20221206 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1587628695; Tue, 06 Dec 2022 22:26:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 7 Dec 2022 13:25:32 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 7 Dec 2022 13:25:32 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu , Ryder Lee Subject: [PATCH v2 1/3] wifi: mt76: mt7915: rework mt7915_thermal_set_cur_throttle_state() Date: Wed, 7 Dec 2022 13:24:58 +0800 Message-ID: <20221207052500.10855-2-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> References: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221206_212616_637272_D085F03F X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This patch includes 3 changes: 1. The maximum throttle state can be set to 100 to fix the problem that thermal_protect_disable can never be triggered. 2. Throttle state do not need to be different from the previous state. This will make it is impossible for users to just change the trigger/restore temp but not the throttle state. 3. Add dev_err so that it is easier to see invalid setting while looking at dmesg. Fixes: 771cd8d4c369 ("mt76: mt7915e: Fix degraded performance after temporary overheat") Co-developed-by: Ryder Lee Signed-off-by: Ryder Lee Signed-off-by: Howard Hsu --- .../net/wireless/mediatek/mt76/mt7915/init.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index c810c31fbd6e..abeecf15f1c8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -131,14 +131,17 @@ mt7915_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev, u8 throttling = MT7915_THERMAL_THROTTLE_MAX - state; int ret; - if (state > MT7915_CDEV_THROTTLE_MAX) + if (state > MT7915_THERMAL_THROTTLE_MAX) { + dev_err(phy->dev->mt76.dev, + "please specify a valid throttling state\n"); return -EINVAL; + } - if (phy->throttle_temp[0] > phy->throttle_temp[1]) - return 0; - - if (state == phy->cdev_state) - return 0; + if (phy->throttle_temp[0] > phy->throttle_temp[1]) { + dev_err(phy->dev->mt76.dev, + "temp1_crit shall not be greater than temp1_max\n"); + return -EINVAL; + } /* * cooling_device convention: 0 = no cooling, more = more cooling @@ -164,7 +167,7 @@ static void mt7915_unregister_thermal(struct mt7915_phy *phy) struct wiphy *wiphy = phy->mt76->hw->wiphy; if (!phy->cdev) - return; + return; sysfs_remove_link(&wiphy->dev.kobj, "cooling_device"); thermal_cooling_device_unregister(phy->cdev); @@ -1101,7 +1104,6 @@ static void mt7915_stop_hardware(struct mt7915_dev *dev) mt7986_wmac_disable(dev); } - int mt7915_register_device(struct mt7915_dev *dev) { struct ieee80211_hw *hw = mt76_hw(dev); From patchwork Wed Dec 7 05:24:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13066626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74C62C47089 for ; Wed, 7 Dec 2022 05:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0CGEMjSYch1/HK0DQ9Nfh/Rz9YDEeejvih+yf/PFCdg=; b=RR9RE4+zH/JVTG0rhMS4gSTBYF tzLhOR0kXDJiUq9RKfO8BMXlJr4D+EeXEtuuNTVzOydzNHOkPtko1SqChIsJpRKGz8svNYrsk26gc wqA1O5dZLcLqiYMsro8x2U1LAf7NMD9dSjKhC6JmTa7hd7EgWPh2sg65/p/dxlMgmK5AysM4GDZjO sNj0PKrI1TywNTF7kyFjedIqLI1QbN6g7LyKxOaln4r+mpmG6izNoiUjSSKkpcgs4vO5WwkMTmFHr VkyHEhD8zLB7IVsrnq0RaBlqb/0oS0pYh4V1quuoNeHfZL+/dtcu0XYTUg3Hhoh+PdwVpQAVL4iEL EfRw76CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwm-00BeS8-W1; Wed, 07 Dec 2022 05:26:20 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwi-00Be8f-IL for linux-mediatek@lists.infradead.org; Wed, 07 Dec 2022 05:26:19 +0000 X-UUID: 8058636a6981481d9f24f7c6a332fca9-20221206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=0CGEMjSYch1/HK0DQ9Nfh/Rz9YDEeejvih+yf/PFCdg=; b=tJgE2b/KoCQMuuBtbokZVBjtoF3fyXgffmDS1Qhr8pY1bNRs2CDD73gXQ+8kSdJ81cC/I+laG9JnkC13n8J3PnyAdramjQ/B67mAcc3mMfJFbmbQcFaFa/bNubWK3UcZ/lLT5R4DOTY+W0y67KWPJ5LBusbowuPW01PgyJeRtro=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:04090d8f-cfbd-4fdd-b8d8-022a42c17a2e,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:dcaaed0,CLOUDID:f280c516-b863-49f8-8228-cbdfeedd1fa4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 8058636a6981481d9f24f7c6a332fca9-20221206 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 89445672; Tue, 06 Dec 2022 22:26:09 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 7 Dec 2022 13:25:36 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 7 Dec 2022 13:25:36 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu Subject: [PATCH v2 2/3] wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only after init_work Date: Wed, 7 Dec 2022 13:24:59 +0800 Message-ID: <20221207052500.10855-3-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> References: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221206_212616_637279_DFADC988 X-CRM114-Status: GOOD ( 10.91 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Enable thermal management by default shall not be executed during mcu init. This causes thermal configuration being reset to the firmware default settings. Fixes: 0063b86c9120 ("mt76: mt7915e: Enable thermal management by default") Signed-off-by: Howard Hsu --- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 3 +-- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index abeecf15f1c8..8f4561eed5db 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -204,8 +204,7 @@ static int mt7915_thermal_init(struct mt7915_phy *phy) phy->throttle_temp[0] = 110; phy->throttle_temp[1] = 120; - return mt7915_mcu_set_thermal_throttling(phy, - MT7915_THERMAL_THROTTLE_MAX); + return 0; } static void mt7915_led_set_config(struct led_classdev *led_cdev, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 0511d6a505b0..fc87216e40b1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -57,6 +57,11 @@ int mt7915_run(struct ieee80211_hw *hw) mt7915_mac_enable_nf(dev, phy->mt76->band_idx); } + ret = mt7915_mcu_set_thermal_throttling(phy, MT7915_THERMAL_THROTTLE_MAX); + + if (ret) + goto out; + ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, phy->mt76->band_idx); if (ret) From patchwork Wed Dec 7 05:25:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13066623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACDA2C352A1 for ; Wed, 7 Dec 2022 05:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Jsfib5T7wSVjC6QbFl/gYrFKUGPmdooacuNRC3W5K6k=; b=hT6UON3LzHRJAVM0Vn6RQwnKW7 tdrKZ+fjP7YliIZaUxDWu919ABMbiNHfWDJQR5lLhGTcaKEI9ez8JiAl3jeOrmh+fPBrweL0/92T0 sLqGRzuG5SL2l7p9EwnKBMSnf8wZvOfJyYV/zwxOzJU7kDCnH+1+XY08UfdVXbbfzpdf042EFxcse LtQ/sfzlAK1hIcteQLiB+IhWETWg9msoCoagkdWcfnAoWlmQj04Ty4WJ2oH7S9V1McmAjhahmxaWv IcPVt1HDuoV2wkA/AqP6BmrElKduqWLJoUUpNu8yEXwSvVngO7RlXDwvyJG+CSEbpTlh0a53A2GBa 9YPXtMHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwQ-00BdgM-9Y; Wed, 07 Dec 2022 05:25:58 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2mwN-00BdMs-ND for linux-mediatek@lists.infradead.org; Wed, 07 Dec 2022 05:25:57 +0000 X-UUID: c76191d8640547978a5f2dda97679839-20221206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Jsfib5T7wSVjC6QbFl/gYrFKUGPmdooacuNRC3W5K6k=; b=b50//Sthinsa4tAoIu6SgH2itSAhbCtxUVtXdUtEFVJ0seStS5Lm8TCS6/Vtjpv27BI06lzPn88u7l6kn3Vc+hd4DpygxEYGrz2AeyG0alwOTMFU0vxyLLRewzM/tw/CEuDZYpDMALi0z6OUtY1yRHPY7a10WazZnA3yNGUWEiw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:b4dea011-003d-4790-9f5c-c39c42747b68,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:dcaaed0,CLOUDID:ba7ec516-b863-49f8-8228-cbdfeedd1fa4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: c76191d8640547978a5f2dda97679839-20221206 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1324297913; Tue, 06 Dec 2022 22:25:42 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 7 Dec 2022 13:25:40 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 7 Dec 2022 13:25:40 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu Subject: [PATCH v2 3/3] wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling() Date: Wed, 7 Dec 2022 13:25:00 +0800 Message-ID: <20221207052500.10855-4-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> References: <20221207052500.10855-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221206_212555_788288_71A30C54 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Firmware expects to disable thermal protect first before reconfiguring. Fixes: 34b877d972be ("mt76: mt7915: add thermal cooling device support") Signed-off-by: Howard Hsu --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index b2652de082ba..176d293eb32a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -3070,19 +3070,22 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state) } __packed req = { .ctrl = { .band_idx = phy->mt76->band_idx, + .type.protect_type = 1, + .type.trigger_type = 1, }, }; - int level; + int level, ret; - if (!state) { - req.ctrl.ctrl_id = THERMAL_PROTECT_DISABLE; - goto out; - } + req.ctrl.ctrl_id = THERMAL_PROTECT_DISABLE; + + ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT), + &req, sizeof(req.ctrl), false); + + if (ret || !state) + return ret; /* set duty cycle and level */ for (level = 0; level < 4; level++) { - int ret; - req.ctrl.ctrl_id = THERMAL_PROTECT_DUTY_CONFIG; req.ctrl.duty.duty_level = level; req.ctrl.duty.duty_cycle = state; @@ -3100,8 +3103,6 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state) req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10); req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]); req.sustain_time = cpu_to_le16(10); - -out: req.ctrl.type.protect_type = 1; req.ctrl.type.trigger_type = 1;