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);