From patchwork Tue Apr 7 17:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 212373 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=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT 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 B2119C2BB85 for ; Tue, 7 Apr 2020 17:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E2D720771 for ; Tue, 7 Apr 2020 17:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726386AbgDGRth (ORCPT ); Tue, 7 Apr 2020 13:49:37 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42814 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgDGRth (ORCPT ); Tue, 7 Apr 2020 13:49:37 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 086692972A7 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Cc: Zhang Rui , "Rafael J . Wysocki" , Len Brown , Jiri Pirko , Ido Schimmel , "David S . Miller" , Peter Kaestle , Darren Hart , Andy Shevchenko , Support Opensource , Daniel Lezcano , Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Andrzej Pietrasiewicz Subject: [RFC 0/8] Stop monitoring disabled devices Date: Tue, 7 Apr 2020 19:49:18 +0200 Message-Id: <20200407174926.23971-1-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The current kernel behavior is to keep polling the thermal zone devices regardless of their current mode. This is not desired, as all such "disabled" devices are meant to be handled by userspace, so polling them makes no sense. There was an attempt to solve this issue: https://lkml.org/lkml/2018/2/26/498 and it ultimately has not succeeded: https://lkml.org/lkml/2018/2/27/910 This is a new attempt addressing all the relevant drivers, and I have identified them with: $ git grep "thermal_zone_device_ops" | grep "= {" | cut -f1 -d: | sort | uniq The idea is to modify thermal_zone_device_update() and monitor_thermal_zone() in such a way that they stop polling a disabled device. To do decide what to do they should call ->get_mode() operation of the specialized thermal zone device in question (e.g. drivers/acpi/thermal.c's). But here comes problem: sometimes a thermal zone device must be initially disabled and becomes enabled only after its sensors appear on the system. If such thermal zone's ->get_mode() /* in the context of thermal_zone_device_update() or monitor_thermal_zone() */ is called _before_ the sensors are available, it will be reported as "disabled" and consequently polling it will be ceased. This is a change in behavior from userspace's perspective. To solve the above described problem I want to introduce the third mode of a thermal_zone_device: initial. The idea is that when the device is in its initial mode, then its polling will be handled as it is now. This is a good thing: should the temperature be just about hitting the critical treshnold early during the boot process, it might be too late if we wait for the userspace to run to save the system from overheating. The initial mode should be reported in sysfs as "enabled" to keep the userspace interface intact.