Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1197140pxb; Fri, 21 Jan 2022 12:02:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYh8AzzR0wceKNZena0pLGnKuIr+gQACC/HbwiTX8AWGv0b+UlBN9ZHTdgq255+qOgWh1I X-Received: by 2002:a17:90a:e7c8:: with SMTP id kb8mr2262958pjb.35.1642795357324; Fri, 21 Jan 2022 12:02:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795357; cv=none; d=google.com; s=arc-20160816; b=dVnkSZAq/QBzY+XFLzo7CTBl/7HH+UkeYKy3YjlCea68b+Avq3vnQ3ZMG+Mu1xxUEu ERbVuCRAe7Gpg/k4df9OYT8/QPLrlV7ejdoGJKWeDcG2akNXK8gKeP5zRnzSF8wXh+LA KNifEECRvL+hsTEC9S7fcM5VNEGL/+lljLS64PzLMOeET+Frym4qzs/86GVN0TjKQeHv XHBSX1LfqeyNy3nJehmB6SXUvHL/LDTkU2g9edbma2O3v7Qt7xI3TtNoZtR+aCI6cOVs OlhJH0mrtCxfd06dL24hVHZ737X04Q5Itmm90VpdSrzfy+6JPaNBA80ZJ1kyuLi9rW70 d8Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=i6H2VKS3zi/cgFysvmh7unIKg4DB6PbdGxzowpLmDaU=; b=G++BC95DRFb5E6GFsMPblSOpY1W/TvjXGjjjwxLvrCTMNyaw1wjcABorTItSBhYWtX YEBqtZCSQsN8FPF1w/WhJnMF6VEGgczkleoLD+NKuZ1atOQpF4sxyewdaVsrq4/2IZsp dWBmjWtkcthXKMn3Lo7b0QfJenvX2bjFznbxPZAgw9h0MnfCmCcw0h5ANYm6bDfEEpta LEer5Ott6WJoSBTSwia02UytYfhNEuX0ofdPQGh9M5jiBz2zdvI33UaC+wj2dUC+rULW wKmBMiSlDGW+wSmy8nrRkqEFITntbz/GELKcc37S4fgxyzK7kaUyvq3oYFGyqcADWBSC OBzw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si7465357pfj.170.2022.01.21.12.02.24; Fri, 21 Jan 2022 12:02:37 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357217AbiASUD0 (ORCPT + 99 others); Wed, 19 Jan 2022 15:03:26 -0500 Received: from mail-qv1-f52.google.com ([209.85.219.52]:35600 "EHLO mail-qv1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbiASUDT (ORCPT ); Wed, 19 Jan 2022 15:03:19 -0500 Received: by mail-qv1-f52.google.com with SMTP id a8so4403590qvx.2; Wed, 19 Jan 2022 12:03:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i6H2VKS3zi/cgFysvmh7unIKg4DB6PbdGxzowpLmDaU=; b=CJ99qgEFoDUo2ZIZ14ec9g/86Zdw0vNX7lI02lowM6WJWAtKkTmdbcAULWMww4fQeu NRscoXuttUo4nxC31JmISH1sO/Mxaht+nbFdUcenzdjICAUIKV1IgIp3DD4SaCoY4bOu 7QJUdcAS1xSgJrqsZeswn5k2aSywOLq9av02T6ywq2nCqRsyzJ9S9rILkmT+XyyYoNur 4AEr3XailYPRUuxhODl4FCt8O2Vc+Rz7XW2yHdimjLntog1b5HpamKlPHUm5LLshVo5M f0TSLpmsV857p65lmGD1Z2bWs1OtPw38NrYbtjI0+jKYkqdNHPAyL/5NU1cBntDu05Vs nJ+Q== X-Gm-Message-State: AOAM53318llr9Q7SK59UPGpV+eTmpZSXn1fuB99+b0LQelrt9hN+veNZ l0/A7VwVLfjDXzSnxtJyRHD6kODg7jnmIlV0zLo= X-Received: by 2002:a05:6214:509e:: with SMTP id kk30mr28063261qvb.61.1642622598524; Wed, 19 Jan 2022 12:03:18 -0800 (PST) MIME-Version: 1.0 References: <1641581806-32550-1-git-send-email-quic_manafm@quicinc.com> In-Reply-To: <1641581806-32550-1-git-send-email-quic_manafm@quicinc.com> From: "Rafael J. Wysocki" Date: Wed, 19 Jan 2022 21:03:07 +0100 Message-ID: Subject: Re: [PATCH v3] thermal/core: Clear all mitigation when thermal zone is disabled To: Manaf Meethalavalappu Pallikunhi Cc: "Rafael J . Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Thara Gopinath , Matthias Kaehlcke , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 7, 2022 at 7:57 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); > + for (trip = 0; trip < tz->trips; trip++) > + handle_thermal_trip(tz, trip); > + It looks to me like this has a potential of confusing user space by setting the temperature to invalid before notifying it that the zone has been disabled. > thermal_notify_tz_disable(tz->id); > + } > > return ret; > } >