Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3254451pxb; Mon, 24 Jan 2022 06:00:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJXVZX7KEFFL5J/Ruvxh1ai8PCypKB2RCiLIWRrchwYJmiUDDZ5BZh2a4mHjehssLpyPWI X-Received: by 2002:a17:90b:250:: with SMTP id fz16mr2031745pjb.188.1643032849231; Mon, 24 Jan 2022 06:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643032849; cv=none; d=google.com; s=arc-20160816; b=0ujZc9+g5/6l3pblo/8/+ExblIPtoWeLnNoM4oStKot11xVgGLLcWbSH5wTtFXuZhR nsnhsOGXM9zUJqRIfL+UbVcYMjDW0PJNvrGuzeHf1MZNaaNo5sMEFLIJiruTVo4ZnZxn eywvTCzkv6+x1yDk5vs94O+cUH+IGa4nsDDKsz6fZNplm9qMgvxVOjdi5y+abpCLUChH LN07A39mIy7ZBSBjDSh2k3xdHNcoJpUXrNMmsqdTBSaPalGZoSsAScsTGeai5UF2PxZy DaYVfrmAUPBhkDIoGE8zKjPtn6eoDIn/aNGDSuI/w9dElQ6d08Wogi3KKPsQYAI3pD1B kTNg== 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=2pHn6VFDo9V2iSXX9J9tHBEdex+fcc+UCqRoXLJMgfA=; b=wvXxiAOhbSYTD5CHeElK/nxnDhuO44gfE8GkUPQWR1tCLGJHizsDxRfRjRhE38V8BF zPFJeMNAGTILzs4ufMeH04SguOac73ZRj6lo7OZHXjUR3+dSD0Ybl5jNFmp7+dD1rz4P X/fZyTIwdnXAJs6gYzmjVhexdI09mTAjqwu5HsiIECkDoL0cc6R99oQNMozSzZaMhsI0 Ft+EbcKCzNmp0cIwsmmDZSnP1OQ2bN0I0/tF7JpnQAY9TcPBQ8yyjw3y3N24wAmnKK0o kxxHC2ezUM/5JWA69xMfE+5W8NrolIFMv+NuMBbBwrLl/mLFaDvqGeK4TqabImtuiG1T V8PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u7fVTzQ6; 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 q34si13522860pgk.819.2022.01.24.06.00.36; Mon, 24 Jan 2022 06:00:49 -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=u7fVTzQ6; 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 S240056AbiAWUvI (ORCPT + 99 others); Sun, 23 Jan 2022 15:51:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237715AbiAWUvF (ORCPT ); Sun, 23 Jan 2022 15:51:05 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A634C06173D for ; Sun, 23 Jan 2022 12:51:04 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id az25so9998659wrb.6 for ; Sun, 23 Jan 2022 12:51:04 -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=2pHn6VFDo9V2iSXX9J9tHBEdex+fcc+UCqRoXLJMgfA=; b=u7fVTzQ6f8YyT+tk5WCIgGkmFky4Kcvn84tExuIQDd06RmqpdKZnulep6DITSmFKkk J54RZ/MMcsimwKPeDCdotQEwwgZDQcF9AfoM0F0ER1rSuIUvrui5Hwy23EvedJloXgEP 6J6gOKRGBkbVq48w+7npzU+DbFA5XhRkAt4T8aWDG/1WUSO+bd05O3xmzyg9nURx5OEu Iy3Fghakg5P2fHo491YIqx8KWuReEJlhlNkwvFTtAj+SniXh1rRVInY9eusZkmPZYb1Q HvajymQpzGoZKuF7IOizmVc0D5/v2UfUDZB9gUxk4TXD9RKOI8X2nwWqSew3Up6YcFMz OATw== 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=2pHn6VFDo9V2iSXX9J9tHBEdex+fcc+UCqRoXLJMgfA=; b=wZ6Gl7fhWzzGbT5P7wvISldIlzOcIDd3QcSCWL6wC6qohyTWGGOozEvnDla/3ZpkIr 6u3vBqeGImX8P1hZgF5MQGF1JVQucS20Cj10eGeTjywpcfJQ7XNnpeUKHhuVqDNixb2v xqDwfcdjm9RQOcffcyhHW/SPzd8NIzpmtXCwZv8iBv+XiPQGWBbzVleYwgGmXBX5z2XY iB3sjUQN/5v/2xOWYBSjgjq6GWfYyBl9kQnfrVadgP53k/884HCop0LY3fovWfUwvjFr HzHmrAjgutCqQNzo9vMnF0ko1WJ4qpUtLL3uiQpvCE8h5UQTSGJMz9pTcMiq8k4h1DRM W7EA== X-Gm-Message-State: AOAM532jigaufG4aGZbChdLsomqACsDK3dAFypEfgidz/uTc6SUaeX3B q+uXVCDye40sHXgnKT5xhE3hlvMA8GWbAA== X-Received: by 2002:adf:f810:: with SMTP id s16mr11946882wrp.25.1642971062941; Sun, 23 Jan 2022 12:51:02 -0800 (PST) Received: from ?IPv6:2a01:e34:ed2f:f020:bc8d:48f2:4c8a:bfa9? ([2a01:e34:ed2f:f020:bc8d:48f2:4c8a:bfa9]) by smtp.googlemail.com with ESMTPSA id u19sm7495797wmm.39.2022.01.23.12.51.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Jan 2022 12:51:02 -0800 (PST) Subject: Re: [PATCH v3] thermal/core: Clear all mitigation when thermal zone is disabled To: Manaf Meethalavalappu Pallikunhi , "Rafael J . Wysocki" , Amit Kucheria , Zhang Rui , Thara Gopinath , Matthias Kaehlcke Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1641581806-32550-1-git-send-email-quic_manafm@quicinc.com> From: Daniel Lezcano Message-ID: <927aca29-fca7-bdf9-9ad6-2599125ca1b4@linaro.org> Date: Sun, 23 Jan 2022 21:51:00 +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: <1641581806-32550-1-git-send-email-quic_manafm@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, semantically speaking disabling a thermal zone would be to detach the thermal zone from its governor and stop the monitoring. May be add the functions - thermal_governor_attach(struct thermal_zone_device *tzd) { ... if (tz->governor && tz->governor->bind_to_tz) { if (tz->governor->bind_to_tz(tz)) { } ... } - thermal_governor_detach(struct thermal_zone_device *tzd) { ... if (tz->governor && tz->governor->unbind_from_tz) tz->governor->unbind_from_tz(tz); ... } And add in the step_wise and power_allocator the reset of the governor's data as well as the cooling device instances in the unbind_from_tz() callback Then, thermal_zone_device_enable() attaches and thermal_zone_device_disable() detaches the governor. Does it make sense ? On 07/01/2022 19:56, 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); > + for (trip = 0; trip < tz->trips; trip++) > + handle_thermal_trip(tz, trip); > + > thermal_notify_tz_disable(tz->id); > + } > > return ret; > } > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog