From patchwork Mon Mar 13 14:34:27 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: 68871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1228878wrd; Mon, 13 Mar 2023 07:48:54 -0700 (PDT) X-Google-Smtp-Source: AK7set/kfnGSgeOLSQY4G+lVZAXt2Y2TnLLHJICGkbbH3O05uAB8lGDvFAmSc9qLFhM3K4bW19Q6 X-Received: by 2002:a05:6a20:548a:b0:cb:e735:65a5 with SMTP id i10-20020a056a20548a00b000cbe73565a5mr43160529pzk.40.1678718934207; Mon, 13 Mar 2023 07:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678718934; cv=none; d=google.com; s=arc-20160816; b=KxK9hwlxoK7/+oS98Rh1gzJmClhYaGggP/bobIOaN+ivxPxIxzAAQAZYYL3D534JXT iy93clA+ePyzqV2Ee25HQKUukVvNuCGcu/vK2PoxsLUx+5yiU1nNuxvKj9naT36DHLDu dsJQ6JDyoKVvzju+EMGg705T3PRnbZ9aXfawKuL8ETl7kH7ZxzN95CtWmkUMN8aY1cbw sW1uKamv2uI6ygmfBcvlt2oVoQqKRSii0zcVYIaAGSISDnj6XncZwcfau5/QMHu9dBna QnTzPmDucE5SUR6cbekATpZvciIeGzRn4vOI+aBQYBBsWjCKmv41RLiDlzAoAOdCQ6f2 Sisw== 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=Hb0KbGnm9qYB8lpGCxdKICWGIDUr4aippGcgKZE6yXo=; b=yCFK5w7j+mwaY1uv/FKYZYBPoIAXlNEhyzh5nT9uDSE8OBRfWIccISLcpdVRWarMTE jpHwS/wDPjcPEYhzSGBMCbxVNmla/CsXZSHpx3Bec6Sgew5pBltXAk9+dNvBzd0zSGHk op7mYZoKYnIKTSzehCQMAi8sjXsgBp18tOc7sN105xtxhjVJ7sjikH926qQPmGCGC0/u DHKtR1ynTTUZ3+30bVCKl/R2CmYLXW01vMQyquyNy5J3TXAnekgIh+gJs9srCswjPbza CQYdvHzFbInTmciydu0l3/vpwT573N72cB4D7Agc0wCpFQWze+HmKvdmTCyEGLak961Q EaTg== 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 f1-20020a63e301000000b004fbb6a09b99si6590390pgh.341.2023.03.13.07.48.39; Mon, 13 Mar 2023 07:48:54 -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 S231435AbjCMOej (ORCPT + 99 others); Mon, 13 Mar 2023 10:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbjCMOeh (ORCPT ); Mon, 13 Mar 2023 10:34:37 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B372234D6; Mon, 13 Mar 2023 07:34:36 -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.1.0) id 3f128afb96eb52b3; Mon, 13 Mar 2023 15:34:34 +0100 Received: from kreacher.localnet (unknown [213.134.189.11]) (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 1A31E9C5854; Mon, 13 Mar 2023 15:34:33 +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 v2 4/4] ACPI: processor: thermal: Update CPU cooling devices on cpufreq policy changes Date: Mon, 13 Mar 2023 15:34:27 +0100 Message-ID: <2893417.e9J7NaK4W3@kreacher> In-Reply-To: <2692681.mvXUDI8C0e@kreacher> References: <2692681.mvXUDI8C0e@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.11 X-CLIENT-HOSTNAME: 213.134.189.11 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvgedgieegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepfeduudeutdeugfelffduieegiedtueefledvjeegffdttefhhffhtefhleejgfetnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepvddufedrudefgedrudekledruddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledruddupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeekpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh 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?1760264385391095891?= X-GMAIL-MSGID: =?utf-8?q?1760264385391095891?= 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 Tested-by: Zhang Rui Reviewed-by: Zhang Rui --- v1 -> v2: Remove the now redundant IS_ERR() checks on cdev before calling thermal_cooling_device_update(). --- drivers/acpi/processor_thermal.c | 14 +++++++++++--- 1 file changed, 11 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,13 @@ 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; + } + + thermal_cooling_device_update(pr->cdev); } } @@ -153,8 +157,12 @@ 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); + + thermal_cooling_device_update(pr->cdev); } } #else /* ! CONFIG_CPU_FREQ */