From patchwork Thu Aug 10 19:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 712502 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 48A4BC41513 for ; Thu, 10 Aug 2023 19:17:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236367AbjHJTR5 (ORCPT ); Thu, 10 Aug 2023 15:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236340AbjHJTR4 (ORCPT ); Thu, 10 Aug 2023 15:17:56 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49FA2271E; Thu, 10 Aug 2023 12:17:50 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id e9d51f748be1c126; Thu, 10 Aug 2023 21:17:48 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 5BB11662742; Thu, 10 Aug 2023 21:17:48 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 1/7] thermal: intel: intel_soc_dts_iosf: Always assume notification support Date: Thu, 10 Aug 2023 21:09:54 +0200 Message-ID: <4864678.31r3eYUQgx@kreacher> In-Reply-To: <5713357.DvuYhMxLoT@kreacher> References: <5713357.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrleeigddufeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdp rhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Rafael J. Wysocki None of the existing callers of intel_soc_dts_iosf_init() passes INTEL_SOC_DTS_INTERRUPT_NONE as the first argument to it, so the notification local variable in it is always true and the notification_support argument of add_dts_thermal_zone() is always true either. For this reason, drop the notification local variable from intel_soc_dts_iosf_init() and the notification_support argument from add_dts_thermal_zone() and rearrange the latter to always set writable_trip_cnt and trip_mask. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -247,12 +247,12 @@ static void remove_dts_thermal_zone(stru } static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, - bool notification_support, int read_only_trip_cnt) + int read_only_trip_cnt) { char name[10]; unsigned long trip; - int trip_mask = 0; - int writable_trip_cnt = 0; + int writable_trip_cnt; + int trip_mask; unsigned long ptps; u32 store_ptps; unsigned long i; @@ -265,10 +265,9 @@ static int add_dts_thermal_zone(int id, goto err_ret; dts->id = id; - if (notification_support) { - writable_trip_cnt = SOC_MAX_DTS_TRIPS - read_only_trip_cnt; - trip_mask = GENMASK(writable_trip_cnt - 1, 0); - } + + writable_trip_cnt = SOC_MAX_DTS_TRIPS - read_only_trip_cnt; + trip_mask = GENMASK(writable_trip_cnt - 1, 0); /* Check if the writable trip we provide is not used by BIOS */ ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, @@ -364,7 +363,6 @@ struct intel_soc_dts_sensors *intel_soc_ enum intel_soc_dts_interrupt_type intr_type, int read_only_trip_count) { struct intel_soc_dts_sensors *sensors; - bool notification; int tj_max; int ret; int i; @@ -387,14 +385,11 @@ struct intel_soc_dts_sensors *intel_soc_ mutex_init(&sensors->dts_update_lock); sensors->intr_type = intr_type; sensors->tj_max = tj_max * 1000; - if (intr_type == INTEL_SOC_DTS_INTERRUPT_NONE) - notification = false; - else - notification = true; + for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { sensors->soc_dts[i].sensors = sensors; ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], - notification, read_only_trip_count); + read_only_trip_count); if (ret) goto err_free; } From patchwork Thu Aug 10 19:12:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 712503 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 0E924C001E0 for ; Thu, 10 Aug 2023 19:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236356AbjHJTR4 (ORCPT ); Thu, 10 Aug 2023 15:17:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236323AbjHJTRt (ORCPT ); Thu, 10 Aug 2023 15:17:49 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D085D2702; Thu, 10 Aug 2023 12:17:48 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 29b733ff90bc66d8; Thu, 10 Aug 2023 21:17:47 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id E1D4F662742; Thu, 10 Aug 2023 21:17:46 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 3/7] thermal: intel: intel_soc_dts_iosf: Pass sensors to update_trip_temp() Date: Thu, 10 Aug 2023 21:12:32 +0200 Message-ID: <1874380.tdWV9SEqCh@kreacher> In-Reply-To: <5713357.DvuYhMxLoT@kreacher> References: <5713357.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrleeigddufeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdp rhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Rafael J. Wysocki After previous changes, update_trip_temp() only uses its dts argument to get to the sensors field in the struct intel_soc_dts_sensor_entry object pointed to by that argument, so pass the value of that field directly to it instead. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -66,7 +66,7 @@ static int sys_get_trip_temp(struct ther return 0; } -static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts, +static int update_trip_temp(struct intel_soc_dts_sensors *sensors, int thres_index, int temp) { int status; @@ -78,7 +78,6 @@ static int update_trip_temp(struct intel u32 store_te_out; u32 te_out; u32 int_enable_bit = SOC_DTS_TE_APICA_ENABLE; - struct intel_soc_dts_sensors *sensors = dts->sensors; if (sensors->intr_type == INTEL_SOC_DTS_INTERRUPT_MSI) int_enable_bit |= SOC_DTS_TE_MSI_ENABLE; @@ -162,7 +161,7 @@ static int configure_trip(struct intel_s { int ret; - ret = update_trip_temp(dts, thres_index, temp); + ret = update_trip_temp(dts->sensors, thres_index, temp); if (ret) return ret; @@ -182,7 +181,7 @@ static int sys_set_trip_temp(struct ther return -EINVAL; mutex_lock(&sensors->dts_update_lock); - status = update_trip_temp(dts, trip, temp); + status = update_trip_temp(sensors, trip, temp); mutex_unlock(&sensors->dts_update_lock); return status; From patchwork Thu Aug 10 19:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 712504 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 6B247C04A6A for ; Thu, 10 Aug 2023 19:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236318AbjHJTRt (ORCPT ); Thu, 10 Aug 2023 15:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236309AbjHJTRs (ORCPT ); Thu, 10 Aug 2023 15:17:48 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 843442702; Thu, 10 Aug 2023 12:17:47 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id c27bbe5e6baaffc0; Thu, 10 Aug 2023 21:17:46 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 8591E662742; Thu, 10 Aug 2023 21:17:45 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 5/7] thermal: intel: intel_soc_dts_iosf: Add helper for resetting trip points Date: Thu, 10 Aug 2023 21:14:49 +0200 Message-ID: <3258210.aeNJFYEL58@kreacher> In-Reply-To: <5713357.DvuYhMxLoT@kreacher> References: <5713357.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrleeigddufeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdp rhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Rafael J. Wysocki Because trip points are reset for each sensor in two places in the same way, add a helper function for that to reduce code duplication a bit. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -369,6 +369,12 @@ void intel_soc_dts_iosf_interrupt_handle } EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_interrupt_handler); +static void dts_trips_reset(struct intel_soc_dts_sensors *sensors, int dts_index) +{ + configure_trip(&sensors->soc_dts[dts_index], 0, 0, 0); + configure_trip(&sensors->soc_dts[dts_index], 1, 0, 0); +} + struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( enum intel_soc_dts_interrupt_type intr_type, int read_only_trip_count) { @@ -424,10 +430,8 @@ err_remove_zone: remove_dts_thermal_zone(&sensors->soc_dts[i]); err_reset_trips: - for (i = 0; i < SOC_MAX_DTS_SENSORS; i++) { - configure_trip(&sensors->soc_dts[i], 0, 0, 0); - configure_trip(&sensors->soc_dts[i], 1, 0, 0); - } + for (i = 0; i < SOC_MAX_DTS_SENSORS; i++) + dts_trips_reset(sensors, i); kfree(sensors); return ERR_PTR(ret); @@ -440,8 +444,7 @@ void intel_soc_dts_iosf_exit(struct inte for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { remove_dts_thermal_zone(&sensors->soc_dts[i]); - configure_trip(&sensors->soc_dts[i], 0, 0, 0); - configure_trip(&sensors->soc_dts[i], 1, 0, 0); + dts_trips_reset(sensors, i); } kfree(sensors); } From patchwork Thu Aug 10 19:17:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 712505 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 433FEC001E0 for ; Thu, 10 Aug 2023 19:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbjHJTRr (ORCPT ); Thu, 10 Aug 2023 15:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235884AbjHJTRq (ORCPT ); Thu, 10 Aug 2023 15:17:46 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D7A2702; Thu, 10 Aug 2023 12:17:45 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id ff766902256c742a; Thu, 10 Aug 2023 21:17:44 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 0FBD1662742; Thu, 10 Aug 2023 21:17:44 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 7/7] thermal: intel: intel_soc_dts_iosf: Use struct thermal_trip Date: Thu, 10 Aug 2023 21:17:36 +0200 Message-ID: <2249203.iZASKD2KPV@kreacher> In-Reply-To: <5713357.DvuYhMxLoT@kreacher> References: <5713357.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrleeigddufeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdp rhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Rafael J. Wysocki Because the number of trip points in each thermal zone and their types are known to intel_soc_dts_iosf_init() prior to the registration of the thermal zones, make it create an array of struct thermal_trip entries in each struct intel_soc_dts_sensor_entry object and make add_dts_thermal_zone() use thermal_zone_device_register_with_trips() for thermal zone registration and pass that array as its second argument. Drop the sys_get_trip_temp() and sys_get_trip_type() callback functions along with the respective callback pointers in tzone_ops, because they are not necessary any more. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 51 +++-------------------------- drivers/thermal/intel/intel_soc_dts_iosf.h | 2 - 2 files changed, 8 insertions(+), 45 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.h =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.h +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.h @@ -29,7 +29,7 @@ struct intel_soc_dts_sensor_entry { int id; u32 store_status; u32 trip_mask; - enum thermal_trip_type trip_types[SOC_MAX_DTS_TRIPS]; + struct thermal_trip trips[SOC_MAX_DTS_TRIPS]; struct thermal_zone_device *tzone; struct intel_soc_dts_sensors *sensors; }; Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -40,32 +40,6 @@ /* Mask for two trips in status bits */ #define SOC_DTS_TRIP_MASK 0x03 -static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip, - int *temp) -{ - int status; - u32 out; - struct intel_soc_dts_sensor_entry *dts; - struct intel_soc_dts_sensors *sensors; - - dts = thermal_zone_device_priv(tzd); - sensors = dts->sensors; - mutex_lock(&sensors->dts_update_lock); - status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, - SOC_DTS_OFFSET_PTPS, &out); - mutex_unlock(&sensors->dts_update_lock); - if (status) - return status; - - out = (out >> (trip * 8)) & SOC_DTS_TJMAX_ENCODING; - if (!out) - *temp = 0; - else - *temp = sensors->tj_max - out * 1000; - - return 0; -} - static int update_trip_temp(struct intel_soc_dts_sensors *sensors, int thres_index, int temp) { @@ -165,7 +139,8 @@ static int configure_trip(struct intel_s if (ret) return ret; - dts->trip_types[thres_index] = trip_type; + dts->trips[thres_index].temperature = temp; + dts->trips[thres_index].type = trip_type; return 0; } @@ -187,16 +162,6 @@ static int sys_set_trip_temp(struct ther return status; } -static int sys_get_trip_type(struct thermal_zone_device *tzd, - int trip, enum thermal_trip_type *type) -{ - struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd); - - *type = dts->trip_types[trip]; - - return 0; -} - static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) { @@ -221,8 +186,6 @@ static int sys_get_curr_temp(struct ther static struct thermal_zone_device_ops tzone_ops = { .get_temp = sys_get_curr_temp, - .get_trip_temp = sys_get_trip_temp, - .get_trip_type = sys_get_trip_type, .set_trip_temp = sys_set_trip_temp, }; @@ -293,11 +256,11 @@ static int add_dts_thermal_zone(int id, } dts->trip_mask = trip_mask; snprintf(name, sizeof(name), "soc_dts%d", id); - dts->tzone = thermal_zone_device_register(name, - SOC_MAX_DTS_TRIPS, - trip_mask, - dts, &tzone_ops, - NULL, 0, 0); + dts->tzone = thermal_zone_device_register_with_trips(name, dts->trips, + SOC_MAX_DTS_TRIPS, + trip_mask, + dts, &tzone_ops, + NULL, 0, 0); if (IS_ERR(dts->tzone)) { ret = PTR_ERR(dts->tzone); goto err_ret;