From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F660C4CEC9 for ; Fri, 13 Sep 2019 20:11:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0883A206BB for ; Fri, 13 Sep 2019 20:11:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Nca5dpbg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388982AbfIMULV (ORCPT ); Fri, 13 Sep 2019 16:11:21 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50928 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388568AbfIMULU (ORCPT ); Fri, 13 Sep 2019 16:11:20 -0400 Received: by mail-wm1-f65.google.com with SMTP id c10so3983233wmc.0 for ; Fri, 13 Sep 2019 13:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zNVxNz3mg2mFN00qDZJTfKjqrppRjdElAR6WRxV8i5s=; b=Nca5dpbg8KWPsdFGVUvrLYgxncEdzK582cO45m88EtKGYmQLX/o8965ZurUD/0ml6j n7cJewG+i6EmT49po/Q4JPEqqErdm6fTV3SYNafapWuovY9QBoccztbv4Rx30t8GxpGt hCKyg4VckBJ+fJWI2jGdRilLf/1mr9xnJ35IuTLtMvzRwnGtewchwQWkL0XHqeUezk2B H5kGDGqAhAdvYyX0lLGgCPbQAKbZGAWFRxngbvZrroD92lnSUTwWhMIZo19GRsVz5KRS 8pr8plRd1G+mqOd3QA7emWfwykNEDUvChG+CqCZTM/B37LgvJcV8hHsUHzOxzk34k/0d 42zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=zNVxNz3mg2mFN00qDZJTfKjqrppRjdElAR6WRxV8i5s=; b=ZOYjGvN3ZFKahGmhdi5CtFu+iEg54L8pUWcRIoXvHjCIcm0X/nzPFvoDfzc7iIIreW yKfaHeD3luZ+dg2TEqnWVOKAnlEuRQQdd3GtZeXhtWlNgRJtzWp2w4Fm4VOyZssZl9on 3Lc7y6QRL0N++gJWae28fNafyKMF4BtXpS0l93StY8NDtcb4CyE+TD7V8KPBOqFj/BrK LxwG9I5WUhnEuH60R3VzFnFIBJHsdOSxwY3msrNMCRf7lceRL03+MNPjYnfGEtfFDAuy QxxH03n4s8m5/2Jk/XkYAU8m5v1SECRoXrrLsGcpFIVo2Dpt9JhI2ogaEz9v9PSAKGmd J3fA== X-Gm-Message-State: APjAAAVRVgekJGtW9ew2ZOKP26WwutLaIQCJ6u7CkV0dDRc2iAgGYid9 fCvdWto86nUbhnpZaPysOdQlwQ== X-Google-Smtp-Source: APXvYqyWTzXdy49xxrxkK7UAjUzcYxRnovSXronlcnLxWCE4YFF9AUy1Xx8MLhpucr5WzMWHDQ1EPw== X-Received: by 2002:a1c:ca0f:: with SMTP id a15mr4792106wmg.102.1568405475350; Fri, 13 Sep 2019 13:11:15 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:1071:7577:6038:b6fe? ([2a01:e34:ed2f:f020:1071:7577:6038:b6fe]) by smtp.googlemail.com with ESMTPSA id d4sm2567802wrq.22.2019.09.13.13.11.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 13:11:14 -0700 (PDT) Subject: Re: [RFC] ARM: dts: omap36xx: Enable thermal throttling To: Adam Ford Cc: "H. Nikolaus Schaller" , Linux-OMAP , Tony Lindgren , =?UTF-8?Q?Andr=c3=a9_Roth?= , Discussions about the Letux Kernel , Linux Kernel Mailing List , Andreas Kemnade , Nishanth Menon , Adam Ford , kernel@pyra-handheld.com References: <20190912183037.18449-1-aford173@gmail.com> <98751DAF-B3F7-4638-97BE-1D067B24EF18@goldelico.com> <7C9393BD-B23B-41A6-BF96-E53CD707AAC7@goldelico.com> <81d6cd33-4930-6753-d5ed-678cb1d2038d@linaro.org> From: Daniel Lezcano Openpgp: preference=signencrypt Autocrypt: addr=daniel.lezcano@linaro.org; prefer-encrypt=mutual; keydata= mQINBFv/yykBEADDdW8RZu7iZILSf3zxq5y8YdaeyZjI/MaqgnvG/c3WjFaunoTMspeusiFE sXvtg3ehTOoyD0oFjKkHaia1Zpa1m/gnNdT/WvTveLfGA1gH+yGes2Sr53Ht8hWYZFYMZc8V 2pbSKh8wepq4g8r5YI1XUy9YbcTdj5mVrTklyGWA49NOeJz2QbfytMT3DJmk40LqwK6CCSU0 9Ed8n0a+vevmQoRZJEd3Y1qXn2XHys0F6OHCC+VLENqNNZXdZE9E+b3FFW0lk49oLTzLRNIq 0wHeR1H54RffhLQAor2+4kSSu8mW5qB0n5Eb/zXJZZ/bRiXmT8kNg85UdYhvf03ZAsp3qxcr xMfMsC7m3+ADOtW90rNNLZnRvjhsYNrGIKH8Ub0UKXFXibHbafSuq7RqyRQzt01Ud8CAtq+w P9EftUysLtovGpLSpGDO5zQ++4ZGVygdYFr318aGDqCljKAKZ9hYgRimPBToDed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ULFQs3dfEx5euWTWnnh7pN30RLg a+0AjSGd886Bh0kT1Dznrite0dzYlTHlacbITZG84yRk/gS7DkYQdjL8zgFr/pxH5CbYJDk0 tYUhisTESeesbvWSPO5uNqqy1dAFw+dqRcF5gXIh3NKX0gqiAA87NM7nL5ym/CNpJ7z7nRC8 qePOXubgouxumi5RQs1+crBmCDa/AyJHKdG2mqCt9fx5EPbDpw6Zzx7hgURh4ikHoS7/tLjK iqWjuat8/HWc01yEd8rtkGuUcMqbCi1XhcAmkaOnX8FYscMRoyyMrWClRZEQRokqZIj79+PR adkDXtr4MeL8BaB7Ij2oyRVjXUwhFQNKi5Z5Rve0a3zvGkkqw8Mz20BOksjSWjAF6g9byukl CUVjC03PdMSufNLK06x5hPc/c4tFR4J9cLrV+XxdCX7r0zGos9SzTPGNuIk1LK++S3EJhLFj 4eoWtNhMWc1uiTf9ENza0ntqH9XBWEQ6IA1gubCniGG+Xg== Message-ID: <7ebe4c56-1b89-d90d-eeb4-25adaa58dd17@linaro.org> Date: Fri, 13 Sep 2019 22:11:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/09/2019 20:46, Adam Ford wrote: > On Fri, Sep 13, 2019 at 12:18 PM Daniel Lezcano > wrote: >> >> On 13/09/2019 18:51, H. Nikolaus Schaller wrote: >> >> [ ... ] >> >>>> Good news (I think) >>>> >>>> With cooling-device = <&cpu 1 2> setup, I was able to ask the max >>>> frequency and it returned 600MHz. >>>> >>>> # cat /sys/devices/virtual/thermal/thermal_zone0/temp >>>> 58500 >>>> # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies >>>> 300000 600000 800000 >>>> # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_m >>>> scaling_max_freq scaling_min_freq >>>> # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq >>>> 600000 >>> >>> looks good! >>> But we have to understand what the <&cpu 1 2> exactly means... >>> >>> Hopefully someone reading your RFCv2 can answer... >> > Daniel, > > Thank you for replying. > >> I may have missed the question :) >> >> These are the states allowed for the cooling device (the one you can see >> in the /sys/class/thermal/cooling_device0/max_state. As the logic is >> inverted for cpufreq, that can be confusing. > > I think that's what has be confused. > >> >> If it was a fan with, let's say 5 speeds, you would use <&fan 0 5>, so >> when the mitigation begins the cooling device state is 0 and then the >> thermal governor increase the state until it sees a cooling effect. >> >> If <&fan 0 2> is set, the governor won't set a state above 2 even if the >> temperature increases. > > I am not sure I know what you mean by 'state' in this context. A thermal zone is managed by the thermal framework as the following: - a sensor - a governor - a cooling device The governor gets the temperature via the sensor and depending on the temperature it will increase or decrease the cooling effect of the cooling device. With a fan, that means it will increase or decrease its speed. With cpufreq, it will decrease or increase the OPP. These are discrete values the governor will use to set the cooling effect. The state is one of these value (the current speed or the current OPP index). Depending on the cooling device, the number of states are different. In the context above, the fan cooling device can be stopped (state=0), running (state=1), running faster (state=2). As the node tells to use no more than 2, then the governor will never go to running much faster (state=3). (That's an example). >> When the cooling driver is able to return the number of states it >> supports, it is safe to set the states to THERMAL_NO_LIMIT and let the >> governor to find the balance point. > > If the cooling driver is using cpufreq, is the number of supported > states equal to the number of operating points given to cpufreq? Yes, absolutely if THERMAL_NO_LIMIT is set [1] (which is what is done most of the cases). Otherwise it will use the boundaries set in <&cpu limit_low limit_high> When changing the limits, a state=1 has a different meaning. For example: 7 OPPs available <&cpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT> : state=[0..7] <&cpu 0 2> : state=[0..2] (1, 2) <&cpu 5 7> : state=[0..3] (5, 6, 7) [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/thermal/cpu_cooling.c#n334 >> Now if the cooling device is cpufreq, the state order is inverted, >> because the cooling effects happens when decreasing the OPP. >> >> If the boards support 7 OPPs, the state 0 is 7 - 0, so no mitigation, if >> the state is 1, the cpufreq is throttle to the 6th OPP, 2 to the 5th OPP >> etc. > > I am not sure how the state would be set to 2. That is a governor decision. Let me give an example with a hikey960 board which has very fast temperature transitions, so it is simpler to illustrate the behavior. The trip point is 75°C. Imagine the CPU gets loaded 100%, the cpufreq sets the OPP to the max (2.36GHz), as the temperature is still under 75°C, there is no mitigation yet, so the cooling device state is 0. In a very few seconds the temperature reaches 75°C, that trigger the monitoring of the thermal zone and the mitigation begins, then the temperature continues to increase very quickly to 78°C, the governor see we are above the trip point and increment the cooling device state (state=>1). That leads to an OPP change from 2.36GHz to 2.11GHz. The governor continues to read the temperature and see the temperature is still increasing (even if it is that happens more slowly), so it increases the state again (state=>2). That leads to an OPP change from 2.11GHz to 1.8GHz. The governor continues to read the temperature and see the temperature decrease, it does nothing. The governor continues to read the temperature, see the temperature decreases and is below 75°C, it decrease the state (state=>1), the OPP change to 2.36GHz. The temperature then increases, etc ... Actually the governors do more than that but it is for the example. So it is a bad idea to set boundaries for the cooling device state as that may prevent the governor to take the right decision for the cooling effect. Imagine in the example above, we set the max state to 1 for the cooling device, that would mean the governor won't be able to stop the temperature increasing, thus ending up to a hard reboot. >> Now the different combinations: >> >> <&cpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT> the governor will use the state >> 0 to 7. >> >> <&cpu THERMAL_NO_LIMIT 2> the governor will use the state 0 to 2 > > What would be the difference between <&cpu THERMAL_NO_LIMIT 2> and > <&cpu 0 2> ? > (if there is any) There is no difference. >> <&cpu 1 2> the governor will use the state 1 and 2. That means there is >> always the cooling effect as the governor won't set it to zero thus >> stopping the mitigation. > > For the purposes of the board in question, we have 4 operating points, > 300MHz, 600MHz, 800MHz and 1GHz. Once the board reaches 90C, we need > them to cease operation at 800MHz and 1GHz and only permit operation > at 300MHz and 600MHz. I am going under the assumption that the cpu > index[0] would be for 300MHz, index[1] = 600MHz, etc. > > If I am interpreting your comment correctly, I should set <&cpu > THERMAL_NO_LIMIT 2> which would allow it to either not cool and run up > to 600MHz and not exceed, is that correct? Nope, it will mean the cooling device can only reduce to 800MHz and to 600MHz to mitigate. Actually the thermal framework neither the kernel are designed to handle this case. They assume the OPPs are stable whatever the thermal situation. That is the reason why I think it is a very interesting use case because it introduces a temperature constraint in addition to a duration for a certain OPP. IMO, that could be an extension of the turbo-mode. With what we have now, I doubt it is feasible. The best we can do is preventing to reach the 90°C, so we remove the OPP temperature constraint. I suppose 85°C is a safe temperature to stick on. And in order to let the governor have free hand. <&cpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT> I don't think that will have a significant impact on performances compared to be able to run at a higher temperature with less OPPs. >> Does it clarify the DT spec? >> > > I think your reply to my inquiry might. If possible, it would be nice > to get this documented into the bindings doc for others in the future. > I can do it, but someone with a better understanding of the concept > maybe more qualified. I can totally understand why some may want to > integrate this into their SoC device trees to slow the processor when > hot. > > Thank you for taking the time to review this. I appreciate it. > > adam > >> >> >> >>> What happens with trip point 60000? >>> (unfortunately one has to reboot in between or can you kexec between two kernel/dtb versions?) >>> >>> BR, >>> Nikolaus >>> >> >> >> -- >> Linaro.org │ Open source software for ARM SoCs >> >> Follow Linaro: Facebook | >> Twitter | >> Blog >> -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog