Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp297943rwb; Tue, 6 Dec 2022 21:31:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/EkSrtlZgqiY3DVEyXpqSDB4X4jEJW9WIaw5ypC9xCAdUjIqdDRsKDUz1EYZY4H+7/6oe X-Received: by 2002:a63:3196:0:b0:478:e7f6:f1e8 with SMTP id x144-20020a633196000000b00478e7f6f1e8mr3929781pgx.264.1670391104251; Tue, 06 Dec 2022 21:31:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670391104; cv=none; d=google.com; s=arc-20160816; b=F82KjFETs7SNTrxHui4cle65ctx09w1dKAlxTaW3+N308NLQ6OsxzaMkxyQXCysRBh 7r0PKnGuqxS64c6PJqJlfm7GhAGk9JXrp+wB+yhTLv8b52XEHs9wgx3G0DvdyXiHaWL6 QSeR1AnImBAf82S60QjNwZYaY2IuGcDEoEIRviKq5zbbl5bWtOROAJdz3kL0CFhr1w4Q GZJ9b4MpIqCgADvwqPwsH5VX0mtKeSeXMBPonxnUYwrfeTSxTnr+vlyUAgHJVMbJDVBr BtlOeUt7ahgFtCHyGeOPwAdEjfRH6O6WPDnbb3dT6jMftQWyy5mZ3j7QE6qAZ40rq3jq v7JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ELs4NC6PiIj6ouI8d5mNN0bzN7g1WKq2EiD/x98tu6M=; b=yRYMncK2NwvPp6hAEmlkuYnDvIUMBVKjGxQgZLNQCOU2LOUKAod+REwSrb9NZUPK5Q TB1Jc23ROOjzAQEKUfMz80BcljkMK5K8vbNragxMm08kJ06HsrzUnFisJBIDxmeYc8NP WZE2+PqCfuCuZ3AcZPIXvLw8/QXXmPV8VoczrFoRGdP7U5SwFAmBfYBJCaVQ68cwqTpw soZOoJu1iZpEPNa8D/7UZYLGzZ/avsXnlixBAhFtGJYhFQ8p9cSm/IpgaBXnbKWutBTB By+L/ILSrDj6QZMM4fNPrVcd01bDmz9MEvNIfuVZCh7mAODHBLj/imA9mUERtA9hJPDV KF+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=owCvSBm0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a63da06000000b0046e9da9ac40si18977858pgh.556.2022.12.06.21.31.36; Tue, 06 Dec 2022 21:31:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=owCvSBm0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbiLGFZi (ORCPT + 66 others); Wed, 7 Dec 2022 00:25:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiLGFZh (ORCPT ); Wed, 7 Dec 2022 00:25:37 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F4AB54B0E for ; Tue, 6 Dec 2022 21:25:36 -0800 (PST) X-UUID: 5c78e7d2ad9d42ffa29de709c3792e1d-20221207 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:38a67e4c-bbc5-4e38-affe-2f5355643631,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:987dc516-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: 5c78e7d2ad9d42ffa29de709c3792e1d-20221207 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1045949619; Wed, 07 Dec 2022 13:25:33 +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; 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 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 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); -- 2.18.0