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.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 566C8C48BE5 for ; Wed, 16 Jun 2021 14:36:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3131961027 for ; Wed, 16 Jun 2021 14:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234041AbhFPOib (ORCPT ); Wed, 16 Jun 2021 10:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234051AbhFPOi2 (ORCPT ); Wed, 16 Jun 2021 10:38:28 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89036C061760 for ; Wed, 16 Jun 2021 07:36:20 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id j62so2784411qke.10 for ; Wed, 16 Jun 2021 07:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=C6N7ZLY1WhDSZqhuZcLY/QHujQYu6PkAlcx3M6QgT6k=; b=lOsfCoqWux3C4DdeAMZTDNufs06iP6UqU1XS14MePe0Fxa/GAhcx+oN0u6vW5Ilm/X lN4FSzc0CG9F8545wOn5VtuDBEFQ8kAASsbxlqYt5DcwEZVQrlG84VemH3pEcOzxbh/l 1pT4rMyWUfJs9Qsmta5CcXcQbaGUkzOQ8T4MoOs4SSnIUTOqD6KMLnTmSaj9kH/v3zKT +pQZL2VHUxAl3cyJjef6Oxy27O9TRzG1Vvj9zeD2CF+gfrgcdVYm2GJIfs6POyw5LCeZ c84PFBSGWQxHOfErl78EpnnNhWJS6WOkxZZzcNZmXRS3gcPOqJEZveBloOPo1Xt7TMw2 aYHA== 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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=C6N7ZLY1WhDSZqhuZcLY/QHujQYu6PkAlcx3M6QgT6k=; b=GBwYn3WepQctzBUAv9s3r4pltgpD/THEIM6TWgxA6Yb38MbaVM76yt1/8a84JEhlfx shM4zsqbJ3Q2UO+IwcWlylsz6mfoEwhfyAJ4hjz2fhXgped6fCNFHHpl3BwZeFDAoWvL ZAZPf/FP/SNx5BOIF9jGDfMvXyR3IIT0onG9tLYqPP5h1BER2X+GjpY86CqC8EXxbQOa EdD5Aj7WrqS6vpJ6CAeNwPAOk7ivNS/CApotUutTn3IyXr5hcTf5WQrWE9IyGtZOYv7z Lsznxg3Ds0B9Kr24Hg3l1/O2HzisJGY84Ebsu47jRdTV/FPLyy4oEVYyVo7pqugFTojG uYNQ== X-Gm-Message-State: AOAM532vEiV1RzrrkgGqpUm33G3lWMz7g1Gz/RrmKQ3NUwDw8JlO5hC/ IgXwi/Bz26LaCW42VHwgDV/EVg== X-Google-Smtp-Source: ABdhPJyQfSgTLuanvM52DFRrLyjJpWyc1bNVtB3kIaDVomzEZTehCLdam7DcZd2qn8FbX1cl+wfGsw== X-Received: by 2002:a05:620a:4da:: with SMTP id 26mr348132qks.336.1623854179605; Wed, 16 Jun 2021 07:36:19 -0700 (PDT) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id a3sm1675158qkc.109.2021.06.16.07.36.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jun 2021 07:36:19 -0700 (PDT) Subject: Re: [PATCH v3 4/7] thermal/drivers/tegra: Add driver for Tegra30 thermal sensor To: Dmitry Osipenko , Daniel Lezcano , Viresh Kumar Cc: Thierry Reding , Jonathan Hunter , Zhang Rui , Amit Kucheria , Andreas Westman Dorcsak , Maxim Schwalm , Svyatoslav Ryhel , Ihor Didenko , Ion Agorria , Matt Merhar , Peter Geis , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org References: <20210529170955.32574-1-digetx@gmail.com> <20210529170955.32574-5-digetx@gmail.com> <6f2b6290-095a-bd39-c160-1616a0ff89b1@linaro.org> <20210615102626.dja3agclwzxv2sj4@vireshk-i7> <595f5e53-b872-bcc6-e886-ed225e26e9fe@gmail.com> <4c7b23c4-cf6a-0942-5250-63515be4a219@gmail.com> <545974aa-bb0f-169b-6f31-6e8c2461343f@linaro.org> From: Thara Gopinath Message-ID: <14b6344b-3994-7977-6933-a2d2357d23d5@linaro.org> Date: Wed, 16 Jun 2021 10:36:17 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/16/21 6:47 AM, Dmitry Osipenko wrote: > 16.06.2021 05:50, Thara Gopinath пишет: > ... >> >> Hi, >> >> Thermal pressure is letting scheduler know that the max capacity >> available for a cpu to schedule tasks is reduced due to a thermal event. >> So you cannot have a h/w thermal pressure and s/w thermal pressure. >> There is eventually only one capping applied at h/w level and the >> frequency corresponding to this capping should be used for thermal >> pressure. >> >> Ideally you should not be having both s/w and h/w trying to throttle at >> the same time. Why is this a scenario and what prevents you from >> disabling s/w throttling when h/w throttling is enabled. Now if there >> has to a aggregation for whatever reason this should be done at the >> thermal driver level and passed to scheduler. > > Hello, > > The h/w mitigation is much more reactive than software, in the same time > it's much less flexible than software. It should provide additional > protection in a cases where software isn't doing a good job. Ideally h/w > mitigation should stay inactive all the time, nevertheless it should be > modeled properly by the driver. Ok. This is kind of opposite to what I am doing on the Qcom platform I am working on. The h/w throttling is the default since like you mentioned it is more reactive. And s/w does only critical trip management. > >>>> >>>> That is a good question. IMO, first step would be to call >>>> cpufreq_update_limits(). >>> >>> Right >>> >>>> [ Cc Thara who implemented the thermal pressure ] >>>> >>>> May be Thara has an idea about how to aggregate both? There is another >>>> series floating around with hardware limiter [1] and the same >>>> problematic. >>>> >>>>   [1] https://lkml.org/lkml/2021/6/8/1791 >>> >>> Thanks, it indeed looks similar. >>> >>> I guess the common thermal pressure update code could be moved out into >>> a new special cpufreq thermal QoS handler (policy->thermal_constraints), >>> where handler will select the frequency constraint and set up the >>> pressure accordingly. So there won't be any races in the code. >>> >> It was a conscious decision to keep thermal pressure update out of qos >> max freq update because there are platforms that don't use the qos >> framework. For eg acpi uses cpufreq_update_policy. >> But you are right. We have two platforms now applying h/w throttling and >> cpufreq_cooling applying s/w throttling. So it does make sense to have >> one api doing all the computation to update thermal pressure. I am not >> sure how exactly/where exactly this will reside. > > The generic cpufreq_cooling already uses QoS for limiting the CPU > frequency. It could be okay to use QoS for the OF drivers, this needs a > closer look. > > We have the case where CPU frequency is changed by the thermal event and > the thermal pressure equation is the same for both s/w cpufreq_cooling > and h/w thermal driver. The pressure is calculated based on the QoS > cpufreq constraint that is already aggregated. > > Hence what we may need to do on the thermal event is: > > 1. Update the QoS request > 2. Update the thermal pressure > 3. Ensure that updates are not racing Yes. So the first two steps you mentioned is exactly what cpufreq_cooling.c also does except for the fact that it is a s/w mitigation. Now if you have two sources that is updating the max frequency via qos, I think you can do either of the following before calculating thermal pressure 1. Read the throttled frequency from h/w if your h/w supports this feature. or 2. Use freq_qos_read_value to get the max frequency value. Either way only the correct throttled capacity should be passed to scheduler. -- Warm Regards Thara (She/Her/Hers) > >> So for starters, I think you should replicate the update of thermal >> pressure in your h/w driver when you know that h/w is >> throttling/throttled the frequency. You can refer to cpufreq_cooling.c >> to see how it is done. >> >> Moving to a common api can be done as a separate patch series. >> > > Thank you for the clarification and suggestion. >