Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3183487rdb; Wed, 13 Sep 2023 04:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqOawozWgzSkiDNMo5NPGX2k/bKmMh81K0C2rKvALGO1bX7dhAx85FSg+eCi+aIggfRtha X-Received: by 2002:a17:902:e552:b0:1c3:dad8:bb99 with SMTP id n18-20020a170902e55200b001c3dad8bb99mr2397454plf.64.1694606380623; Wed, 13 Sep 2023 04:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694606380; cv=none; d=google.com; s=arc-20160816; b=R84Rklo7mslOTnxKaTXXyG/7gwFNzUDkexC/SnCXC2E/IpKksTsipgfp2lX+f0CAk/ bw3WL9znAxfbB7watt8J/Zk9CLzk0LEalharf+OpMzxXFQFmO/Qw0LTWpXIFJd/ua81x qG4RZxCybJ2Lw42uvP49XWjPjgI+D5TvDR0IV3i48gQMxKpEYA1Uw6a9+1Jowadrmm6P PBqj6xwafYtm7ys81DPhMb7fropM5WKcOAqWvIrXN3o1G8H6AQaWxmKDzMCBZzveH0TR oYlf7xIoBOhcTXblxyhgFRqFF6c+dz0nfT6YeKlsSQIL8NH7BIDlYEql0D1/WEnFNkAO TeHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ibyZ5LJzB/pb6BwD3l40RfUor4LBH1wlTEIRku+Sfuw=; fh=Op0dIohkcZ+Jrg+sxda+z3IbZO8gftns/dF+ttL0Qfg=; b=RmSER7IrACIL8Q9u/rGo1ytSy7b/HFdmxDiaOXuN+S0M5ipKzu1l8KHaqU1VSyTnsp Z57p3UwAzuc18sDuj03ZVMaEBnm59obmi3FFkXag008QZ/qZFRt0r3XhphRLsX/hw29c UeCC7RisWgPy4Bx08tn+/oJIGuNtHIqiU+XWzjwlJBFR1MCKo0PUqiVOjSndsAB/bf+P YljujrwuTTK4EinpDlqddYbQcoYnA3UpTPLT5OEM2pS7TqwOXXZRcNgU6c5eY5KHtc20 wdB34Y8rltVR63hgooyJDsJUmjtcMEikzgHW67OcZe5p/AAXDxUqGBkZ+5UsFSXWcmuW DlJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ORMUwgS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id kg7-20020a170903060700b001bb907f3981si9636704plb.302.2023.09.13.04.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 04:59:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ORMUwgS2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8F86680926AA; Wed, 13 Sep 2023 04:44:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240441AbjIMLoD (ORCPT + 99 others); Wed, 13 Sep 2023 07:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbjIMLoB (ORCPT ); Wed, 13 Sep 2023 07:44:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC15710E6; Wed, 13 Sep 2023 04:43:57 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id AE873660733E; Wed, 13 Sep 2023 12:43:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694605436; bh=rJbG4m613P7qZGZ7uqt8izGJD3tSdXSLnNutOtXNuWs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ORMUwgS2B3hoimYVbdUOKJqBVEH4GpvH6354MjoGlyb1nIxiwdh76Z1bHMBHCZHhE gJM0wLw4mvf80N0ATzZoRb063pKYtM5V+SisHSjZ6/lh8W/98BBT2QGinDJXG4iddQ +kP9Y5O9EFlBqKEaaw3kmPPzO8vcDqhu5vLjIx3Zc/YyApq8xIdiH1gAv59MW6DfQz 7f37oC1Zo+nh4PH0WJ6OyJJ40ejgySOTwx75PCxf2AsF3O5xkoU0Xyvw+Fams+27Y+ d49E3yiEG0ad1jlmikDFuPZhSYHfFcF6P7hhg8oW/eWeFjRr1PEOC6yyuT/q2furYO fZAQGZkalpOOg== Message-ID: Date: Wed, 13 Sep 2023 13:43:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [RFC v1 3/3] thermal/drivers/mediatek/lvts_thermal: add mt7988 support Content-Language: en-US To: frank-w@public-files.de, Frank Wunderlich , linux-mediatek@lists.infradead.org Cc: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Daniel Golle References: <20230911183354.11487-1-linux@fw-web.de> <20230911183354.11487-4-linux@fw-web.de> <8949cbfa-acae-d6ac-e5fb-f238a29630bc@collabora.com> <465DDC1C-D687-47A7-966C-73FB42CFC5DD@public-files.de> From: AngeloGioacchino Del Regno In-Reply-To: <465DDC1C-D687-47A7-966C-73FB42CFC5DD@public-files.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:44:09 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Il 13/09/23 12:52, Frank Wunderlich ha scritto: > Am 13. September 2023 10:16:51 MESZ schrieb AngeloGioacchino Del Regno : > Hi angelo, > > thanks for first look > >> Il 11/09/23 20:33, Frank Wunderlich ha scritto: >>> From: Frank Wunderlich >>> >>> Add Support for mediatek fologic 880/MT7988. >>> >>> Signed-off-by: Frank Wunderlich >>> --- >>> drivers/thermal/mediatek/lvts_thermal.c | 73 +++++++++++++++++++++++++ >>> 1 file changed, 73 insertions(+) >>> >>> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c >>> index c1004b4da3b6..48b257a3c80e 100644 >>> --- a/drivers/thermal/mediatek/lvts_thermal.c >>> +++ b/drivers/thermal/mediatek/lvts_thermal.c >>> @@ -82,6 +82,8 @@ >>> #define LVTS_GOLDEN_TEMP_DEFAULT 50 >>> #define LVTS_COEFF_A_MT8195 -250460 >>> #define LVTS_COEFF_B_MT8195 250460 >>> +#define LVTS_COEFF_A_MT7988 -204650 >>> +#define LVTS_COEFF_B_MT7988 204650 >>> #define LVTS_MSR_IMMEDIATE_MODE 0 >>> #define LVTS_MSR_FILTERED_MODE 1 >>> @@ -1272,6 +1274,67 @@ static int lvts_remove(struct platform_device *pdev) >>> return 0; >>> } >>> +/* >>> + * LVTS MT7988 >>> + */ >>> +#define LVTS_HW_SHUTDOWN_MT7988 117000 >> >> Are you sure that this chip's Tj is >117°C ?! >> >> Looks a bit high... if it is exactly 117°C, I would suggest cutting earlier, >> either at 110 (safe side) or 115: after all, this is a life-saver feature and >> the chip is actually never meant to *constantly* work at 110°C (as it would >> degrade fast and say goodbye earlier than "planned"). > > I took values from SDK > > https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/refs/heads/master/target/linux/mediatek/files-5.4/drivers/thermal/mediatek/soc_temp_lvts.c#1483 > That kernel also defines 117°C for MT8195, which leaves me a bit dubious. For safety, I would recommend using the same 105°C hw shutdown temperature for 7988 as well: after all if you think about it, reaching that kind of temperature means that there's a real problem (fan stopped working and/or heatsink detached) that needs attention. This is because you'll have trip points in devicetree that should throttle the CPU in case it reaches at least a dangerously high temperature (read: a temperature outside the recommended continuous operation range), bringing the temperatures down because of the throttling action; I would imagine throttling the CPU a bit down at 80°C, then a bit more at 90°C - but then, if the temps won't drop like that, there's clearly a HW-related issue that must be addressed (like the fan/heatsink scenario that I just described). Though, take this as an advice; I'll respect whichever decision you'll take. >>> +//enum mt7988_lvts_domain { MT7988_AP_DOMAIN, MT7988_NUM_DOMAIN }; >>> + >>> +enum mt7988_lvts_sensor_enum { >>> + MT7988_TS3_0, >>> + MT7988_TS3_1, >>> + MT7988_TS3_2, >>> + MT7988_TS3_3, >>> + MT7988_TS4_0, >>> + MT7988_TS4_1, >>> + MT7988_TS4_2, >>> + MT7988_TS4_3, >>> + MT7988_NUM_TS >>> +}; > >> This enumeration should be definitions in bindings (mediatek,lvts-thermal.h). >> >> Besides, the LVTS is about internal temperatures, so those TS3_x and 4_x can >> be renamed like what was done for MT8192 and MT8195: this is because you will >> never see TS3_2 being CPU2 on a board and CPU4 on another, being those - again - >> internal to the SoC, hence unchangeable. > > Right these sensors are internally only and i took naming from sdk to avoid confusion. And i have not more information about these internal sensors (special meaning),but their values are packed together to get the resulting (average) temperature. > >> Another reason is that you'll anyway have to refer to those sensors in the >> devicetree to configure thermal trips and such, so... :-) > > In device tree it will look like this: > > https://github.com/frank-w/BPI-Router-Linux/blob/6.5-lvts/arch/arm64/boot/dts/mediatek/mt7988a.dtsi#L771 > > Daniel has also defined thermal trips there,but these are untested atm. I only verified temperature itself i get from sysfs as far as i can (start at ~40°C and reaching ~70 while running). > Check how it's done in mt8192.dtsi and mt8195.dtsi: we're using the definitions from the bindings for thermal zones. At least for consistency (apart from other even more valid considerations), that's how it should be done: please do it like that. Besides, I think that you can definitely guess what `TS` is CPU related: checking the driver and devicetree from the downstream kernel that you provided, what I understand is: 1. Your naming TS3,4 corresponds to TS2,3 downstream (so it's wrong?) 2. Downstream TS2 is related to the CPU cores, so it should be - TS2_0 - CPU0 - TS2_1 - CPU1 - TS2_2 - CPU2 - TS2_3 - CPU3 The other set of thermal sensors seem to be completely unused, so we cannot guess just by looking at the code. Since you have the hardware, you may be able to take a position about what they are by checking what sensor heats up for each "action" (could be ethernet controller or infra or whatever else); if in doubt, just leave them out, but add a comment saying that there are more sensors and say where, so that if anyone finds what they're for, it'll be easy to add them. In any case, adding thermal sensors that you don't know about is meaningless, as the sense of all this is: - Monitoring temperatures of the hardware - Taking action to prevent temperature overrun but if you don't know what you're reading, you can't interpret temperatures for something unknown, hence you can't as well take action to prevent overruns, as you won't know what's the maximum temperature for "unknown thing" :-) Regards, Angelo