Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp799875pxb; Tue, 3 Nov 2020 12:53:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpl3/wTSkTOcBlKh8LInH7W/eK3p9LVALjLJ5up7Iyj0G5ZBgfnzVQrsnq4P+w2UM+wmdY X-Received: by 2002:aa7:c704:: with SMTP id i4mr23496692edq.51.1604436816336; Tue, 03 Nov 2020 12:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604436816; cv=none; d=google.com; s=arc-20160816; b=aMdjDn1+osIe6WLRDw+Oplh6WwHpfMKpd+WySEUGzXFi+syZMdhRzNkGWUhGCmglwV y/FzOoQrwD6Jbha3PpQlAOioRF6DCSxDKg94gIP4HzqdtQqPk71mehNSjWz/9c7Onyzk zpbdltphVsHqdIEVx707rfrPXH5hQGeDPZlELEp+uGCTW9p4jnofy5HkXwnSvzey3WCH ey+9g5v4y3TfXjKipyEX1xKm0vjhttma5hPBNWcEQwuAoBo4NE7pEB7R5uXSfnHSrekk F9cownTbYCXlp6B/wWEIt0st1ptgAW4FvdOuH8W9GEf+wr/y9S4iWoRwHuzLfEE27f10 Fdaw== 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=trVzqIaaCR4kMX4TUW8yazVPLy5Av9VGIuvmunKcrgo=; b=gC660vvWmAVv560TSz5CMgX4dObrnX5aLkeMw842vYVJcxF7HlBdrdtB6IC8SY17Kc qIifFr/rjWb0j0pRWcE9CfwtaEVFdpjoJPRwZplXJeGkMNRdTocBl0PAXFV3AoDxGwJy 3IqhHDlAlMJRk5dKCSNAH2CoKy2UICJ/r3LWegjT/OAiagc3a/n5olV0BJxhqgrTTJJD rGC8fPPHCiQKQ1WEbXqM5rpVAjwbwMUNWfUrIPfnHdPvBoM6bH2W9mqvyvW32JirxKmQ 3NHNzM8Lpj1/gRhlHBEatrXtAVs+NQJUPSONonFMdNVuI/rTNoHIE+h1E7loOzx7mqX4 PW4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AS0kW0ia; 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=fail (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 o16si10252432edi.462.2020.11.03.12.53.12; Tue, 03 Nov 2020 12:53:36 -0800 (PST) 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=@kernel.org header.s=default header.b=AS0kW0ia; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731229AbgKCUuo (ORCPT + 99 others); Tue, 3 Nov 2020 15:50:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:45006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731851AbgKCUum (ORCPT ); Tue, 3 Nov 2020 15:50:42 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F7C622404; Tue, 3 Nov 2020 20:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436642; bh=74KF8pX5Ws56tLv45is/0QJDtB5rGm0h+2J+LFmRumM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AS0kW0iaTbAYSt5ecvAMHbbhN6Ip4XzGGuKUWx2WXD1rG71pOFsvc8pLLjVZj0afH XThHHLf7W/66XLcOZvbEDcbwbtoxDmAwu5D5SdbRAGeHe5Kg5r2e5KlkNINt6ktUpV Hxph9oIuNk8pDNoP20qvBLMIqKh8z+KWg7zWb9pw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Rui , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 5.9 338/391] cpufreq: intel_pstate: Avoid missing HWP max updates in passive mode Date: Tue, 3 Nov 2020 21:36:29 +0100 Message-Id: <20201103203409.939835927@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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 e0be38ed4ab413ddd492118cf146369b86ee0ab5 upstream. If the cpufreq policy max limit is changed when intel_pstate operates in the passive mode with HWP enabled and the "powersave" governor is used on top of it, the HWP max limit is not updated as appropriate. Namely, in the "powersave" governor case, the target P-state is always equal to the policy min limit, so if the latter does not change, intel_cpufreq_adjust_hwp() is not invoked to update the HWP Request MSR due to the "target_pstate != old_pstate" check in intel_cpufreq_update_pstate(), so the HWP max limit is not updated as a result. Also, if the CPUFREQ_NEED_UPDATE_LIMITS flag is not set for the driver and the target frequency does not change along with the policy max limit, the "target_freq == policy->cur" check in __cpufreq_driver_target() prevents the driver's ->target() callback from being invoked at all, so the HWP max limit is not updated. To prevent that occurring, set the CPUFREQ_NEED_UPDATE_LIMITS flag in the intel_cpufreq driver structure if HWP is enabled and modify intel_cpufreq_update_pstate() to do the "target_pstate != old_pstate" check only in the non-HWP case and let intel_cpufreq_adjust_hwp() always run in the HWP case (it will update HWP Request only if the cached value of the register is different from the new one including the limits, so if neither the target P-state value nor the max limit changes, the register write will still be avoided). Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled") Reported-by: Zhang Rui Cc: 5.9+ # 5.9+: 1c534352f47f cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS ... Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Tested-by: Zhang Rui Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/intel_pstate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -2550,14 +2550,12 @@ static int intel_cpufreq_update_pstate(s int old_pstate = cpu->pstate.current_pstate; target_pstate = intel_pstate_prepare_request(cpu, target_pstate); - if (target_pstate != old_pstate) { + if (hwp_active) { + intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch); + cpu->pstate.current_pstate = target_pstate; + } else if (target_pstate != old_pstate) { + intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch); cpu->pstate.current_pstate = target_pstate; - if (hwp_active) - intel_cpufreq_adjust_hwp(cpu, target_pstate, - fast_switch); - else - intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, - fast_switch); } intel_cpufreq_trace(cpu, fast_switch ? INTEL_PSTATE_TRACE_FAST_SWITCH : @@ -3014,6 +3012,7 @@ static int __init intel_pstate_init(void hwp_mode_bdw = id->driver_data; intel_pstate.attr = hwp_cpufreq_attrs; intel_cpufreq.attr = hwp_cpufreq_attrs; + intel_cpufreq.flags |= CPUFREQ_NEED_UPDATE_LIMITS; if (!default_driver) default_driver = &intel_pstate;