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: 134204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp649781vqi; Thu, 10 Aug 2023 12:55:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFx7PW+ERN2Jp7Xn9TqqvFfeXKcxJ2n+Y2EiUGbOwgf/C5aqV1lIJPSOAmj8PMIZsBcyh2Y X-Received: by 2002:a05:6402:1846:b0:523:406a:5f6 with SMTP id v6-20020a056402184600b00523406a05f6mr7496edy.12.1691697308825; Thu, 10 Aug 2023 12:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691697308; cv=none; d=google.com; s=arc-20160816; b=O7iTqjKB78qDGFLHV/bOzU+7h+Rb0XbyK+v7kPiJfTyAA0r4i7nKjKHdi6dCnEHSfG jNzvxUN5x6EOKBsRWP2BMymUC5wHGyRrEl1YlSvo9sAUvz2yz0ybYjy+2ladDbmeRwvh wUEHJ63VmeRHjQwJS/GZweItNa0s8D7+vh1YJxQyQ/NLOuDqHg/zUWPQOgsM/1KUaqri 2z5X0zAQKm/TrCE2MY6eSezUNRx7umerPOyU6OvBkputCkvLeVHpLzGHh8OV4Zz281jd +LZrGV96lYtoH2ncOFAXg6bimowSNLEt0KuGMSXpj/qbWY5s8ZW0Qa5RNhsv4R5aySld dAYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=havrLkioI+kZxpQoV/J+Hvd1ZRA2vwjsEMOwli/+W5c=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=I89ct4HdYiJbiZjeeQjKBAnjIk7tPbiy9hp2GopljXxRwV4Knypk1+bN3IeJnO1JZA SSTzPBryDpOrElPsmRVe5hPWmPXCCWP1YBK8jS6jVQDgg+NrpTTSaaTMhuMabdkCYDJY X4krciRlb+z1RsVncOrNFSq7qYBZHwXvLiIirFn1SihjzgHCUfxHJqjC2kQCKKERqGJg c+Z+IHQFkchU6H3bcxKmAH7Nz8+rfs1zV3V3rtVszvOKRhxsL8+h7Ny791O45BHNFbgf Aj8qHFX91nnsTmdARGpInBm8pio2Fm5CDANT3WLVvz7NYtBwn23FHe0LTMweiQ1ujveX Jwzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020aa7cf17000000b005231425d183si2140187edy.216.2023.08.10.12.54.44; Thu, 10 Aug 2023 12:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236393AbjHJTSC (ORCPT + 99 others); Thu, 10 Aug 2023 15:18:02 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773873197238758406 X-GMAIL-MSGID: 1773873197238758406 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:11:26 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: 134197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp647741vqi; Thu, 10 Aug 2023 12:50:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGusK5iJMVpuLxtCaydJNVK7XBrV1ERzWIogNwnsscFT0u1RXNawKlGAQLX63gpZghB0Pt3 X-Received: by 2002:aa7:d3d8:0:b0:523:c5ff:729f with SMTP id o24-20020aa7d3d8000000b00523c5ff729fmr2002edr.6.1691697036992; Thu, 10 Aug 2023 12:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691697036; cv=none; d=google.com; s=arc-20160816; b=floqp5bdVnWCvzomALvJO7LJommoOO5mmYZZ2Xqd97HZyEW0dqpk15D0ZM23uQhagU lygJ6lsJiuPiKMthZ9ON+Rrx+ivounO7F0CXNuqwnkawqvUkThxUOUoyW1b908YuyeJ/ RLe/OxX0ORtHXeVGC35RU7BWbNbzKf10A/gUQGBCuw5uovpPDgruJJbM036lVp+rRbeR qC/TBhaTk0YbmwtxfOPI871oiV7e0AvVFGCurWzb+QmpJSTu8czXtwDYBOC28v//3JXf CU8O9PTvF/vuyCan4J8o8rGxwp/yYjrGpEGxPR18Mlr27/cGExa8qZ5TD1u/JSSJIpwS txlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=x2JkrTnEPr8oVZH47pfxATk47HBJlQxuCL+KddofBtc=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=xPB4BfPQeireA7U0Z/gjT/DnKi4heg6TTTE4uYh5rg5bhXN0VX4Uc8Ohj9PbIz2smw c1MXmnwear+IJVXJEaQDPERsE9cSc/hwIBd0styQtynr/0vjmbBvMYUE0A8M2vK6X+Zm SMcl+t169ujALN/Ra80qjuaD2gvs3kimkjiBc2ICI+UTBuBd3KJahfbEbdPqCJoHwHAL ZPwlKThSKrlufg/l0lp2KPUjX+q+1ibFqbV6IEmbDaH+gx0uObAJh05HFWzLHE5y7ac7 Af7vWAwOaHFbZMIa6JKNlWjFQ8pxuGEp56Dsdf7OIkFsaSGnls00AKEdbdthKWCjvqvk +upA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r5-20020aa7c145000000b00522b10235f3si1921544edp.163.2023.08.10.12.50.13; Thu, 10 Aug 2023 12:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjHJTSB (ORCPT + 99 others); Thu, 10 Aug 2023 15:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235315AbjHJTRu (ORCPT ); Thu, 10 Aug 2023 15:17:50 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 966712717; Thu, 10 Aug 2023 12:17:49 -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 00465989895b177a; 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 A98FB662742; Thu, 10 Aug 2023 21:17:47 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 2/7] thermal: intel: intel_soc_dts_iosf: Untangle update_trip_temp() Date: Thu, 10 Aug 2023 21:11:26 +0200 Message-ID: <2306583.ElGaqSPkdT@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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773872912407732902 X-GMAIL-MSGID: 1773872912407732902 From: Rafael J. Wysocki Function update_trip_temp() is currently used for the initialization of trip points as well as for changing trip point temperatures in sys_set_trip_temp(). This is quite confusing and passing the value of dts->trip_types[trip] to it so that it can store that value in the same memory location is not particularly useful, because it only is necessary to set the trip point type once, at the initialization time. For this reason, drop the last argument from update_trip_temp() and introduce configure_trip() calling the former internally for the initial configuration of trip points. Modify the majority of update_trip_temp() callers to use configure_trip() instead of it. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 37 ++++++++++++++++++----------- 1 file changed, 24 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 @@ -67,8 +67,7 @@ static int sys_get_trip_temp(struct ther } static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts, - int thres_index, int temp, - enum thermal_trip_type trip_type) + int thres_index, int temp) { int status; u32 temp_out; @@ -142,8 +141,6 @@ static int update_trip_temp(struct intel if (status) goto err_restore_te_out; - dts->trip_types[thres_index] = trip_type; - return 0; err_restore_te_out: iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, @@ -159,6 +156,21 @@ err_restore_ptps: return status; } +static int configure_trip(struct intel_soc_dts_sensor_entry *dts, + int thres_index, enum thermal_trip_type trip_type, + int temp) +{ + int ret; + + ret = update_trip_temp(dts, thres_index, temp); + if (ret) + return ret; + + dts->trip_types[thres_index] = trip_type; + + return 0; +} + static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { @@ -170,8 +182,7 @@ static int sys_set_trip_temp(struct ther return -EINVAL; mutex_lock(&sensors->dts_update_lock); - status = update_trip_temp(dts, trip, temp, - dts->trip_types[trip]); + status = update_trip_temp(dts, trip, temp); mutex_unlock(&sensors->dts_update_lock); return status; @@ -317,7 +328,7 @@ int intel_soc_dts_iosf_add_read_only_cri j = find_first_zero_bit(&mask, SOC_MAX_DTS_TRIPS); if (j < SOC_MAX_DTS_TRIPS) - return update_trip_temp(entry, j, temp, THERMAL_TRIP_CRITICAL); + return configure_trip(entry, j, THERMAL_TRIP_CRITICAL, temp); } return -EINVAL; @@ -395,13 +406,13 @@ struct intel_soc_dts_sensors *intel_soc_ } for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { - ret = update_trip_temp(&sensors->soc_dts[i], 0, 0, - THERMAL_TRIP_PASSIVE); + ret = configure_trip(&sensors->soc_dts[i], 0, + THERMAL_TRIP_PASSIVE, 0); if (ret) goto err_remove_zone; - ret = update_trip_temp(&sensors->soc_dts[i], 1, 0, - THERMAL_TRIP_PASSIVE); + ret = configure_trip(&sensors->soc_dts[i], 1, + THERMAL_TRIP_PASSIVE, 0); if (ret) goto err_remove_zone; } @@ -422,8 +433,8 @@ void intel_soc_dts_iosf_exit(struct inte int i; for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { - update_trip_temp(&sensors->soc_dts[i], 0, 0, 0); - update_trip_temp(&sensors->soc_dts[i], 1, 0, 0); + configure_trip(&sensors->soc_dts[i], 0, 0, 0); + configure_trip(&sensors->soc_dts[i], 1, 0, 0); remove_dts_thermal_zone(&sensors->soc_dts[i]); } kfree(sensors); 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: 134184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp637198vqi; Thu, 10 Aug 2023 12:28:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8AawklVyaXF6Mbpmy5UmgzUQazYOYkwzZh3DRtF8cqF4nCDI3SvgoORHg3JDzsJBV5az4 X-Received: by 2002:a17:907:2ccf:b0:993:f349:c98c with SMTP id hg15-20020a1709072ccf00b00993f349c98cmr2742537ejc.4.1691695680758; Thu, 10 Aug 2023 12:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691695680; cv=none; d=google.com; s=arc-20160816; b=a3ogJTOmG7qAeIgL0ZKQ77SdhN+n1BEOKOV1Vcn9QgbazEc6gm7/jfgOm28v4/VoLy 8Twf9k9tYhsuXCf4etgAKavBJj95xNnebu/L2+mvAfaXc1IYUV4ftRCatlUVrEd0if59 pmXvQwkl+fLYHSM/HHesjZgSvGOdZrnSSpR1ocdc1S8Fl+dxsyi7g3cpapxYnCvDo4+o G0akCnF5FLZnHGlA+J6Go+QCOjdv+miUTYE/irtnmqnpoxgtls5rv2AgIB0O20hElqz2 CFBRFuXisrHDsO8WXvqCQxtpYYcaYMA+SUhoFmwam72IO5PJaBQ6gSQCMQFZ3r9HHEjD WSyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=a127CFoSdsMJrWdM6IhZeIGPCxNlNiewdOe0Q6RLrsE=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=RQUQNRjZMG7BPq0fzuQkzDpQdEGWalXTSgpkbgPT3zD57FM41JYvBn9R7LK8u3CoPS 1hR+edU+IIYlpQ5aVQOiPfW2+npPw0Jarj+Z/BVyI82m/WvvtX1Ex0iFZmF2XYfDTXgr l9pqGbDXs27gUhKiBbyb0/T/HBLgG7dGxWZl3fvR2bCUmPK7NQGdDRaZSXjzofND8dJy m74GGxtUglyw4MHDL2uDryMvxDo3VOhvN/xjy6kZPxEzt0F0YUr/JutLzbIzptUbig4T bO5TkXVIvadix5ghfG+/GueUo0LM/XPlyXpa6lIdADBiKTIKF5TKpU9o6g0/ciEYgl3Q LixA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a17090608c300b0099331b3e6f6si1735364eje.661.2023.08.10.12.27.36; Thu, 10 Aug 2023 12:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236368AbjHJTR5 (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:57 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773871490364606879 X-GMAIL-MSGID: 1773871490364606879 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:13:25 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: 134199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp647962vqi; Thu, 10 Aug 2023 12:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhlXG+EneVZZOKijHxkfUFroEoRUKv0Ph1bO1wy+OAruZhcREjwtExMj7RxqBrI9HkuztM X-Received: by 2002:a2e:98ca:0:b0:2b7:2ea:33c3 with SMTP id s10-20020a2e98ca000000b002b702ea33c3mr9360ljj.22.1691697069558; Thu, 10 Aug 2023 12:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691697069; cv=none; d=google.com; s=arc-20160816; b=UM8WqxA5kKBXenSilZdFsLEonMMG1F1Kenk3ZNWC0GUGG9kw47hGUMO5KLhADakJeg A4gvodfIMvuQB5JepsW5DvbIpcO4EujmHdJGDGK54E3etzWo3mrf6YjDBPgyGfJKiDjy Hni7nrIdKs1GyxGQqZ8e9c5P8GqJQ2Y5bSUvjlUdgpjBW6gIFTMrupGfg9nc0yeXbG2X hFB/zW7kc8x8Shp0kX0grWAeVGvH9CTcczHsCMMyC7cZAHeXpRtV/1W7wOvSnrja2Gv7 thb3ODp+FM2HHndB9Ajz3wi0giGza371ZtAtMMJwPL5HlE6PJ7epE3yXPWoyhIqYNpoC E6QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JE+qceskLV8uSBGMVJM6XhYt5LJ6L9wx/CFgJ3Rp27o=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=dNTEfNFfrjg2lGvKiah/KngGfvWr8YECmLr5zPcWfaIIdzJy7m7KW+ZvMM+YU0IoIZ jm0kLwNiom1O9cv/Mq3AuvphLPj09+b+sEe2cg2oh1Dq+Q9QPjX/esyeUnS9BIzFdVJZ vpFqmkh5EwHBoPy/zAGFBnzq7nhS7sP5QiC8m6IK/9qauwTSmSOwQ1XExx+xEJ+jyUM/ GdABzpfHqlIjyYEvWP2js8T15qOyJVTaCbxfcawaGrfQWgo/7FKT8ADHpBtSZzK3+Pdo 6c+CFQ0MNSgF/LH8fxxrGQRporDREGy3bU3RsUx1lwnxsGQ1Cq5RIDsCbjrK97P6jIsX pOhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a17090633d600b00992d26308c0si2001144eja.538.2023.08.10.12.50.45; Thu, 10 Aug 2023 12:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236338AbjHJTRz (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbjHJTRs (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 2A9DE271E; 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 956638716e953904; 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 37BD2662742; 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 4/7] thermal: intel: intel_soc_dts_iosf: Change initialization ordering Date: Thu, 10 Aug 2023 21:13:25 +0200 Message-ID: <13337847.uLZWGnKmhe@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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773872946208706189 X-GMAIL-MSGID: 1773872946208706189 From: Rafael J. Wysocki The initial configuration of trip points in intel_soc_dts_iosf_init() takes place after registering the sensor thermal zones which is potentially problematic, because it may race with the setting of trip point temperatures via sysfs, as there is no synchronization between it and sys_set_trip_temp(). To address this, change the initialization ordering so that the trip points are configured prior to the registration of thermal zones. Accordingly, change the cleanup ordering in intel_soc_dts_iosf_exit() to remove the thermal zones before resetting the trip points. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 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 @@ -398,30 +398,37 @@ struct intel_soc_dts_sensors *intel_soc_ 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], - read_only_trip_count); - if (ret) - goto err_free; - } - for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { ret = configure_trip(&sensors->soc_dts[i], 0, THERMAL_TRIP_PASSIVE, 0); if (ret) - goto err_remove_zone; + goto err_reset_trips; ret = configure_trip(&sensors->soc_dts[i], 1, THERMAL_TRIP_PASSIVE, 0); if (ret) + goto err_reset_trips; + } + + for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { + ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], + read_only_trip_count); + if (ret) goto err_remove_zone; } return sensors; + err_remove_zone: for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) remove_dts_thermal_zone(&sensors->soc_dts[i]); -err_free: +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); + } + kfree(sensors); return ERR_PTR(ret); } @@ -432,9 +439,9 @@ void intel_soc_dts_iosf_exit(struct inte int i; 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); - remove_dts_thermal_zone(&sensors->soc_dts[i]); } kfree(sensors); } 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: 134210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp654380vqi; Thu, 10 Aug 2023 13:02:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxN/oLpbodHUoH1z2S45bmg5rnKx3T1VZKV+BANqyFlO6mqaG3akE3wkI1NS6091KN5umD X-Received: by 2002:a05:6402:799:b0:51d:95f2:ee76 with SMTP id d25-20020a056402079900b0051d95f2ee76mr11999edy.27.1691697765621; Thu, 10 Aug 2023 13:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691697765; cv=none; d=google.com; s=arc-20160816; b=hvdOrZuBs3moMZUnf/DlMIJqsln+UnPmjJfuL+m5EsOByqHu95fNduq27ujFWbZVGL 58iCVG5ZNmVn7Z6irqUxlVKjqktArmGmEkmZuMP2uVNjk905P4uSGfdspXd347GoH9Ln YdoKHjSIe/KfCgl3TqEmFFF7WIvXdRLNnTZFDo5+lOr+n6+S3ip9HgQ3m0goLKpWfNGc wUUdh7RdPO1GTjMxsSnIq712I/faDmuhlM41dw6gjAhMl2iqhn3Fmu13j0b8yKd5MCNF x0T5zUdSi/ZplHkXA3Gqpjz+7kBtaOzei2fsKBvZUk03OCn4wP2xa+bCI9TayRXZQn9u l1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZhzALKAeB+WpQCdXbMENj9FqdnE4p8jmSZS4rEeDous=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=guDW3F1vVCOwl1UqvAfAJoIHcDq8ZuHmG1KglhQrg21p1Mdos0WDayYFWrRDTQUHe9 FPiKMKLbttauN77qLG7b83CemzSc2fLvk5oFiGT2jQHP3pevx+094ZhlZ4cZ3l67mQ9b 0HVEFL/dVj1YQ7JOgE35NGGBKKtwwuEi+x9RzX2mCc5qnOU8cNVYGFRymP8qL/w9MsXj GqaqIGVvdsPykdahyeutrmHeJ706TK4tksC8xJBrHFE0Bkjv6gh+tSRSAv7MmxBJnzBk Wc14y0jVUA8GqliLNMqn8RZF7SNrBC7CoUqIel+x4WTfPXwiv/ozDQGTpItOn5w5gby/ J2BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a056402185400b005231db4d83csi2053720edy.245.2023.08.10.13.02.21; Thu, 10 Aug 2023 13:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236334AbjHJTRv (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:51 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773873676510117424 X-GMAIL-MSGID: 1773873676510117424 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:16:14 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: 134203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp649077vqi; Thu, 10 Aug 2023 12:53:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtKp2n3ylARnlC2bV09Spi08Q/ZgTsivv6J09hvn7V1jCNm5vPQh2CA57gzHyr8EwJpb7l X-Received: by 2002:aa7:ccce:0:b0:523:1f33:cf9 with SMTP id y14-20020aa7ccce000000b005231f330cf9mr2890648edt.25.1691697217956; Thu, 10 Aug 2023 12:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691697217; cv=none; d=google.com; s=arc-20160816; b=U7vhV+rG3Z+vch2+iN5wknTkWTZOItdS4AO51gwcKZuWZCDZs1hdbjYEuEyXTEUyzc 6Mnh+I0oWBF/aRqgx73SOrkSWBQrxT9uXs+k47YWG4w/OgnwbaAdRlE/gOZ1flBoy5OW Izdppa1oCNucAJ8MTeRWPivU3N818Mc5uMzriasU9DpgxkrBrJ7J6JxjOgbzPjr1nQZD 2NXYY3MOXylIDr967sHpW7U9+RlS+4sg8eue1ToTMQGY4VPRJSJmycLgaUqry9boGsAm mhdj/p5dGnLtjKvZZywat32b6+Og2RZQbVaQ3JQzVtI6r8ds2YTORn3naUPeVid5t/FQ LLHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=M/vlBif9aMiQm2hwge9WX3Mk5Qnv2rqdbkJQvgGenB8=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=LMS1sB8FkneA401QlIHw3x42jqYxakrdmXONA7gJwgHzSIYBmHJWJsu5XJqeyaOjPn adkvtixIOJj58G7KsA5tMYj6omIqCm9EYj/zj9fW71tHG1NUarpS+tRSODFaldXiYx4t j5oGBdWGPvSLx8nOjtCrODbOTSqNOUz9zQ13F6ZdYdOA8XBzREyNaefWFj3GNrX9IJV+ QG4Zxmn3KMtolIpDzD4GGcZewFBWcpVb7MsahVOPS7bUoPjsWoXcOtLZYH6LaYj5QbJq Rc8JbUjzsV/4hwBNC2G6lT3bjAmRJx6vzIhMdwaW82e5wfY+dwunSktCRLF3vMBJfw6U 7g7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020aa7cf17000000b005231425d183si2140187edy.216.2023.08.10.12.53.14; Thu, 10 Aug 2023 12:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbjHJTRt (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236300AbjHJTRr (ORCPT ); Thu, 10 Aug 2023 15:17:47 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8842717; Thu, 10 Aug 2023 12:17:46 -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 1a9d5b36f8f22aa9; Thu, 10 Aug 2023 21:17:45 +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 C4FAB662742; 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 6/7] thermal: intel: intel_soc_dts_iosf: Rework critical trip setup Date: Thu, 10 Aug 2023 21:16:14 +0200 Message-ID: <8269586.T7Z3S40VBb@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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773873101731413709 X-GMAIL-MSGID: 1773873101731413709 From: Rafael J. Wysocki Critical trip points appear in the DTS thermal zones only after those thermal zones have been registered via intel_soc_dts_iosf_init(). Moreover, they are "created" by changing the type of an existing trip point from THERMAL_TRIP_PASSIVE to THERMAL_TRIP_CRITICAL via intel_soc_dts_iosf_add_read_only_critical_trip(), the caller of which has to be careful enough to pass at least 1 as the number of read-only trip points to intel_soc_dts_iosf_init() beforehand. This is questionable, because user space may have started to use the trips at the time when intel_soc_dts_iosf_add_read_only_critical_trip() runs and there is no synchronization between it and sys_set_trip_temp(). To address it, use the observation that nonzero number of read-only trip points is only passed to intel_soc_dts_iosf_init() when critical trip points are going to be used, so in fact that function may get all of the information regarding the critical trip points upfront and it can configure them before registering the corresponding thermal zones. Accordingly, replace the read_only_trip_count argument of intel_soc_dts_iosf_init() with a pair of new arguments related to critical trip points: a bool one indicating whether or not critical trip points are to be used at all and an int one representing the critical trip point temperature offset relative to Tj_max. Use these arguments to configure the critical trip points before the registration of the thermal zones and to compute the number of writeable trip points in add_dts_thermal_zone(). Modify both callers of intel_soc_dts_iosf_init() to take these changes into account and drop the intel_soc_dts_iosf_add_read_only_critical_trip() call, that is not necessary any more, from intel_soc_thermal_init(), which also allows it to return success right after requesting the IRQ. Finally, drop intel_soc_dts_iosf_add_read_only_critical_trip() altogether, because it does not have any more users. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c | 2 drivers/thermal/intel/intel_soc_dts_iosf.c | 51 +++------- drivers/thermal/intel/intel_soc_dts_iosf.h | 8 - drivers/thermal/intel/intel_soc_dts_thermal.c | 17 --- 4 files changed, 27 insertions(+), 51 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 @@ -257,11 +257,11 @@ static void remove_dts_thermal_zone(stru } static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, - int read_only_trip_cnt) + bool critical_trip) { + int writable_trip_cnt = SOC_MAX_DTS_TRIPS; char name[10]; unsigned long trip; - int writable_trip_cnt; int trip_mask; unsigned long ptps; u32 store_ptps; @@ -276,7 +276,9 @@ static int add_dts_thermal_zone(int id, dts->id = id; - writable_trip_cnt = SOC_MAX_DTS_TRIPS - read_only_trip_cnt; + if (critical_trip) + writable_trip_cnt--; + trip_mask = GENMASK(writable_trip_cnt - 1, 0); /* Check if the writable trip we provide is not used by BIOS */ @@ -315,25 +317,6 @@ err_ret: return ret; } -int intel_soc_dts_iosf_add_read_only_critical_trip( - struct intel_soc_dts_sensors *sensors, int critical_offset) -{ - int i, j; - - for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { - struct intel_soc_dts_sensor_entry *entry = &sensors->soc_dts[i]; - int temp = sensors->tj_max - critical_offset; - unsigned long mask = entry->trip_mask; - - j = find_first_zero_bit(&mask, SOC_MAX_DTS_TRIPS); - if (j < SOC_MAX_DTS_TRIPS) - return configure_trip(entry, j, THERMAL_TRIP_CRITICAL, temp); - } - - return -EINVAL; -} -EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_add_read_only_critical_trip); - void intel_soc_dts_iosf_interrupt_handler(struct intel_soc_dts_sensors *sensors) { u32 sticky_out; @@ -375,8 +358,9 @@ static void dts_trips_reset(struct intel 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) +struct intel_soc_dts_sensors * +intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type, + bool critical_trip, int crit_offset) { struct intel_soc_dts_sensors *sensors; int tj_max; @@ -386,9 +370,6 @@ struct intel_soc_dts_sensors *intel_soc_ if (!iosf_mbi_available()) return ERR_PTR(-ENODEV); - if (read_only_trip_count > SOC_MAX_DTS_TRIPS) - return ERR_PTR(-EINVAL); - tj_max = intel_tcc_get_tjmax(-1); if (tj_max < 0) return ERR_PTR(tj_max); @@ -403,6 +384,9 @@ struct intel_soc_dts_sensors *intel_soc_ sensors->tj_max = tj_max * 1000; for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { + enum thermal_trip_type trip_type; + int temp; + sensors->soc_dts[i].sensors = sensors; ret = configure_trip(&sensors->soc_dts[i], 0, @@ -410,15 +394,20 @@ struct intel_soc_dts_sensors *intel_soc_ if (ret) goto err_reset_trips; - ret = configure_trip(&sensors->soc_dts[i], 1, - THERMAL_TRIP_PASSIVE, 0); + if (critical_trip) { + trip_type = THERMAL_TRIP_CRITICAL; + temp = sensors->tj_max - crit_offset; + } else { + trip_type = THERMAL_TRIP_PASSIVE; + temp = 0; + } + ret = configure_trip(&sensors->soc_dts[i], 1, trip_type, temp); if (ret) goto err_reset_trips; } for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { - ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], - read_only_trip_count); + ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], critical_trip); if (ret) goto err_remove_zone; } 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 @@ -42,11 +42,11 @@ struct intel_soc_dts_sensors { struct intel_soc_dts_sensor_entry soc_dts[SOC_MAX_DTS_SENSORS]; }; -struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( - enum intel_soc_dts_interrupt_type intr_type, int read_only_trip_count); + +struct intel_soc_dts_sensors * +intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type, + bool critical_trip, int crit_offset); void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors); void intel_soc_dts_iosf_interrupt_handler( struct intel_soc_dts_sensors *sensors); -int intel_soc_dts_iosf_add_read_only_critical_trip( - struct intel_soc_dts_sensors *sensors, int critical_offset); #endif Index: linux-pm/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c +++ linux-pm/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c @@ -59,7 +59,7 @@ static int proc_thermal_pci_probe(struct * ACPI/MSR. So we don't want to fail for auxiliary DTSs. */ proc_priv->soc_dts = intel_soc_dts_iosf_init( - INTEL_SOC_DTS_INTERRUPT_MSI, 0); + INTEL_SOC_DTS_INTERRUPT_MSI, false, 0); if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) { ret = pci_enable_msi(pdev); Index: linux-pm/drivers/thermal/intel/intel_soc_dts_thermal.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_thermal.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_thermal.c @@ -51,7 +51,8 @@ static int __init intel_soc_thermal_init return -ENODEV; /* Create a zone with 2 trips with marked as read only */ - soc_dts = intel_soc_dts_iosf_init(INTEL_SOC_DTS_INTERRUPT_APIC, 1); + soc_dts = intel_soc_dts_iosf_init(INTEL_SOC_DTS_INTERRUPT_APIC, true, + crit_offset); if (IS_ERR(soc_dts)) { err = PTR_ERR(soc_dts); return err; @@ -88,21 +89,7 @@ static int __init intel_soc_thermal_init } } - err = intel_soc_dts_iosf_add_read_only_critical_trip(soc_dts, - crit_offset); - if (err) - goto error_trips; - return 0; - -error_trips: - if (soc_dts_thres_irq) { - free_irq(soc_dts_thres_irq, soc_dts); - acpi_unregister_gsi(soc_dts_thres_gsi); - } - intel_soc_dts_iosf_exit(soc_dts); - - return err; } static void __exit intel_soc_thermal_exit(void) 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: 134183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp636755vqi; Thu, 10 Aug 2023 12:27:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE42HTOQrHHsrNtvOyN+0z39FTjrYNRxEvKLWwoD0CWiYH8c9o3baXn4UJAIeR7ajiEAGVA X-Received: by 2002:a05:6512:23aa:b0:4f8:76ba:ad3c with SMTP id c42-20020a05651223aa00b004f876baad3cmr3108419lfv.55.1691695628415; Thu, 10 Aug 2023 12:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691695628; cv=none; d=google.com; s=arc-20160816; b=ZXT89BqbuzmNBIQB9OjOg18XQqkA6kQXElPPVAF+UVWhSDUnq9dr2d9TV4mL85F7w7 6MBjTcCWok1R3SoxY4eK7gGa3FNHoXNjUBMLMWZylwU0M883RNAv8kGvlzSkGVAwEGBC A6faT1LhTQ4kHc+zL3qy6AftcyAKS0XxJg9HJffEglShWlRTzZkDQhBfR+dktLEvd9hz DsvIIg2vVumErhVZIF53sQ1hg/eyRt4IFLKsf/bUEegXMC1NKHAlsHJeczTUfe/kdNmC Ld7zMP4VLmIlPqLooSch/GFSlMLoG2jB2KQN/4xQKxIDc6AXgdcsGHhPomMD8nGQLTnf R+1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GuL5gVZZJVtO/t4aY0Z/jvnZ+Fzou0yXvNBqjfK700g=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=G8ev/2dkJeAemqpq9ROUuuIvxJDVjuJxc6Enyn0gNAkpvJSl7CMknWfVTAUH/1fnYh gmx6Opw14/DL6ZletmQwaeFO1254OF9EXdz8RYfjX21GPYG/x3tmc75U9aIFQ/rtEEH+ avKzM1Yma8e5yUGvJVL1G56l1WVAFUUMRCX/o9kGeoMZN93eZIMa9Hy/A5/A+QBDkbGj 4REQM6LMZsQaBkWAPg3V51K1yBKmMZjJ4NC36orlBj70JmWLZCgC7eyPHIw5qnAGTKL2 YFCPyDj6oHGcaAJuOEb1RRrQzhIsapcrmNCd0f609GRgRETRDH1CDDcOTKUpQ6PxJ1Aa WEUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020aa7c50c000000b005233615686esi2175432edq.32.2023.08.10.12.26.44; Thu, 10 Aug 2023 12:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbjHJTRs (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:48 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773871435400586465 X-GMAIL-MSGID: 1773871435400586465 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;