Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp51116pxy; Wed, 21 Apr 2021 18:12:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweS2ttiQzD0u87WcWq7bGuARApTR8/o4iT7YeJe3RqOMFoR8a68n/ofOCzDv4gz8d+Lh94 X-Received: by 2002:a63:5604:: with SMTP id k4mr900214pgb.123.1619053931320; Wed, 21 Apr 2021 18:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619053931; cv=none; d=google.com; s=arc-20160816; b=wqKdNLr4DWGlmGq7QeE0hjdPejldM2fpf5JGybAVKNjHma6gw9lRDZvc9QAKFjHmiU 66qa+m9ZDZlTGYzuj/Y1yqL5c52Cx3aN3bbK7/1eHYvespvJHCwALIdHvmUvvsvTiGzX LTnUEK33Q64X7tnm4vlj35WpvqF4kKRyTYREOInYjj+hFFyUAZIHFK4Nb6UuJU2WvWJ3 YhE0v1Ii1fjhroq6xiNa7fyUhFvVIXAALmI5YAb52iFyyD4O8XSlWoShui8eB+gs0j/F 09LTmvrZWgzPx/d8lCE1W6R3T2jIatacwWBA1JLpNchAx/fN4UhmXCkwb+AobvmRv8RF WCNw== 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=C8hP4+z2WbhscSQAz+hMrFvl0ahTG92QSHsPLXt/qQE=; b=X4bIGdvPF+yvNHg8y0jv1xtb6/9eUsXh69buSPcn3rtGhOLbwHa2VH+0KbAT6nRKOF TrzsGIsQy6LkEdyws7lHrR1eTkgY/KPYvSucZ3bQycBBkaAfXOHCn1khID/vSYlomuIK pTuyckqQS4iQNPt62gGBP3hfhI+29GoSowseLMyjZMuj22zg6iOddmuCSaUcNo+v7lti YM2Agipdv3f34A/sJhn8D3eXRJzs7M86S8sVHXx+YM/y3De/gPgtTI1hzjB5Z3O14d5q WWZax1ji8wBkYZ9Nbk9FHaw6mXZf0b2SRVyMiUkW6Twn9vonggFsGERK8+6nT4sxNW2t sWUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si1177120pla.361.2021.04.21.18.11.59; Wed, 21 Apr 2021 18:12:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244807AbhDURld (ORCPT + 99 others); Wed, 21 Apr 2021 13:41:33 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:51594 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243098AbhDURlc (ORCPT ); Wed, 21 Apr 2021 13:41:32 -0400 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 2.0.5) id 31b07786e97dcc5f; Wed, 21 Apr 2021 19:40:57 +0200 Received: from kreacher.localnet (89-64-80-44.dynamic.chello.pl [89.64.80.44]) (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 A8DFF669387; Wed, 21 Apr 2021 19:40:56 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: Srinivas Pandruvada , LKML Subject: [PATCH] cpufreq: intel_pstate: Use HWP if enabled by platform firmware Date: Wed, 21 Apr 2021 19:40:56 +0200 Message-ID: <2602702.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.80.44 X-CLIENT-HOSTNAME: 89-64-80-44.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvddtkedguddujecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhephfegtdffjeehkeegleejveevtdeugfffieeijeduuddtkefgjedvheeujeejtedvnecukfhppeekledrieegrdektddrgeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeelrdeigedrkedtrdeggedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki It turns out that there are systems where HWP is enabled during initialization by the platform firmware (BIOS), but HWP EPP support is not advertised. After commit 7aa1031223bc ("cpufreq: intel_pstate: Avoid enabling HWP if EPP is not supported") intel_pstate refuses to use HWP on those systems, but the fallback PERF_CTL interface does not work on them either because of enabled HWP, and once enabled, HWP cannot be disabled. Consequently, the users of those systems cannot control CPU performance scaling. Address this issue by making intel_pstate use HWP unconditionally if it is enabled already when the driver starts. Fixes: 7aa1031223bc ("cpufreq: intel_pstate: Avoid enabling HWP if EPP is not supported") Reported-by: Srinivas Pandruvada Tested-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki Cc: 5.9+ # 5.9+ --- drivers/cpufreq/intel_pstate.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -3229,6 +3229,14 @@ static const struct x86_cpu_id hwp_suppo {} }; +static bool intel_pstate_hwp_is_enabled(void) +{ + u64 value; + + rdmsrl(MSR_PM_ENABLE, value); + return !!(value & 0x1); +} + static int __init intel_pstate_init(void) { const struct x86_cpu_id *id; @@ -3247,8 +3255,12 @@ static int __init intel_pstate_init(void * Avoid enabling HWP for processors without EPP support, * because that means incomplete HWP implementation which is a * corner case and supporting it is generally problematic. + * + * If HWP is enabled already, though, there is no choice but to + * deal with it. */ - if (!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) { + if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || + intel_pstate_hwp_is_enabled()) { hwp_active++; hwp_mode_bdw = id->driver_data; intel_pstate.attr = hwp_cpufreq_attrs;