Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp190323pxj; Tue, 18 May 2021 00:46:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweHoSmh5rlfRx9bwozSs/f4+702cE2vdBYrHMCtcCytNAmD5VnphPO1VQjmnXRLkc8cNy1 X-Received: by 2002:a02:ca07:: with SMTP id i7mr4140424jak.11.1621323975498; Tue, 18 May 2021 00:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621323975; cv=none; d=google.com; s=arc-20160816; b=dLWBN4uz+bDjTW0breNwjPwbVTT1Xt0MQ3EVs4XdAbWUEcs5L4EGDYrIQIyStbzBtV kiM0Oz/A5QJ4FOqtgMBZgH53UuNyfDPno0kcsIG+/+X8Ff5OV6c4Hhiuk8aftbReQz59 ti41pCrvQzskLCMNR4JEdrnotPzBsv4q5GJEZear/eZrEcyLeJBiMPbaNPLOYJOB9xyp DxIBuMo6f2FxcxiwANZ7h3zVQnpBwvztJkWJSv6+esVjbp3XaS2Wwb6nek9uXYKU4Nhv R/Iy0DBJ2OMBemHSNMqcOXnLlIwVv1jORwlNBBnlviglUOQLv7lE8kSHCEtUFDimDwG4 Sgfg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mm/Ird/T0CgyCVJVewwPKzaPQTuxAZ5b3eEBcSElNiI=; b=DerHCTs700UB9T6J+q12L429aZZ7GDNDhOvAtxKympC1276ye0pWGCjv4w6kYFuNkO kwE8f0MBc1ZEa06rCKSeG0pXzHWD3lKddedDHCVexuSkPC9AmQzhqdg8Y5CPE1tNcbcx psOfG8QjdwoOjqbbmA2Ts7iYTb6ifvkAw51gxUQ7AZG3ZfhcUjl1on5XhF/IDmSjQ+us gt4e9GQtJUm3ZL2wQEE/j1z3lrW6Rkwh/JHDmAlFMOo8wbL+sJiev+HRKPbAzrJ44O7T i/00t9Flh5DIH+xioiaGalfv8P8wWYZRh3v6ryO23uDonnCMWv0ZlaA0nd3KQDAFyCHD DwIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FLURY65L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x4si10815878ilm.150.2021.05.18.00.45.44; Tue, 18 May 2021 00:46:15 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FLURY65L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240354AbhEQO5Q (ORCPT + 99 others); Mon, 17 May 2021 10:57:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239301AbhEQOsC (ORCPT ); Mon, 17 May 2021 10:48:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBCC261973; Mon, 17 May 2021 14:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261334; bh=qWnEuDp7tInVLGa7lowuhueGdRtSWa778KG1J/vM9ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FLURY65LdWtXuHX8x3Awy/LJdtNFftoCliShUI9vY4amIG8rXa6QZMGhAg+0er3vw uQhzkc3GOnF4v2ramzDA4pd+x62PZx5u0iA/PswWOa350YbgHCwcBOaHrWucAL+CdM ds1aBiT8kHn9KnnfnvxY5Xyw1nJBJbVG0lXE7EOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH 5.10 009/289] cpufreq: intel_pstate: Use HWP if enabled by platform firmware Date: Mon, 17 May 2021 15:58:54 +0200 Message-Id: <20210517140305.489057408@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit e5af36b2adb858e982d78d41d7363d05d951a19a upstream. 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+ Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/intel_pstate.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -3019,6 +3019,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; @@ -3037,8 +3045,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;