From patchwork Fri Mar 3 19:23:58 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: 64060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp588832wrd; Fri, 3 Mar 2023 11:27:39 -0800 (PST) X-Google-Smtp-Source: AK7set9YZGofup93LBBZVH2TINs+YWKlJxrA04cfq0MpaFuob8QusVJKYO1ZvIfQynMxVjfaKskk X-Received: by 2002:a17:906:b097:b0:8af:1a8c:f13f with SMTP id x23-20020a170906b09700b008af1a8cf13fmr3347596ejy.71.1677871659579; Fri, 03 Mar 2023 11:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677871659; cv=none; d=google.com; s=arc-20160816; b=EMjKkVcf3Iq7eH6Ei74Rk+3C2ePJI5XLs67cxJ1bwxwuXANlNMK1dHdCYRYftENJ6e 9yTWYAOu/Pyb4jNmVzeie3NoHLyCSk4I9sBK2f0N1cy1ySZKjvO5x9DiZ6Tjjjp8TykQ IY0NObKSDUoLqjseVEl3umrFgP0ApwaAxESeDNcZVj5Isr/zFA9wqEC2HZ+P+3c/yFbX zokC+uOPWpO50Z4kNYG5tlu2C2jEYqYflTEcs3A2hs3HgxNosVbjMSPsMFsAEk5L3Dja 0/9zpLm1dG5W2GlhPjM1iiueVU0qaHwvRxN8YxqBBzstEa9kii2rZRx7TRZ0uBabacuE gZmw== 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=Q4Y3uZprhKVftKfB7D8521kVJLhsDmFBPkn7jw+vS0Y=; b=Uo+0HSBzHoIg2ddrKImvsN6RMb6O54YoJIKmEV/Z2xSiLGo/o3yvqxRVf1oOCoE9js YOdzNhonAmiU65dQzVNIdGWLVSr2UkqaXk34nsxEzIPAfOyBSC9y43axcoEQOyvpwFc/ bo1phbTAai9qmpfMABI5E7jmWB63uhYg0lQfitfvdWiIwmpUiW2ZYVdei0tUyY1tJE2t Hk5QGL3kDRMvpKAlbKLlCm0XQJLzjfxOFrFYGhQXbxNTQ0/wYyhtI3GsVlExWqsgtKwG s8/FCUxErEJWwyp3dY+KXX3zYanpxpLJq6A5nb5E6TW9HR3UFaxZASkO0eksYJP5ghjD Yqpw== 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 o25-20020aa7d3d9000000b004bc2794f642si3354670edr.407.2023.03.03.11.27.17; Fri, 03 Mar 2023 11:27:39 -0800 (PST) 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 S231415AbjCCTYN (ORCPT + 99 others); Fri, 3 Mar 2023 14:24:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjCCTYL (ORCPT ); Fri, 3 Mar 2023 14:24:11 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECBC510408; Fri, 3 Mar 2023 11:24:09 -0800 (PST) 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.1.0) id 45dcb4239fb6fbda; Fri, 3 Mar 2023 20:24:07 +0100 Received: from kreacher.localnet (unknown [213.134.183.41]) (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 CE9CC20619DE; Fri, 3 Mar 2023 20:24:06 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: Zhang Rui , Linux ACPI , LKML , Daniel Lezcano , Srinivas Pandruvada , Viresh Kumar , Quanxian Wang Subject: [PATCH v1 4/4] ACPI: processor: thermal: Update CPU cooling devices on cpufreq policy changes Date: Fri, 03 Mar 2023 20:23:58 +0100 Message-ID: <1936685.PYKUYFuaPT@kreacher> In-Reply-To: <2148907.irdbgypaU6@kreacher> References: <2148907.irdbgypaU6@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.183.41 X-CLIENT-HOSTNAME: 213.134.183.41 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrudelledguddukecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeefudduuedtuefgleffudeigeeitdeufeelvdejgefftdethffhhfethfeljefgteenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppedvudefrddufeegrddukeefrdegudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukeefrdeguddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepkedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgv rhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759375953394739506?= X-GMAIL-MSGID: =?utf-8?q?1759375953394739506?= From: Rafael J. Wysocki When a cpufreq policy appears or goes away, the CPU cooling devices for the CPUs covered by that policy need to be updated so that the new processor_get_max_state() value is stored as max_state and the statistics in sysfs are rearranged for each of them. Do that accordingly in acpi_thermal_cpufreq_init() and acpi_thermal_cpufreq_exit(). Fixes: a365105c685c("thermal: sysfs: Reuse cdev->max_state") Reported-by: Wang, Quanxian Link: https://lore.kernel.org/linux-pm/53ec1f06f61c984100868926f282647e57ecfb2d.camel@intel.com/ Signed-off-by: Rafael J. Wysocki --- drivers/acpi/processor_thermal.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) Index: linux-pm/drivers/acpi/processor_thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_thermal.c +++ linux-pm/drivers/acpi/processor_thermal.c @@ -140,9 +140,14 @@ void acpi_thermal_cpufreq_init(struct cp ret = freq_qos_add_request(&policy->constraints, &pr->thermal_req, FREQ_QOS_MAX, INT_MAX); - if (ret < 0) + if (ret < 0) { pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu, ret); + continue; + } + + if (!IS_ERR(pr->cdev)) + thermal_cooling_device_update(pr->cdev); } } @@ -153,8 +158,13 @@ void acpi_thermal_cpufreq_exit(struct cp for_each_cpu(cpu, policy->related_cpus) { struct acpi_processor *pr = per_cpu(processors, cpu); - if (pr) - freq_qos_remove_request(&pr->thermal_req); + if (!pr) + continue; + + freq_qos_remove_request(&pr->thermal_req); + + if (!IS_ERR(pr->cdev)) + thermal_cooling_device_update(pr->cdev); } } #else /* ! CONFIG_CPU_FREQ */