From patchwork Tue Mar 7 13:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 660367 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 1E6B8C6FD1B for ; Tue, 7 Mar 2023 13:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbjCGNiB (ORCPT ); Tue, 7 Mar 2023 08:38:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjCGNh7 (ORCPT ); Tue, 7 Mar 2023 08:37:59 -0500 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 7B6A6525D for ; Tue, 7 Mar 2023 05:37:56 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j2so12127832wrh.9 for ; Tue, 07 Mar 2023 05:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196275; 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=b5lJEnGWoR5daba7syY/YlJQMJlulw+k3BHuc1yDN1U=; b=HNwN9xLjHkYN2k4XJ8+FCxhbozlsuAWJRVES03TTNWLuJDi7/D9zR0blvPsClZ4aJF dZVBH9kFIfyJNf3aBDJqkT/ANpEmjPCvvMpjtEVRpbSzXmJKheHZkXa/xF2aCcoUksQG /OHuCQKOOxEDZu67yNYMjHLCbqBQ7uQNupFZKwbvHiTGsnjdtceKUahaCVtpqEa0P5BL yZ7RFojSHhXPz0U3y2KlOY3Vnagf+/0/imHZ/YHPIsbGd+BtzVH9Jnb3EyKFJoEkIHb6 XMLn49DMTSr7koKc390uGmGAn0KPKhDsaY/9OjWfea4UP28n3QM7vmfL86Rfl69LBlQM 2f+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196275; 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=b5lJEnGWoR5daba7syY/YlJQMJlulw+k3BHuc1yDN1U=; b=IYcdc4QTDpCiGdW+KrmOFHEh03Tq4YSarxxZ3RRE9uNX6FbCf/d1AHoSSvQuuN63Bn T0hzA6oJ6dD+spyU65BK7Kh7VB2rHoQPpe4ao9n6VXQ95SJUqHyzOJX6hwqirhJzRICb lvo4pE0kO/MJhrBt4tvQaV97fZNuLnbMZpCNQAyR5xJrZzGA1cq5vKofpZ9OO1Ru9kkX 5H04Qe8QMZRezhuXSAje3qXjGRaBs2XNV3UeQFmH9HIOKqIC0U5rF4FA3SK2AZlGed1S dlxoxQe3VMZ91/OtgedQU5A8Mgp5l+P2ciJhf54TIyVgVPlkUCzgdfFpZkUlVWBj9KMR N9YQ== X-Gm-Message-State: AO0yUKU3nrys6GbonNAbOlIEP9YCrKK5BsoKqcGVfdKku7Vv7GPy2wlJ 1Rz2taYcWuDsTLYeUOAhldQheA== X-Google-Smtp-Source: AK7set8ZMrApDRZd5133PVg919iApzpcGKhJiym0d1GCCx1FzE5z2niOOu588zS7WXr0/sPqW8nwbw== X-Received: by 2002:adf:e745:0:b0:2c5:a38f:ca3a with SMTP id c5-20020adfe745000000b002c5a38fca3amr13239879wrn.10.1678196274952; Tue, 07 Mar 2023 05:37:54 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:54 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Steven Rostedt , Amit Daniel Kachhap , Viresh Kumar , Lukasz Luba , Masami Hiramatsu , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list), linux-trace-kernel@vger.kernel.org (open list:TRACING) Subject: [PATCH v1 01/11] thermal/core: Relocate the traces definition in thermal directory Date: Tue, 7 Mar 2023 14:37:25 +0100 Message-Id: <20230307133735.90772-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The traces are exported but only local to the thermal core code. On the other side, the traces take the thermal zone device structure as argument, thus they have to rely on the exported thermal.h header file. As we want to move the structure to the private thermal core header, first we have to relocate those traces to the same place as many drivers do. Cc: Steven Rostedt Suggested-by: Steven Rostedt Signed-off-by: Daniel Lezcano Reviewed-by: Steven Rostedt (Google) --- drivers/thermal/Makefile | 3 ++- drivers/thermal/cpufreq_cooling.c | 2 +- drivers/thermal/devfreq_cooling.c | 2 +- drivers/thermal/gov_fair_share.c | 2 +- drivers/thermal/gov_power_allocator.c | 2 +- drivers/thermal/gov_step_wise.c | 2 +- drivers/thermal/thermal_core.c | 2 +- drivers/thermal/thermal_helpers.c | 3 +-- .../events/thermal.h => drivers/thermal/thermal_trace.h | 6 ++++++ .../thermal/thermal_trace_ipa.h | 6 ++++++ 10 files changed, 21 insertions(+), 9 deletions(-) rename include/trace/events/thermal.h => drivers/thermal/thermal_trace.h (97%) rename include/trace/events/thermal_power_allocator.h => drivers/thermal/thermal_trace_ipa.h (96%) diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index eed300e83d48..058664bc3ec0 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -2,7 +2,7 @@ # # Makefile for sensor chip drivers. # - +CFLAGS_thermal_core.o := -I$(src) obj-$(CONFIG_THERMAL) += thermal_sys.o thermal_sys-y += thermal_core.o thermal_sysfs.o thermal_sys-y += thermal_trip.o thermal_helpers.o @@ -16,6 +16,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o thermal_sys-$(CONFIG_THERMAL_ACPI) += thermal_acpi.o # governors +CFLAGS_gov_power_allocator.o := -I$(src) thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += gov_fair_share.o thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += gov_step_wise.o diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index 9f8b438fcf8f..65ef08b30334 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -23,7 +23,7 @@ #include #include -#include +#include "thermal_trace.h" /* * Cooling state <-> CPUFreq frequency diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index 24b474925cd6..262e62ab6cf2 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -20,7 +20,7 @@ #include #include -#include +#include "thermal_trace.h" #define SCALE_ERROR_MITIGATION 100 diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index aad7d5fe3a14..1ce5692151f5 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -11,7 +11,7 @@ */ #include -#include +#include "thermal_trace.h" #include "thermal_core.h" diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 0eaf1527d3e3..3df2d440d73d 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -12,7 +12,7 @@ #include #define CREATE_TRACE_POINTS -#include +#include "thermal_trace_ipa.h" #include "thermal_core.h" diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 31235e169c5a..f69c83e2992d 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -12,7 +12,7 @@ #include #include -#include +#include "thermal_trace.h" #include "thermal_core.h" diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 46dedfe061df..cec72c6673a5 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -22,7 +22,7 @@ #include #define CREATE_TRACE_POINTS -#include +#include "thermal_trace.h" #include "thermal_core.h" #include "thermal_hwmon.h" diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index 9558339f5633..c41b1a5700a5 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -19,9 +19,8 @@ #include #include -#include - #include "thermal_core.h" +#include "thermal_trace.h" int get_tz_trend(struct thermal_zone_device *tz, int trip) { diff --git a/include/trace/events/thermal.h b/drivers/thermal/thermal_trace.h similarity index 97% rename from include/trace/events/thermal.h rename to drivers/thermal/thermal_trace.h index e58bf3072f32..459c8ce6cf3b 100644 --- a/include/trace/events/thermal.h +++ b/drivers/thermal/thermal_trace.h @@ -195,5 +195,11 @@ TRACE_EVENT(thermal_power_devfreq_limit, #endif /* CONFIG_DEVFREQ_THERMAL */ #endif /* _TRACE_THERMAL_H */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE thermal_trace + /* This part must be outside protection */ #include diff --git a/include/trace/events/thermal_power_allocator.h b/drivers/thermal/thermal_trace_ipa.h similarity index 96% rename from include/trace/events/thermal_power_allocator.h rename to drivers/thermal/thermal_trace_ipa.h index 1c8fb95544f9..84568db5421b 100644 --- a/include/trace/events/thermal_power_allocator.h +++ b/drivers/thermal/thermal_trace_ipa.h @@ -84,5 +84,11 @@ TRACE_EVENT(thermal_power_allocator_pid, ); #endif /* _TRACE_THERMAL_POWER_ALLOCATOR_H */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE thermal_trace_ipa + /* This part must be outside protection */ #include From patchwork Tue Mar 7 13:37:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 660905 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 23893C678D4 for ; Tue, 7 Mar 2023 13:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbjCGNiA (ORCPT ); Tue, 7 Mar 2023 08:38:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbjCGNh7 (ORCPT ); Tue, 7 Mar 2023 08:37:59 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E909031 for ; Tue, 7 Mar 2023 05:37:57 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id h11so12146234wrm.5 for ; Tue, 07 Mar 2023 05:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196276; 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=mIjogzcbB9NbNQDtYcUOxd5sO+Lh6rQ2yVngUMiZyBg=; b=YG5ga49pJHXfSemMbf0p1srILRTv58YCHpLvV/P7+8IagzwrOhVhY7ZKGa0EYsmRo/ G2CoSa4u0ZEPOC0Vr70fZU1bQ41CO1Y4MMaxwuSbD7SbxOR1Dzpss8lJ/qrzohTOAMFs TWxHtI4ngmaSsg3tMPJcWKwjqdVjAyBsxhGaReWOJlZo4/jUDQVQSh+7eDi7aKiHqvWq Vs/+qJbWZzqKUHoiZSdeKb362nA3ACs5FJymKmMPaLPNbJgJYa34BxAVmMeOvtmasGxV EgAlVDdpg2jnHLSqMEooMAFjtMZYCMpfINVTeqnOeyNAxNeurKrrDromBo23nT+lHimD 0F5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196276; 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=mIjogzcbB9NbNQDtYcUOxd5sO+Lh6rQ2yVngUMiZyBg=; b=5WU4MNM5Ib36asPAJQFTfnyibvCVg8V2GTky/AnfmMSvd4IJzuwoSwVxzVJYV0+P7R UF7RXPdzQBnVdqM2pB/wDtUu6nJ/6UVCOqepFvP3ASfVFsa/MNX1kq0yTyPT+8A9FXuH daqrH0YK/eRlkbIscZycg0p9u/J537MWYtdR0iNi28WYyHZ1aid4KvzemuEthA73y0l2 XbsHOnrTwSGBgcl6uWm2LcRJDeW813JZ5igl9RApHJ5B5/DTEk428I5NbkX1pyAKCT5o 2bXSxzco0MjlUONgdh/Wr5dwhQRnwL0eyzklhyerE6VY5tshPve8MLRQ+D3bw1M7s+3n iieA== X-Gm-Message-State: AO0yUKXLIy1JwBBKNn8v/FoJ39z7Scm77VCpxvWx04q5/yLuMe4/yu95 RCyZVXC7JDG28GF579icjVb6TQ== X-Google-Smtp-Source: AK7set/4lXJCmPfCyDhu+dCKKQKbXeAog36vaBFmsPGjAwv5R3tEcPT/BWmWipC6Naeq00anV5N6JA== X-Received: by 2002:a5d:5253:0:b0:2c5:5d21:7d4c with SMTP id k19-20020a5d5253000000b002c55d217d4cmr9400374wrc.43.1678196276323; Tue, 07 Mar 2023 05:37:56 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:56 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Jernej Skrabec , Adam Ward , Tim Zimmermann , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 02/11] thermal/drivers/intel_pch_thermal: Use thermal driver device to write a trace Date: Tue, 7 Mar 2023 14:37:26 +0100 Message-Id: <20230307133735.90772-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The pch_critical() callback accesses the thermal zone device structure internals, it dereferences the thermal zone struct device and the 'type'. For the former, the driver related device should be use instead and for the latter an accessor already exists. Use them instead of accessing the internals. Signed-off-by: Daniel Lezcano --- drivers/thermal/intel/intel_pch_thermal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index dce50d239357..0de46057db2a 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -127,7 +127,10 @@ static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp) static void pch_critical(struct thermal_zone_device *tzd) { - dev_dbg(&tzd->device, "%s: critical temperature reached\n", tzd->type); + struct pch_thermal_device *ptd = thermal_zone_device_priv(tzd); + + dev_dbg(&ptd->pdev->dev, "%s: critical temperature reached\n", + thermal_zone_device_type(tzd)); } static struct thermal_zone_device_ops tzd_ops = { From patchwork Tue Mar 7 13:37:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 660904 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 ED525C6FD1A for ; Tue, 7 Mar 2023 13:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbjCGNiC (ORCPT ); Tue, 7 Mar 2023 08:38:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbjCGNiB (ORCPT ); Tue, 7 Mar 2023 08:38:01 -0500 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 AC7B6E05D for ; Tue, 7 Mar 2023 05:37:58 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id q16so12162503wrw.2 for ; Tue, 07 Mar 2023 05:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196277; 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=nLUnfNdm2yVAS1wkgyhep1P3VK/E8L4MHqepWzvtV2A=; b=qKIJrWS9HlseEtztfIrN6k80cK8FLhU5mOoTqsxRKIDDswm6hrdb/9FJXWSrtgL4Pm ZymY4A+L/FR0vKcMRpxJnpy3ko7ZviX2L3xB7TSfO4MkZ5K4R5T7I6j2QJO/IV2kfHfa xRqWqAfhDP64AdJkXBlw4aRFPruwVqGBE9ynzgRIdvtK8gIYV3EbAI7UtfctX4+wYbIN bMGDMVGkXtrCoEnJcQJBTZ58XDpIflI+VbB0IaYvqcKCQ/6UeWX4Am5pQ3QL1N23Kf+T qNq7IV3DjqUzZ5e0CsHVPgb0IYpSE/rwbzlDfi4qNQ1X4w8H8QslY8Sjm5y/QHleuooc 8giw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196277; 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=nLUnfNdm2yVAS1wkgyhep1P3VK/E8L4MHqepWzvtV2A=; b=pF2WuAwcQL9vq0/aF6TXO//bpJJju/VbKP7WmDRjwuOh5TWrmBx/2XX2OdMltYMUne 6AEzadAUZG0jvhH26ynzkGgfC3vVh2S0R1cjEWwcuKmNWzBbc4Vk0kYbbZKNw46qxYDx uwUlkb34sUYYYJIFbvpkzEmw/9MYyCN8DW/cgBdzv1Cz4anTGHlX4cWZ1jGntqnIHQKG 06YQ5FvMN4H9X+BOVt7ONveR4UtQ7BWIre3krgu/i8J5VcuNAYAbdyBJDfS8spBbG6aI 9AqbzO96I3cn8f9LmDVxNUIbnP5ouuoy8WsCOILlCEpafZ2l5zvhka2fGRD4vnPIklFc ZAxg== X-Gm-Message-State: AO0yUKWfxsgC8Z0Vq2y+mHSylDpLRdu3Bxj9UU0ciHIE/u1CQi7ENyCW 7QjggStjJQoKwPfZHRVfWXCoSA4Bt6X4WC6SrZc= X-Google-Smtp-Source: AK7set+5bl0ivxq0qjIDEGdtaLKiDFJabUVOomnEhZz+7wzT8OijXNC2nxhhd/MkVveZgS5ZEKTF/w== X-Received: by 2002:adf:e948:0:b0:2c7:478:d1d9 with SMTP id m8-20020adfe948000000b002c70478d1d9mr9055975wrn.33.1678196277140; Tue, 07 Mar 2023 05:37:57 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:56 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Sujith Thomas , linux-pm@vger.kernel.org (open list:INTEL MENLOW THERMAL DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 03/11] thermal/drivers/intel_menlow: Remove add_one_attribute Date: Tue, 7 Mar 2023 14:37:27 +0100 Message-Id: <20230307133735.90772-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver hooks the thermal framework sysfs to add some driver specific information. A debatable approach as that may belong the device sysfs directory, not the thermal zone directory. As the driver is accessing the thermal internals, we should provide at least an API to the thermal framework to add an attribute to the existing sysfs thermal zone entry. Before doing that and given the age of the driver (2008) may be it is worth to double check if these attributes are really needed. So my first proposal is to remove them if that does not hurt. Signed-off-by: Daniel Lezcano --- drivers/thermal/intel/intel_menlow.c | 193 --------------------------- 1 file changed, 193 deletions(-) diff --git a/drivers/thermal/intel/intel_menlow.c b/drivers/thermal/intel/intel_menlow.c index 5a6ad0552311..5a9738a93083 100644 --- a/drivers/thermal/intel/intel_menlow.c +++ b/drivers/thermal/intel/intel_menlow.c @@ -230,174 +230,8 @@ struct intel_menlow_attribute { static LIST_HEAD(intel_menlow_attr_list); static DEFINE_MUTEX(intel_menlow_attr_lock); -/* - * sensor_get_auxtrip - get the current auxtrip value from sensor - * @handle: Object handle - * @index : GET_AUX1/GET_AUX0 - * @value : The address will be fill by the value - */ -static int sensor_get_auxtrip(acpi_handle handle, int index, - unsigned long long *value) -{ - acpi_status status; - - if ((index != 0 && index != 1) || !value) - return -EINVAL; - - status = acpi_evaluate_integer(handle, index ? GET_AUX1 : GET_AUX0, - NULL, value); - if (ACPI_FAILURE(status)) - return -EIO; - - return 0; -} - -/* - * sensor_set_auxtrip - set the new auxtrip value to sensor - * @handle: Object handle - * @index : GET_AUX1/GET_AUX0 - * @value : The value will be set - */ -static int sensor_set_auxtrip(acpi_handle handle, int index, int value) -{ - acpi_status status; - union acpi_object arg = { - ACPI_TYPE_INTEGER - }; - struct acpi_object_list args = { - 1, &arg - }; - unsigned long long temp; - - if (index != 0 && index != 1) - return -EINVAL; - - status = acpi_evaluate_integer(handle, index ? GET_AUX0 : GET_AUX1, - NULL, &temp); - if (ACPI_FAILURE(status)) - return -EIO; - if ((index && value < temp) || (!index && value > temp)) - return -EINVAL; - - arg.integer.value = value; - status = acpi_evaluate_integer(handle, index ? SET_AUX1 : SET_AUX0, - &args, &temp); - if (ACPI_FAILURE(status)) - return -EIO; - - /* do we need to check the return value of SAX0/SAX1 ? */ - - return 0; -} - -#define to_intel_menlow_attr(_attr) \ - container_of(_attr, struct intel_menlow_attribute, attr) - -static ssize_t aux_show(struct device *dev, struct device_attribute *dev_attr, - char *buf, int idx) -{ - struct intel_menlow_attribute *attr = to_intel_menlow_attr(dev_attr); - unsigned long long value; - int result; - - result = sensor_get_auxtrip(attr->handle, idx, &value); - if (result) - return result; - - return sprintf(buf, "%lu", deci_kelvin_to_celsius(value)); -} - -static ssize_t aux0_show(struct device *dev, - struct device_attribute *dev_attr, char *buf) -{ - return aux_show(dev, dev_attr, buf, 0); -} - -static ssize_t aux1_show(struct device *dev, - struct device_attribute *dev_attr, char *buf) -{ - return aux_show(dev, dev_attr, buf, 1); -} - -static ssize_t aux_store(struct device *dev, struct device_attribute *dev_attr, - const char *buf, size_t count, int idx) -{ - struct intel_menlow_attribute *attr = to_intel_menlow_attr(dev_attr); - int value; - int result; - - /*Sanity check; should be a positive integer */ - if (!sscanf(buf, "%d", &value)) - return -EINVAL; - - if (value < 0) - return -EINVAL; - - result = sensor_set_auxtrip(attr->handle, idx, - celsius_to_deci_kelvin(value)); - return result ? result : count; -} - -static ssize_t aux0_store(struct device *dev, - struct device_attribute *dev_attr, - const char *buf, size_t count) -{ - return aux_store(dev, dev_attr, buf, count, 0); -} - -static ssize_t aux1_store(struct device *dev, - struct device_attribute *dev_attr, - const char *buf, size_t count) -{ - return aux_store(dev, dev_attr, buf, count, 1); -} - /* BIOS can enable/disable the thermal user application in dabney platform */ #define BIOS_ENABLED "\\_TZ.GSTS" -static ssize_t bios_enabled_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - acpi_status status; - unsigned long long bios_enabled; - - status = acpi_evaluate_integer(NULL, BIOS_ENABLED, NULL, &bios_enabled); - if (ACPI_FAILURE(status)) - return -ENODEV; - - return sprintf(buf, "%s\n", bios_enabled ? "enabled" : "disabled"); -} - -static int intel_menlow_add_one_attribute(char *name, umode_t mode, void *show, - void *store, struct device *dev, - acpi_handle handle) -{ - struct intel_menlow_attribute *attr; - int result; - - attr = kzalloc(sizeof(struct intel_menlow_attribute), GFP_KERNEL); - if (!attr) - return -ENOMEM; - - sysfs_attr_init(&attr->attr.attr); /* That is consistent naming :D */ - attr->attr.attr.name = name; - attr->attr.attr.mode = mode; - attr->attr.show = show; - attr->attr.store = store; - attr->device = dev; - attr->handle = handle; - - result = device_create_file(dev, &attr->attr); - if (result) { - kfree(attr); - return result; - } - - mutex_lock(&intel_menlow_attr_lock); - list_add_tail(&attr->node, &intel_menlow_attr_list); - mutex_unlock(&intel_menlow_attr_lock); - - return 0; -} static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl, void *context, void **rv) @@ -420,12 +254,6 @@ static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl, if (ACPI_FAILURE(status)) return (status == AE_NOT_FOUND) ? AE_OK : status; - result = intel_menlow_add_one_attribute("aux0", 0644, - aux0_show, aux0_store, - &thermal->device, handle); - if (result) - return AE_ERROR; - status = acpi_get_handle(handle, GET_AUX1, &dummy); if (ACPI_FAILURE(status)) goto aux1_not_found; @@ -434,27 +262,6 @@ static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl, if (ACPI_FAILURE(status)) goto aux1_not_found; - result = intel_menlow_add_one_attribute("aux1", 0644, - aux1_show, aux1_store, - &thermal->device, handle); - if (result) { - intel_menlow_unregister_sensor(); - return AE_ERROR; - } - - /* - * create the "dabney_enabled" attribute which means the user app - * should be loaded or not - */ - - result = intel_menlow_add_one_attribute("bios_enabled", 0444, - bios_enabled_show, NULL, - &thermal->device, handle); - if (result) { - intel_menlow_unregister_sensor(); - return AE_ERROR; - } - return AE_OK; aux1_not_found: From patchwork Tue Mar 7 13:37: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: 660366 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 B3052C678D4 for ; Tue, 7 Mar 2023 13:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbjCGNiG (ORCPT ); Tue, 7 Mar 2023 08:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbjCGNiC (ORCPT ); Tue, 7 Mar 2023 08:38:02 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0E31042F for ; Tue, 7 Mar 2023 05:37:59 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id p26so7767483wmc.4 for ; Tue, 07 Mar 2023 05:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196278; 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=tjVs2mfF+5OS1VMRPgk5J2R/XS+QKw7GSrWzqh0h9oE=; b=nwuS1n1dGQucPh2XKQbKMbOfHQRb0TXCyHjqV8hQgGiVYUnv0Z3JoxSW+QcolIIoIx KeP+LoD37PZSFj1miZWKNKd6cf47xdV05BRMhAyd0n+h7HXQ5MD0UA1CZUPtdge59bPX X3yl2i2+ZXMnPdjps2s4t/n8BjImhsnOmUzRdHGT4V8hSkxpcwZgpxakbO56kEjzLtNs e+aEFbPjVqMBaygI1zsl/2MZsMjItMSs3LTCaJyWJhb0sLDRFZXFOabMbcyVeapHf1k3 Ats2QvQeA8o4+B45RMyqkJNqoxVUdxPQKUgWlZ6VIYugABEn3NSbi5gHPXfxR2+mt6w5 PBtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196278; 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=tjVs2mfF+5OS1VMRPgk5J2R/XS+QKw7GSrWzqh0h9oE=; b=KlQzWwLIQbt60u0bTVGhFRhwNEdkXyjcB/ugK8RqtgVYBLHfG2TTCboVaCwBI+vcKY 9NrrPiyIA/g8Tj9vmDDgu/L98nGsiW+OK6ylKSphU+towa4couuLwABo7cXBSlbetcbo 5w1GPRc3Z8A5UyVTbQyFfc3I9xk+SIsyCq1so98CCWFSRfhL/6G25b+DfhoarhUAJBpA s5DsPJ1e6je15Y/Rq/PnYj9PBO3q8ZRYXcFhtC5ll18sSw/vEJoAKVsC/2HvazLAG6Lz q9sAwAFtd5Rh5O5r2ogfZFdAHZvd3mfQ5PsH0ZW9fbrPPTdy+o9nDPJ4DNFd1CqSQvLL w6BA== X-Gm-Message-State: AO0yUKXEa7tGMUV5xJkb+yP2oFaTpKXypi4NqgJOdyrPXN5pi4Xld99o QBKmQrjiEaWj3Xcrc0p8Yr+dcw== X-Google-Smtp-Source: AK7set+QqlE9Bn/nNAwKCGRX2rPLbgBL7L/YeIJ1qEiaPgZwrdF+xKnMDrwXF7my9fvBOXimUa8Jrw== X-Received: by 2002:a05:600c:ad3:b0:3ea:e667:b1ee with SMTP id c19-20020a05600c0ad300b003eae667b1eemr12281365wmr.38.1678196277915; Tue, 07 Mar 2023 05:37:57 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:57 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Linus Walleij , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 04/11] thermal/drivers/db8500: Use driver dev instead of tz->device Date: Tue, 7 Mar 2023 14:37:28 +0100 Message-Id: <20230307133735.90772-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The db8500 driver uses the thermal zone device instead of the device attached to it. In order to prevent the drivers to access the thermal zone device structure, replace the thermal zone device by the driver to show the debug message. Cc: Linus Walleij Signed-off-by: Daniel Lezcano Reviewed-by: Linus Walleij --- drivers/thermal/db8500_thermal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c index c0418497520c..de790e526ca5 100644 --- a/drivers/thermal/db8500_thermal.c +++ b/drivers/thermal/db8500_thermal.c @@ -53,6 +53,7 @@ static const unsigned long db8500_thermal_points[] = { struct db8500_thermal_zone { struct thermal_zone_device *tz; + struct device *dev; unsigned long interpolated_temp; unsigned int cur_index; }; @@ -114,7 +115,7 @@ static irqreturn_t prcmu_low_irq_handler(int irq, void *irq_data) idx -= 1; db8500_thermal_update_config(th, idx, next_low, next_high); - dev_dbg(&th->tz->device, + dev_dbg(th->dev, "PRCMU set max %ld, min %ld\n", next_high, next_low); thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED); @@ -136,7 +137,7 @@ static irqreturn_t prcmu_high_irq_handler(int irq, void *irq_data) db8500_thermal_update_config(th, idx, next_low, next_high); - dev_dbg(&th->tz->device, + dev_dbg(th->dev, "PRCMU set max %ld, min %ld\n", next_high, next_low); } else if (idx == num_points - 1) /* So we roof out 1 degree over the max point */ @@ -157,6 +158,8 @@ static int db8500_thermal_probe(struct platform_device *pdev) if (!th) return -ENOMEM; + th->dev = dev; + low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW"); if (low_irq < 0) return low_irq; From patchwork Tue Mar 7 13:37: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: 660365 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 3A7A4C6FD1E for ; Tue, 7 Mar 2023 13:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbjCGNiI (ORCPT ); Tue, 7 Mar 2023 08:38:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbjCGNiC (ORCPT ); Tue, 7 Mar 2023 08:38:02 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC2541115B for ; Tue, 7 Mar 2023 05:37:59 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id v16so12209966wrn.0 for ; Tue, 07 Mar 2023 05:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196279; 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=QFz3DL0wcsZVMgUUsHXDAfK6kJlbLDI4poI1FgV3Faw=; b=o+72SkNnGvUEZIoRxtbUn1yxoMbJK4ejWB7UdQfvn95oxQ1qGBRQkmTuvFIHCKSEQD 6V5Sb6way+IpVf1rC8Ts5ep1iztmQ7/B5Y21IzuyFDdX+ydu10oWZgvAd0kfo1C0jFU2 NXTAAd8/JNFFoLXX4Rcp6pauvrWKWmbMd1vPw7jlce/er2GgJSWLGuHD0rRIfYnu19Ml 4vgQqfv+uSE5DPvKzEY6foTsKhTkpPVp93OodQ6cgqwHb7g2vuwjKwmV3bpdPPwELa5m gZQr4IFv45Lh0vAKTshQ6V6mhjkdZSkHBM2U1mSk8lPzeCubKqrGFKAAhOLrd582PJub NIWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196279; 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=QFz3DL0wcsZVMgUUsHXDAfK6kJlbLDI4poI1FgV3Faw=; b=mduPY8vUs6RkWsw+JfdHPSjHj2eCin4fRbmKeqb2VuPSNossBqfjtPwnYkAuQ5lz5f sVrRKdwf5CxCeVWx0SYtYx1XNEEapqeE5HQsX4avXZwlyZToheGgeufbYPweoS3nasGD 2donjFliIxZkqlrlAUKuAe+lnb720BPq6kVrVxCQXYkrxjsAmffOWJnm+R6hM4tAQGz1 86drEQ/uXSWh+KX05WGkZSIuKkrTRaZS0whB9NnW9kI39CC5OTMWwQSFbyRyyUuhgr/t rVbm7+MhU+ymzrPz7xhD5uC/zXTVTejiJPlQPCgWcF7XI+NrJj0hvJBuKRG2DPuMZImz lxsQ== X-Gm-Message-State: AO0yUKXB+2EcJ0APGt3KbAnRQGY7kV5Cdz6scU4lIKScoVOvDeFScfKx P7yt68qG6+9yljpZ/sBLa2MEzA== X-Google-Smtp-Source: AK7set9FSAFaADctvHU6vRmP3wIycBL+2ZqOFueq/Gl1g4rVDNPyVhEDXxA8gJtuA2idcajBArYPsQ== X-Received: by 2002:a5d:66ce:0:b0:2c7:8f73:7700 with SMTP id k14-20020a5d66ce000000b002c78f737700mr9276509wrw.39.1678196279346; Tue, 07 Mar 2023 05:37:59 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:59 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Maxime Coquelin , Alexandre Torgue , Florian Fainelli , =?utf-8?q?Niklas_S=C3=B6derlund?= , Minghao Chi , Mark Brown , linux-pm@vger.kernel.org (open list:THERMAL), linux-stm32@st-md-mailman.stormreply.com (moderated list:ARM/STM32 ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32 ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 05/11] thermal/drivers/stm: Don't set no_hwmon to false Date: Tue, 7 Mar 2023 14:37:29 +0100 Message-Id: <20230307133735.90772-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal->tzp->no_hwmon parameter is only used when calling thermal_zone_device_register(). Setting it to 'false' before calling thermal_add_hwmon_sysfs() has no effect. Remove the call and again prevent the drivers to access the thermal internals. Cc: Maxime Coquelin Cc: Alexandre Torgue Signed-off-by: Daniel Lezcano --- drivers/thermal/st/stm_thermal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c index 6f2bad8ef82f..903fcf1763f1 100644 --- a/drivers/thermal/st/stm_thermal.c +++ b/drivers/thermal/st/stm_thermal.c @@ -558,7 +558,6 @@ static int stm_thermal_probe(struct platform_device *pdev) * Thermal_zone doesn't enable hwmon as default, * enable it here */ - sensor->th_dev->tzp->no_hwmon = false; ret = thermal_add_hwmon_sysfs(sensor->th_dev); if (ret) goto err_tz; From patchwork Tue Mar 7 13:37: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: 660903 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 505B0C6FD1B for ; Tue, 7 Mar 2023 13:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjCGNiG (ORCPT ); Tue, 7 Mar 2023 08:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbjCGNiC (ORCPT ); Tue, 7 Mar 2023 08:38:02 -0500 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 B13C24EC7 for ; Tue, 7 Mar 2023 05:38:00 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j2so12128121wrh.9 for ; Tue, 07 Mar 2023 05:38:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196280; 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=JdJDrqqtlUNFE/DFGXP1EExWYwWTrZ4sgoVgCOKRcHw=; b=V4DzUa/CJXmEKyz8Xpy8/QGIKXBudu8ASEL6k8YrDJZSBCz38x5ZOffeZtMUdO57ki ITJyzDUh1dSdl8jwqFsAXbKJwIkdCxzK52vv1w3ry+4IgzfMQ7NpjyrwZyoj/9KFpGRf e35A86LQwKNWwcNbSCrCCHdHghj0uj5f5EYTQ/eefhnk1XIuhrNifsMUylxxf5OiWN60 M/aUUCIWGaINg+xt7BMcqrewBKIv2hSmM97nsqNxjEOAUZiAMsSjGFBVIgE8G/708Xh+ W0TiVoin/cQPePlabFlMqdwQftivwZqIYmq3lMpkQ9xkG9gEzBMkhA0C/yFM+K34lIUb x0uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196280; 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=JdJDrqqtlUNFE/DFGXP1EExWYwWTrZ4sgoVgCOKRcHw=; b=wuBKW8RnMjekpAMy/4Xy0kjLY8wwDphW+CLRu0APEiovHGG8TOKoFIs2oYfL0FzzJ9 XgMoAJe6SupxSzAGMAPqwdQK9Ysyl6kd5y2zbjZO0gLBhEttEOxcrk/px/UW6PmTFHV4 YXMXD2d+TScSSC5Bj1QwDgF9PumcOnqZ2VrpBQfPUD5YCCoEICXulDs9rcHb8tFlGePv xxL5FcCHxQ5+Lh4kn1jgFxr0YLFWDjfdX8l+PNEmeXoU5u57d2PAhs45JCTjT0luN0Tr myLUnFGqW8ozSOoOGJtS2Vqmx6561Y6PXzeLgtiqNopL1t9L6bUUcguZ/8kcP02A6zrG cBiQ== X-Gm-Message-State: AO0yUKWrqbVHSPqkIBx7IPLNarnRWOhhI/+eiijf0woimmi7x8XEV3tu 8JkFyPucDZ9FHrQkjOo+Iq11jQ== X-Google-Smtp-Source: AK7set9/G2RCKujNj/awqunJtgb4/HR/pw5Zjft48/44xtwqy0fHRIBEntFMik1v/yB+mPnrmmq9Cg== X-Received: by 2002:adf:f70d:0:b0:2c7:c9e:2c41 with SMTP id r13-20020adff70d000000b002c70c9e2c41mr9490477wrp.57.1678196280284; Tue, 07 Mar 2023 05:38:00 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:37:59 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Keerthy , Eduardo Valentin , linux-pm@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER), linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 06/11] thermal/drivers/ti: Use fixed update interval Date: Tue, 7 Mar 2023 14:37:30 +0100 Message-Id: <20230307133735.90772-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the TI thermal driver sets the sensor update interval based on the polling of the thermal zone. In order to get the polling rate, the code inspects the thermal zone device strcuture internals, thus breaking the self-encapsulation of the thermal framework core framework. On the other side, we see the common polling rates set in the device tree for the platforms using this driver are 500 or 1000 ms. Setting the polling rate to 250 ms would be far enough to cover the combination we found in the device tree. Instead of accessing the thermal zone device structure polling rate, let's use a common update interval of 250 ms for the driver. Cc: Keerthy Signed-off-by: Daniel Lezcano --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index 0c8914017c18..430c4b43151f 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -23,6 +23,8 @@ #include "ti-bandgap.h" #include "../thermal_hwmon.h" +#define TI_BANDGAP_UPDATE_INTERVAL_MS 250 + /* common data structures */ struct ti_thermal_data { struct cpufreq_policy *policy; @@ -159,7 +161,6 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, char *domain) { struct ti_thermal_data *data; - int interval; data = ti_bandgap_get_sensor_data(bgp, id); @@ -177,10 +178,9 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, return PTR_ERR(data->ti_thermal); } - interval = jiffies_to_msecs(data->ti_thermal->polling_delay_jiffies); - ti_bandgap_set_sensor_data(bgp, id, data); - ti_bandgap_write_update_interval(bgp, data->sensor_id, interval); + ti_bandgap_write_update_interval(bgp, data->sensor_id, + TI_BANDGAP_UPDATE_INTERVAL_MS); if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal)) dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n"); From patchwork Tue Mar 7 13:37: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: 660902 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 B3B7EC678D4 for ; Tue, 7 Mar 2023 13:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbjCGNiQ (ORCPT ); Tue, 7 Mar 2023 08:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbjCGNiF (ORCPT ); Tue, 7 Mar 2023 08:38:05 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B5D2A6C2 for ; Tue, 7 Mar 2023 05:38:03 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id j2so12128192wrh.9 for ; Tue, 07 Mar 2023 05:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196281; 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=fpDMcBBLQyF8LgqHxboWMTUnYVwMKYwzb0k+I2z6s1c=; b=lisF83AxJvSh6DA0RlrtTx09wKFawmHLIpSEn4KF0rznqL5TJpY1E9n2PY4Sfo9+QG uh7WuzJnm7J3PM/cwsJxcDK6N7kD6x+WmDK3pFw9JxOfO+MRb/W88kLm1shD2LHhH8ew cbFDopAM4fsLuhoFCF0IBlPYZMaKmPa9tG7f3tFcwqh9o27n3MaKlgeVmBQXxyYYPvmN OlKzfd+OqgN81HU0s1U95UHmnZ4edFAdq/qvBVaZiaXQAKOnlXa4c7YzUaqYJnkHJZ6J WS5GyHeG6Qk0XMQR9hGfPOtTHvIeRjBuzWz+LNF51lXn9RIEWRppGsn9W+Ya0SJ816mp K7dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196281; 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=fpDMcBBLQyF8LgqHxboWMTUnYVwMKYwzb0k+I2z6s1c=; b=IeYV1JZXwT5UWGxH1rWF6ZgXaoxSN8c/yA8aTFofIf2Ps4mR53VBi8YmuMHKcf0qxA DPyzG9jphZfWpgbVOB3HU/YzxgPJ0c+LzsOKCsoP17dI4I/5Va7YeDy+751xqBetzLjV aXK3EuTtHfMx82qzqx5H/Q9kgufaL8vOtUka9zyjgpsqVp6LjEfs/N1KmEMlaMn7vRS1 3fxmgFUnhas33dA5waGayskZCRF1cYMwnweruAbcsDOPH2Ltrz9yNG18omgsTZVHzP6e VCPDzOGmIOV2Tw8Tc6GlMuiDMOc8dpZr8CmkV0w6yOZL2zJm3/kah0Ndj9r0LGWFVyDE Kdqw== X-Gm-Message-State: AO0yUKUUGajYrBYE/z9ShYH+HF8EK0sDIvo//4tV1fGlbtUA8j/rwgag FQLtySlofhEfuUinyZ2z5fsTpQ== X-Google-Smtp-Source: AK7set8lV3Qtw70a9ky+eOgzFG00YBYwvd9fFWnYlMqkkOwH3u5x7jj9HhyKgtqvVbIPNs7maG344Q== X-Received: by 2002:adf:e343:0:b0:2c7:f56:285b with SMTP id n3-20020adfe343000000b002c70f56285bmr9946678wrj.63.1678196281789; Tue, 07 Mar 2023 05:38:01 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:38:01 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , =?utf-8?q?Niklas_S=C3=B6derlund?= , ye xingchen , Thierry Reding , linux-pm@vger.kernel.org (open list:THERMAL), linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 07/11] thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister Date: Tue, 7 Mar 2023 14:37:31 +0100 Message-Id: <20230307133735.90772-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver is using the devm_thermal_of_zone_device_register(). In the error path of the function calling devm_thermal_of_zone_device_register(), the function devm_thermal_of_zone_unregister() should be called instead of thermal_of_zone_unregister(), otherwise this one will be called twice when the device is freed. The same happens for the remove function where the devm_ guarantee the thermal_of_zone_unregister() will be called, so adding this call in the remove function will lead to a double free also. Use devm_ variant in the error path of the probe function. Remove thermal_of_zone_unregister() in the remove function. Cc: Florian Fainelli Cc: Ray Jui Cc: Scott Branden Signed-off-by: Daniel Lezcano --- drivers/thermal/broadcom/bcm2835_thermal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c index a217d832f24e..ea07152a6d0d 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -269,13 +269,13 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) */ err = thermal_add_hwmon_sysfs(tz); if (err) - goto err_tz; + goto err_clk; bcm2835_thermal_debugfs(pdev); return 0; err_tz: - thermal_of_zone_unregister(tz); + devm_thermal_of_zone_unregister(&pdev->dev, tz); err_clk: clk_disable_unprepare(data->clk); @@ -285,10 +285,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) static int bcm2835_thermal_remove(struct platform_device *pdev) { struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); - struct thermal_zone_device *tz = data->tz; debugfs_remove_recursive(data->debugfsdir); - thermal_of_zone_unregister(tz); clk_disable_unprepare(data->clk); return 0; From patchwork Tue Mar 7 13:37: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: 660364 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 8516FC678D5 for ; Tue, 7 Mar 2023 13:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjCGNiR (ORCPT ); Tue, 7 Mar 2023 08:38:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjCGNiL (ORCPT ); Tue, 7 Mar 2023 08:38:11 -0500 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 4A22F302B7 for ; Tue, 7 Mar 2023 05:38:04 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id h11so12146577wrm.5 for ; Tue, 07 Mar 2023 05:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196282; 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=XIQnAKa+Qd5OpVdv8Ipf7C/Ypn0D8rKAisdiD5QMAh0=; b=G4uhG+HEW8aKELDM9Sy8xcuArFEvPYHxeEkSAvAihRjKNrflmzusgFYLdZ6+RHVh5B NsN7nMiaQntRZ+1FEkyXzfHyTK8hS1ErM8pzN1kbfdkpSaDi4q6nj29PUGEPD+IPtrfs XIEDDn9ou1+JxDIwPIYD6WYKTwmJgij/up31knXXFZrb4YPWBMvTUBVU/UwOKtQUVfnm CreZ6KCGIcrnAb8Uuiop6VJzNyzydlhSZZ3Z6jHM6Di6BKWfsIs6poNUHrlABfLSUoDM 0dQafcbtghCvErUNVZ1FA+pke96IeRx1/xbNiBSA8/FhHP9VV3fJSVmIHpYHxfLVyl1F 4mmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196282; 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=XIQnAKa+Qd5OpVdv8Ipf7C/Ypn0D8rKAisdiD5QMAh0=; b=GUOaSuRosBVR11oR5A0WOUGnqjMvRBN7iYbHOMQmdhZ9SFs7GT9nTzbd5pA+Xky95y ouN7ghpfxYmT0BwXS2EUc39Sc0q8LSbjmSKJWUBsOdmmRzrefV/SaLPPnWaerMkGaRfK vwEIv217c8ylBZnDAtR47Dr9BnT3MvmcBT+t201W5ZVyLFsv/RFz/PI5pXZFP2Yq2yQV ophPtch9vpwV1TSH6gu8rvzM/c1YAujeWhhFF9047JOLoPkC6TDJLRqWSdb2HVvBxd08 Enlfeu4h+QBaslfebgQrO3U3X7a5+Zrj9kWDw1Wq8ZLOKj7vUNgxs7Ds8xXcOAk5BSWE 5Tyw== X-Gm-Message-State: AO0yUKVUqrhnclPSNz6qdHvprAxj9zAjvoEe2JE1yuZv2LXeaI33r/u1 oT+p5AXqHiQUpHNXCr934j9s89bZ/z5BbToAPes= X-Google-Smtp-Source: AK7set8fFI/JB2Jnnf1mxMvT9ESytvP5zxJQvQvFS2t55nzmCv96eO4scnTxq1vQ75sdSG/Kt0TaFg== X-Received: by 2002:a5d:4810:0:b0:2cb:c66d:6ac1 with SMTP id l16-20020a5d4810000000b002cbc66d6ac1mr8681462wrq.3.1678196282682; Tue, 07 Mar 2023 05:38:02 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:38:02 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 08/11] thermal/of: Unexport unused OF functions Date: Tue, 7 Mar 2023 14:37:32 +0100 Message-Id: <20230307133735.90772-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The functions thermal_of_zone_register() and thermal_of_zone_unregister() are no longer needed from the drivers as the devm_ variant is always used. Make them static in the C file and remove their declaration from thermal.h Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 8 +++----- include/linux/thermal.h | 17 ----------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index ff4d12ef51bc..6fb14e521197 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -439,7 +439,7 @@ static int thermal_of_unbind(struct thermal_zone_device *tz, * * @tz: a pointer to the thermal zone structure */ -void thermal_of_zone_unregister(struct thermal_zone_device *tz) +static void thermal_of_zone_unregister(struct thermal_zone_device *tz) { struct thermal_trip *trips = tz->trips; struct thermal_zone_params *tzp = tz->tzp; @@ -451,7 +451,6 @@ void thermal_of_zone_unregister(struct thermal_zone_device *tz) kfree(tzp); kfree(ops); } -EXPORT_SYMBOL_GPL(thermal_of_zone_unregister); /** * thermal_of_zone_register - Register a thermal zone with device node @@ -473,8 +472,8 @@ EXPORT_SYMBOL_GPL(thermal_of_zone_unregister); * - ENOMEM: if one structure can not be allocated * - Other negative errors are returned by the underlying called functions */ -struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, - const struct thermal_zone_device_ops *ops) +static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, + const struct thermal_zone_device_ops *ops) { struct thermal_zone_device *tz; struct thermal_trip *trips; @@ -550,7 +549,6 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(thermal_of_zone_register); static void devm_thermal_of_zone_release(struct device *dev, void *res) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index eb80cee4f64f..8cdf94cdc5ff 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -297,25 +297,12 @@ struct thermal_zone_params { /* Function declarations */ #ifdef CONFIG_THERMAL_OF -struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, - const struct thermal_zone_device_ops *ops); - struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, const struct thermal_zone_device_ops *ops); -void thermal_of_zone_unregister(struct thermal_zone_device *tz); - void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz); -void thermal_of_zone_unregister(struct thermal_zone_device *tz); - #else -static inline -struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, - const struct thermal_zone_device_ops *ops) -{ - return ERR_PTR(-ENOTSUPP); -} static inline struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, @@ -324,10 +311,6 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in return ERR_PTR(-ENOTSUPP); } -static inline void thermal_of_zone_unregister(struct thermal_zone_device *tz) -{ -} - static inline void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz) { From patchwork Tue Mar 7 13:37: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: 660901 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 CA1BAC6FD1B for ; Tue, 7 Mar 2023 13:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbjCGNiT (ORCPT ); Tue, 7 Mar 2023 08:38:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231147AbjCGNiM (ORCPT ); Tue, 7 Mar 2023 08:38:12 -0500 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 49CC611666 for ; Tue, 7 Mar 2023 05:38:04 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j2so12128282wrh.9 for ; Tue, 07 Mar 2023 05:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196283; 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=U8j4bJo1oZVc8oVRbgCLsTpymyaRowPacMWUlyxZyaA=; b=M+pDCn8yf+ZYz0M24b8vuev3cxkgCkT7t7+FWsP48E+EBPLbO5oHJz69sm7CpRRzI5 AbnzlqXMTSAOfze4yP5pEmF32IuLZlR6+gD7hlbfmmUnyv0leh8ayItqNRRnlP+53C2G 8QTKBOXoL58ihGEEdQ6Bsf3u6rw7kdWeRLBIXjWmRTsvYK8o/eq9yjjN7h5ekGP683EC CeHNoPRdbqxR9ILWERajpgbyg00Ks/UIKBwyX1KBbhWa+XC46HIKevd/tajORB43bXNC h3hGnrEI0h1kpKk9FhviJyB5pULyEUQu+AQRZyCDbsV+w7Grvv71nwL8I8ZX1XVYCnvs YLOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196283; 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=U8j4bJo1oZVc8oVRbgCLsTpymyaRowPacMWUlyxZyaA=; b=EhVmmZxwCCYjk8WZ1cv3bE72jAhoWdimr1AaGo958CiSH5EW6d0qcryzXezrBvlyjN eGnxEoz0P7+R8HMkMKW+QbfyXmV3uNg3R130ebzcgdS9HnUkOaH8zsSfpSKUgM+Iif// o5+EMjI278DNj1p7A2DYOU8JMoEU9i5BNFoDnDQr3yO09+JQwo55dAfiD4hVPLEjU7J0 Qj2JnbHUN9XYPBJhyCmPdCH+pF6YodF3NXDsxM6VRdxnd66HQwXCHMU0Ea2dS21b6787 fEHzcNUts35PS8ImBjTVweEGkoflKkvaS4zWulSvx7BGxmHMlRGGyQoqDFudmH2UE+VL fCUA== X-Gm-Message-State: AO0yUKWUAGZ4oi4+ad0iYTE92npJEUCrGgGLT5hA1X42s7GkDZokEjYp u8jSuXQioIkdJaJVKHIjHK0LjQ== X-Google-Smtp-Source: AK7set+uCREgdZyDrbl/tbTOC9EGTEAhWUZhLQ2zomC+C7qdM8BhdSDTWRbvqdAJqphUshGOdOlnBg== X-Received: by 2002:adf:df04:0:b0:2c7:1dc4:5c4e with SMTP id y4-20020adfdf04000000b002c71dc45c4emr10251708wrl.32.1678196283559; Tue, 07 Mar 2023 05:38:03 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:38:03 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 09/11] thermal/core: Add a linked device parameter Date: Tue, 7 Mar 2023 14:37:33 +0100 Message-Id: <20230307133735.90772-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Some drivers want to create a link from the thermal zone to the device sysfs entry and vice versa. That is the case of the APCI driver. Having a backpointer from the device to the thermal zone sounds akward as we can have the same device instantiating multiple thermal zones so there will be a conflict while creating the second link with the same name. Moreover, the userspace has enough information to build the dependency from the thermal zone device link without having this cyclic link from the device to thermal zone. Anyway, everything in its time. This change allows to create a these cyclic links tz <-> device as ACPI does and will allow to remove the code in the ACPI driver. The limitation of this change is there can be only a 1:1 relationship between the device and the thermal zone, otherwise the 'thermal_zone' link name will conflict with the previous link with the same name. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 16 ++++++++++++++++ include/linux/thermal.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cec72c6673a5..ca91189bc441 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1340,6 +1340,18 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t list_add_tail(&tz->node, &thermal_tz_list); mutex_unlock(&thermal_list_lock); + if (tzp && tzp->linked_dev) { + result = sysfs_create_link(&tzp->linked_dev->kobj, + &tz->device.kobj, "thermal_zone"); + if (result) + goto out_list_del; + + result = sysfs_create_link(&tz->device.kobj, + &tzp->linked_dev->kobj, "device"); + if (result) + goto out_del_link; + } + /* Bind cooling devices for this zone */ bind_tz(tz); @@ -1354,6 +1366,10 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t return tz; +out_del_link: + sysfs_remove_link(&tz->device.kobj, "thermal_zone"); +out_list_del: + list_del(&tz->node); unregister: device_del(&tz->device); release_device: diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 8cdf94cdc5ff..f60d7edf1e5d 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -256,6 +256,13 @@ struct thermal_zone_params { int num_tbps; /* Number of tbp entries */ struct thermal_bind_params *tbp; + /* + * @linked_dev: Add a cross link from the device to the + * thermal zone and vice versa. They will be named + * respectively 'device' and 'thermal_zone' + */ + struct device *linked_dev; + /* * Sustainable power (heat) that this thermal zone can dissipate in * mW From patchwork Tue Mar 7 13:37: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: 660363 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 5D6EDC678D4 for ; Tue, 7 Mar 2023 13:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbjCGNiV (ORCPT ); Tue, 7 Mar 2023 08:38:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231166AbjCGNiM (ORCPT ); Tue, 7 Mar 2023 08:38:12 -0500 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 E27DF3646D for ; Tue, 7 Mar 2023 05:38:04 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id f11so12137238wrv.8 for ; Tue, 07 Mar 2023 05:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678196284; 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=8U/QSyAheawCOnLmWTGKUDR8tl2aMMA2m4dtkvqkUZc=; b=GR6ZQlXqA5cqbeBm2gQcshttPTPWd+AO20+ha+UgpBnbdoF57VHEazFHgSYJbPDU7h jbJKY7pNig8f1vgtG5FHV7ImJRpzSHWX9XGcBv2zacGJDfGl0h0f7/47LutUsYIfiK6x jqQiM3SCII7ftweKSw2deYgPSj7CfP6cs82rGAgVQWVwcQYXbGwYzCS6orzKGRK9CsxW 0/KpHJXqXSaqZ2NRrumfb5XowjkTAdqEgpM8ApxlZrPCG8lodXqqoNSOskqX8n+DCJgH YX1wsWuEkmda/NWDY8dYOn4EJcAt6mLtao7N/IYPFmZwBVSXNe1BTjnml4WooEhfTJrv 8Hog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678196284; 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=8U/QSyAheawCOnLmWTGKUDR8tl2aMMA2m4dtkvqkUZc=; b=2z1ipM8QX2NdF7M6APALBhSbJDqmssuPuWXEZX02FVmCPwuLY2hYCSWsXcxqrAcw3P sux7EzsmXseNiYE+5W7v2tqfLa7oGB6NiCNypBsjuyVyfvz95Eg8jDEMc+gI34sE+4aN sYDP1cySZkEC6BLHybsvNuM1rt4ZGXIjNDXd/g1K4aP0wyU4zvrzkRnDO6Pvkhcw1wUo j3eeH639jgfnVXRZuWv2lsYI5oBRbwy4Cwgk3x3P2TtLV2L52nYzTOzsH9daizi7Qwys RU0tC06XBb6oJx5fFzc2YPIkP8eev2bLZbLyO3vn4kTsZDterxnvIOX0KCxysLJmH0L8 Gpxw== X-Gm-Message-State: AO0yUKVycc3SzaChw+o0iZT2o/uODiaqJ5nkUaVFcI4AOUB0EpALE34B Au7wyhSkYECsNapTMIqN/i4jQw== X-Google-Smtp-Source: AK7set8oVcooSVgCWWdmxDWpuyEd2Z3jvnRJ2CeM+7+8qMqBJQHNlAg09K5E7c9EClzqOD8fHohQ1Q== X-Received: by 2002:adf:e74a:0:b0:2c7:efb:dded with SMTP id c10-20020adfe74a000000b002c70efbddedmr10591530wrn.24.1678196284325; Tue, 07 Mar 2023 05:38:04 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:5ab9:1ac6:870d:35c]) by smtp.gmail.com with ESMTPSA id v5-20020a5d43c5000000b002c55de1c72bsm12311477wrr.62.2023.03.07.05.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 05:38:04 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, amitk@kernel.org, linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 10/11] thermal/core: Alloc-copy-free the thermal zone parameters structure Date: Tue, 7 Mar 2023 14:37:34 +0100 Message-Id: <20230307133735.90772-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307133735.90772-1-daniel.lezcano@linaro.org> References: <20230307133735.90772-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The caller of the function thermal_zone_device_register_with_trips() can pass a thermal_zone_params structure parameter. This one is used by the thermal core code until the thermal zone is destroyed. That forces the caller, so the driver, to keep the pointer valid until it unregisters the thermal zone if we want to make the thermal zone device structure private the core code. As the thermal zone device structure would be private, the driver can not access to thermal zone device structure to retrieve the tzp field after it passed it to register the thermal zone. So instead of forcing the users of the function to deal with the tzp structure life cycle, make the usage easier by allocating our own thermal zone params, copying the parameter content and by freeing at unregister time. The user can then create the parameters on the stack, pass it to the registering function and forget about it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index ca91189bc441..6cbda8f4522e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1263,13 +1263,19 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t if (!tz) return ERR_PTR(-ENOMEM); + if (tzp) { + tz->tzp = kmemdup(tzp, sizeof(*tzp), GFP_KERNEL); + if (!tz->tzp) + goto free_tz; + } + INIT_LIST_HEAD(&tz->thermal_instances); ida_init(&tz->ida); mutex_init(&tz->lock); id = ida_alloc(&thermal_tz_ida, GFP_KERNEL); if (id < 0) { result = id; - goto free_tz; + goto free_tzp; } tz->id = id; @@ -1279,7 +1285,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ops->critical = thermal_zone_device_critical; tz->ops = ops; - tz->tzp = tzp; tz->device.class = thermal_class; tz->devdata = devdata; tz->trips = trips; @@ -1377,6 +1382,8 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t tz = NULL; remove_id: ida_free(&thermal_tz_ida, id); +free_tzp: + kfree(tz->tzp); free_tz: kfree(tz); return ERR_PTR(result); @@ -1472,6 +1479,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) device_del(&tz->device); mutex_unlock(&tz->lock); + kfree(tzp); + put_device(&tz->device); thermal_notify_tz_delete(tz_id);