From patchwork Thu May 25 14:01:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 686340 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9A4C7EE29 for ; Thu, 25 May 2023 14:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241438AbjEYOCa (ORCPT ); Thu, 25 May 2023 10:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241461AbjEYOC3 (ORCPT ); Thu, 25 May 2023 10:02:29 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56D941A2 for ; Thu, 25 May 2023 07:02:02 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-30a8c4afa46so795738f8f.1 for ; Thu, 25 May 2023 07:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023320; x=1687615320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HUbH3AqqDl8CE94ueCQYCD3fcBOZcuYmHQxQOWzVdSI=; b=AB/2sJFSbuTqwsZTCrfgFt0hVWsnb/KsgsZvmfNIJ/vK0a8oqMv1d5VqO+0UXeGcqC WNmVQURw2sdgCCZv2evGfdvntSL9XeVy7KQIio/WVhMEEWuRkFMYfDq8Nwg/DahYA5zy egQSSPXTeS52CzY8Bd1kfbW+OFdLCwoBKT/jkG7tCa5iRqLXAJRZtsfkr0V7d/FGDrqa 8h2UGsOQHanQlZTXB1y644pZaRDcfNFSFHfjU5XvOTetWyShK4SwDSBraE7w7DUZiSVN 9IPrrwyvzX4KGugorH2+x1cOBhmY8zb+uqKHmkyHmToSDvbK20MDgJEUWTpCUrXA22CL 922g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023320; x=1687615320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HUbH3AqqDl8CE94ueCQYCD3fcBOZcuYmHQxQOWzVdSI=; b=OaCwyJIVwgtWbA16eojjc3rd4lfnP+1mDhItmNOePjzn1ouqKVfh0truIEdqnPRtnj +Q7ka/VkrQxvlB9ZWa8X+tJarX5kezmUqV5bxb9onuWdaDX8hjswWVCqcT2LJ+DEcxSv uRYG/EUut+iHGZuJNFbi1/ubwl9j2z1Q1SSFWHvXRmKan999f5wV88N8y0n0TRMGv837 LjpE1olxp2OOravjjpsBVr/wLm/6gdNMBQM4QJmJlibP3jDMihUdSQn7Cz5H4mRr4hvb VbeG86/5zc5ColHQCqjg1/U8QmWY+uo7Rwzg9+Sg19cEOVi977sGAV7tgZ31GvlmFjQJ 86AA== X-Gm-Message-State: AC+VfDyrScMti+yz+q/fomt+zab2vUWhzqLRaMHTO/I1wOtZ1ARYTtqP O0ax/aNjApNw8ADFoTPXBZ9L1w== X-Google-Smtp-Source: ACHHUZ4tXSENb+Vpjdf1ltyggjuSDPeNMOgHYDIP1ZGt4QKGSuaeGFxeAHpbVKgbP5ttyGtPZ1y0ew== X-Received: by 2002:adf:f644:0:b0:309:6fe4:a20d with SMTP id x4-20020adff644000000b003096fe4a20dmr2025859wrp.9.1685023320556; Thu, 25 May 2023 07:02:00 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:01:59 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Sandipan Patra , Gal Pressman , Saeed Mahameed , Jakub Kicinski , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/8] net/mlx5: Update the driver with the recent thermal changes Date: Thu, 25 May 2023 16:01:28 +0200 Message-Id: <20230525140135.3589917-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal framework is migrating to the generic trip points. The set of changes also implies a self-encapsulation of the thermal zone device structure where the internals are no longer directly accessible but with accessors. Use the new API instead, so the next changes can be pushed in the thermal framework without this driver failing to compile. No functional changes intended. Cc: Sandipan Patra Cc: Gal Pressman Cc: Saeed Mahameed Cc: Jakub Kicinski Signed-off-by: Daniel Lezcano --- drivers/net/ethernet/mellanox/mlx5/core/thermal.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/thermal.c b/drivers/net/ethernet/mellanox/mlx5/core/thermal.c index e47fa6fb836f..20bb5eb266c1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/thermal.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/thermal.c @@ -45,7 +45,7 @@ static int mlx5_thermal_get_mtmp_temp(struct mlx5_core_dev *mdev, u32 id, int *p static int mlx5_thermal_get_temp(struct thermal_zone_device *tzdev, int *p_temp) { - struct mlx5_thermal *thermal = tzdev->devdata; + struct mlx5_thermal *thermal = thermal_zone_device_priv(tzdev); struct mlx5_core_dev *mdev = thermal->mdev; int err; @@ -81,12 +81,13 @@ int mlx5_thermal_init(struct mlx5_core_dev *mdev) return -ENOMEM; thermal->mdev = mdev; - thermal->tzdev = thermal_zone_device_register(data, - MLX5_THERMAL_NUM_TRIPS, - MLX5_THERMAL_TRIP_MASK, - thermal, - &mlx5_thermal_ops, - NULL, 0, MLX5_THERMAL_POLL_INT_MSEC); + thermal->tzdev = thermal_zone_device_register_with_trips(data, + NULL, + MLX5_THERMAL_NUM_TRIPS, + MLX5_THERMAL_TRIP_MASK, + thermal, + &mlx5_thermal_ops, + NULL, 0, MLX5_THERMAL_POLL_INT_MSEC); if (IS_ERR(thermal->tzdev)) { dev_err(mdev->device, "Failed to register thermal zone device (%s) %ld\n", data, PTR_ERR(thermal->tzdev)); From patchwork Thu May 25 14:01:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 686339 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 221DDC7EE2F for ; Thu, 25 May 2023 14:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241494AbjEYOCc (ORCPT ); Thu, 25 May 2023 10:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241461AbjEYOCa (ORCPT ); Thu, 25 May 2023 10:02:30 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE731BF for ; Thu, 25 May 2023 07:02:04 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-30a892c45c4so1447206f8f.3 for ; Thu, 25 May 2023 07:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023322; x=1687615322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1j7DEK4Cs605GdbFytd8yvP1DYwQA/vZtllLhSrFvtw=; b=TVdRlvGXq5UJzCs8zBpNYE7Mo3z4zAUQ3wD/Fscb1Hvi2iqfbNiVxtVrKKDSj27kW2 jMYPMcyINK/v7Ot3JUABFDPzISMCNJDrEyK80OstgthKDIn2nrWVPdYMYkXDDiBG/uVM 9/6uj9o9+iLU0xV7AkGvcnZjSkUx2dTuihku91BF7EZ/AiTKxulDni2P/xE0bzJOafqn C71itLZLEwBmPfXFV6EeLnJmZxJlXQo9az2N+kPtkw6T4AXU/ydkxmBK8fIJf+hWq9oC c5GoUA448WKOqv/Cegx1AtzLO+OyV7QklXU9926pCJgZnlhTGXk/dsDBzPuYkXKGyo0r YTzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023322; x=1687615322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1j7DEK4Cs605GdbFytd8yvP1DYwQA/vZtllLhSrFvtw=; b=ZNVvNfInQF+szXFElNYmOY4/spjBIMEkR/vDkO1RgiYPm16MI6j1ZkQG3xNGvpQG5A VaHOmwnEjzor04Ozi3DEIYZmgcSL3t7v/LsPa21bfc45HxnaRArGY1zxEGVxWC+XSZ+C KqHW4yWuTi9HKWPrZNaWkP9ry3vQqCmC0jWajbxZ1o8IoFQGt7reFc8f/oQffUI6B+N9 HSkYPstdYBxc3hPaj2TwBSMjMtllX5bK8sZMUXcQBidZjXD12gmY8wJsKQJTl08zFUBW 52aX1VK9tA9p5WvFYRBgBPLEf4m7uoAWMqjyU8XBOizm5xhFbcuUuvJ3s348MRQrGZEJ DpWQ== X-Gm-Message-State: AC+VfDy9hFTTxIkTlPFybBn0Ffb3JyHdXVEkikpT1EVpVyK3dy4ycqVp YgJQb4bbCOpRIeboQIEGVa0AhQ== X-Google-Smtp-Source: ACHHUZ5LM5Z8W7aWw6DA+W4MrQBidpOgqN1Z5sdkDoOLagy8R3yj/V83aSDwf8MPE4AeXpn0XWknrQ== X-Received: by 2002:adf:dcce:0:b0:307:8c47:a266 with SMTP id x14-20020adfdcce000000b003078c47a266mr2567631wrm.61.1685023322111; Thu, 25 May 2023 07:02:02 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:01 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , Lukasz Luba , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/8] thermal/core: Hardening the self-encapsulation Date: Thu, 25 May 2023 16:01:29 +0200 Message-Id: <20230525140135.3589917-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal private header has leaked all around the drivers which interacted with the core internals. The thermal zone structure which was part of the exported header led also to a leakage of the fields into the different drivers, making very difficult to improve the core code without having to change the drivers. Now we fixed how the thermal drivers were interacting with the thermal zones (actually fixed how they should not interact). The thermal zone structure has been moved to the private thermal core header. This header has been removed from the different drivers and must belong to the core code only. In order to prevent this private header to be included again in the drivers, make explicit only the core code can include this header by defining a THERMAL_CORE_SUBSYS macro. The private header will contain a check against this macro. The Tegra SoCtherm driver needs to access thermal_core.h to have the get_thermal_instance() function definition. It is the only one remaining driver which need to access the thermal_core.h header, so the check will emit a warning at compilation time. Thierry Reding is reworking the driver to get rid of this function [1] and thus when the changes will be merged, the compilation warning will be converted to a compilation error, closing definitively the door to the drivers willing to play with the thermal zone device internals. No functional changes intended. [1] https://lore.kernel.org/all/20230414125721.1043589-1-thierry.reding@gmail.com/ Cc: Thierry Reding Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_bang_bang.c | 1 + drivers/thermal/gov_fair_share.c | 1 + drivers/thermal/gov_power_allocator.c | 1 + drivers/thermal/gov_step_wise.c | 1 + drivers/thermal/gov_user_space.c | 1 + drivers/thermal/thermal_acpi.c | 1 + drivers/thermal/thermal_core.c | 1 + drivers/thermal/thermal_core.h | 4 ++++ drivers/thermal/thermal_helpers.c | 1 + drivers/thermal/thermal_hwmon.c | 1 + drivers/thermal/thermal_netlink.c | 1 + drivers/thermal/thermal_of.c | 1 + drivers/thermal/thermal_sysfs.c | 1 + drivers/thermal/thermal_trip.c | 1 + 14 files changed, 17 insertions(+) diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c index 1b121066521f..752c627075ba 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -11,6 +11,7 @@ #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index 03c2daeb6ee8..108cb5074594 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -13,6 +13,7 @@ #include #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 8642f1096b91..d1c6ad92e5b4 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -14,6 +14,7 @@ #define CREATE_TRACE_POINTS #include "thermal_trace_ipa.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #define INVALID_TRIP -1 diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 1050fb4d94c2..1c844004afe5 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -14,6 +14,7 @@ #include #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* diff --git a/drivers/thermal/gov_user_space.c b/drivers/thermal/gov_user_space.c index 8bc1c22aaf03..8883c9ca930f 100644 --- a/drivers/thermal/gov_user_space.c +++ b/drivers/thermal/gov_user_space.c @@ -13,6 +13,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static int user_space_bind(struct thermal_zone_device *tz) diff --git a/drivers/thermal/thermal_acpi.c b/drivers/thermal/thermal_acpi.c index 0e5698818f69..556c9f0cc40d 100644 --- a/drivers/thermal/thermal_acpi.c +++ b/drivers/thermal/thermal_acpi.c @@ -9,6 +9,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 842f678c1c3e..6bca97e27d59 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -24,6 +24,7 @@ #define CREATE_TRACE_POINTS #include "thermal_trace.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 3d4a787c6b28..84ada34ff079 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -14,6 +14,10 @@ #include "thermal_netlink.h" +#ifndef THERMAL_CORE_SUBSYS +#warning This header can only be included by the thermal core code +#endif + /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise" diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index cfba0965a22d..164c4627949e 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -19,6 +19,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_trace.h" diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index fbe55509e307..3401258e55c6 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -17,6 +17,7 @@ #include #include "thermal_hwmon.h" +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* hwmon sys I/F */ diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index 08bc46c3ec7b..f3ac6432bf5f 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -11,6 +11,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" static const struct genl_multicast_group thermal_genl_mcgrps[] = { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 6fb14e521197..0f2aca2d1dea 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -17,6 +17,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /*** functions parsing device tree nodes ***/ diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 6c20c9f90a05..ccda2579ae82 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -19,6 +19,7 @@ #include #include +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" /* sys I/F for thermal zone */ diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c index 907f3a4d7bc8..61d927c35776 100644 --- a/drivers/thermal/thermal_trip.c +++ b/drivers/thermal/thermal_trip.c @@ -7,6 +7,7 @@ * * Thermal trips handling */ +#define THERMAL_CORE_SUBSYS #include "thermal_core.h" int __for_each_thermal_trip(struct thermal_zone_device *tz, From patchwork Thu May 25 14:01:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 685794 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F99C7EE33 for ; Thu, 25 May 2023 14:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241475AbjEYOCc (ORCPT ); Thu, 25 May 2023 10:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241476AbjEYOCb (ORCPT ); Thu, 25 May 2023 10:02:31 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 357F2E5F for ; Thu, 25 May 2023 07:02:05 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f6042d610fso6926465e9.1 for ; Thu, 25 May 2023 07:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023323; x=1687615323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8B9aQ7Lplcn7G2JB0WPPOQOR+fAGdexdV4KhX+LOA7s=; b=CxESNjIkH3BboOwT79PfxTbJqEYO+ulPMr3xuPgq2RQc2zfHIA96lwJCDWHXUrvzm6 piAYphSeATpyEUOwZ6GBdLtnJ4aDCc6tfX5DVVhVxBPEykCgBBh9EFG4dpc6XDeKqE67 VkDHGrzXmUDv07jcMWvLfTEp/6bsqma5lwiNy9qGZ0GuRx4DcybOPU5p+kSGRuWUruvO Y1G7iYNI6MR73/gHHYrDnZGZcYDqolv410rYhvZnlHxLAO1FTad0IvgF+YzIBKHEvxsM bNlX7G9V77O1U5KNpzXOVby1gYgLgnP04O8EMEZ8qzh51m3REi+0rd7wRUdPancKMU4C S+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023323; x=1687615323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8B9aQ7Lplcn7G2JB0WPPOQOR+fAGdexdV4KhX+LOA7s=; b=lCimw2mld7TjwBXXtaKMpMdCyAmqCrm5J+KjgS1R0CCH/Jc92bDZzx//Aa1xSqFGuk RAm4C7Te5gEm1TGs27Lb2qb9/GS+UywCZiYLOemr6YACsdzZauYWTAcgJ73HVhwLJc6M sGu2/6WkMFwQI22sZc0jfhvm961RBUCkUBiuILp6rQkL9H2HVEsg7Jt7mI4gEiusB3Q6 I+v7pC9ab46zmln51iR+jrXsNWkCMBcc2fHH2z8GkTWA+09mV+Tf6gGWo8h2UrHnlK1q Zs9LabZN3Wk4LpPCl4F8oRbUQ9WP1nn+RO7V1a0ApDcqO/pMY52AkHRTOmCyXkTOnQGk Tz5g== X-Gm-Message-State: AC+VfDwFY8G9iApxkkUr5415xJrcTelDVpwgb9Oo3/IiMzcm1Q/nfQWE nIThjCnpQVHHH5XPzPL5vAOSQg== X-Google-Smtp-Source: ACHHUZ4F1fh7DZgNjE4ieVsv54Ei3k5AvurrK2sWewLerZ2R9/Zni1p50lrMYUzDcyELCRbAnCitsA== X-Received: by 2002:a5d:69c4:0:b0:2cf:f01f:ed89 with SMTP id s4-20020a5d69c4000000b002cff01fed89mr2474905wrw.24.1685023323146; Thu, 25 May 2023 07:02:03 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:02 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Lukasz Luba , Amit Kucheria , Zhang Rui , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/8] thermal/core: Reorder the headers inclusion Date: Thu, 25 May 2023 16:01:30 +0200 Message-Id: <20230525140135.3589917-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The next changes will move the thermal device structure inside the thermal core code. Consequently, the traces must be included after thermal_core.h as this one contains the thermal zone device structure definition the traces need. Reorder the inclusions. No functional changes intended. Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_power_allocator.c | 6 +++--- drivers/thermal/thermal_core.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index d1c6ad92e5b4..6056ed15460b 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -11,12 +11,12 @@ #include #include -#define CREATE_TRACE_POINTS -#include "thermal_trace_ipa.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" +#define CREATE_TRACE_POINTS +#include "thermal_trace_ipa.h" + #define INVALID_TRIP -1 #define FRAC_BITS 10 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 6bca97e27d59..afcd4197babd 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -21,13 +21,13 @@ #include #include -#define CREATE_TRACE_POINTS -#include "thermal_trace.h" - #define THERMAL_CORE_SUBSYS #include "thermal_core.h" #include "thermal_hwmon.h" +#define CREATE_TRACE_POINTS +#include "thermal_trace.h" + static DEFINE_IDA(thermal_tz_ida); static DEFINE_IDA(thermal_cdev_ida); From patchwork Thu May 25 14:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 686338 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DA29C7EE29 for ; Thu, 25 May 2023 14:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241498AbjEYOCd (ORCPT ); Thu, 25 May 2023 10:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241493AbjEYOCc (ORCPT ); Thu, 25 May 2023 10:02:32 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB68E61 for ; Thu, 25 May 2023 07:02:06 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3078cc99232so2114715f8f.3 for ; Thu, 25 May 2023 07:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023324; x=1687615324; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f7GrEPFhayNtImibH8MsMjS6Dma/89gLhxwpMIW9yxY=; b=RpvIHYxC1L44ES6U7GEAWLQGswS5iAFE0DExP5zmyuhCwp7enuXc3eZ7jBk7SR+zHy L9vLWMb4rDhnPg2g1VoGUgfGv6uDlrEjB9T77/gkUMJk0570P5oaBsrexSVDVmBatg1A BsbgJxWYkogcPg4g7RiuDdlNkiWARFam2jLJJzSM+LLTPNSuPspqetAZC0qlLq9+olwB Ycen8vukVwyZsSMDPhZ1TY0Fgv8hFTCyZ8Ai/+93q1IBYLWaNlFUKD9vonAR85ypcRC8 wVGb5MHogYaxZxR41PPplCGVsUrD6hnAYp11/RvhLOpWV2lQIMfWKwb3A7VAlWynMr5p zSpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023324; x=1687615324; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f7GrEPFhayNtImibH8MsMjS6Dma/89gLhxwpMIW9yxY=; b=hMO7hM18bq7tF+OxKeJDcCHogk71Loi1z/kbANgUPX2WUt36LLDW+p2SoZsEQHziSQ Q4XzaN02qaVB+OxkSVv8frVArFqOQY/IvVusrQghx84AMs33V0ddsQE3xCjlGoC0ifCM 3rz2Tpxz7jk8rV9f6OKU7X10xNtrdWRy2J27Xt1MIp3cTvR9So70G4non+YOzCWfPhpb KWgfW0MFrKIf2NTMohda3BWoL5NFKxgl+Lwvc12do/D9zGCITWnkitHthXDxJ+XGooMQ VB0m3kKyY/i9ClzReiWlP4JaSYp/JDcUfsvxedk5vErqbli1kwTXOoesVnf81yQXTZYu G8JQ== X-Gm-Message-State: AC+VfDymgURi1YdLCcw3mhoz9Voj07ftB0YxnnMyY1z2gEexxggigfzx MDQ1laGGzHF/cUiYMyH7CAEqWw== X-Google-Smtp-Source: ACHHUZ5ji2kITZJRetE5AnyLqm88KcN37w8yCMnnvtqmdUj9ATobOayhpip9OOZqEWhQTZZlK7zm2A== X-Received: by 2002:a5d:5248:0:b0:307:873d:2ea with SMTP id k8-20020a5d5248000000b00307873d02eamr2413486wrc.47.1685023324377; Thu, 25 May 2023 07:02:04 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:03 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 4/8] thermal/core: Update the generic trip points Date: Thu, 25 May 2023 16:01:31 +0200 Message-Id: <20230525140135.3589917-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org At this point, the generic trip points rework allows to create a thermal zone with a fixed number of trip points. This usage satisfy almost all of the existing drivers. A few remaining drivers have a mechanism where the firmware updates the trip points. But there is no such update mechanism for the generic trip points, thus those drivers can not be converted to the generic approach. This patch provides a function 'thermal_zone_trips_update()' allowing to change the trip points of a thermal zone. At the same time, with the logic the trip points array is passed as a parameter to the thermal zone at creation time, we make our own private trip points array by copying the one passed as parameter. Note, no code has been found where the trip points update leads to a refresh of the trip points in sysfs, so it is very unlikey the number of trip points changes. However, for the sake of consistency it would be nicer to have the trip points being refreshed in sysfs also, but that could be done in a separate set of changes. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 40 ++++++++--------- drivers/thermal/thermal_core.h | 3 ++ drivers/thermal/thermal_trip.c | 78 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 4 ++ 4 files changed, 102 insertions(+), 23 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index afcd4197babd..3688b06401c8 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1224,32 +1224,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t return ERR_PTR(-EINVAL); } - /* - * Max trip count can't exceed 31 as the "mask >> num_trips" condition. - * For example, shifting by 32 will result in compiler warning: - * warning: right shift count >= width of type [-Wshift-count- overflow] - * - * Also "mask >> num_trips" will always be true with 32 bit shift. - * E.g. mask = 0x80000000 for trip id 31 to be RW. Then - * mask >> 32 = 0x80000000 - * This will result in failure for the below condition. - * - * Check will be true when the bit 31 of the mask is set. - * 32 bit shift will cause overflow of 4 byte integer. - */ - if (num_trips > (BITS_PER_TYPE(int) - 1) || num_trips < 0 || mask >> num_trips) { - pr_err("Incorrect number of thermal trips\n"); - return ERR_PTR(-EINVAL); - } - if (!ops) { pr_err("Thermal zone device ops not defined\n"); return ERR_PTR(-EINVAL); } - if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) - return ERR_PTR(-EINVAL); - if (!thermal_class) return ERR_PTR(-ENODEV); @@ -1283,8 +1262,22 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t tz->ops = ops; tz->device.class = thermal_class; tz->devdata = devdata; - tz->trips = trips; - tz->num_trips = num_trips; + + if (trips) { + result = __thermal_zone_trips_update(tz, trips, num_trips, mask); + if (result) + goto remove_id; + } else { + /* + * Legacy trip point handling + */ + if ((!tz->ops->get_trip_type || !tz->ops->get_trip_temp) && num_trips) { + result = -EINVAL; + goto remove_id; + } + + tz->num_trips = num_trips; + } thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1451,6 +1444,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) mutex_unlock(&tz->lock); kfree(tz->tzp); + kfree(tz->trips); put_device(&tz->device); diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 84ada34ff079..c27a9930f904 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -125,6 +125,9 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz, void __thermal_zone_set_trips(struct thermal_zone_device *tz); int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, struct thermal_trip *trip); +int __thermal_zone_trips_update(struct thermal_zone_device *tz, + struct thermal_trip *trips, + int num_trips, int mask); int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); /* sysfs I/F */ diff --git a/drivers/thermal/thermal_trip.c b/drivers/thermal/thermal_trip.c index 61d927c35776..171b1902c01c 100644 --- a/drivers/thermal/thermal_trip.c +++ b/drivers/thermal/thermal_trip.c @@ -7,6 +7,8 @@ * * Thermal trips handling */ +#include + #define THERMAL_CORE_SUBSYS #include "thermal_core.h" @@ -181,3 +183,79 @@ int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, return 0; } + +int __thermal_zone_trips_update(struct thermal_zone_device *tz, struct thermal_trip *trips, + int num_trips, int mask) +{ + struct thermal_trip *new_trips; + + /* + * Legacy trip point handling is incompatible with this + * function + */ + if (tz->ops->get_trip_type || tz->ops->get_trip_temp) { + pr_err("Legacy trip points use incompatible function '%s'\n", __func__); + return -ENOSYS; + } + + /* + * Max trip count can't exceed 31 as the "mask >> num_trips" condition. + * For example, shifting by 32 will result in compiler warning: + * warning: right shift count >= width of type [-Wshift-count- overflow] + * + * Also "mask >> num_trips" will always be true with 32 bit shift. + * E.g. mask = 0x80000000 for trip id 31 to be RW. Then + * mask >> 32 = 0x80000000 + * This will result in failure for the below condition. + * + * Check will be true when the bit 31 of the mask is set. + * 32 bit shift will cause overflow of 4 byte integer. + */ + if (num_trips > (BITS_PER_TYPE(int) - 1) || num_trips < 0 || mask >> num_trips) { + pr_err("Incorrect number of thermal trips\n"); + return -EINVAL; + } + + /* + * New generic trip point handling + */ + if (num_trips > 0 && !trips) { + pr_err("Inconsistent parameters\n"); + return -EINVAL; + } + + /* + * Allocate our private trip points array structure + */ + new_trips = kmemdup(trips, sizeof(*trips) * num_trips, GFP_KERNEL); + if (!new_trips) + return -ENOMEM; + + /* + * Newly allocated thermal zone will have the 'trips' field + * NULL, kfree() is immune against that + */ + kfree(tz->trips); + tz->trips = new_trips; + tz->num_trips = num_trips; + + return 0; +} + +int thermal_zone_trips_update(struct thermal_zone_device *tz, struct thermal_trip *trips, + int num_trips, int mask) +{ + int ret; + + mutex_lock(&tz->lock); + ret = __thermal_zone_trips_update(tz, trips, num_trips, mask); + mutex_unlock(&tz->lock); + + if (ret) + return ret; + + __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); + + return 0; +} +EXPORT_SYMBOL_GPL(thermal_zone_trips_update); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 87837094d549..83937256a01c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -291,6 +291,10 @@ int thermal_zone_get_num_trips(struct thermal_zone_device *tz); int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); +int thermal_zone_trips_update(struct thermal_zone_device *tz, + struct thermal_trip *trips, + int num_trips, int mask); + #ifdef CONFIG_THERMAL_ACPI int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp); int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp); From patchwork Thu May 25 14:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 685793 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06E00C77B7A for ; Thu, 25 May 2023 14:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241502AbjEYOCd (ORCPT ); Thu, 25 May 2023 10:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241495AbjEYOCc (ORCPT ); Thu, 25 May 2023 10:02:32 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABA1E64 for ; Thu, 25 May 2023 07:02:08 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3094910b150so2109566f8f.0 for ; Thu, 25 May 2023 07:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023326; x=1687615326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3wdkc7RVIiuUcIo6x94zTHppu2nSL2mGFfMHnbXI87Y=; b=j68NHVr1A3FrdpKdp18jpST9Sx6UadVozGKrTknOB3eBJ4WeHJSoaNWhCxAnQZHxcO OK+lkClFJqErAGSG1mMvT9dGU+HaTk1QBPscxFzumfxrz4FPkDJEmYKt42BlBk9Yk8r5 Ig7mwdOQox1TXqzCJCSyywxNTjRyS8rnqbVUyhLzv9iCzmfqtVMXV/t//hAbIUD2jcAM 6k5gkFmClpoOCIvH4k9xZy4DJq1MECkXNSIB60sXzV4WpdBNA8/+OW8+Zo7mySzgU/9m t0QRWL6rRBEaA6oqq7G2RsRZS7okaKvcE7VQ4x5AmMMVaKJo/zAfk3gcmKL+qSyYBf/M 3Y0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023326; x=1687615326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3wdkc7RVIiuUcIo6x94zTHppu2nSL2mGFfMHnbXI87Y=; b=RsSApaEYl0e9XYTBXlBMnU6fB3+faV0Fi33g4FW8ejefXqJCtVV10NvjD2oWUfyqYF g3PO0EiF8bkPgUUDc6iG8Y65YENjsH8UwVefq2andsQWXdUaG6ZFN86/fNw8ceoeoYNW 9EO8FxS/+lY8L/fEyUJ6ddyIKSuKIl2v1Rll/trqSZGCYKtossrJnK8+zyCIzVDK4v82 /WLLTl2ZTWMxOq2eM17zP/E6XCeg4HWEEXBcHXrQ1Z51kpIZ8UadaeM4Lx2ThdiK3LHs Dd/xgaZHqYgiFIgqH80lf3wn4l7+5dpKJvkiVGCWJ8RSszmVqearT2/9j4NCM3p8kGEC xKmQ== X-Gm-Message-State: AC+VfDwg1WCgUjsqgtDyG7JtA9ANgF8OmxXh6pylW0FCS+UtJO5MPDtT RVgVnNsPrN2z7QKhD1VI8bCk4w== X-Google-Smtp-Source: ACHHUZ4HXcVqrErnKOD0gX1c0NtHgLr7aNYM4nVVOMMcdXEkN7kok08EYdZSFXbqboyZhUMV95dbKA== X-Received: by 2002:adf:eec4:0:b0:2ef:eb54:4dc0 with SMTP id a4-20020adfeec4000000b002efeb544dc0mr2504739wrp.51.1685023326212; Thu, 25 May 2023 07:02:06 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:05 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , Jernej Skrabec , Baolin Wang , AngeloGioacchino Del Regno , Srinivas Pandruvada , "Lee, Chun-Yi" , ye xingchen , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 5/8] thermal/drivers/int3400: Use thermal zone device wrappers Date: Thu, 25 May 2023 16:01:32 +0200 Message-Id: <20230525140135.3589917-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver is accessing the thermal zone device structure but the accessors are already existing and we want to consolidate the thermal core code by preventing accesses to the internals from the drivers. Let's use these accessors. On the other side, the code is getting directly the temperature from tz->temperature, but the temperature is a faked on, so we can replace this access by the fake temp and remove the thermal zone device structure access. Signed-off-by: Daniel Lezcano --- .../thermal/intel/int340x_thermal/int3400_thermal.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 810231b59dcd..66e34241b33a 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -15,6 +15,7 @@ #define INT3400_THERMAL_TABLE_CHANGED 0x83 #define INT3400_ODVP_CHANGED 0x88 #define INT3400_KEEP_ALIVE 0xA0 +#define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */ enum int3400_thermal_uuid { INT3400_THERMAL_ACTIVE = 0, @@ -453,6 +454,7 @@ static void int3400_notify(acpi_handle handle, void *data) { struct int3400_thermal_priv *priv = data; + struct device *dev; char *thermal_prop[5]; int therm_event; @@ -475,12 +477,14 @@ static void int3400_notify(acpi_handle handle, return; } - thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", priv->thermal->type); - thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", priv->thermal->temperature); + dev = thermal_zone_device(priv->thermal); + + thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", thermal_zone_device_type(priv->thermal)); + thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", INT3400_FAKE_TEMP); thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP="); thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event); thermal_prop[4] = NULL; - kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop); + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, thermal_prop); kfree(thermal_prop[0]); kfree(thermal_prop[1]); kfree(thermal_prop[2]); @@ -490,7 +494,7 @@ static void int3400_notify(acpi_handle handle, static int int3400_thermal_get_temp(struct thermal_zone_device *thermal, int *temp) { - *temp = 20 * 1000; /* faked temp sensor with 20C */ + *temp = INT3400_FAKE_TEMP; return 0; } From patchwork Thu May 25 14:01:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 686337 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CE68C77B7A for ; Thu, 25 May 2023 14:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241505AbjEYOCn (ORCPT ); Thu, 25 May 2023 10:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241495AbjEYOCe (ORCPT ); Thu, 25 May 2023 10:02:34 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D1CE67 for ; Thu, 25 May 2023 07:02:10 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-309382efe13so1508142f8f.2 for ; Thu, 25 May 2023 07:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023328; x=1687615328; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=00zbO/h32JbOBK4pj9NMcyYg6KfU8i34rsNlNDxLhwU=; b=WqiKxZE9ZACdkHhs/a94AzeA/I0y8YTIHAIfJS41qFT48zEv9pAwMfMC0Y9tq3zc+R zZz7vOUhG2LrYLlq2yoFzOjYRa3OBZA5Sttsdkitc7wmouzZmYA/ZdaVtMgyGrTKHApr +HnIPQDzpREbZRzcCkWhKn1o8x5QQpeNX2/w+VVh1JD702Lj6xl6GQYvBVnrP1w8BLg/ b+ky7KJk7gNHqJV2xEpTBvTN1G1Vclx9W2nYUu2St6/c53Z6KM93zAthmZlGFs6JGdQx QACkydqiSFpCRqeAFzEJsn8YFNp9H6Oq0LXlBSJA6S+BQCBRWfhMns817mFlI2j6dTtr iIHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023328; x=1687615328; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=00zbO/h32JbOBK4pj9NMcyYg6KfU8i34rsNlNDxLhwU=; b=UXdewDGSR5Bn86D4SpemWgROPucEavHAlpRmGC2aZwuM+1NvxCz8uZujKjsJZ51KOw LFc4Er8EJ528ip/ta8HI1AMUTMgaVtmMG+fPCIQoZIaTlPzDQMuIAviR8/vvSjzPiXPx SHo4tuyKnYuel/puBa9gK4Gi6nuXr/ojMLFVurbFgg8njQOMKmR9Tof1jtqkbqov2U+B cZ4NnyT5AwPpIvR5pizU9+JUevfnzu0O9xP8MRXXdxqaucxlj7/WYHx5m7x2UB9MD8+U 9cskrpz2CkLqQmpIGUcKgjzgH45PYDmBq/vf0IjTwChRdjow/wlaXYGShb1+LujHna5o 6xug== X-Gm-Message-State: AC+VfDyY2Jl8uOn6j1bi6+1k7C2qUFyWv6kgXNWBzmvb7ZEfizF6OThN P0s0lXsdlRvB00WxJX9fFQKokw== X-Google-Smtp-Source: ACHHUZ6v7mcKs1ULB0e/sneWV6xt3S8X1TWh52w1LQ58NQpdPLcw+H3cCfaVH8wNWaIxhLUQsyVHiQ== X-Received: by 2002:a05:6000:1208:b0:309:3ddc:1c8c with SMTP id e8-20020a056000120800b003093ddc1c8cmr2608310wrx.20.1685023328305; Thu, 25 May 2023 07:02:08 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:07 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , AngeloGioacchino Del Regno , Baolin Wang , Linus Walleij , ye xingchen , "Lee, Chun-Yi" , Srinivas Pandruvada , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 6/8] thermal/drivers/int340x: Do not check the thermal zone state Date: Thu, 25 May 2023 16:01:33 +0200 Message-Id: <20230525140135.3589917-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver is accessing the thermal zone state to ensure the state is different from the one we want to set. We don't want the driver to access the thermal zone device internals. Actually, the thermal core code already checks if the thermal zone's state is different before calling this function, thus this check is duplicate. Remove it. Signed-off-by: Daniel Lezcano --- .../intel/int340x_thermal/int3400_thermal.c | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 66e34241b33a..cba636d6784d 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -503,32 +503,28 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal, { struct int3400_thermal_priv *priv = thermal_zone_device_priv(thermal); int result = 0; + int enabled; if (!priv) return -EINVAL; - if (mode != thermal->mode) { - int enabled; + enabled = mode == THERMAL_DEVICE_ENABLED; - enabled = mode == THERMAL_DEVICE_ENABLED; - - if (priv->os_uuid_mask) { - if (!enabled) { - priv->os_uuid_mask = 0; - result = set_os_uuid_mask(priv, priv->os_uuid_mask); - } - goto eval_odvp; + if (priv->os_uuid_mask) { + if (!enabled) { + priv->os_uuid_mask = 0; + result = set_os_uuid_mask(priv, priv->os_uuid_mask); } - - if (priv->current_uuid_index < 0 || - priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID) - return -EINVAL; - - result = int3400_thermal_run_osc(priv->adev->handle, - int3400_thermal_uuids[priv->current_uuid_index], - &enabled); + goto eval_odvp; } + if (priv->current_uuid_index < 0 || + priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID) + return -EINVAL; + + result = int3400_thermal_run_osc(priv->adev->handle, + int3400_thermal_uuids[priv->current_uuid_index], + &enabled); eval_odvp: evaluate_odvp(priv); From patchwork Thu May 25 14:01:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 685792 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C79A7C77B7A for ; Thu, 25 May 2023 14:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241562AbjEYOCy (ORCPT ); Thu, 25 May 2023 10:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241530AbjEYOCr (ORCPT ); Thu, 25 May 2023 10:02:47 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706BFE76 for ; Thu, 25 May 2023 07:02:17 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3093a7b71fbso2102473f8f.2 for ; Thu, 25 May 2023 07:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023330; x=1687615330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ItegjrGGv11f7pKzf7OY/tEt56zaRuB7g6O2qnWaWE=; b=u602UsgORyj8+WQfir0DgKNegXC6dcDBBELHq8gxS5Ipba6T6z16yPBMdx4vPoBo4h uWOwJtDjijNAJ9aUxqnEd5aFg5s0qeM71KrD6G5bzvBux8r/qAUXVKPIGrYRVEXkJ7GD n0gItdYiBPi06mIzuh+DDyi5fH/73jIFpVR2zzCrA0u4NogeKM5sEzb8YNbN8kdeOQiu 08V2P6PVoPwZgWfvNOG3Doduihqpp+LGW1+sFQsiqmUd9VnpnnZDf1ERjOu75nivbcaZ ax1AFJa+Iy0UoHewlnsCQeMN3xufkW2xSvyI8KhvRqRCHK1Yyko8CfMHdlTGaTvwFpC/ ornQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023330; x=1687615330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ItegjrGGv11f7pKzf7OY/tEt56zaRuB7g6O2qnWaWE=; b=VRYvZ2dWHVOBWhzCz9EBvGKNZHyA4Fp6gf/sxEnovdKeQRGRu4wfjqto2wYEuzl2RX D30WgiZuzuEbxb5f8+5iOcp9W9UlZHeghzr+wPFXDM9dNXHydSSAcSohCmvx9STT5CKy nt2y4YlaTrGRLcLM4gepuOAdVBzRkQozJXoy8e4wX3NbewpMKnPI/8cQgsbgFXhV0Jmh pesdD62syEZw8UKBNw6ZXCu+V7l4agh2yfIIgfiUwObVDoKG+APHf+Hu22QlURirTb3a Fq9mEAoeAWqos2nSzFurs6rEYKGn5c8bwrFwnm/rGvIHbqEGWt36jv3SfN4A9VugiwVQ 3LJQ== X-Gm-Message-State: AC+VfDwY90MgYvF6Eli+XXOw+TjImYsxCGEPoVDl8vjw4nS83xr9+Qbc 6tbTy7GEZOVrZXT0QgmkbDjjgLE+qSQLdq1IVUg= X-Google-Smtp-Source: ACHHUZ5FJcIDH0IGIR9EZH+aqkLlq+kUdkJo9afvSvi2Qak2Ss7gX3cbcULnrr1M6Z0y+2mj+TFGog== X-Received: by 2002:a5d:694c:0:b0:30a:bae7:9848 with SMTP id r12-20020a5d694c000000b0030abae79848mr1766026wrw.13.1685023330426; Thu, 25 May 2023 07:02:10 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , Srinivas Pandruvada , Baolin Wang , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 7/8] thermal/drivers/int340x: Use thermal zone device trip update Date: Thu, 25 May 2023 16:01:34 +0200 Message-Id: <20230525140135.3589917-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The current code takes the thermal zone device lock to update the thermal trips. Now we have an API allowing to update the thermal trip directly, so use it and get ride of the thermal zone lock access. Take also the opportunity to use the zone>-type accessor. Signed-off-by: Daniel Lezcano --- .../int340x_thermal/int340x_thermal_zone.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 89cf007146ea..94697063f41e 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -58,7 +58,8 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, static void int340x_thermal_critical(struct thermal_zone_device *zone) { - dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); + dev_dbg(thermal_zone_device(zone), "%s: critical temperature reached\n", + thermal_zone_device_type(zone)); } static struct thermal_zone_device_ops int340x_thermal_zone_ops = { @@ -215,13 +216,15 @@ EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) { struct acpi_device *zone_adev = int34x_zone->adev; - struct thermal_trip *zone_trips = int34x_zone->trips; - int trip_cnt = int34x_zone->zone->num_trips; + struct thermal_trip *zone_trips; + int trip_cnt = thermal_zone_get_num_trips(int34x_zone->zone); int act_trip_nr = 0; int i; - mutex_lock(&int34x_zone->zone->lock); - + zone_trips = kmemdup(int34x_zone->trips, sizeof(*zone_trips) * trip_cnt, GFP_KERNEL); + if (!zone_trips) + return; + for (i = int34x_zone->aux_trip_nr; i < trip_cnt; i++) { int temp, err; @@ -250,7 +253,9 @@ void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) zone_trips[i].temperature = temp; } - mutex_unlock(&int34x_zone->zone->lock); + if (!thermal_zone_trips_update(int34x_zone->zone, zone_trips, trip_cnt, + GENMASK_ULL((trip_cnt) - 1, 0))) + int34x_zone->trips = zone_trips; } EXPORT_SYMBOL_GPL(int340x_thermal_update_trips); From patchwork Thu May 25 14:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 686336 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78BF2C7EE2D for ; Thu, 25 May 2023 14:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241533AbjEYOCz (ORCPT ); Thu, 25 May 2023 10:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241532AbjEYOCs (ORCPT ); Thu, 25 May 2023 10:02:48 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06302E4F for ; Thu, 25 May 2023 07:02:19 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3078a3f3b5fso2128824f8f.0 for ; Thu, 25 May 2023 07:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685023331; x=1687615331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xlMjiYWjIod1M5ysecwWR9Zw02vJku0YSHje4x3URRI=; b=w1RsQ+stlMrNo0+vFPex2i/zi2qhFPU+CG+4wI4u4KpQiT7VBQ6e3KEg8o5ksT22h5 2rWiRy33QN4BFcZxdsBLNxdSk0xC4y6NjDXQYitf8YgGuLluXosBbSmIKQA8ph9Fl45R oTIPz/Od566ZvOtUFKDcJn3tBUsIjj6LxWHBEYAwkJfh8sVd2xc0lRvTwoMYDLgSw5XN uSlV7pXP3ezzS56NM2yclfL5Q+71pi3xDuWsMCLCDcHsq2ZtebcR4QGrsWcoLm6nNVqa S8+V+FKrddJIkmwQVwgEnPYxzRJWSz6xCRwKMnpi56Ip1M6a6Z2WWNs+9jb2S9wG/83c aBJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685023331; x=1687615331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xlMjiYWjIod1M5ysecwWR9Zw02vJku0YSHje4x3URRI=; b=aGVslnpMABM7uMv3iC6XteMe4PyF2JHeHAMBCXEQlfQ/LB3F5OHxB2qtrBjEG4ozai l/d11//PRtPbO+eCmaJd7EdnSIXpEu3zeC7dceel3/MYAMNPHrToyjP6oNTkVIc3G0LW H1Ihm1X0QW0b2NZ8shEkeVnP9CXOv282hc5GH1KFsIYlo1GGofU+pNZcyD8DYRthPNO1 GVkH/54nteMHpzHdVBQ7/n792lfEzRkx58HRMmh/j7NK3NT/wVBgIoou6+wAP+ZgI4HO cMpnUb3kGNzG95yPCUSiRwS04h+LxoPfEuyO28yMMU9B8tSkw8/ewS5+p7x6qUe4BGSY Hdsw== X-Gm-Message-State: AC+VfDyM/yG9uSrIRYU+yXcVMoFk6DStszYcDMJR7nbBLwwgPxWYRyq+ yvfIUhrIL3XsdYnTfckJBEXCIQ== X-Google-Smtp-Source: ACHHUZ6VTuTPHdSAz9DsUXXmuiMQweDChxDD2cBuim7IKj+jS9IGjmwrEViGz+Z1wiMrdyCg6dK5UQ== X-Received: by 2002:adf:f348:0:b0:306:3381:67fe with SMTP id e8-20020adff348000000b00306338167femr2737955wrp.27.1685023331567; Thu, 25 May 2023 07:02:11 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5aef:8608:89d7:7961]) by smtp.gmail.com with ESMTPSA id u4-20020adfdd44000000b003063176ef09sm1944866wrm.6.2023.05.25.07.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 07:02:11 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com, Amit Kucheria , Zhang Rui , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 8/8] thermal/core: Move the thermal zone structure to the private core header Date: Thu, 25 May 2023 16:01:35 +0200 Message-Id: <20230525140135.3589917-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525140135.3589917-1-daniel.lezcano@linaro.org> References: <20230525140135.3589917-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The code in the different drivers have been sanitized and they no longer access the thermal zone structure internals. This one is just a pointer passed around to the thermal core code as a handler. Move the structure definition to the private core code header to self-encapsulate the core code. No functional changes intented. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 75 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 75 ---------------------------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c27a9930f904..b93386640799 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -18,6 +18,81 @@ #warning This header can only be included by the thermal core code #endif +/** + * struct thermal_zone_device - structure for a thermal zone + * @id: unique id number for each thermal zone + * @type: the thermal zone device type + * @device: &struct device for this thermal zone + * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature + * @trip_type_attrs: attributes for trip points for sysfs: trip type + * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis + * @mode: current mode of this thermal zone + * @devdata: private pointer for device private data + * @trips: an array of struct thermal_trip + * @num_trips: number of trip points the thermal zone supports + * @trips_disabled; bitmap for disabled trips + * @passive_delay_jiffies: number of jiffies to wait between polls when + * performing passive cooling. + * @polling_delay_jiffies: number of jiffies to wait between polls when + * checking whether trip points have been crossed (0 for + * interrupt driven systems) + * @temperature: current temperature. This is only for core code, + * drivers should use thermal_zone_get_temp() to get the + * current temperature + * @last_temperature: previous temperature read + * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION + * @passive: 1 if you've crossed a passive trip point, 0 otherwise. + * @prev_low_trip: the low current temperature if you've crossed a passive + trip point. + * @prev_high_trip: the above current temperature if you've crossed a + passive trip point. + * @need_update: if equals 1, thermal_zone_device_update needs to be invoked. + * @ops: operations this &thermal_zone_device supports + * @tzp: thermal zone parameters + * @governor: pointer to the governor for this thermal zone + * @governor_data: private pointer for governor data + * @thermal_instances: list of &struct thermal_instance of this thermal zone + * @ida: &struct ida to generate unique id for this zone's cooling + * devices + * @lock: lock to protect thermal_instances list + * @node: node in thermal_tz_list (in thermal_core.c) + * @poll_queue: delayed work for polling + * @notify_event: Last notification event + */ +struct thermal_zone_device { + int id; + char type[THERMAL_NAME_LENGTH]; + struct device device; + struct attribute_group trips_attribute_group; + struct thermal_attr *trip_temp_attrs; + struct thermal_attr *trip_type_attrs; + struct thermal_attr *trip_hyst_attrs; + enum thermal_device_mode mode; + void *devdata; + struct thermal_trip *trips; + int num_trips; + unsigned long trips_disabled; /* bitmap for disabled trips */ + unsigned long passive_delay_jiffies; + unsigned long polling_delay_jiffies; + int temperature; + int last_temperature; + int emul_temperature; + int passive; + int prev_low_trip; + int prev_high_trip; + atomic_t need_update; + struct thermal_zone_device_ops *ops; + struct thermal_zone_params *tzp; + struct thermal_governor *governor; + void *governor_data; + struct list_head thermal_instances; + struct ida ida; + struct mutex lock; + struct list_head node; + struct delayed_work poll_queue; + enum thermal_notify_event notify_event; +}; + /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise" diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 83937256a01c..0ea2da5c33ac 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -112,81 +112,6 @@ struct thermal_cooling_device { struct list_head node; }; -/** - * struct thermal_zone_device - structure for a thermal zone - * @id: unique id number for each thermal zone - * @type: the thermal zone device type - * @device: &struct device for this thermal zone - * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature - * @trip_type_attrs: attributes for trip points for sysfs: trip type - * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis - * @mode: current mode of this thermal zone - * @devdata: private pointer for device private data - * @trips: an array of struct thermal_trip - * @num_trips: number of trip points the thermal zone supports - * @trips_disabled; bitmap for disabled trips - * @passive_delay_jiffies: number of jiffies to wait between polls when - * performing passive cooling. - * @polling_delay_jiffies: number of jiffies to wait between polls when - * checking whether trip points have been crossed (0 for - * interrupt driven systems) - * @temperature: current temperature. This is only for core code, - * drivers should use thermal_zone_get_temp() to get the - * current temperature - * @last_temperature: previous temperature read - * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION - * @passive: 1 if you've crossed a passive trip point, 0 otherwise. - * @prev_low_trip: the low current temperature if you've crossed a passive - trip point. - * @prev_high_trip: the above current temperature if you've crossed a - passive trip point. - * @need_update: if equals 1, thermal_zone_device_update needs to be invoked. - * @ops: operations this &thermal_zone_device supports - * @tzp: thermal zone parameters - * @governor: pointer to the governor for this thermal zone - * @governor_data: private pointer for governor data - * @thermal_instances: list of &struct thermal_instance of this thermal zone - * @ida: &struct ida to generate unique id for this zone's cooling - * devices - * @lock: lock to protect thermal_instances list - * @node: node in thermal_tz_list (in thermal_core.c) - * @poll_queue: delayed work for polling - * @notify_event: Last notification event - */ -struct thermal_zone_device { - int id; - char type[THERMAL_NAME_LENGTH]; - struct device device; - struct attribute_group trips_attribute_group; - struct thermal_attr *trip_temp_attrs; - struct thermal_attr *trip_type_attrs; - struct thermal_attr *trip_hyst_attrs; - enum thermal_device_mode mode; - void *devdata; - struct thermal_trip *trips; - int num_trips; - unsigned long trips_disabled; /* bitmap for disabled trips */ - unsigned long passive_delay_jiffies; - unsigned long polling_delay_jiffies; - int temperature; - int last_temperature; - int emul_temperature; - int passive; - int prev_low_trip; - int prev_high_trip; - atomic_t need_update; - struct thermal_zone_device_ops *ops; - struct thermal_zone_params *tzp; - struct thermal_governor *governor; - void *governor_data; - struct list_head thermal_instances; - struct ida ida; - struct mutex lock; - struct list_head node; - struct delayed_work poll_queue; - enum thermal_notify_event notify_event; -}; - /** * struct thermal_governor - structure that holds thermal governor information * @name: name of the governor