Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2961362pxj; Mon, 17 May 2021 14:12:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9Uwagwoy7+kYAa4uREzueU84BNBtZjCIxZh6d7WhW7amcBGBYbVdpkYVqEEjsKKV+307n X-Received: by 2002:a05:6402:188:: with SMTP id r8mr2401354edv.75.1621285944847; Mon, 17 May 2021 14:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621285944; cv=none; d=google.com; s=arc-20160816; b=BLQ5V5zuHuw0bc1ofLitgFukUHKMMbk4m5nXZdN5DIEv64qxDHpgzpq4mIIV2DCxXz myECiYdxwBbhl9TconCfQHcfNxaqHHvKNaqTO2N1H/36Ur2v92L8XkoZhggegpMPqNvW UpcWHugtsOVGYnqf8wumC9Knq0yVw39r2h6+cK6ionlw2RKH8VlJSzGj1Si0ZSyd2g1I 6bIGepQdhHXFpjzw9N9TebMoBssSG7IyXn3g6854Nl2T1gvV4LBnLxm3v/w1/LPgRiGF bSAcVmBQEom0Rf43sWFUZW9MHT0cQLLe7A5U0I/J4JcqroPSRDWfSojTmlM1tn1cZ9fk 2MDA== 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=apGo9/GLc9hAPioTGfwQACOfNHnyqBeQQnSYyMiSnCo=; b=gugbHJ0XOTKMolN2F86eLX0b0zEDhAcnon18Qm1DqPL6BY2KfPXLAnK5MuBLOLSWWX x1yoCOh0XEWRjEhapsdvHX3b0kaHrWQS0vjVu402MAK5omopdgcwr3bfYXYrm28iTDxr BMcaAUKy2Cn1b1AW8HccRT8r96YzOgkQOxInQC6WVhiD4x4EmboVgUMc5UQliycW7Bko iVt9EpmXOmd2LY1x/MIxz7c0U90Uc7Xrh6kYt5KE2RmKRfBIH1+Brv5h2flGXKwbGX04 aoDN60lRNFhz8fPyul95cWU8cr5Cz6XYiYpo4mCUaBh6a05Ft3zh4hJLz6UE1/d54TX4 CU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pj80yGes; 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 ga3si16239501ejc.284.2021.05.17.14.12.01; Mon, 17 May 2021 14:12:24 -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=Pj80yGes; 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 S238121AbhEQOIO (ORCPT + 99 others); Mon, 17 May 2021 10:08:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:59666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237934AbhEQOGw (ORCPT ); Mon, 17 May 2021 10:06:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 068546128A; Mon, 17 May 2021 14:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260328; bh=CHDLsbY41fpI6Ik6L7y4vSF1M3Gyohgf3E2GyIpl/78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pj80yGesv7PwIMFMNhfBrJb1rSAQSKp+JnHsucmwDEsJbQNykaa9wyP8DkopbGqjV fooxp/8+c+3rsnIiOx0wVhb6W+MfqCu5BZmyqMoNF1AsG5KBKlhOBTwZn+G5D/2Q/w AqrzvPb+SwGP2sU9nc0ymVT355bsNXaT5cvyczx4= 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.12 010/363] cpufreq: intel_pstate: Use HWP if enabled by platform firmware Date: Mon, 17 May 2021 15:57:56 +0200 Message-Id: <20210517140302.896186357@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 @@ -3054,6 +3054,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; @@ -3072,8 +3080,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;