From patchwork Tue Oct 19 16:35:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12570597 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD879C433F5 for ; Tue, 19 Oct 2021 16:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1F106135E for ; Tue, 19 Oct 2021 16:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhJSQhf (ORCPT ); Tue, 19 Oct 2021 12:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbhJSQhe (ORCPT ); Tue, 19 Oct 2021 12:37:34 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B098C06161C for ; Tue, 19 Oct 2021 09:35:21 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 67-20020a1c1946000000b0030d4c90fa87so4015339wmz.2 for ; Tue, 19 Oct 2021 09:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=goeAxY6VmGCgCRvdus1WGmsm0JBbAmio3aubFOTGKbw=; b=qeHGvpSDyNQqJdm2AmtQXasO76AGIjS87PPJJuVJGWuq92jcPARXqp7MLjME+fspWs jtDBUdZ8XOXED3ASVkoGhcqZ7u2SbBphpDCS5SJWMiNvL1GS0/fW7IX3f97ssMxRC6Qp s29EHvyFExobD5R2vUdIsYHx9/o9blxVf3L3YiK1HtjqvCsjOBZt9dCl3Y/QxQ8kuX7Y gEuhpF/10DUIQvXAL+RjzC8OHdObNB+HAKTuhEAfEmZOWlQdF7M4XH14bt2p/G5mf5UR olJPQ6jFyIP2y7LuEyMNi73scpLAHVlTPrMCkldd5eeNXqBcKibkxWcpOCd/X+jNL7VX lLyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=goeAxY6VmGCgCRvdus1WGmsm0JBbAmio3aubFOTGKbw=; b=KTf9kYa4gKk8SKJX1QdZsp+itwHC+nNLskYX0QtjfVS94KLCtd3CaGWvl4Yt6dpCke aLORY0/nFhlUVa/8yLedYqTptY7dqjE/EPqVAFBkvIBn/pNjmwl6nlR4KkGt56DHSjER l/PS0sew9zP5V7EbDeetnVjdQWakicd4L0ozghd7RLZrj6P5BHFjPy3zKxB+2fV3Um0t 3sDUMFRiKzE8lMXu3VHGNYXKtlmlgBfUvRA6ie2Vv+15ImsxEHOnTGU/1TbkNj/iVwng tDfpXr+q4steHa/u9rsyRFsJto35IRTeEAx+L7Hg1kNamvO6C8F0kPT1b3xhI5z2a2du YmZA== X-Gm-Message-State: AOAM530nC8MuDZsHC/x/jwuOqM2V6kCP9Pdgwoyf6e/C/d/KaYGfRYVZ w9vQZX+np1MTHMSsWsgO3QvCFQ== X-Google-Smtp-Source: ABdhPJwXcBW9oqMddFNVyWlNt00vWahXExfjGsBr5Zmtccj3G9KGWojwfLxYbfxBsqVOkvfdVWe4xA== X-Received: by 2002:a7b:c149:: with SMTP id z9mr7210087wmi.177.1634661319624; Tue, 19 Oct 2021 09:35:19 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:4799:198d:b6ef:8da7]) by smtp.gmail.com with ESMTPSA id n7sm15377389wra.37.2021.10.19.09.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 09:35:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J . Wysocki" , Zhang Rui , Amit Kucheria Subject: [PATCH v3 1/2] thermal/core: Make the userspace governor deprecated Date: Tue, 19 Oct 2021 18:35:05 +0200 Message-Id: <20211019163506.2831454-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The userspace governor is sending temperature when polling is active and trip point crossed events. Nothing else. AFAICT, this governor is used with custom kernels making the userspace governor co-existing with another governor on the same thermal zone because there was no notification mechanism, implying a hack in the framework to support this configuration. The new netlink thermal notification is able to provide more information than the userspace governor and give the opportunity to the users of this governor to replace it by a dedicated notification framework. The userspace governor will be removed as its usage is no longer needed. Add a warning message to tell the userspace governor is deprecated. Signed-off-by: Daniel Lezcano Acked-by: Rafael J. Wysocki Reviewed-by: Lukasz Luba --- drivers/thermal/gov_user_space.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/thermal/gov_user_space.c b/drivers/thermal/gov_user_space.c index 82a7198bbe71..f4fe050e1cbc 100644 --- a/drivers/thermal/gov_user_space.c +++ b/drivers/thermal/gov_user_space.c @@ -15,6 +15,14 @@ #include "thermal_core.h" +static int user_space_bind(struct thermal_zone_device *tz) +{ + pr_warn("Userspace governor deprecated: use thermal netlink " \ + "notification instead\n"); + + return 0; +} + /** * notify_user_space - Notifies user space about thermal events * @tz: thermal_zone_device @@ -43,5 +51,6 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip) static struct thermal_governor thermal_gov_user_space = { .name = "user_space", .throttle = notify_user_space, + .bind_to_tz = user_space_bind, }; THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space); From patchwork Tue Oct 19 16:35:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12570599 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE779C433EF for ; Tue, 19 Oct 2021 16:35:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A554C6135E for ; Tue, 19 Oct 2021 16:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbhJSQhf (ORCPT ); Tue, 19 Oct 2021 12:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbhJSQhf (ORCPT ); Tue, 19 Oct 2021 12:37:35 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45449C061768 for ; Tue, 19 Oct 2021 09:35:22 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id y74-20020a1c7d4d000000b00322f53b9bbfso3827337wmc.3 for ; Tue, 19 Oct 2021 09:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6lGbUk9scuSolc0mMC7O3O5jKEdhtvYf+nI62abO4j4=; b=ppRTjWSzYtJqN0FzfUhvG4tLw/33KSdRGOXyf0A972B6B9Qqo8wsj6RBVzmuuqb/wW GwNSwmXgm9JVb512/caLZjdGQeYjwLQJpKqRkxTPjAXApdz0Jj8cG6gPgzIzibmQ4LPb VDMb35EslXmp7JmscSylFEmQY60WdVrn4uOIZ3AZXnt7nFCqcHV58xzIocbGEZMkAcOx sGwcWTkiQtLyDJ23NKScPp5QxBFih7YB0A6Xbq7YnDhZOryF3SFot24TLJB2LMzJOPWB r3+3xQozGKC7oswJO0f2E98ameFHg+zigQHiyvRqraVCu60IP7tBnXyHDqauaDVY2qZC 13Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6lGbUk9scuSolc0mMC7O3O5jKEdhtvYf+nI62abO4j4=; b=y9i/J9w4T9/8D84nnbI6En2YOSmylgL+KQVuD/FZtMCEsEql2f5oLiab3HhSr86dBQ /dXj4m5JwkhVJ96uubXxZj8NjpfvpG695oWxP48p30ZHJyWleaWvALZykjXqMpdv03zp A1DWvmnbqN0oh7JBpJ/n3rk5ILYacVL3WQXIIYqyB6n1Z1k0Op1SRByOLSiyI46fNdOO Nnj2O5748RlKBqzTSTSc9ry07I/xR7RmGMwV+X6BF4z3/ho5c6HWNFVxlLySygvR2JLF 9HKB7Lk3l51MYNXHbwpUa15ogHFlG/THBOlhbKsV10f+qJbMt9b/eZBjov6RVI2nTtq6 3CUw== X-Gm-Message-State: AOAM5316fT/g1K6PW0glMvk+hU2KfAJt1VMRRr4QnbOGQ2YYoJxTm7iQ cbV82S3B3ZT4j0Io5WqrQE8uKA== X-Google-Smtp-Source: ABdhPJz4qYyTxSplorxLWlOxOc1azR2uKhPM6L83bGXJ4bXdXMR5I0XYlkeHzwIxpQijTU0pclODLQ== X-Received: by 2002:a7b:c08a:: with SMTP id r10mr7301002wmh.135.1634661320770; Tue, 19 Oct 2021 09:35:20 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:4799:198d:b6ef:8da7]) by smtp.gmail.com with ESMTPSA id n7sm15377389wra.37.2021.10.19.09.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 09:35:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Zhang Rui , Amit Kucheria Subject: [PATCH v3 2/2] thermal/core: Deprecate changing cooling device state from userspace Date: Tue, 19 Oct 2021 18:35:06 +0200 Message-Id: <20211019163506.2831454-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019163506.2831454-1-daniel.lezcano@linaro.org> References: <20211019163506.2831454-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it. The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision. We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power. The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous. The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos. As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future. Emit a warning and deprecate the interface. Signed-off-by: Daniel Lezcano Acked-by: Rafael J. Wysocki --- drivers/thermal/thermal_sysfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 1c4aac8464a7..f154bada2906 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -610,6 +610,9 @@ cur_state_store(struct device *dev, struct device_attribute *attr, unsigned long state; int result; + dev_warn_once(&cdev->device, + "Setting cooling device state is deprecated\n"); + if (sscanf(buf, "%ld\n", &state) != 1) return -EINVAL;