Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3628695rwl; Tue, 27 Dec 2022 12:14:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuUHpZjMPb23Eobxw2ytUguqZgNB8ILVqPRFTFR3smWKy5HvBkENNU+qWV6T1nlfwJ1OapY X-Received: by 2002:a17:907:6746:b0:840:758a:9155 with SMTP id qm6-20020a170907674600b00840758a9155mr27783211ejc.12.1672172047747; Tue, 27 Dec 2022 12:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672172047; cv=none; d=google.com; s=arc-20160816; b=gkf4tzLq19CsVlBo2b/7E0mOW7NeRFkQ/vtJgoQk4BxACR2mHbT+VZgQcBBOBJ8//U Pk4Zp5T9tvN3wBmrtYkpTHZgQ1RS6fjVVmjTmuEevWDakZoXJNAwDO1/5sddIRNgsZov PSWIgFHaOsWOei6A0N7wF9J47Zi5KFHsxKRkw8BHuq7qw3s4Ank87XFae+4gX50Qn9yT SDK5Otcm74d7gk6OKThOOH+vplpMc9J7zWmWaRihUDGgkKqU4ZVWbOyGO0DCrDNOzUuc PN8Sw2yAJpmQLd0rgfOqR9QP5vOzRoQff31w8fz8ch0Fq85M0OiyK0tIKjmjV2gg64Oc RSww== 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 :message-id:date:subject:cc:to:from; bh=jbobXY0IufRhIjMjqgH6VvroHlzOP8CSLt/5noAp9bs=; b=ZCtamjWCgTIGrD4yjnFgED2FavzB+k8T40ZHpfRfmiKoDSgdyG+b6pHnQXRslcS6e+ GB7cAtPspERjKY8iSGeOxAsN3JdratK3s7Lc+O5UhWv9gHyms4fpZwAANS3zZtIJHv/A oP3ndlJyOJukwsVqWO+mCWaTzMYeCnMYNapFWU9jWYMFWb3gKjaIYpMDKmRCdfqpninV Qq86fjB7C/pgn/XFo+4u92QGz/O8K4AbbEBYPpNoLFnX/g6qHjLeBvpnu8ShfRjJYTcF +9AYcHJ1ZAHUfmPMFPxtarjxQtBZf2kqHQmqEOJxNY3FDx+CdSC2KpYbZ5kEEHOayTd/ Wv4A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a056402190600b0048477a5116csi7415391edz.571.2022.12.27.12.13.51; Tue, 27 Dec 2022 12:14:07 -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 S231749AbiL0Tx6 (ORCPT + 66 others); Tue, 27 Dec 2022 14:53:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiL0Tx5 (ORCPT ); Tue, 27 Dec 2022 14:53:57 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A23E51131; Tue, 27 Dec 2022 11:53:55 -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 f43143bd2e72e6b3; Tue, 27 Dec 2022 20:53:53 +0100 Received: from kreacher.localnet (unknown [213.134.183.5]) (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 3FA3E28A34C8; Tue, 27 Dec 2022 20:53:53 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Linux PM Cc: Pratyush Yadav , LKML , Linux ACPI , Srinivas Pandruvada Subject: [PATCH v1 1/2] ACPI: processor: perflib: Use the "no limit" frequency QoS Date: Tue, 27 Dec 2022 20:51:43 +0100 Message-ID: <12138067.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.183.5 X-CLIENT-HOSTNAME: 213.134.183.5 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedriedtgddufeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepffffffekgfehheffleetieevfeefvefhleetjedvvdeijeejledvieehueevueffnecukfhppedvudefrddufeegrddukeefrdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekfedrhedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehpthihrggurghvsegrmhgriihonhdruggvpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhv rghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh 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,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 From: Rafael J. Wysocki When _PPC returns 0, it means that the CPU frequency is not limited by the platform firmware, so make acpi_processor_get_platform_limit() update the frequency QoS request used by it to "no limit" in that case and avoid updating the QoS request when the _PPC return value has not changed. This addresses a problem with limiting CPU frequency artificially on some systems after CPU offline/online to the frequency that corresponds to the first entry in the _PSS return package. While at it, move the _PPC return value check against the state count earlier to avoid setting performance_platform_limit to an invalid value. Reported-by: Pratyush Yadav Signed-off-by: Rafael J. Wysocki --- drivers/acpi/processor_perflib.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) Index: linux-pm/drivers/acpi/processor_perflib.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_perflib.c +++ linux-pm/drivers/acpi/processor_perflib.c @@ -53,6 +53,8 @@ static int acpi_processor_get_platform_l { acpi_status status = 0; unsigned long long ppc = 0; + s32 qos_value; + int index; int ret; if (!pr) @@ -72,17 +74,30 @@ static int acpi_processor_get_platform_l } } + index = ppc; + + if (pr->performance_platform_limit == index || + ppc >= pr->performance->state_count) + return 0; + pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id, - (int)ppc, ppc ? "" : "not"); + index, index ? "is" : "is not"); - pr->performance_platform_limit = (int)ppc; + pr->performance_platform_limit = index; - if (ppc >= pr->performance->state_count || - unlikely(!freq_qos_request_active(&pr->perflib_req))) + if (unlikely(!freq_qos_request_active(&pr->perflib_req))) return 0; - ret = freq_qos_update_request(&pr->perflib_req, - pr->performance->states[ppc].core_frequency * 1000); + /* + * If _PPC returns 0, it means that all of the available states can be + * used ("no limit"). + */ + if (index == 0) + qos_value = FREQ_QOS_MAX_DEFAULT_VALUE; + else + qos_value = pr->performance->states[index].core_frequency * 1000; + + ret = freq_qos_update_request(&pr->perflib_req, qos_value); if (ret < 0) { pr_warn("Failed to update perflib freq constraint: CPU%d (%d)\n", pr->id, ret);