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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 D399FC2BA19 for ; Tue, 14 Apr 2020 18:04:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7576020767 for ; Tue, 14 Apr 2020 18:04:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Vt/zi5D8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7576020767 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r/4s0h9YKtqw9+skPsv1Itz/pZ+/0JFjVeIidfQTrLY=; b=Vt/zi5D8KUwAutTMI3Gkm4vdb/ 7s+ecUIUZDMRfZC7ynt7jmlIF/gLabu40LF8+6vH3lro0/piEOw4STetHyT6uy4iQFVNBwGt9OguB z57N4zmprzxaOFwkJYWqgk9b1wx5tg/8Qwl+goik2+afPy0Jzp3aCx3ggQcwZTJjAlV1BJ5PbKZTV 5syASmaTXjAPsbh3RaUjU++YL+OkWwOFzNu0vncQ97vZhUENm+5CMqt/Xxy0cnPfFVh+LCBonf/TC IbQszOJ6VpGlSmpPI4kbCBGbH829p+/2XZyG2MiLhqyFGnVJbWaVoEWADg2gWo8ue4+QDiFXbTbOp a7Edkpgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jOPus-0004pX-P4; Tue, 14 Apr 2020 18:04:10 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jOPsS-0002Uz-QK for linux-arm-kernel@lists.infradead.org; Tue, 14 Apr 2020 18:01:43 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 0C0432A1BE9 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC v2 9/9] thermal: core: Stop polling DISABLED thermal devices Date: Tue, 14 Apr 2020 20:01:05 +0200 Message-Id: <20200414180105.20042-10-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200414180105.20042-1-andrzej.p@collabora.com> References: <2bc5a902-acde-526a-11a5-2357d899916c@linaro.org> <20200414180105.20042-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200414_110140_996639_D8B6C4C3 X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Polling DISABLED devices is not desired, as all such "disabled" devices are meant to be handled by userspace. Add a new mode: THERMAL_DEVICE_INITIAL. It is dedicated to handle devices which must be initially DISABLED, but which are polled at startup nonetheless. THERMAL_DEVICE_INITIAL shall be reported as "enabled" in sysfs to keep the userspace interface intact. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 18 ++++++++++++++++-- drivers/thermal/thermal_sysfs.c | 4 ++-- include/linux/thermal.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 7637ddb79813..c3c966a5a50b 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -305,13 +305,22 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } +static inline bool should_stop_polling(struct thermal_zone_device *tz) +{ + return thermal_zone_device_get_mode(tz) == THERMAL_DEVICE_DISABLED; +} + void monitor_thermal_zone(struct thermal_zone_device *tz) { + bool stop; + + stop = should_stop_polling(tz); + mutex_lock(&tz->lock); - if (tz->passive) + if (!stop && tz->passive) thermal_zone_device_set_polling(tz, tz->passive_delay); - else if (tz->polling_delay) + else if (!stop && tz->polling_delay) thermal_zone_device_set_polling(tz, tz->polling_delay); else thermal_zone_device_set_polling(tz, 0); @@ -490,6 +499,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, { int count; + if (should_stop_polling(tz)) + return; + if (atomic_read(&in_suspend)) return; @@ -1356,6 +1368,8 @@ thermal_zone_device_register(const char *type, int trips, int mask, list_add_tail(&tz->node, &thermal_tz_list); mutex_unlock(&thermal_list_lock); + tz->mode = THERMAL_DEVICE_INITIAL; + /* Bind cooling devices for this zone */ bind_tz(tz); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index bc34d0f9768b..9d26196735bd 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -53,8 +53,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf) mode = thermal_zone_device_get_mode(tz); - return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_ENABLED ? "enabled" - : "disabled"); + return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_DISABLED ? "disabled" + : "enabled"); } static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index efb481088035..2f61f461da50 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -50,6 +50,7 @@ struct thermal_instance; enum thermal_device_mode { THERMAL_DEVICE_DISABLED = 0, THERMAL_DEVICE_ENABLED, + THERMAL_DEVICE_INITIAL, }; enum thermal_trip_type { -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel