Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1193824pxb; Fri, 21 Jan 2022 11:58:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4l7dDlK/Qgx+i3atQuoiPLUjz3CTqPFEeGuLnjuZv/OtOMMnWYBjUtGgUc6MpknYbmxLe X-Received: by 2002:a17:90a:6346:: with SMTP id v6mr2194067pjs.191.1642795107003; Fri, 21 Jan 2022 11:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795106; cv=none; d=google.com; s=arc-20160816; b=s4ZHuszafahgN5m724ciwxYNpBvJcirZZPlAQwEieEUZuZxHR0ilqy+cgWyYWR6tao bvkMp2yFTEIzKROkJwVX3NTk0d7XULjIz3iaaYGnNzGzgX2jwiuvagWV/Ug1e7MvZ1Ev Rn/5dsrcCDUuuoL4NGmDBxlV9pthxBnlkBwBjfjY0XRavdcpbE0HpMRfmL3SDp0dI2KI s+YjpSUbGr/a9uCEPzAJc34/P5+5A1A/g8KV8efA80Pw1/u41QNv+meEwi+SPRCTAhJu 9oNCodo6/8WEqCBOQ1PFHLJhA6d23YnY0VGf42eHKtfREBAFBF76YmBMYMSR3zxmkRzc 2bfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Ji7iGAxDJEeqfoAnF5QNg6c4bsnLencbEnYiubnXrLA=; b=l2F6EXUVBW5maQCP0MjH+GdMci2Uv1Hdb6EsAczGbDv2bAShcx4+uklwm5iJMF9vEM /wGJBRAbovh2bU11fp9EY0SF679ZIPrGt7Do4+tKjNuOnNLiqTpSKbF2y5Z93Ww1zPGX qvHqonOflf7KcKHSyMBS5UtAQYxPpQ/3d6BTwVoGP2mckzn4MLY9HOtr7fBgKQyVxHGW NZDOi5NrBe2U206CO7gyn8BNEb/dB8s9GhNUOrJCR9nPOzerhFqLid5BetjBGTnJgEyX xsuSaJ1Dx5hMTr11Qmw+56DYLqT0YG2A8JEr3PCh3ir17RZK+JyHEVibcUZx+6k87WdX 4OaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTF5V7vF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nu18si8719466pjb.42.2022.01.21.11.58.15; Fri, 21 Jan 2022 11:58:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTF5V7vF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236888AbiASTMQ (ORCPT + 99 others); Wed, 19 Jan 2022 14:12:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236679AbiASTMP (ORCPT ); Wed, 19 Jan 2022 14:12:15 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAFCBC061574 for ; Wed, 19 Jan 2022 11:12:14 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id o1-20020a1c4d01000000b0034d95625e1fso2026988wmh.4 for ; Wed, 19 Jan 2022 11:12:14 -0800 (PST) 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=Ji7iGAxDJEeqfoAnF5QNg6c4bsnLencbEnYiubnXrLA=; b=QTF5V7vFYj7cQQydREB5BXMKVt4yV03Y5KYj1RbvffieD+/j9C4e5IDsXeoUXynC6p fcy+UxQvYkY5evkuGk4B/UG893ZqNr0PW/EmPRgS0MEDcY6J832WcUOjnloC+Kv6Kj6O 1n/eZoo9TrjTeHcshGTVoXgq0ZZAKyFOhFUDfS+Q0+1VoYi4w6ZurwAqiamq6WcoDq9I eJuP9UK9kXp+yV3WzA2zoeceX18K48FyNmz/QafrPWTkoYPafl5VjJHuulqPlzqjcOz8 fnRg4J/GpV2CItVXNowLOcJg3yX8dbSaSvnZpUPFAOjdJNpmzGiIwVsXu/7joHkQdmWt R54g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Ji7iGAxDJEeqfoAnF5QNg6c4bsnLencbEnYiubnXrLA=; b=Azc/WLs73RC4JDhinBCKMUZM+xRnhxotFDidyiNJay4nF5Q1onG3E9zZAOYzwLgDPS +1WBwXKLaK+73FtoaHeBsP2dqvt097iN5CFdSroJTUJ/DGmxRyk7c6mfggoFj5iOK7wr kRpECdFFuaoo5y+VJmHEIRaso9nKcHThlZyLZ+nUPqLstuex/saMuBcrjunb51EGcsgy FTQo80HuKSrEWBj6uvY0YuKaySKkfpnUyKO0hVEP6tVIJbLvqxT2mQLX3miDmlcS9f24 tTIc68cWdIXIQM9JIWdgmZ0Iui7rB0Mng/Hiv+ZqyIxrP/lzp5Q4wjqbYV7uC2JPpdk2 Ni2w== X-Gm-Message-State: AOAM532ZiCXe6pIIx1RrDAmxYhu959g5CoqLVcSxFyyQ6igRT6bk5Ckx ZALvmuHmgfq2FNZHNs81hDeuzQ+s4svLWUjI X-Received: by 2002:a1c:448b:: with SMTP id r133mr1554740wma.110.1642619533242; Wed, 19 Jan 2022 11:12:13 -0800 (PST) Received: from ?IPv6:2a01:e34:ed2f:f020:ff82:2d59:f05c:6474? ([2a01:e34:ed2f:f020:ff82:2d59:f05c:6474]) by smtp.googlemail.com with ESMTPSA id o33sm11664320wms.3.2022.01.19.11.12.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Jan 2022 11:12:12 -0800 (PST) Subject: Re: [PATCH v3] thermal/core: Clear all mitigation when thermal zone is disabled To: Manaf Meethalavalappu Pallikunhi , Thara Gopinath , "Rafael J . Wysocki" , Amit Kucheria , Zhang Rui , Matthias Kaehlcke , thara.gopinath@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1641581806-32550-1-git-send-email-quic_manafm@quicinc.com> <7c29c833-b558-f0ab-83ab-08371785ffd1@quicinc.com> <9fb8fb88-73d7-771e-1309-4363907f7c01@quicinc.com> From: Daniel Lezcano Message-ID: Date: Wed, 19 Jan 2022 20:12:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <9fb8fb88-73d7-771e-1309-4363907f7c01@quicinc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Manaf, On 19/01/2022 20:05, Manaf Meethalavalappu Pallikunhi wrote: > Hi Rafael/Daniel, > > Could you please check and comment  ? It is in my todo list, I'll review it before the end of the week. Regards -- Daniel > On 1/11/2022 2:15 AM, Manaf Meethalavalappu Pallikunhi wrote: >> Hi Thara, >> >> On 1/10/2022 11:25 PM, Thara Gopinath wrote: >>> Hi Manaf, >>> >>> On 1/7/22 1:56 PM, Manaf Meethalavalappu Pallikunhi wrote: >>>> Whenever a thermal zone is in trip violated state, there is a chance >>>> that the same thermal zone mode can be disabled either via thermal >>>> core API or via thermal zone sysfs. Once it is disabled, the framework >>>> bails out any re-evaluation of thermal zone. It leads to a case where >>>> if it is already in mitigation state, it will stay the same state >>>> until it is re-enabled. >>>> >>>> To avoid above mentioned issue, on thermal zone disable request >>>> reset thermal zone and clear mitigation for each trip explicitly. >>>> >>>> Signed-off-by: Manaf Meethalavalappu Pallikunhi >>>> >>>> --- >>>>   drivers/thermal/thermal_core.c | 12 ++++++++++-- >>>>   1 file changed, 10 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/thermal/thermal_core.c >>>> b/drivers/thermal/thermal_core.c >>>> index 51374f4..e288c82 100644 >>>> --- a/drivers/thermal/thermal_core.c >>>> +++ b/drivers/thermal/thermal_core.c >>>> @@ -447,10 +447,18 @@ static int thermal_zone_device_set_mode(struct >>>> thermal_zone_device *tz, >>>>         thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); >>>>   -    if (mode == THERMAL_DEVICE_ENABLED) >>>> +    if (mode == THERMAL_DEVICE_ENABLED) { >>>>           thermal_notify_tz_enable(tz->id); >>>> -    else >>>> +    } else { >>>> +        int trip; >>>> + >>>> +        /* make sure all previous throttlings are cleared */ >>>> +        thermal_zone_device_init(tz); >>> >>> It looks weird to do a init when you are actually disabling the >>> thermal zone. >>> >>> >>>> +        for (trip = 0; trip < tz->trips; trip++) >>>> +            handle_thermal_trip(tz, trip); >>> >>> So this is exactly what thermal_zone_device_update does except that >>> thermal_zone_device_update checks for the mode and bails out if the >>> zone is disabled. >>> This will work because as you explained in v2, the temperature is >>> reset in thermal_zone_device_init and handle_thermal_trip will remove >>> the mitigation if any. >>> >>> My two cents here (Rafael and Daniel can comment more on this). >>> >>> I think it will be cleaner if we can have a third mode >>> THERMAL_DEVICE_DISABLING and have thermal_zone_device_update handle >>> clearing the mitigation. So this will look like >>> if (mode == THERMAL_DEVICE_DISABLED) >>>     tz->mode = THERMAL_DEVICE_DISABLING; >>> else >>>     tz->mode = mode; >>> >>> thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); >>> >>> if (mode == THERMAL_DEVICE_DISABLED) >>>     tz->mode = mode; >>> >>> You will have to update update_temperature to set tz->temperature = >>> THERMAL_TEMP_INVALID and thermal_zone_set_trips to set >>> tz->prev_low_trip = -INT_MAX and tz->prev_high_trip = INT_MAX for >>> THERMAL_DEVICE_DISABLING mode. >> >> I think just updating above fields doesn't guarantee complete clearing >> of mitigation for all governors. For  step_wise governor, to make sure >> mitigation removed completely, we have to set each >> thermal-instance->initialized = false as well. >> >> If we add that to above list of variables in update_temperature() >> under if (mode == THERMAL_DEVICE_DISABLING) , it is same as >> thermal_zone_device_init function does in current patch. We are just >> resetting same fields in different place under a new mode, right ? >> >> Thanks, >> >> Manaf >> -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog