From patchwork Tue Dec 6 01:29:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13065288 X-Patchwork-Delegate: nbd@nbd.name 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27DD0C47089 for ; Tue, 6 Dec 2022 01:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231960AbiLFBba (ORCPT ); Mon, 5 Dec 2022 20:31:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbiLFBb2 (ORCPT ); Mon, 5 Dec 2022 20:31:28 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CF7E1EC75 for ; Mon, 5 Dec 2022 17:31:26 -0800 (PST) X-UUID: 0bee2fcb5b6b4231b5a20a4bd1d84324-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=2q+cYyA+eU3efar4YrIT4KglvWnkd7xCksdSU/9600Y=; b=bUAxt1mZeEq+b1kq14gsAjTcoALWQUw0OCs/hPscIWZGMq1TM7DSPAfiTyc7VrXdlfqztXvzL3bQvmryRw3hE3GsFde7wgFGQq3HZsLaZ5mHYbls8HPxWk+sCnneRdyh1W5/juyzAUAxYsAqitQ7loJH31BKMgTmzTb4jjbvzYg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:6ccda5ef-45bb-4a03-9493-d6a5e3209e37,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:8172a016-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: 0bee2fcb5b6b4231b5a20a4bd1d84324-20221206 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 499356346; Tue, 06 Dec 2022 09:31:19 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 6 Dec 2022 09:31:18 +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; Tue, 6 Dec 2022 09:31:18 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu , Ryder Lee Subject: [PATCH 1/3] wifi: mt76: mt7915: rework mt7915_thermal_set_cur_throttle_state() Date: Tue, 6 Dec 2022 09:29:49 +0800 Message-ID: <20221206012951.10719-2-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> References: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch includes 3 changes: 1. The maximum throttle state can be set to 100 to fix the problem that maximum tx cyle can only be set to 99. 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: 9fee8f3736eb ("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 Tue Dec 6 01:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13065289 X-Patchwork-Delegate: nbd@nbd.name 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0204FC4708E for ; Tue, 6 Dec 2022 01:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbiLFBbb (ORCPT ); Mon, 5 Dec 2022 20:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbiLFBb2 (ORCPT ); Mon, 5 Dec 2022 20:31:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F181DF18 for ; Mon, 5 Dec 2022 17:31:27 -0800 (PST) X-UUID: 93b7f41405764a2eb841c651c5b1afd2-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=zoVXkwUOmjVgqBFQ8Wiwthi4PPghZRvpSDeFn15tlbI=; b=pBi4Qye441nurPvungQPbOxga0ZqDof+uZozM9A0LLt94otHdHPM+XTg/XTEMnNexi48GsqBVJq4eeHDuqxGKnqqy9XAMkx9zqJq4BrzXan/VVyHUnCkehqrOTkYPzoO1bz1/r0SQBZIkfMVO3E7iO/8/+NwOMUVNsNfbuyFF3s=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:015334ef-a6a4-4c5d-a72b-371320950ed0,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:75 X-CID-INFO: VERSION:1.1.14,REQID:015334ef-a6a4-4c5d-a72b-371320950ed0,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:75 X-CID-META: VersionHash:dcaaed0,CLOUDID:8872a016-b863-49f8-8228-cbdfeedd1fa4,B ulkID:22120609312274RTOEHV,BulkQuantity:0,Recheck:0,SF:28|17|19|48,TC:nil, Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 93b7f41405764a2eb841c651c5b1afd2-20221206 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 736439031; Tue, 06 Dec 2022 09:31:21 +0800 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; Tue, 6 Dec 2022 09:31:20 +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; Tue, 6 Dec 2022 09:31:20 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu Subject: [PATCH 2/3] wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only after init_work Date: Tue, 6 Dec 2022 09:29:50 +0800 Message-ID: <20221206012951.10719-3-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> References: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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: c67df0d3130a ("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 Tue Dec 6 01:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Hsu X-Patchwork-Id: 13065287 X-Patchwork-Delegate: nbd@nbd.name 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BFDDC4708C for ; Tue, 6 Dec 2022 01:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbiLFBb3 (ORCPT ); Mon, 5 Dec 2022 20:31:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbiLFBb2 (ORCPT ); Mon, 5 Dec 2022 20:31:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0B681E3EE for ; Mon, 5 Dec 2022 17:31:26 -0800 (PST) X-UUID: b38e1c255f674f4b9744ef1a3bee7825-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=rf2xlHbnDoi+Wpwgi2HpILhMqC3GA1rq9G2fhy9H4X4=; b=tkQ8Jtd662x3QmtmTYhDzSZ6cK6SHT92ApiHeYOlCfr+UT0kQa/ZDgoF4jYEgYERRi+QDKVPaT2UhAjfl+OpgRUbU6lm6PaiX9f9jADuQtZYjCjbh3qJx8mDnjX3cMzD3L+B2D2eXnOWU6fp3wIC2ANQe0lGNMpDVGPtKJL5AcY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:8e1cd9cf-8a27-44d4-b60a-767b99c1e6b4,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:95 X-CID-INFO: VERSION:1.1.14,REQID:8e1cd9cf-8a27-44d4-b60a-767b99c1e6b4,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:95 X-CID-META: VersionHash:dcaaed0,CLOUDID:e472a016-b863-49f8-8228-cbdfeedd1fa4,B ulkID:221206093125MAWOBAQD,BulkQuantity:0,Recheck:0,SF:28|17|19|48,TC:nil, Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: b38e1c255f674f4b9744ef1a3bee7825-20221206 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 846715754; Tue, 06 Dec 2022 09:31:24 +0800 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; Tue, 6 Dec 2022 09:31:22 +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; Tue, 6 Dec 2022 09:31:22 +0800 From: Howard Hsu To: Felix Fietkau CC: Lorenzo Bianconi , Ryder Lee , Shayne Chen , Evelyn Tsai , , , Howard Hsu Subject: [PATCH 3/3] wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling() Date: Tue, 6 Dec 2022 09:29:51 +0800 Message-ID: <20221206012951.10719-4-howard-yh.hsu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> References: <20221206012951.10719-1-howard-yh.hsu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Firmware expects to disable thermal protect first before reconfiguring. Fixes: afab0e8202ff ("mt76: mt7915: add thermal cooling device support") Signed-off-by: Howard Hsu --- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index b2652de082ba..e1b6d644cc14 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -3070,18 +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; @@ -3101,7 +3105,6 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state) 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;