Message ID | 20240106222357.23835-1-alchark@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp303920dyq; Sat, 6 Jan 2024 14:24:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhHZ8oAuzSrH/JOC2LahZgBqyijsbFRotS+YWLa6qCsC0ql4XfP4xvdWkJ9b7apuITkWPx X-Received: by 2002:a17:902:c404:b0:1d4:672f:4809 with SMTP id k4-20020a170902c40400b001d4672f4809mr645656plk.129.1704579886820; Sat, 06 Jan 2024 14:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704579886; cv=none; d=google.com; s=arc-20160816; b=BZkTVLsM/gcOzCDJF8nC8FflufAqPfhVkJjsu52EZm/t9bqX0N/0SKek99ZtqEZYqP peHdDM/P5w76Q4hwAAROsd0z/Pn7gkQbt6PEXLLoUgm/sRUzu98UbZ0a1nsywpi7tX+p 7Dwu+y4T9UHP33LxWrH2J+/ps1WrTQ7/w9fasfL+dmR9mVhu4eLkUUCztEgmvkY+RujJ fmdvT5i8tWLZGSopXV/LIhxA+FFguqsfJVczWmdTGkCDVxAGZ9PO8KFgWEKwc0OiMYoa aGngK3MhWMeaZ+Pnlddlz64q3Xn9RV8Xqnt3V59+ttJw0TnDuL/pHGHU8jrSacjJPCqP sBFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=IZIA5zf/VHPtEHf5BZda2vmVXuJ+Vs5INvQNZOIe84E=; fh=c30vSLxUoiTZMpwQgyTz/D5WjuHw+K/owoU+JFI5Msw=; b=kubkleGxvmzWHHsPJ7MK4MGHmR5UupX4/eRCOaV/vd3yGHSeCVxMm1a7t030dKzeFd oQsw5OqpkS7JCwxMg6xs/MwSBcvLNzJgYRilaWH7tf47Cd4bF7ZVSji7asZGlItX8X1s 5ZROMGsV4fFuyf6z/BIqpxuZXrjCIAUsb70rYEz3884Rk8lqVrPdAmzBvkV3am/GIlhN I5t7jM2swcpno3HCDclLyW+db4XEP4lBqKFGmkeVbkGEiZvWHJh1h6U41AqWdN3CJOxw 7rKr8evxpNrIVzq9SBVMwFvrTn45iJOwAMKTj0tgsyHyxj7KrOB8+n8Fn3xBQ4MSePpx n0OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V6OBQTpB; spf=pass (google.com: domain of linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e7-20020a17090301c700b001d50870e21csi1552310plh.538.2024.01.06.14.24.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 14:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V6OBQTpB; spf=pass (google.com: domain of linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18730-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9E29BB20D1B for <ouuuleilei@gmail.com>; Sat, 6 Jan 2024 22:24:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 870B8107A3; Sat, 6 Jan 2024 22:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V6OBQTpB" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4707B101D3; Sat, 6 Jan 2024 22:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40d8902da73so6368495e9.2; Sat, 06 Jan 2024 14:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704579853; x=1705184653; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=IZIA5zf/VHPtEHf5BZda2vmVXuJ+Vs5INvQNZOIe84E=; b=V6OBQTpB5sZBkqHa6eGS4C9ZS7yI4rLqHlZFdgmdySdVuQVPKiFR1jCdwXWlevASDH lG2XL8fNSn0P+VUFYDh3iF4koUooY5FxCIXtDKx0F+40kaD2MdJT3lVuoJ9Z2xPZW5bH pP9xfmLLd6gFrUrqlnc4xcN66zcnWXdjXuhS6Rk6w8+sJ8VrE34DK1mHkOwafLPSqL7v mbI7IiN6f4jBzSEaHYIN/0NTKl82iVN+Y2gbfLGMbVEIzV7fns3xAEeLoj62c3pTYErj lmN1Q3l4vCWVsZaEtgveMdotzzoPTo9fZTP1E2kgiKQoygksAW02iw/HPHCerAmgE/vn zHuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704579853; x=1705184653; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IZIA5zf/VHPtEHf5BZda2vmVXuJ+Vs5INvQNZOIe84E=; b=imSwucjlfo6w9jw9BDwTrWw8nfkmhvUYw5JLR3o6f5Y8qw8uqdptAMkxG+WrHF+osL vBxA/0h9adQ2IoNy4v71VWw+euenYzrLsudnM2cQ30RPl6VqRzey1cDFbBORbw8gwcSn 014m8T3kYKnfUpyLwnOwAFyoRhgZc4flVrXpypDCYrOrrEnXNp+I8NjTYUjhu+zJ8Xc3 O2JWtn6uNFdPgTZGPv2SeJA5m0PV0LpUrU4u4x300KH9sx6VHlPqlYzKsokH0V0hF7Cq XER0POvtFhqxOmqAZFoA1RSUi9oJOeDQfRAH9yh31QFPkhdsjL1o341X35v5kyNQ+xmG Sr8A== X-Gm-Message-State: AOJu0Yw9vCDtzp6WD17rqFxeXyXeZ2fy+I5NxyxZK546Eofd/FWFDDf9 nE1gt37oAkPoEPeOeiKzPPc= X-Received: by 2002:a05:600c:5027:b0:40e:43e5:f33f with SMTP id n39-20020a05600c502700b0040e43e5f33fmr39936wmr.65.1704579853213; Sat, 06 Jan 2024 14:24:13 -0800 (PST) Received: from latitude-fedora.lan ([2001:8f8:183b:50fb::d35]) by smtp.gmail.com with ESMTPSA id w15-20020adfe04f000000b00336471bc7ffsm4078128wrh.109.2024.01.06.14.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 14:24:12 -0800 (PST) From: Alexey Charkov <alchark@gmail.com> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Sebastian Reichel <sebastian.reichel@collabora.com>, Cristian Ciocaltea <cristian.ciocaltea@collabora.com>, Christopher Obbard <chris.obbard@collabora.com>, =?utf-8?b?VGFtw6FzIFN6xbFj?= =?utf-8?b?cw==?= <szucst@iit.uni-miskolc.hu>, Shreeya Patel <shreeya.patel@collabora.com>, Kever Yang <kever.yang@rock-chips.com>, Chris Morgan <macromorgan@hotmail.com>, Alexey Charkov <alchark@gmail.com>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: dts: rockchip: enable built-in thermal monitoring on rk3588 Date: Sun, 7 Jan 2024 02:23:42 +0400 Message-ID: <20240106222357.23835-1-alchark@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787381559435665692 X-GMAIL-MSGID: 1787381559435665692 |
Series |
arm64: dts: rockchip: enable built-in thermal monitoring on rk3588
|
|
Commit Message
Alexey Charkov
Jan. 6, 2024, 10:23 p.m. UTC
Include thermal zones information in device tree for rk3588 variants
and enable the built-in thermal sensing ADC on RADXA Rock 5B
Signed-off-by: Alexey Charkov <alchark@gmail.com>
---
.../boot/dts/rockchip/rk3588-rock-5b.dts | 4 +
arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 143 ++++++++++++++++++
2 files changed, 147 insertions(+)
Comments
Hello Alexey, Please see my comments below. On 2024-01-06 23:23, Alexey Charkov wrote: > Include thermal zones information in device tree for rk3588 variants > and enable the built-in thermal sensing ADC on RADXA Rock 5B > > Signed-off-by: Alexey Charkov <alchark@gmail.com> > --- > .../boot/dts/rockchip/rk3588-rock-5b.dts | 4 + > arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 143 ++++++++++++++++++ > 2 files changed, 147 insertions(+) > > diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > index a5a104131403..f9d540000de3 100644 > --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > @@ -772,3 +772,7 @@ &usb_host1_ehci { > &usb_host1_ohci { > status = "okay"; > }; > + > +&tsadc { > + status = "okay"; > +}; > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > index 8aa0499f9b03..8235991e3112 100644 > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > @@ -10,6 +10,7 @@ > #include <dt-bindings/reset/rockchip,rk3588-cru.h> > #include <dt-bindings/phy/phy.h> > #include <dt-bindings/ata/ahci.h> > +#include <dt-bindings/thermal/thermal.h> > > / { > compatible = "rockchip,rk3588"; > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { > status = "disabled"; > }; > > + thermal_zones: thermal-zones { > + soc_thermal: soc-thermal { It should be better to name it cpu_thermal instead. In the end, that's what it is. > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + sustainable-power = <2100>; /* milliwatts */ These three comments above are pretty much redundant. > + > + thermal-sensors = <&tsadc 0>; An empty line should be added here. > + trips { > + threshold: trip-point-0 { It should be better to name it cpu_alert0 instead, because that's what other newer dtsi files already use. > + temperature = <75000>; > + hysteresis = <2000>; > + type = "passive"; > + }; > + target: trip-point-1 { It should be better to name it cpu_alert1 instead, because that's what other newer dtsi files already use. > + temperature = <85000>; > + hysteresis = <2000>; > + type = "passive"; > + }; > + soc_crit: soc-crit { It should be better to name it cpu_crit instead, because that's what other newer dtsi files already use. > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ These two comments above are pretty much redundant. It also applies to all other similar comments below. > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + cooling-maps { > + map0 { > + trip = <&target>; Shouldn't &threshold (i.e. &cpu_alert0) be referenced here instead? > + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; Shouldn't all big CPU cores be listed here instead? > + contribution = <1024>; > + }; > + map1 { > + trip = <&target>; Shouldn't &target (i.e. &cpu_alert1) be referenced here instead? > + cooling-device = <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; Shouldn't all little and big CPU cores be listed here instead? > + contribution = <1024>; > + }; > + map2 { > + trip = <&target>; > + cooling-device = <&cpu_b2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; > + contribution = <1024>; > + }; Isn't this cooling map redundant? > + }; > + }; > + > + bigcore0_thermal: bigcore0-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 1>; > + > + trips { > + big0_crit: big0-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + > + bigcore1_thermal: bigcore1-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 2>; > + > + trips { > + big1_crit: big1-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + > + little_core_thermal: littlecore-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 3>; > + > + trips { > + little_crit: little-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + > + center_thermal: center-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 4>; > + > + trips { > + center_crit: center-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + > + gpu_thermal: gpu-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 5>; > + > + trips { > + gpu_crit: gpu-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + > + npu_thermal: npu-thermal { > + polling-delay-passive = <20>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + thermal-sensors = <&tsadc 6>; > + > + trips { > + npu_crit: npu-crit { > + /* millicelsius */ > + temperature = <115000>; > + /* millicelsius */ > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + }; > + }; > + > saradc: adc@fec10000 { > compatible = "rockchip,rk3588-saradc"; > reg = <0x0 0xfec10000 0x0 0x10000>;
Hello Dragan, Thanks a lot for your review and comments! Some reflections below. On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: > > Hello Alexey, > > Please see my comments below. > > On 2024-01-06 23:23, Alexey Charkov wrote: > > Include thermal zones information in device tree for rk3588 variants > > and enable the built-in thermal sensing ADC on RADXA Rock 5B > > > > Signed-off-by: Alexey Charkov <alchark@gmail.com> > > --- > > .../boot/dts/rockchip/rk3588-rock-5b.dts | 4 + > > arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 143 ++++++++++++++++++ > > 2 files changed, 147 insertions(+) > > > > diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > > b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > > index a5a104131403..f9d540000de3 100644 > > --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > > +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > > @@ -772,3 +772,7 @@ &usb_host1_ehci { > > &usb_host1_ohci { > > status = "okay"; > > }; > > + > > +&tsadc { > > + status = "okay"; > > +}; > > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > > index 8aa0499f9b03..8235991e3112 100644 > > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > > @@ -10,6 +10,7 @@ > > #include <dt-bindings/reset/rockchip,rk3588-cru.h> > > #include <dt-bindings/phy/phy.h> > > #include <dt-bindings/ata/ahci.h> > > +#include <dt-bindings/thermal/thermal.h> > > > > / { > > compatible = "rockchip,rk3588"; > > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { > > status = "disabled"; > > }; > > > > + thermal_zones: thermal-zones { > > + soc_thermal: soc-thermal { > > It should be better to name it cpu_thermal instead. In the end, that's > what it is. The TRM document says the first TSADC channel (to which this section applies) measures the temperature near the center of the SoC die, which implies not only the CPU but also the GPU at least. RADXA's kernel for Rock 5B also has GPU passive cooling as one of the cooling maps under this node (not included here, as we don't have the GPU node in .dtsi just yet). So perhaps naming this one cpu_thermal could be misleading? > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + sustainable-power = <2100>; /* milliwatts */ > > These three comments above are pretty much redundant. Noted, will drop in v2 > > + > > + thermal-sensors = <&tsadc 0>; > > An empty line should be added here. Noted, will add in v2 > > + trips { > > + threshold: trip-point-0 { > > It should be better to name it cpu_alert0 instead, because that's what > other newer dtsi files already use. Reflecting on your comments here and below, I'm thinking that maybe it would be better to define only the critical trip point for the SoC overall, and then have alerts along with the respective cooling maps separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we have more granular temperature measurement here than in previous RK chipsets it might be better to only throttle the "offending" cores, not the full package. What do you think? Downstream DT doesn't follow this approach though, so maybe there's something I'm missing here. > > + temperature = <75000>; > > + hysteresis = <2000>; > > + type = "passive"; > > + }; > > + target: trip-point-1 { > > It should be better to name it cpu_alert1 instead, because that's what > other newer dtsi files already use. > > > + temperature = <85000>; > > + hysteresis = <2000>; > > + type = "passive"; > > + }; > > + soc_crit: soc-crit { > > It should be better to name it cpu_crit instead, because that's what > other newer dtsi files already use. Seems to me that if I define separate trips for the three groups of CPU cores as mentioned above this would better stay as soc_crit, as it applies to the whole die rather than the CPU cluster alone. Then 'threshold' and 'target' will go altogether, and I'll have separate *_alert0 and *_alert1 per CPU group. >> > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > These two comments above are pretty much redundant. It also applies to > all other similar comments below. Noted, thanks - will drop all the noise in v2. > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + cooling-maps { > > + map0 { > > + trip = <&target>; > > Shouldn't &threshold (i.e. &cpu_alert0) be referenced here instead? > > > + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; > > Shouldn't all big CPU cores be listed here instead? I guess if a separate trip point is defined for cpu_l0,1,2,3 then it would need to throttle at 75C, and then cpu_b0,1 and cpu_b2,3 at 85C each. Logic being that if a sensor stacked in the middle of a group of four cores shows 75C then one of the four might well be in abnormal temperature range already (85+), while sensors next to only two big cores each will likely show temperatures similar to the actual core temperature. > > + contribution = <1024>; > > + }; > > + map1 { > > + trip = <&target>; > > Shouldn't &target (i.e. &cpu_alert1) be referenced here instead? > > > + cooling-device = <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; > > Shouldn't all little and big CPU cores be listed here instead? > > > + contribution = <1024>; > > + }; > > + map2 { > > + trip = <&target>; > > + cooling-device = <&cpu_b2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; > > + contribution = <1024>; > > + }; > > Isn't this cooling map redundant? Will refactor the above, thanks. > > + }; > > + }; > > + > > + bigcore0_thermal: bigcore0-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 1>; > > + > > + trips { > > + big0_crit: big0-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + > > + bigcore1_thermal: bigcore1-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 2>; > > + > > + trips { > > + big1_crit: big1-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + > > + little_core_thermal: littlecore-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 3>; > > + > > + trips { > > + little_crit: little-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + > > + center_thermal: center-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 4>; > > + > > + trips { > > + center_crit: center-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + > > + gpu_thermal: gpu-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 5>; > > + > > + trips { > > + gpu_crit: gpu-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + > > + npu_thermal: npu-thermal { > > + polling-delay-passive = <20>; /* milliseconds */ > > + polling-delay = <1000>; /* milliseconds */ > > + thermal-sensors = <&tsadc 6>; > > + > > + trips { > > + npu_crit: npu-crit { > > + /* millicelsius */ > > + temperature = <115000>; > > + /* millicelsius */ > > + hysteresis = <2000>; > > + type = "critical"; > > + }; > > + }; > > + }; > > + }; > > + > > saradc: adc@fec10000 { > > compatible = "rockchip,rk3588-saradc"; > > reg = <0x0 0xfec10000 0x0 0x10000>;
On 2024-01-08 14:41, Alexey Charkov wrote: > Hello Dragan, Hello Alexey! :) I apologize for my delayed response. It took me almost a month to nearly fully recover from some really nasty flu that eventually went into my lungs. It was awful and I'm still not back to my 100%. :( > Thanks a lot for your review and comments! Some reflections below. Thank you for your work and for your detailed response. Please see my comments below, which apply to your v2 submission as a well, to which I'll respond separately a bit later. > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: >> On 2024-01-06 23:23, Alexey Charkov wrote: >> > Include thermal zones information in device tree for rk3588 variants >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B >> > >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> >> > --- >> > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> > index 8aa0499f9b03..8235991e3112 100644 >> > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> > @@ -10,6 +10,7 @@ >> > #include <dt-bindings/reset/rockchip,rk3588-cru.h> >> > #include <dt-bindings/phy/phy.h> >> > #include <dt-bindings/ata/ahci.h> >> > +#include <dt-bindings/thermal/thermal.h> >> > >> > / { >> > compatible = "rockchip,rk3588"; >> > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { >> > status = "disabled"; >> > }; >> > >> > + thermal_zones: thermal-zones { >> > + soc_thermal: soc-thermal { >> >> It should be better to name it cpu_thermal instead. In the end, >> that's >> what it is. > > The TRM document says the first TSADC channel (to which this section > applies) measures the temperature near the center of the SoC die, > which implies not only the CPU but also the GPU at least. RADXA's > kernel for Rock 5B also has GPU passive cooling as one of the cooling > maps under this node (not included here, as we don't have the GPU node > in .dtsi just yet). So perhaps naming this one cpu_thermal could be > misleading? Ah, I see now, thanks for reminding; it's all described on page 1,372 of the first part of the RK3588 TRM v1.0. Having that in mind, I'd suggest that we end up naming it package_thermal. The temperature near the center of the chip is usually considered to be the overall package temperature; for example, that's how the user-facing CPU temperatures are measured in the x86_64 world. >> > + trips { >> > + threshold: trip-point-0 { >> >> It should be better to name it cpu_alert0 instead, because that's what >> other newer dtsi files already use. > > Reflecting on your comments here and below, I'm thinking that maybe it > would be better to define only the critical trip point for the SoC > overall, and then have alerts along with the respective cooling maps > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we > have more granular temperature measurement here than in previous RK > chipsets it might be better to only throttle the "offending" cores, > not the full package. > > What do you think? > > Downstream DT doesn't follow this approach though, so maybe there's > something I'm missing here. I agree, it's better to fully utilize the higher measurement granularity made possible by having multiple temperature sensors available. I also agree that we should have only the critical trip defined for the package-level temperature sensor. Let's have the separate temperature measurements for the CPU (sub)clusters do the thermal throttling, and let's keep the package-level measurement for the critical shutdowns only. IIRC, some MediaTek SoC dtsi already does exactly that. Of course, there are no reasons not to have the critical trips defined for the CPU (sub)clusters as well. >> > + temperature = <75000>; >> > + hysteresis = <2000>; >> > + type = "passive"; >> > + }; >> > + target: trip-point-1 { >> >> It should be better to name it cpu_alert1 instead, because that's what >> other newer dtsi files already use. >> >> > + temperature = <85000>; >> > + hysteresis = <2000>; >> > + type = "passive"; >> > + }; >> > + soc_crit: soc-crit { >> >> It should be better to name it cpu_crit instead, because that's what >> other newer dtsi files already use. > > Seems to me that if I define separate trips for the three groups of > CPU cores as mentioned above this would better stay as soc_crit, as it > applies to the whole die rather than the CPU cluster alone. Then > 'threshold' and 'target' will go altogether, and I'll have separate > *_alert0 and *_alert1 per CPU group. It should perhaps be the best to have "passive", "hot" and "critical" trips defined for all three CPU groups/(sub)clusters, separately of course, to have even higher granularity when it comes to the resulting thermal throttling. >> > + hysteresis = <2000>; >> > + type = "critical"; >> > + }; >> > + }; >> > + cooling-maps { >> > + map0 { >> > + trip = <&target>; >> >> Shouldn't &threshold (i.e. &cpu_alert0) be referenced here instead? >> >> > + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; >> >> Shouldn't all big CPU cores be listed here instead? > > I guess if a separate trip point is defined for cpu_l0,1,2,3 then it > would need to throttle at 75C, and then cpu_b0,1 and cpu_b2,3 at 85C > each. Logic being that if a sensor stacked in the middle of a group of > four cores shows 75C then one of the four might well be in abnormal > temperature range already (85+), while sensors next to only two big > cores each will likely show temperatures similar to the actual core > temperature. I think we shouldn't make any assumptions of how the CPU cores heat up and affect each other, because we don't really know the required details. Instead, we should simply define the reasonable values for the "passive", "hot" and "critical" trips, and leave the rest to the standard thermal throttling logic. I hope you agree. In the end, that's why we have separate thermal sensors available.
On Thu, Jan 18, 2024 at 10:48 PM Dragan Simic <dsimic@manjaro.org> wrote: > > On 2024-01-08 14:41, Alexey Charkov wrote: > > Hello Dragan, > > Hello Alexey! :) > > I apologize for my delayed response. It took me almost a month to > nearly fully recover from some really nasty flu that eventually went > into my lungs. It was awful and I'm still not back to my 100%. :( Ouch, I hope you get well soon! > > Thanks a lot for your review and comments! Some reflections below. > > Thank you for your work and for your detailed response. Please see my > comments below, which apply to your v2 submission as a well, to which > I'll respond separately a bit later. > > > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: > >> On 2024-01-06 23:23, Alexey Charkov wrote: > >> > Include thermal zones information in device tree for rk3588 variants > >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B > >> > > >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> > >> > --- > >> > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> > index 8aa0499f9b03..8235991e3112 100644 > >> > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> > @@ -10,6 +10,7 @@ > >> > #include <dt-bindings/reset/rockchip,rk3588-cru.h> > >> > #include <dt-bindings/phy/phy.h> > >> > #include <dt-bindings/ata/ahci.h> > >> > +#include <dt-bindings/thermal/thermal.h> > >> > > >> > / { > >> > compatible = "rockchip,rk3588"; > >> > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { > >> > status = "disabled"; > >> > }; > >> > > >> > + thermal_zones: thermal-zones { > >> > + soc_thermal: soc-thermal { > >> > >> It should be better to name it cpu_thermal instead. In the end, > >> that's > >> what it is. > > > > The TRM document says the first TSADC channel (to which this section > > applies) measures the temperature near the center of the SoC die, > > which implies not only the CPU but also the GPU at least. RADXA's > > kernel for Rock 5B also has GPU passive cooling as one of the cooling > > maps under this node (not included here, as we don't have the GPU node > > in .dtsi just yet). So perhaps naming this one cpu_thermal could be > > misleading? > > Ah, I see now, thanks for reminding; it's all described on page 1,372 > of the first part of the RK3588 TRM v1.0. > > Having that in mind, I'd suggest that we end up naming it > package_thermal. > The temperature near the center of the chip is usually considered to be > the overall package temperature; for example, that's how the > user-facing > CPU temperatures are measured in the x86_64 world. Sounds good, will rename in v3! > >> > + trips { > >> > + threshold: trip-point-0 { > >> > >> It should be better to name it cpu_alert0 instead, because that's what > >> other newer dtsi files already use. > > > > Reflecting on your comments here and below, I'm thinking that maybe it > > would be better to define only the critical trip point for the SoC > > overall, and then have alerts along with the respective cooling maps > > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we > > have more granular temperature measurement here than in previous RK > > chipsets it might be better to only throttle the "offending" cores, > > not the full package. > > > > What do you think? > > > > Downstream DT doesn't follow this approach though, so maybe there's > > something I'm missing here. > > I agree, it's better to fully utilize the higher measurement granularity > made possible by having multiple temperature sensors available. > > I also agree that we should have only the critical trip defined for the > package-level temperature sensor. Let's have the separate temperature > measurements for the CPU (sub)clusters do the thermal throttling, and > let's keep the package-level measurement for the critical shutdowns > only. > IIRC, some MediaTek SoC dtsi already does exactly that. > > Of course, there are no reasons not to have the critical trips defined > for the CPU (sub)clusters as well. I think I'll also add a board-specific active cooling mechanism on the package level in the next iteration, given that Rock 5B has a PWM fan defined as a cooling device. That will go in the separate patch that updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also duly noted, thank you!) > >> > + temperature = <75000>; > >> > + hysteresis = <2000>; > >> > + type = "passive"; > >> > + }; > >> > + target: trip-point-1 { > >> > >> It should be better to name it cpu_alert1 instead, because that's what > >> other newer dtsi files already use. > >> > >> > + temperature = <85000>; > >> > + hysteresis = <2000>; > >> > + type = "passive"; > >> > + }; > >> > + soc_crit: soc-crit { > >> > >> It should be better to name it cpu_crit instead, because that's what > >> other newer dtsi files already use. > > > > Seems to me that if I define separate trips for the three groups of > > CPU cores as mentioned above this would better stay as soc_crit, as it > > applies to the whole die rather than the CPU cluster alone. Then > > 'threshold' and 'target' will go altogether, and I'll have separate > > *_alert0 and *_alert1 per CPU group. > > It should perhaps be the best to have "passive", "hot" and "critical" > trips defined for all three CPU groups/(sub)clusters, separately of > course, to have even higher granularity when it comes to the resulting > thermal throttling. I looked through drivers/thermal/rockchip_thermal.c, and it doesn't seem to provide any callback for the "hot" trip as part of its struct thermal_zone_device_ops, so I guess it would be redundant in our case here? I couldn't find any generic mechanism to react to "hot" trips, and they seem to be purely driver-specific, thus no-op in case of Rockchips - or am I missing something? > >> > + hysteresis = <2000>; > >> > + type = "critical"; > >> > + }; > >> > + }; > >> > + cooling-maps { > >> > + map0 { > >> > + trip = <&target>; > >> > >> Shouldn't &threshold (i.e. &cpu_alert0) be referenced here instead? > >> > >> > + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; > >> > >> Shouldn't all big CPU cores be listed here instead? > > > > I guess if a separate trip point is defined for cpu_l0,1,2,3 then it > > would need to throttle at 75C, and then cpu_b0,1 and cpu_b2,3 at 85C > > each. Logic being that if a sensor stacked in the middle of a group of > > four cores shows 75C then one of the four might well be in abnormal > > temperature range already (85+), while sensors next to only two big > > cores each will likely show temperatures similar to the actual core > > temperature. > > I think we shouldn't make any assumptions of how the CPU cores heat up > and affect each other, because we don't really know the required > details. > Instead, we should simply define the reasonable values for the > "passive", > "hot" and "critical" trips, and leave the rest to the standard thermal > throttling logic. I hope you agree. > > In the end, that's why we have separate thermal sensors available. Indeed! I'll add extra "passive" alerts though (at 75C) to enable the power allocation governor to initialize its PID parameters calculation before the control temperature setpoint gets hit (per Daniel's feedback under separate cover). Thanks again for your review and comments on this one! Best regards, Alexey
Hello Alexey, On 2024-01-21 19:56, Alexey Charkov wrote: > On Thu, Jan 18, 2024 at 10:48 PM Dragan Simic <dsimic@manjaro.org> > wrote: >> On 2024-01-08 14:41, Alexey Charkov wrote: >> I apologize for my delayed response. It took me almost a month to >> nearly fully recover from some really nasty flu that eventually went >> into my lungs. It was awful and I'm still not back to my 100%. :( > > Ouch, I hope you get well soon! Thank you, let's hope so. It's been really exhausting. :( >> > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: >> >> On 2024-01-06 23:23, Alexey Charkov wrote: >> >> > Include thermal zones information in device tree for rk3588 variants >> >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B >> >> > >> >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> >> >> > --- >> >> > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> >> > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> >> > index 8aa0499f9b03..8235991e3112 100644 >> >> > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> >> > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi >> >> > @@ -10,6 +10,7 @@ >> >> > #include <dt-bindings/reset/rockchip,rk3588-cru.h> >> >> > #include <dt-bindings/phy/phy.h> >> >> > #include <dt-bindings/ata/ahci.h> >> >> > +#include <dt-bindings/thermal/thermal.h> >> >> > >> >> > / { >> >> > compatible = "rockchip,rk3588"; >> >> > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { >> >> > status = "disabled"; >> >> > }; >> >> > >> >> > + thermal_zones: thermal-zones { >> >> > + soc_thermal: soc-thermal { >> >> >> >> It should be better to name it cpu_thermal instead. In the end, >> >> that's what it is. >> > >> > The TRM document says the first TSADC channel (to which this section >> > applies) measures the temperature near the center of the SoC die, >> > which implies not only the CPU but also the GPU at least. RADXA's >> > kernel for Rock 5B also has GPU passive cooling as one of the cooling >> > maps under this node (not included here, as we don't have the GPU node >> > in .dtsi just yet). So perhaps naming this one cpu_thermal could be >> > misleading? >> >> Ah, I see now, thanks for reminding; it's all described on page 1,372 >> of the first part of the RK3588 TRM v1.0. >> >> Having that in mind, I'd suggest that we end up naming it >> package_thermal. >> The temperature near the center of the chip is usually considered to >> be >> the overall package temperature; for example, that's how the >> user-facing >> CPU temperatures are measured in the x86_64 world. > > Sounds good, will rename in v3! Thanks, I'm glad you agree. >> >> > + trips { >> >> > + threshold: trip-point-0 { >> >> >> >> It should be better to name it cpu_alert0 instead, because that's what >> >> other newer dtsi files already use. >> > >> > Reflecting on your comments here and below, I'm thinking that maybe it >> > would be better to define only the critical trip point for the SoC >> > overall, and then have alerts along with the respective cooling maps >> > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we >> > have more granular temperature measurement here than in previous RK >> > chipsets it might be better to only throttle the "offending" cores, >> > not the full package. >> > >> > What do you think? >> > >> > Downstream DT doesn't follow this approach though, so maybe there's >> > something I'm missing here. >> >> I agree, it's better to fully utilize the higher measurement >> granularity >> made possible by having multiple temperature sensors available. >> >> I also agree that we should have only the critical trip defined for >> the >> package-level temperature sensor. Let's have the separate temperature >> measurements for the CPU (sub)clusters do the thermal throttling, and >> let's keep the package-level measurement for the critical shutdowns >> only. IIRC, some MediaTek SoC dtsi already does exactly that. >> >> Of course, there are no reasons not to have the critical trips defined >> for the CPU (sub)clusters as well. > > I think I'll also add a board-specific active cooling mechanism on the > package level in the next iteration, given that Rock 5B has a PWM fan > defined as a cooling device. That will go in the separate patch that > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also > duly noted, thank you!) Great, thanks. Sure, making use of the Rock 5B's support for attaching a PWM-controlled cooling fan is the way to go. Just to reiterate a bit, any "active" trip points belong to the board dts file(s), because having a cooling fan is a board-specific feature. As a note, you may also want to have a look at the RockPro64 dts(i) files, for example; the RockPro64 also comes with a cooling fan connector and the associated PWM fan control logic. >> >> > + temperature = <75000>; >> >> > + hysteresis = <2000>; >> >> > + type = "passive"; >> >> > + }; >> >> > + target: trip-point-1 { >> >> >> >> It should be better to name it cpu_alert1 instead, because that's what >> >> other newer dtsi files already use. >> >> >> >> > + temperature = <85000>; >> >> > + hysteresis = <2000>; >> >> > + type = "passive"; >> >> > + }; >> >> > + soc_crit: soc-crit { >> >> >> >> It should be better to name it cpu_crit instead, because that's what >> >> other newer dtsi files already use. >> > >> > Seems to me that if I define separate trips for the three groups of >> > CPU cores as mentioned above this would better stay as soc_crit, as it >> > applies to the whole die rather than the CPU cluster alone. Then >> > 'threshold' and 'target' will go altogether, and I'll have separate >> > *_alert0 and *_alert1 per CPU group. >> >> It should perhaps be the best to have "passive", "hot" and "critical" >> trips defined for all three CPU groups/(sub)clusters, separately of >> course, to have even higher granularity when it comes to the resulting >> thermal throttling. > > I looked through drivers/thermal/rockchip_thermal.c, and it doesn't > seem to provide any callback for the "hot" trip as part of its struct > thermal_zone_device_ops, so I guess it would be redundant in our case > here? I couldn't find any generic mechanism to react to "hot" trips, > and they seem to be purely driver-specific, thus no-op in case of > Rockchips - or am I missing something? That's a good question. Please, let me go through the code in detail, and I'll get back with an update soon. Also, please wait a bit with sending the v3, until all open questions are addressed. >> >> > + hysteresis = <2000>; >> >> > + type = "critical"; >> >> > + }; >> >> > + }; >> >> > + cooling-maps { >> >> > + map0 { >> >> > + trip = <&target>; >> >> >> >> Shouldn't &threshold (i.e. &cpu_alert0) be referenced here instead? >> >> >> >> > + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; >> >> >> >> Shouldn't all big CPU cores be listed here instead? >> > >> > I guess if a separate trip point is defined for cpu_l0,1,2,3 then it >> > would need to throttle at 75C, and then cpu_b0,1 and cpu_b2,3 at 85C >> > each. Logic being that if a sensor stacked in the middle of a group of >> > four cores shows 75C then one of the four might well be in abnormal >> > temperature range already (85+), while sensors next to only two big >> > cores each will likely show temperatures similar to the actual core >> > temperature. >> >> I think we shouldn't make any assumptions of how the CPU cores heat up >> and affect each other, because we don't really know the required >> details. >> Instead, we should simply define the reasonable values for the >> "passive", >> "hot" and "critical" trips, and leave the rest to the standard thermal >> throttling logic. I hope you agree. >> >> In the end, that's why we have separate thermal sensors available. > > Indeed! I'll add extra "passive" alerts though (at 75C) to enable the > power allocation governor to initialize its PID parameters calculation > before the control temperature setpoint gets hit (per Daniel's > feedback under separate cover). I'm glad you agree. Adding one more "passive" trip point makes sense, but please let me go through the code in detail first.
On Mon, Jan 22, 2024 at 8:55 AM Dragan Simic <dsimic@manjaro.org> wrote: > > Hello Alexey, > > On 2024-01-21 19:56, Alexey Charkov wrote: > > On Thu, Jan 18, 2024 at 10:48 PM Dragan Simic <dsimic@manjaro.org> > > wrote: > >> On 2024-01-08 14:41, Alexey Charkov wrote: > >> I apologize for my delayed response. It took me almost a month to > >> nearly fully recover from some really nasty flu that eventually went > >> into my lungs. It was awful and I'm still not back to my 100%. :( > > > > Ouch, I hope you get well soon! > > Thank you, let's hope so. It's been really exhausting. :( > > >> > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: > >> >> On 2024-01-06 23:23, Alexey Charkov wrote: > >> >> > Include thermal zones information in device tree for rk3588 variants > >> >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B > >> >> > > >> >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> > >> >> > --- > >> >> > diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> >> > b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> >> > index 8aa0499f9b03..8235991e3112 100644 > >> >> > --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> >> > +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi > >> >> > @@ -10,6 +10,7 @@ > >> >> > #include <dt-bindings/reset/rockchip,rk3588-cru.h> > >> >> > #include <dt-bindings/phy/phy.h> > >> >> > #include <dt-bindings/ata/ahci.h> > >> >> > +#include <dt-bindings/thermal/thermal.h> > >> >> > > >> >> > / { > >> >> > compatible = "rockchip,rk3588"; > >> >> > @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { > >> >> > status = "disabled"; > >> >> > }; > >> >> > > >> >> > + thermal_zones: thermal-zones { > >> >> > + soc_thermal: soc-thermal { > >> >> > >> >> It should be better to name it cpu_thermal instead. In the end, > >> >> that's what it is. > >> > > >> > The TRM document says the first TSADC channel (to which this section > >> > applies) measures the temperature near the center of the SoC die, > >> > which implies not only the CPU but also the GPU at least. RADXA's > >> > kernel for Rock 5B also has GPU passive cooling as one of the cooling > >> > maps under this node (not included here, as we don't have the GPU node > >> > in .dtsi just yet). So perhaps naming this one cpu_thermal could be > >> > misleading? > >> > >> Ah, I see now, thanks for reminding; it's all described on page 1,372 > >> of the first part of the RK3588 TRM v1.0. > >> > >> Having that in mind, I'd suggest that we end up naming it > >> package_thermal. > >> The temperature near the center of the chip is usually considered to > >> be > >> the overall package temperature; for example, that's how the > >> user-facing > >> CPU temperatures are measured in the x86_64 world. > > > > Sounds good, will rename in v3! > > Thanks, I'm glad you agree. > > >> >> > + trips { > >> >> > + threshold: trip-point-0 { > >> >> > >> >> It should be better to name it cpu_alert0 instead, because that's what > >> >> other newer dtsi files already use. > >> > > >> > Reflecting on your comments here and below, I'm thinking that maybe it > >> > would be better to define only the critical trip point for the SoC > >> > overall, and then have alerts along with the respective cooling maps > >> > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we > >> > have more granular temperature measurement here than in previous RK > >> > chipsets it might be better to only throttle the "offending" cores, > >> > not the full package. > >> > > >> > What do you think? > >> > > >> > Downstream DT doesn't follow this approach though, so maybe there's > >> > something I'm missing here. > >> > >> I agree, it's better to fully utilize the higher measurement > >> granularity > >> made possible by having multiple temperature sensors available. > >> > >> I also agree that we should have only the critical trip defined for > >> the > >> package-level temperature sensor. Let's have the separate temperature > >> measurements for the CPU (sub)clusters do the thermal throttling, and > >> let's keep the package-level measurement for the critical shutdowns > >> only. IIRC, some MediaTek SoC dtsi already does exactly that. > >> > >> Of course, there are no reasons not to have the critical trips defined > >> for the CPU (sub)clusters as well. > > > > I think I'll also add a board-specific active cooling mechanism on the > > package level in the next iteration, given that Rock 5B has a PWM fan > > defined as a cooling device. That will go in the separate patch that > > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also > > duly noted, thank you!) > > Great, thanks. Sure, making use of the Rock 5B's support for attaching > a PWM-controlled cooling fan is the way to go. > > Just to reiterate a bit, any "active" trip points belong to the board > dts > file(s), because having a cooling fan is a board-specific feature. As a > note, you may also want to have a look at the RockPro64 dts(i) files, > for > example; the RockPro64 also comes with a cooling fan connector and the > associated PWM fan control logic. Thanks for the pointer! There is also a helpful doc within devicetree bindings descriptions, although it sits under hwmon which was a bit confusing to me. I've already tested it locally (by adding to the board dts), and it spins up and down quite nicely, and even modulates the fan speed swiftly when the load changes - yay! > >> >> > + temperature = <75000>; > >> >> > + hysteresis = <2000>; > >> >> > + type = "passive"; > >> >> > + }; > >> >> > + target: trip-point-1 { > >> >> > >> >> It should be better to name it cpu_alert1 instead, because that's what > >> >> other newer dtsi files already use. > >> >> > >> >> > + temperature = <85000>; > >> >> > + hysteresis = <2000>; > >> >> > + type = "passive"; > >> >> > + }; > >> >> > + soc_crit: soc-crit { > >> >> > >> >> It should be better to name it cpu_crit instead, because that's what > >> >> other newer dtsi files already use. > >> > > >> > Seems to me that if I define separate trips for the three groups of > >> > CPU cores as mentioned above this would better stay as soc_crit, as it > >> > applies to the whole die rather than the CPU cluster alone. Then > >> > 'threshold' and 'target' will go altogether, and I'll have separate > >> > *_alert0 and *_alert1 per CPU group. > >> > >> It should perhaps be the best to have "passive", "hot" and "critical" > >> trips defined for all three CPU groups/(sub)clusters, separately of > >> course, to have even higher granularity when it comes to the resulting > >> thermal throttling. > > > > I looked through drivers/thermal/rockchip_thermal.c, and it doesn't > > seem to provide any callback for the "hot" trip as part of its struct > > thermal_zone_device_ops, so I guess it would be redundant in our case > > here? I couldn't find any generic mechanism to react to "hot" trips, > > and they seem to be purely driver-specific, thus no-op in case of > > Rockchips - or am I missing something? > > That's a good question. Please, let me go through the code in detail, > and I'll get back with an update soon. Also, please wait a bit with > sending the v3, until all open questions are addressed. Of course. Thank you for taking the time to dig through this one with me! Best regards, Alexey
On 2024-01-22 07:03, Alexey Charkov wrote: > On Mon, Jan 22, 2024 at 8:55 AM Dragan Simic <dsimic@manjaro.org> > wrote: >> On 2024-01-21 19:56, Alexey Charkov wrote: >> > On Thu, Jan 18, 2024 at 10:48 PM Dragan Simic <dsimic@manjaro.org> wrote: >> >> On 2024-01-08 14:41, Alexey Charkov wrote: >> >> > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: >> >> >> On 2024-01-06 23:23, Alexey Charkov wrote: >> >> >> > Include thermal zones information in device tree for rk3588 variants >> >> >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B >> >> >> > >> >> >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> >> >> >> > --- >> >> >> > + trips { >> >> >> > + threshold: trip-point-0 { >> >> >> >> >> >> It should be better to name it cpu_alert0 instead, because that's what >> >> >> other newer dtsi files already use. >> >> > >> >> > Reflecting on your comments here and below, I'm thinking that maybe it >> >> > would be better to define only the critical trip point for the SoC >> >> > overall, and then have alerts along with the respective cooling maps >> >> > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we >> >> > have more granular temperature measurement here than in previous RK >> >> > chipsets it might be better to only throttle the "offending" cores, >> >> > not the full package. >> >> > >> >> > What do you think? >> >> > >> >> > Downstream DT doesn't follow this approach though, so maybe there's >> >> > something I'm missing here. >> >> >> >> I agree, it's better to fully utilize the higher measurement >> >> granularity >> >> made possible by having multiple temperature sensors available. >> >> >> >> I also agree that we should have only the critical trip defined for >> >> the >> >> package-level temperature sensor. Let's have the separate temperature >> >> measurements for the CPU (sub)clusters do the thermal throttling, and >> >> let's keep the package-level measurement for the critical shutdowns >> >> only. IIRC, some MediaTek SoC dtsi already does exactly that. >> >> >> >> Of course, there are no reasons not to have the critical trips defined >> >> for the CPU (sub)clusters as well. >> > >> > I think I'll also add a board-specific active cooling mechanism on the >> > package level in the next iteration, given that Rock 5B has a PWM fan >> > defined as a cooling device. That will go in the separate patch that >> > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also >> > duly noted, thank you!) >> >> Great, thanks. Sure, making use of the Rock 5B's support for >> attaching >> a PWM-controlled cooling fan is the way to go. >> >> Just to reiterate a bit, any "active" trip points belong to the board >> dts file(s), because having a cooling fan is a board-specific feature. >> As a note, you may also want to have a look at the RockPro64 dts(i) >> files, for example; the RockPro64 also comes with a cooling fan >> connector and the associated PWM fan control logic. > > Thanks for the pointer! There is also a helpful doc within devicetree > bindings descriptions, although it sits under hwmon which was a bit > confusing to me. I've already tested it locally (by adding to the > board dts), and it spins up and down quite nicely, and even modulates > the fan speed swiftly when the load changes - yay! Nice! Also, isn't it like magic? :) To me, turning LEDs on/off and controlling fans acts as some kind of a "bridge" between the virtual and the real world. :) As a suggestion, it would be good to test with a couple of different fans, to make sure that the PWM values work well for more that one fan model. The Rock 5B requires a 5 V fan, if I'm not mistaken? >> >> >> > + temperature = <75000>; >> >> >> > + hysteresis = <2000>; >> >> >> > + type = "passive"; >> >> >> > + }; >> >> >> > + target: trip-point-1 { >> >> >> >> >> >> It should be better to name it cpu_alert1 instead, because that's what >> >> >> other newer dtsi files already use. >> >> >> >> >> >> > + temperature = <85000>; >> >> >> > + hysteresis = <2000>; >> >> >> > + type = "passive"; >> >> >> > + }; >> >> >> > + soc_crit: soc-crit { >> >> >> >> >> >> It should be better to name it cpu_crit instead, because that's what >> >> >> other newer dtsi files already use. >> >> > >> >> > Seems to me that if I define separate trips for the three groups of >> >> > CPU cores as mentioned above this would better stay as soc_crit, as it >> >> > applies to the whole die rather than the CPU cluster alone. Then >> >> > 'threshold' and 'target' will go altogether, and I'll have separate >> >> > *_alert0 and *_alert1 per CPU group. >> >> >> >> It should perhaps be the best to have "passive", "hot" and "critical" >> >> trips defined for all three CPU groups/(sub)clusters, separately of >> >> course, to have even higher granularity when it comes to the resulting >> >> thermal throttling. >> > >> > I looked through drivers/thermal/rockchip_thermal.c, and it doesn't >> > seem to provide any callback for the "hot" trip as part of its struct >> > thermal_zone_device_ops, so I guess it would be redundant in our case >> > here? I couldn't find any generic mechanism to react to "hot" trips, >> > and they seem to be purely driver-specific, thus no-op in case of >> > Rockchips - or am I missing something? >> >> That's a good question. Please, let me go through the code in detail, >> and I'll get back with an update soon. Also, please wait a bit with >> sending the v3, until all open questions are addressed. > > Of course. Thank you for taking the time to dig through this one with > me! I'm glad to help. It's important to have working thermal throttling on the supported RK3588-based boards.
On Mon, Jan 22, 2024 at 10:22 AM Dragan Simic <dsimic@manjaro.org> wrote: > > On 2024-01-22 07:03, Alexey Charkov wrote: > > On Mon, Jan 22, 2024 at 8:55 AM Dragan Simic <dsimic@manjaro.org> > > wrote: > >> On 2024-01-21 19:56, Alexey Charkov wrote: > >> > On Thu, Jan 18, 2024 at 10:48 PM Dragan Simic <dsimic@manjaro.org> wrote: > >> >> On 2024-01-08 14:41, Alexey Charkov wrote: > >> >> > On Sun, Jan 7, 2024 at 2:54 AM Dragan Simic <dsimic@manjaro.org> wrote: > >> >> >> On 2024-01-06 23:23, Alexey Charkov wrote: > >> >> >> > Include thermal zones information in device tree for rk3588 variants > >> >> >> > and enable the built-in thermal sensing ADC on RADXA Rock 5B > >> >> >> > > >> >> >> > Signed-off-by: Alexey Charkov <alchark@gmail.com> > >> >> >> > --- > >> >> >> > + trips { > >> >> >> > + threshold: trip-point-0 { > >> >> >> > >> >> >> It should be better to name it cpu_alert0 instead, because that's what > >> >> >> other newer dtsi files already use. > >> >> > > >> >> > Reflecting on your comments here and below, I'm thinking that maybe it > >> >> > would be better to define only the critical trip point for the SoC > >> >> > overall, and then have alerts along with the respective cooling maps > >> >> > separately for A76-0,1, A76-2,3, A55-0,1,2,3? After all, given that we > >> >> > have more granular temperature measurement here than in previous RK > >> >> > chipsets it might be better to only throttle the "offending" cores, > >> >> > not the full package. > >> >> > > >> >> > What do you think? > >> >> > > >> >> > Downstream DT doesn't follow this approach though, so maybe there's > >> >> > something I'm missing here. > >> >> > >> >> I agree, it's better to fully utilize the higher measurement > >> >> granularity > >> >> made possible by having multiple temperature sensors available. > >> >> > >> >> I also agree that we should have only the critical trip defined for > >> >> the > >> >> package-level temperature sensor. Let's have the separate temperature > >> >> measurements for the CPU (sub)clusters do the thermal throttling, and > >> >> let's keep the package-level measurement for the critical shutdowns > >> >> only. IIRC, some MediaTek SoC dtsi already does exactly that. > >> >> > >> >> Of course, there are no reasons not to have the critical trips defined > >> >> for the CPU (sub)clusters as well. > >> > > >> > I think I'll also add a board-specific active cooling mechanism on the > >> > package level in the next iteration, given that Rock 5B has a PWM fan > >> > defined as a cooling device. That will go in the separate patch that > >> > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also > >> > duly noted, thank you!) > >> > >> Great, thanks. Sure, making use of the Rock 5B's support for > >> attaching > >> a PWM-controlled cooling fan is the way to go. > >> > >> Just to reiterate a bit, any "active" trip points belong to the board > >> dts file(s), because having a cooling fan is a board-specific feature. > >> As a note, you may also want to have a look at the RockPro64 dts(i) > >> files, for example; the RockPro64 also comes with a cooling fan > >> connector and the associated PWM fan control logic. > > > > Thanks for the pointer! There is also a helpful doc within devicetree > > bindings descriptions, although it sits under hwmon which was a bit > > confusing to me. I've already tested it locally (by adding to the > > board dts), and it spins up and down quite nicely, and even modulates > > the fan speed swiftly when the load changes - yay! > > Nice! Also, isn't it like magic? :) To me, turning LEDs on/off and > controlling fans acts as some kind of a "bridge" between the virtual > and the real world. :) Oh yes! I also keep admiring how one can add just a couple of lines of text here and there that's not even real code, and the whole kernel machinery starts crunching numbers, analyzing temperatures, running PID loops, etc etc so that I could enjoy the satisfying whistle of a small fan when I type `make -j8` :-D > As a suggestion, it would be good to test with a couple of different > fans, to make sure that the PWM values work well for more that one fan > model. The Rock 5B requires a 5 V fan, if I'm not mistaken? It is 5V, yes. I only have one fan to try though, and I simply relied on the PWM values that are already defined in the upstream rk3588-rock-5b.dts. They don't look ideal for my particular fan, because the lowest non-zero cooling state currently uses a PWM value of 95, which doesn't always make it spin up. But in the end it doesn't seem to matter that much, because that tiny fan needs to spin at full 255 whenever all eight cores are loaded (and even then it can only balance the temperature at around 60.5С), and when the load is lighter (such as during various ./configure runs) it just switches off completely as the temperature goes down to 46C even with the fan not spinning. I don't currently use the GPU/NPU/VPU though - maybe those would produce more moderate load which could benefit from spinning the fan at medium speeds. Best regards, Alexey
On 2024-01-22 08:36, Alexey Charkov wrote: > On Mon, Jan 22, 2024 at 10:22 AM Dragan Simic <dsimic@manjaro.org> > wrote: >> On 2024-01-22 07:03, Alexey Charkov wrote: >> > On Mon, Jan 22, 2024 at 8:55 AM Dragan Simic <dsimic@manjaro.org> wrote: >> >> On 2024-01-21 19:56, Alexey Charkov wrote: >> >> > I think I'll also add a board-specific active cooling mechanism on the >> >> > package level in the next iteration, given that Rock 5B has a PWM fan >> >> > defined as a cooling device. That will go in the separate patch that >> >> > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also >> >> > duly noted, thank you!) >> >> >> >> Great, thanks. Sure, making use of the Rock 5B's support for attaching >> >> a PWM-controlled cooling fan is the way to go. >> >> >> >> Just to reiterate a bit, any "active" trip points belong to the board >> >> dts file(s), because having a cooling fan is a board-specific feature. >> >> As a note, you may also want to have a look at the RockPro64 dts(i) >> >> files, for example; the RockPro64 also comes with a cooling fan >> >> connector and the associated PWM fan control logic. >> > >> > Thanks for the pointer! There is also a helpful doc within devicetree >> > bindings descriptions, although it sits under hwmon which was a bit >> > confusing to me. I've already tested it locally (by adding to the >> > board dts), and it spins up and down quite nicely, and even modulates >> > the fan speed swiftly when the load changes - yay! >> >> Nice! Also, isn't it like magic? :) To me, turning LEDs on/off and >> controlling fans acts as some kind of a "bridge" between the virtual >> and the real world. :) > > Oh yes! I also keep admiring how one can add just a couple of lines of > text here and there that's not even real code, and the whole kernel > machinery starts crunching numbers, analyzing temperatures, running > PID loops, etc etc so that I could enjoy the satisfying whistle of a > small fan when I type `make -j8` :-D Yes, it's very satisfying, :) and it also demonstrates the true power of the device trees as hardware definitions. Just a few more lines and the cooling works! :) >> As a suggestion, it would be good to test with a couple of different >> fans, to make sure that the PWM values work well for more that one fan >> model. The Rock 5B requires a 5 V fan, if I'm not mistaken? > > It is 5V, yes. I only have one fan to try though, and I simply relied > on the PWM values that are already defined in the upstream > rk3588-rock-5b.dts. They don't look ideal for my particular fan, > because the lowest non-zero cooling state currently uses a PWM value > of 95, which doesn't always make it spin up. But in the end it doesn't > seem to matter that much, because that tiny fan needs to spin at full > 255 whenever all eight cores are loaded (and even then it can only > balance the temperature at around 60.5С), and when the load is lighter > (such as during various ./configure runs) it just switches off > completely as the temperature goes down to 46C even with the fan not > spinning. I see, 5 V fans unfortunately aren't very common. I'm not sure why Radxa opted for 5 V there; maybe the goal was to use Raspberry Pi 5 V fans, but using those tiny fans doesn't make much sense, IMHO. I think you can freely adjust the PWM values a bit to make your fan start reliably at the lowest state, regardless of how rarely that state will be used. See, if your fan doesn't spin up reliably with the current lowest state, chances for other fan models not to spin up are quite high. IOW, it's better to play safe there, if you agree. What kind of heatsink are you using with your Rock 5B? Ah yes, and what's the actual model of the fan you're using? > I don't currently use the GPU/NPU/VPU though - maybe those would > produce more moderate load which could benefit from spinning the fan > at medium speeds. Perhaps, but it will need to be tested at some point. Have you tried loading only one or two CPU cores?
On Mon, Jan 22, 2024 at 11:57 AM Dragan Simic <dsimic@manjaro.org> wrote: > > On 2024-01-22 08:36, Alexey Charkov wrote: > > On Mon, Jan 22, 2024 at 10:22 AM Dragan Simic <dsimic@manjaro.org> > > wrote: > >> On 2024-01-22 07:03, Alexey Charkov wrote: > >> > On Mon, Jan 22, 2024 at 8:55 AM Dragan Simic <dsimic@manjaroorg> wrote: > >> >> On 2024-01-21 19:56, Alexey Charkov wrote: > >> >> > I think I'll also add a board-specific active cooling mechanism on the > >> >> > package level in the next iteration, given that Rock 5B has a PWM fan > >> >> > defined as a cooling device. That will go in the separate patch that > >> >> > updates rk3588-rock-5b.dts (your feedback to v2 of this patch is also > >> >> > duly noted, thank you!) > >> >> > >> >> Great, thanks. Sure, making use of the Rock 5B's support for attaching > >> >> a PWM-controlled cooling fan is the way to go. > >> >> > >> >> Just to reiterate a bit, any "active" trip points belong to the board > >> >> dts file(s), because having a cooling fan is a board-specific feature. > >> >> As a note, you may also want to have a look at the RockPro64 dts(i) > >> >> files, for example; the RockPro64 also comes with a cooling fan > >> >> connector and the associated PWM fan control logic. > >> > > >> > Thanks for the pointer! There is also a helpful doc within devicetree > >> > bindings descriptions, although it sits under hwmon which was a bit > >> > confusing to me. I've already tested it locally (by adding to the > >> > board dts), and it spins up and down quite nicely, and even modulates > >> > the fan speed swiftly when the load changes - yay! > >> > >> Nice! Also, isn't it like magic? :) To me, turning LEDs on/off and > >> controlling fans acts as some kind of a "bridge" between the virtual > >> and the real world. :) > > > > Oh yes! I also keep admiring how one can add just a couple of lines of > > text here and there that's not even real code, and the whole kernel > > machinery starts crunching numbers, analyzing temperatures, running > > PID loops, etc etc so that I could enjoy the satisfying whistle of a > > small fan when I type `make -j8` :-D > > Yes, it's very satisfying, :) and it also demonstrates the true power > of the device trees as hardware definitions. Just a few more lines and > the cooling works! :) > > >> As a suggestion, it would be good to test with a couple of different > >> fans, to make sure that the PWM values work well for more that one fan > >> model. The Rock 5B requires a 5 V fan, if I'm not mistaken? > > > > It is 5V, yes. I only have one fan to try though, and I simply relied > > on the PWM values that are already defined in the upstream > > rk3588-rock-5b.dts. They don't look ideal for my particular fan, > > because the lowest non-zero cooling state currently uses a PWM value > > of 95, which doesn't always make it spin up. But in the end it doesn't > > seem to matter that much, because that tiny fan needs to spin at full > > 255 whenever all eight cores are loaded (and even then it can only > > balance the temperature at around 60.5С), and when the load is lighter > > (such as during various ./configure runs) it just switches off > > completely as the temperature goes down to 46C even with the fan not > > spinning. > > I see, 5 V fans unfortunately aren't very common. I'm not sure why > Radxa opted for 5 V there; maybe the goal was to use Raspberry Pi 5 V > fans, but using those tiny fans doesn't make much sense, IMHO. > > I think you can freely adjust the PWM values a bit to make your fan > start reliably at the lowest state, regardless of how rarely that state > will be used. See, if your fan doesn't spin up reliably with the > current > lowest state, chances for other fan models not to spin up are quite > high. > IOW, it's better to play safe there, if you agree. > > What kind of heatsink are you using with your Rock 5B? Ah yes, and > what's the actual model of the fan you're using? I use Radxa's 4012 heatsink-fan assembly that comes as an add-on option when buying the board itself from Allnet. I guess I'll include slightly adjusted PWM values in the rk3588-rock-5b.dts patch to better represent my fan's "preferred" range (in my experience a PWM value of around 120 is the reliable lower end - it would continue spinning below that point but won't always start without being pushed manually) > > I don't currently use the GPU/NPU/VPU though - maybe those would > > produce more moderate load which could benefit from spinning the fan > > at medium speeds. > > Perhaps, but it will need to be tested at some point. Have you tried > loading only one or two CPU cores? I do see the full range of PWM values being used, including intermediate ones. It doesn't go zero to hero :) My point was more about the default fan not being super mighty vs. the full package thermal output, which will likely mean that intermediate values are rarely used. But I'll double check with more varied loads to make sure it behaves in a sensible way (especially given that I'll be testing purely interrupt-driven operation per Daniel's guidance in the other sub-thread). Best regards, Alexey
On 2024-01-22 15:20, Alexey Charkov wrote: > On Mon, Jan 22, 2024 at 11:57 AM Dragan Simic <dsimic@manjaro.org> > wrote: >> On 2024-01-22 08:36, Alexey Charkov wrote: >> > On Mon, Jan 22, 2024 at 10:22 AM Dragan Simic <dsimic@manjaro.org> wrote: >> >> As a suggestion, it would be good to test with a couple of different >> >> fans, to make sure that the PWM values work well for more that one fan >> >> model. The Rock 5B requires a 5 V fan, if I'm not mistaken? >> > >> > It is 5V, yes. I only have one fan to try though, and I simply relied >> > on the PWM values that are already defined in the upstream >> > rk3588-rock-5b.dts. They don't look ideal for my particular fan, >> > because the lowest non-zero cooling state currently uses a PWM value >> > of 95, which doesn't always make it spin up. But in the end it doesn't >> > seem to matter that much, because that tiny fan needs to spin at full >> > 255 whenever all eight cores are loaded (and even then it can only >> > balance the temperature at around 60.5С), and when the load is lighter >> > (such as during various ./configure runs) it just switches off >> > completely as the temperature goes down to 46C even with the fan not >> > spinning. >> >> I see, 5 V fans unfortunately aren't very common. I'm not sure why >> Radxa opted for 5 V there; maybe the goal was to use Raspberry Pi 5 V >> fans, but using those tiny fans doesn't make much sense, IMHO. >> >> I think you can freely adjust the PWM values a bit to make your fan >> start reliably at the lowest state, regardless of how rarely that >> state >> will be used. See, if your fan doesn't spin up reliably with the >> current >> lowest state, chances for other fan models not to spin up are quite >> high. IOW, it's better to play safe there, if you agree. >> >> What kind of heatsink are you using with your Rock 5B? Ah yes, and >> what's the actual model of the fan you're using? > > I use Radxa's 4012 heatsink-fan assembly that comes as an add-on > option when buying the board itself from Allnet. I guess I'll include > slightly adjusted PWM values in the rk3588-rock-5b.dts patch to better > represent my fan's "preferred" range (in my experience a PWM value of > around 120 is the reliable lower end - it would continue spinning > below that point but won't always start without being pushed manually) Sure, just go ahead. You're using an official active cooling solution for the Rock 5B, so adjusting the PWM values a bit to make the fan start up reliably is even more warranted. >> > I don't currently use the GPU/NPU/VPU though - maybe those would >> > produce more moderate load which could benefit from spinning the fan >> > at medium speeds. >> >> Perhaps, but it will need to be tested at some point. Have you tried >> loading only one or two CPU cores? > > I do see the full range of PWM values being used, including > intermediate ones. It doesn't go zero to hero :) My point was more > about the default fan not being super mighty vs. the full package > thermal output, which will likely mean that intermediate values are > rarely used. But I'll double check with more varied loads to make sure > it behaves in a sensible way (especially given that I'll be testing > purely interrupt-driven operation per Daniel's guidance in the other > sub-thread). I see, thanks for the clarification. :) The 4012 fan and heatsink seem rather tiny; [1] a more beefy assembly, with more thermal mass, larger fin surface and a fan that pushes a bit more air across its RPM range, would probably result in a noticeably broader use of the intermediate PWM values. [1] https://shop.allnetchina.cn/products/active-heat-sink-for-visionfive-sbc
diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts index a5a104131403..f9d540000de3 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts @@ -772,3 +772,7 @@ &usb_host1_ehci { &usb_host1_ohci { status = "okay"; }; + +&tsadc { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi index 8aa0499f9b03..8235991e3112 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi @@ -10,6 +10,7 @@ #include <dt-bindings/reset/rockchip,rk3588-cru.h> #include <dt-bindings/phy/phy.h> #include <dt-bindings/ata/ahci.h> +#include <dt-bindings/thermal/thermal.h> / { compatible = "rockchip,rk3588"; @@ -2112,6 +2113,148 @@ tsadc: tsadc@fec00000 { status = "disabled"; }; + thermal_zones: thermal-zones { + soc_thermal: soc-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + sustainable-power = <2100>; /* milliwatts */ + + thermal-sensors = <&tsadc 0>; + trips { + threshold: trip-point-0 { + temperature = <75000>; + hysteresis = <2000>; + type = "passive"; + }; + target: trip-point-1 { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + soc_crit: soc-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&target>; + cooling-device = <&cpu_l0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + map1 { + trip = <&target>; + cooling-device = <&cpu_b0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + map2 { + trip = <&target>; + cooling-device = <&cpu_b2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + }; + }; + + bigcore0_thermal: bigcore0-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 1>; + + trips { + big0_crit: big0-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + bigcore1_thermal: bigcore1-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 2>; + + trips { + big1_crit: big1-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + little_core_thermal: littlecore-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 3>; + + trips { + little_crit: little-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + center_thermal: center-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 4>; + + trips { + center_crit: center-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + gpu_thermal: gpu-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 5>; + + trips { + gpu_crit: gpu-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + npu_thermal: npu-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + thermal-sensors = <&tsadc 6>; + + trips { + npu_crit: npu-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; + saradc: adc@fec10000 { compatible = "rockchip,rk3588-saradc"; reg = <0x0 0xfec10000 0x0 0x10000>;