From patchwork Mon Nov 30 05:36:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 335501 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 35472C64E8A for ; Mon, 30 Nov 2020 05:37:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D423320809 for ; Mon, 30 Nov 2020 05:37:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726005AbgK3Fhb (ORCPT ); Mon, 30 Nov 2020 00:37:31 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58765 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgK3Fhb (ORCPT ); Mon, 30 Nov 2020 00:37:31 -0500 Received: from 220-133-187-190.hinet-ip.hinet.net ([220.133.187.190] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kjbrh-0002xu-Kv; Mon, 30 Nov 2020 05:36:46 +0000 From: Kai-Heng Feng To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: andrzej.p@collabora.com, mjg59@google.com, srinivas.pandruvada@linux.intel.com, Kai-Heng Feng , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/3] thermal: core: Add indication for userspace usage Date: Mon, 30 Nov 2020 13:36:38 +0800 Message-Id: <20201130053640.54608-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We are seeing thermal shutdown on Intel based mobile workstations, the shutdown happens during the first trip handle in thermal_zone_device_register(): kernel: thermal thermal_zone15: critical temperature reached (101 C), shutting down However, we shouldn't do a thermal shutdown here, since 1) We may want to use a dedicated daemon, Intel's thermald in this case, to handle thermal shutdown. 2) For ACPI based system, _CRT doesn't mean shutdown unless it's inside ThermalZone. ACPI Spec, 11.4.4 _CRT (Critical Temperature): "... If this object it present under a device, the device’s driver evaluates this object to determine the device’s critical cooling temperature trip point. This value may then be used by the device’s driver to program an internal device temperature sensor trip point." So a "critical trip" here merely means we should take a more aggressive cooling method. So add an indication to let thermal core know it should leave thermal device to userspace to handle. Signed-off-by: Kai-Heng Feng --- drivers/thermal/thermal_core.c | 3 +++ include/linux/thermal.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index c6d74bc1c90b..6561e3767529 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1477,6 +1477,9 @@ thermal_zone_device_register(const char *type, int trips, int mask, goto unregister; } + if (tz->tzp && tz->tzp->userspace) + thermal_zone_device_disable(tz); + mutex_lock(&thermal_list_lock); list_add_tail(&tz->node, &thermal_tz_list); mutex_unlock(&thermal_list_lock); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index d07ea27e72a9..e8e8fac78fc8 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -247,6 +247,8 @@ struct thermal_zone_params { */ bool no_hwmon; + bool userspace; + int num_tbps; /* Number of tbp entries */ struct thermal_bind_params *tbp; From patchwork Mon Nov 30 05:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 334961 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 B86DAC5519F for ; Mon, 30 Nov 2020 05:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 635972074A for ; Mon, 30 Nov 2020 05:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgK3Fhn (ORCPT ); Mon, 30 Nov 2020 00:37:43 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58786 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgK3Fhn (ORCPT ); Mon, 30 Nov 2020 00:37:43 -0500 Received: from 220-133-187-190.hinet-ip.hinet.net ([220.133.187.190] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kjbrn-0002y4-5l; Mon, 30 Nov 2020 05:36:52 +0000 From: Kai-Heng Feng To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: andrzej.p@collabora.com, mjg59@google.com, srinivas.pandruvada@linux.intel.com, Kai-Heng Feng , Bartlomiej Zolnierkiewicz , Peter Kaestle , Gayatri Kammela , Takashi Iwai , Andrew Morton , Andy Shevchenko , Akinobu Mita , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] thermal: int340x: Indicate userspace usage Date: Mon, 30 Nov 2020 13:36:39 +0800 Message-Id: <20201130053640.54608-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130053640.54608-1-kai.heng.feng@canonical.com> References: <20201130053640.54608-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The device isn't present under ACPI ThermalZone, and there's a dedicated userspace daemon for this thermal device. Let thermal core know it shouldn't handle trips to avoid surprising thermal shutdown. Signed-off-by: Kai-Heng Feng --- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 1 + .../thermal/intel/int340x_thermal/int340x_thermal_zone.c | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 0966551cbaaa..2002bc96eb3c 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -439,6 +439,7 @@ static struct thermal_zone_device_ops int3400_thermal_ops = { static struct thermal_zone_params int3400_thermal_params = { .governor_name = "user_space", .no_hwmon = true, + .userspace = true, }; static void int3400_setup_gddv(struct int3400_thermal_priv *priv) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 6e479deff76b..a103eb42ef2d 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -208,6 +208,7 @@ EXPORT_SYMBOL_GPL(int340x_thermal_read_trips); static struct thermal_zone_params int340x_thermal_params = { .governor_name = "user_space", .no_hwmon = true, + .userspace = true, }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, @@ -259,14 +260,9 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, ret = PTR_ERR(int34x_thermal_zone->zone); goto err_thermal_zone; } - ret = thermal_zone_device_enable(int34x_thermal_zone->zone); - if (ret) - goto err_enable; return int34x_thermal_zone; -err_enable: - thermal_zone_device_unregister(int34x_thermal_zone->zone); err_thermal_zone: acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); From patchwork Mon Nov 30 05:36:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 335500 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 2A5CDC71156 for ; Mon, 30 Nov 2020 05:38:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC9F12074A for ; Mon, 30 Nov 2020 05:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbgK3Fhn (ORCPT ); Mon, 30 Nov 2020 00:37:43 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58787 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbgK3Fhn (ORCPT ); Mon, 30 Nov 2020 00:37:43 -0500 Received: from 220-133-187-190.hinet-ip.hinet.net ([220.133.187.190] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kjbrs-0002yW-GG; Mon, 30 Nov 2020 05:36:57 +0000 From: Kai-Heng Feng To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: andrzej.p@collabora.com, mjg59@google.com, srinivas.pandruvada@linux.intel.com, Kai-Heng Feng , Andy Shevchenko , Sumeet Pawnikar , Akinobu Mita , Chuhong Yuan , Gayatri Kammela , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] thermal: intel: intel_pch_thermal: Indicate userspace usage Date: Mon, 30 Nov 2020 13:36:40 +0800 Message-Id: <20201130053640.54608-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130053640.54608-1-kai.heng.feng@canonical.com> References: <20201130053640.54608-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The device isn't present under ACPI ThermalZone, and there's a dedicated userspace daemon for this thermal device. Let thermal core know it shouldn't handle trips to avoid surprising thermal shutdown. Signed-off-by: Kai-Heng Feng --- drivers/thermal/intel/intel_pch_thermal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index 3b813ebb6ca1..e55e6318d733 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -270,6 +270,10 @@ static struct thermal_zone_device_ops tzd_ops = { .get_trip_temp = pch_get_trip_temp, }; +static struct thermal_zone_params tzd_params = { + .userspace = true, +}; + enum board_ids { board_hsw, board_wpt, @@ -346,21 +350,16 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev, goto error_cleanup; ptd->tzd = thermal_zone_device_register(bi->name, nr_trips, 0, ptd, - &tzd_ops, NULL, 0, 0); + &tzd_ops, &tzd_params, 0, 0); if (IS_ERR(ptd->tzd)) { dev_err(&pdev->dev, "Failed to register thermal zone %s\n", bi->name); err = PTR_ERR(ptd->tzd); goto error_cleanup; } - err = thermal_zone_device_enable(ptd->tzd); - if (err) - goto err_unregister; return 0; -err_unregister: - thermal_zone_device_unregister(ptd->tzd); error_cleanup: iounmap(ptd->hw_base); error_release: