Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp873398rdb; Fri, 2 Feb 2024 06:43:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHA0vaRCPUoNHCsR0Gm3j0ytI3Ya5TetKw61li9Ed7vu/GfAv53MNdjngM88d0TIHr1IaeC X-Received: by 2002:a17:906:fa0f:b0:a29:852c:dd21 with SMTP id lo15-20020a170906fa0f00b00a29852cdd21mr4265776ejb.10.1706885004545; Fri, 02 Feb 2024 06:43:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706885004; cv=pass; d=google.com; s=arc-20160816; b=iaApht4WbkM+Bw9BZXDCllb2DUm5F1s7VevJgZijdMr4EWU6AfdE27mOZuSUdPQ0qK G7kN/iw4qBaEbAgoV+TQlKBw52wCrT9+icfOl5jWzWRBEOYKy0eXja9mKxSRQvDPF06z i46jMRVMNUXztDvzsNKawCTGEnHZiS7dYQa7wO3vqBONU+YNMnbdjyQ3hBTUcoUcP1vq bxTrtvTyeXfnsqGtA/Oi9wnaexjkEfwNydVZj5KK5/fHR5ARb+2sAF/qnbFoobQpCcuV Hj9ZqVEAbC8G0hi+ovUVshaPbvrRXhdVn1db2dVZx6YH0Bc+jQf8Jj8ZASxnc9U3T6WC Z1Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=sFAaQtnlWIpYNCTfSJwnfI9Pa1J9XaJ9vd8HlS5BD0g=; fh=fqEkQRQGECRKsjPAKIrdL0z8AEQdtU04UfOjmUuYZUQ=; b=W/dLeoHtrR+fPxCdcb/d8Fq5J6KFoM6MmArduaft79hkVeA57pEaWB1GRGWx1V/AGf mmQWjRyGyYZonITLXbbQ+p1mgwneLVwLWtP4gwcfwX5MSVIV14fd0vIe2pBOCOBhxbdi bGzQTE+5MkEqK1xjjaTUOFHm1+e9aFOU3nTj5WapIqgLr3hA1lRMBP7cev27F8B7+/N/ L6AK2Y/DEkBiDKLPfUbTpgD1OsnImq/vnjDOXzUAaZK8mEKWIPifQbwu/3DcCh+ri6H5 N1UXr0oRT0Fcnmstty5n4fHkmASUoIng7LmCf1tQgDk32jAJYatS/0RdBwQXFWqClw/3 aWBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ajj968zZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-49963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCXwuSeaTDxP73VdfG0eB7wT+efj4Teod9qyGhcFkjb8Bbe0xT0UuK+qEjw8EikTA+wR5tpYrEXVcK7QuTm9uT4llvGozHmMUKuw0vhsCw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dv22-20020a170906b81600b00a372965a8fcsi171931ejb.923.2024.02.02.06.43.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 06:43:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ajj968zZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-49963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49963-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 222FF1F2B5E8 for ; Fri, 2 Feb 2024 14:43:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C40F014533C; Fri, 2 Feb 2024 14:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ajj968zZ" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 9B7DF145334; Fri, 2 Feb 2024 14:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706884978; cv=none; b=O9XuYJq8W/l6wkJcJRrA+UHHHeqwg3EbkfIn34i+aq/Q5MIcO9UiNIlPN3EOgFSaUJkLxhA5cw0gvSAcnzsP69OHiYUyNMclTe3hQrIsSFORIPMiYuVA9IVVSmjKlBzWcx+WauR8jfYy7rbtXKWSvsjPj57FFrCWa4jEUnCf5SA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706884978; c=relaxed/simple; bh=Skl0uNsAfIqnGfpunFUR+l+xqfAMlFPfSnT85gXQXn8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GPOhQJai4IHXUeQaf6kJd56AHwOPGyIy0PYY8gGxgrIr/De6Ntt9rskDAlorZpXM0sPQg/gEGH7IkCbr6/QdSk1VQVBUNcK4b6+qxGGb0hK97feShHei1IavmqOdI/UROCmJa4PAdRauYhalQKDwxXMiOn9KjjZAI2lhz8cLj8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ajj968zZ; arc=none smtp.client-ip=209.85.218.50 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-ej1-f50.google.com with SMTP id a640c23a62f3a-a354fc17f24so281443866b.0; Fri, 02 Feb 2024 06:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706884975; x=1707489775; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sFAaQtnlWIpYNCTfSJwnfI9Pa1J9XaJ9vd8HlS5BD0g=; b=Ajj968zZcOT1V2l6N8zVWbD8B0i/a9Byzx8lBtN6HSa56qC1lurToDp7pSxu9mG68/ qCzUJAuHVn2OXoMD+Bd8y93lla2QRpNVPqkuAtisr+WmYm5bABf8nwyxcctyQnxwjCxZ ukOr036j92mmpwpkgNh6WUC/Evg5c7ARkQMX5ALacIeJHajcNbbLBEnbZ4MOcljSv0Uj n0ImNtgCCoiEniz/j0lHzy/dYhiLunYGjs2ZgLvLLNYf/BFerfBxdhZAUZ+5BWvaZSeW U8+nk0BZ2U5Vhto1dakCoKS6p4KP0ZZJeRrIte9ogX8kOHdvN6bNUR44jMT4xcO0YOoT 1lxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706884975; x=1707489775; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sFAaQtnlWIpYNCTfSJwnfI9Pa1J9XaJ9vd8HlS5BD0g=; b=mIkKaljF/eDGut6SrUqOR3FwhvqM/xA8n2UTbiG3ZI6v+NZ2TnsK00NzMWTaBxib09 HlvZIAoU9W06gcBYmzElayFQ7vfjcwTiB+7Vt+ukj5sOah55RoLaNbxub1uvE/+yeh6U cXWZWjPRTLT4+O/s8OM0xZpIzfD25hxDP9HwXFFyWNAMVVeaRcsiYbKxV9do2eRv34Pe FHy+87cSxk/T1IEF0qV/Ijhws49zOSOENO9wvg+BSULi/PXHj6ULmJjG4raXd+XNp3Oj WFqO+GneFGuoN4b6Ew/nyRvERNgdvj2JOeYytxt2EScygX/XtI6KK4pm+JoWiFTz0qCV HVuQ== X-Gm-Message-State: AOJu0YyvC1m+YuurxxDFmp1us2ULr3xTUA2WmxFqmEEFkriDNmQ07Ea7 8twuj0pMe2t1eFaqrpob17EUos6VuNdQw6F9+EDRnjoSMAIGC1us9o6JblkVxZS1szG6Xcqgwdv nXZN5gA24AYH9ISJyxB8MnynieHE= X-Received: by 2002:a17:906:ae9a:b0:a36:5079:d6cb with SMTP id md26-20020a170906ae9a00b00a365079d6cbmr4184988ejb.56.1706884974435; Fri, 02 Feb 2024 06:42:54 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240130-rk-dts-additions-v2-0-c6222c4c78df@gmail.com> <20240130-rk-dts-additions-v2-2-c6222c4c78df@gmail.com> <5e3e12d65e4919372e7fb02d56202393@manjaro.org> In-Reply-To: From: Alexey Charkov Date: Fri, 2 Feb 2024 18:42:42 +0400 Message-ID: Subject: Re: [PATCH v2 2/4] arm64: dts: rockchip: enable temperature driven fan control on Rock 5B To: Dragan Simic Cc: wens@kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Daniel Lezcano , Viresh Kumar , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 11:43=E2=80=AFPM Dragan Simic w= rote: > > On 2024-02-01 20:31, Dragan Simic wrote: > > On 2024-02-01 20:15, Alexey Charkov wrote: > >> On Thu, Feb 1, 2024 at 9:34=E2=80=AFPM Dragan Simic > >> wrote: > >>> On 2024-02-01 15:26, Chen-Yu Tsai wrote: > >>> > On Wed, Jan 31, 2024 at 2:22=E2=80=AFAM Alexey Charkov > >>> > wrote: > >>> >> > >>> >> This enables thermal monitoring on Radxa Rock 5B and links the PWM > >>> >> fan as an active cooling device managed automatically by the therm= al > >>> >> subsystem, with a target SoC temperature of 65C and a minimum-spin > >>> >> interval from 55C to 65C to ensure airflow when the system gets wa= rm > >>> >> > >>> >> Acked-by: Daniel Lezcano > >>> >> Signed-off-by: Alexey Charkov > >>> >> --- > >>> >> arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts | 34 > >>> >> ++++++++++++++++++++++++- > >>> >> 1 file changed, 33 insertions(+), 1 deletion(-) > >>> >> > >>> >> diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > >>> >> b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > >>> >> index a0e303c3a1dc..b485edeef876 100644 > >>> >> --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > >>> >> +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5b.dts > >>> >> @@ -52,7 +52,7 @@ led_rgb_b { > >>> >> > >>> >> fan: pwm-fan { > >>> >> compatible =3D "pwm-fan"; > >>> >> - cooling-levels =3D <0 95 145 195 255>; > >>> >> + cooling-levels =3D <0 120 150 180 210 240 255>; > >>> >> fan-supply =3D <&vcc5v0_sys>; > >>> >> pwms =3D <&pwm1 0 50000 0>; > >>> >> #cooling-cells =3D <2>; > >>> >> @@ -173,6 +173,34 @@ &cpu_l3 { > >>> >> cpu-supply =3D <&vdd_cpu_lit_s0>; > >>> >> }; > >>> >> > >>> >> +&package_thermal { > >>> >> + polling-delay =3D <1000>; > >>> >> + > >>> >> + trips { > >>> >> + package_fan0: package-fan0 { > >>> >> + temperature =3D <55000>; > >>> >> + hysteresis =3D <2000>; > >>> >> + type =3D "active"; > >>> >> + }; > >>> >> + package_fan1: package-fan1 { > >>> >> + temperature =3D <65000>; > >>> >> + hysteresis =3D <2000>; > >>> >> + type =3D "active"; > >>> >> + }; > >>> >> + }; > >>> >> + > >>> >> + cooling-maps { > >>> >> + map0 { > >>> >> + trip =3D <&package_fan0>; > >>> >> + cooling-device =3D <&fan THERMAL_NO_LIMIT = 1>; > >>> >> + }; > >>> >> + map1 { > >>> >> + trip =3D <&package_fan1>; > >>> >> + cooling-device =3D <&fan 1 THERMAL_NO_LIMI= T>; > >>> >> + }; > >>> >> + }; > >>> >> +}; > >>> >> + > >>> >> &i2c0 { > >>> >> pinctrl-names =3D "default"; > >>> >> pinctrl-0 =3D <&i2c0m2_xfer>; > >>> >> @@ -731,6 +759,10 @@ regulator-state-mem { > >>> >> }; > >>> >> }; > >>> >> > >>> >> +&tsadc { > >>> >> + status =3D "okay"; > >>> >> +}; > >>> >> + > >>> > > >>> > Is there any reason this can't be enabled by default in the .dtsi f= ile? > >>> > The thermal sensor doesn't depend on anything external, so there sh= ould > >>> > be no reason to push this down to the board level. > >>> > >>> Actually, there is a reason. Different boards can handle the > >>> critical > >>> overheating differently, by letting the CRU or the PMIC handle it. > >>> This > >>> was also the case for the RK3399. > >>> > >>> Please, have a look at the following DT properties, which are > >>> consumed > >>> by drivers/thermal/rockchip_thermal.c: > >>> - "rockchip,hw-tshut-mode" > >>> - "rockchip,hw-tshut-polarity" > >>> > >>> See also page 1,372 of the RK3588 TRM v1.0. > >>> > >>> This has also reminded me to check how is the Rock 5B actually wired, > >>> just to make sure. We actually need to provide the two DT properties > >>> listed above, at least to avoid emitting the warnings. > >> > >> Well the defaults are already provided in rk3588s.dtsi, so there won't > >> be any warnings (see lines 2222-2223 in Linus' master version), and > >> according to the vendor kernel those are also what Rock 5B uses. > > > > Yes, I noticed the same a couple of minutes after sending my last > > message, but didn't want to make more noise about it. :) I would've > > mentioned it in my next message, of course. > > Just checked the Rock 5B schematic and it expects the CRU to be used > to perform the hardware reset in case of a thermal runaway, so the > defaults in the RK3588s dtsi are fine. I had to double-check it. :) I've just looked at Rock 5B, Rock 5A and NanoPC T6 schematics, and they all seem to have the TSADC_SHUT line connected to RESET_L. At the same time, Radxa's device tree uses the default CRU-based option. To me this seems to imply that the CRU option should always work, by the virtue of CRU being on-chip. At the same time, if the right GPIOs are wired to the PMIC reset line for a particular board, the board may also choose to use the GPIO option - or stick with CRU. If that interpretation is correct, then I suggest we enable TSADC by default in the .dtsi, and let it handle both throttling and CRU-based critical resets on all boards. Those who know what they are doing may then elect to switch their board to GPIO-PMIC based reset. What do you think? > However, now I have some open questions related to interrupt-driven > operation. I'll research it further and come back with an update. > > >> This made me think however: what if a board doesn't enable TSADC, but > >> has OPPs in place for higher voltage and frequency states? There won't > >> be any throttling (as there won't be any thermal monitoring) and there > >> might not be a critical shutdown at all if it heats up - possibly even > >> causing hardware damage. In this case it seems that having TSADC > >> enabled by default would at least trigger passive cooling, hopefully > >> avoiding the critical shutdown altogether and making those properties > >> irrelevant in 99% cases. > > > > Those are very good questions. Thumbs up! > > > > The trouble is that the boards can use different wiring to handle the > > thermal runaways, by expecting the PMIC to handle it or not. Thus, > > it's IMHO better to simply leave that to be tested and enabled on a > > board-by-board basis, whenever a new RK3588(s)-based board is added. > > > > Thus, the only right way at this point would be to merge the addition > > of the OPPs and the enabling of the TSADC for all currently supported > > RK3588(s)-based boards at once, instead of just for the Rock 5B. If we can agree on a workable 'default-on' configuration for TSADC to be included in the .dtsi I think that would be preferable, because it would enable all boards to benefit from higher OPPs and throttling. This would also save us from a scenario when OPPs get included in the default .dtsi, but TSADC is off by default, and then some poor soul tries to add a new board with a minimal .dts, forgetting to enable TSADC and having their SoC fried under high load... > > I can handle the required changes for the QuartzPro64 dts file. For > > other supported RK3588(s)-based boards, if there are no people having > > access to them and willing to perform the dts changes and the testing, > > I'd be willing to go through the board schematics, to enable the > > TSADC for them as well. > > Please, let me know are you fine with the above-described approach. I believe it's great if we can go through the schematics no matter what! Although if we agree that CRU is an always-working default option for all, then why don't we just enable TSADC for all, and leave the conversion to GPIO-PMIC resets for later and for where it's needed? Best regards, Alexey