Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1042299pxx; Tue, 27 Oct 2020 07:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiVB7r4WNNIsrIhkRzNtBEZd4d9GXo7I4e1JgG3AIA1E2zUDCYdt6Ew41lLdIOB8VNcUk4 X-Received: by 2002:aa7:d514:: with SMTP id y20mr2498422edq.24.1603807309569; Tue, 27 Oct 2020 07:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603807309; cv=none; d=google.com; s=arc-20160816; b=R3gAPhnJ1suetcNHqJMkSeWFXzQ+8FIEPNJHUiQh1lAdVWp42z0o1Bk9aQPWilYC2i R/LD9gthKwDwRRy1sucSLnPbAxl6oJMVXFL7l6KPrpX0l0xr0zKew2eAdl0/AcSHSjK2 ETYmE5mfVQG+GLx8ZFbMBI2zKMnqaq0ZynQEDGPfcsw6y1QxVRMs0558qzWoDzV5S8Z8 lnXFBKgzpoVLgpkKkRt3WjAWVqht4feUpeMSI/X7ptxxqm7S9GeXRdXuxP8h+VHuaNrP 8IjYF4+z2wtZBWYZIvdcoMvxleHGDFZmGv3zkAZYqlJfjEhULzw0C35Tb3OXxbFkd5KC ufSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hQGNSG6H63pNMqU9sqlYyAvudn7TgOWia7TrZnYgCGA=; b=WYLY2/tZsM2QxWNXJ3QQB+jLZw3gyD09ruhXT0ThjmUAxQoPZwnIIkpX82RAN590KN zH4sxsvg/7Qw5cY0rGTGy7DeMYnaeaA6shFs7iM4XuG9XyahrPBp33ck3ZQrBx6bxWXI u/ZGNIqqbzDo0X9YNQHhSSrYJ+l9NQPr5zlzyb52mE3nwz1c2eft2H+4aY5W9OqQgB8D Zp9DzD082Sug16FDommnASSKXugIQ7Ou8oxgKR+SZVwJ3Eeg+dcZpXWsqg8yxth7o075 VKWzZilxyhtsSViLCd3XDRuTI4I3wulWFxwu3wlPE/AK2FXCAGw/1/JtxHUBsXn1NANF ttpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dslmTjfT; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si1296001ejk.22.2020.10.27.07.01.25; Tue, 27 Oct 2020 07:01:49 -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=@linaro.org header.s=google header.b=dslmTjfT; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437039AbgJ0DGk (ORCPT + 99 others); Mon, 26 Oct 2020 23:06:40 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:54678 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436963AbgJ0DGk (ORCPT ); Mon, 26 Oct 2020 23:06:40 -0400 Received: by mail-pj1-f68.google.com with SMTP id az3so31302pjb.4 for ; Mon, 26 Oct 2020 20:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hQGNSG6H63pNMqU9sqlYyAvudn7TgOWia7TrZnYgCGA=; b=dslmTjfTyW/nmJjmrd21DA5VZKLPsSKSKJ/TS/vNkxy8txy30oHZga1/qwbm5ZRUJ9 EljbDC769ItR4eOBQKI6WaJp9Ifixi+ipqvmQd9N7JZHF3iGlllrgagDD8SiDBJXb5YY tkr4Z/QpDSPWE7qotli6QTHiN2Vf6ltGrmdevTGdDY3YUwpm/Jv2QGW7L93A5iG7WONx ZoURF997b1/SZ/5g0zO7mQPBkTtjlqcxOz8DdkLpiB0TEoxa5SSMLde6Zd1iWR7r5/Rs /lrEvEKZokC3LicmO+tuoKUoIqL761daXgaWFqSQo/+AJ2cJ067t+yam/5+nEEKrTTsW Y18g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hQGNSG6H63pNMqU9sqlYyAvudn7TgOWia7TrZnYgCGA=; b=cGMELG4uM7dt+9r6nBcQ3F8q1biSOrdE8cVYWstpcwcwfbklJqwbh3nEGNc8VvrEaV 5s1SR0vKxgnZmvPrMgRPpdyDe3QcU1vP49X6PQDIqWISsRVu1VtWSRtSVgsBo2MI9NEk PFO+BGobzP6psvCTcR43jbbG1+7PJ12/1QcLFFOSnWXIJW7NPrJdSfkQsjF4y0nzauGc ds9LZiK5ZI5ZyJD/M5J6JN2Je3xc+INeJk5IGgkRmBVnJdvLB0AD10GWpz/hfVRNP2bW YAm1gj70rc3BpS07CZReW4DujsEpsgozdp00gwg4q7hOscTnGB9GWbsYi4deZrgqQK/2 G0RQ== X-Gm-Message-State: AOAM532HJSOiOVv69XlMsEyxjUdzoDDVEqLNI9nDcVlt3PLIaFwpdmSK dsqCpEbbMRXgZRlwtz2Vs+c8ig== X-Received: by 2002:a17:902:c24b:b029:d3:f3e6:1915 with SMTP id 11-20020a170902c24bb02900d3f3e61915mr317961plg.56.1603767998331; Mon, 26 Oct 2020 20:06:38 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id 17sm165872pfj.49.2020.10.26.20.06.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2020 20:06:37 -0700 (PDT) Date: Tue, 27 Oct 2020 08:36:36 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Srinivas Pandruvada , Zhang Rui Subject: Re: [PATCH v2 2/4] cpufreq: intel_pstate: Avoid missing HWP max updates in passive mode Message-ID: <20201027030636.hvqllxkarjvb5wnn@vireshk-i7> References: <2183878.gTFULuzKx9@kreacher> <3212190.yEXfVNHMLB@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3212190.yEXfVNHMLB@kreacher> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23-10-20, 17:35, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > 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+ > Signed-off-by: Rafael J. Wysocki > --- > > The v2 is just the intel_pstate changes (without the core changes) and setting > the new flag. > > --- > drivers/cpufreq/intel_pstate.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > Index: linux-pm/drivers/cpufreq/intel_pstate.c > =================================================================== > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c > +++ linux-pm/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; Acked-by: Viresh Kumar -- viresh