Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1360871pxb; Fri, 10 Sep 2021 04:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcL9bljr7KeUzF7pMsCNq6u+MlcimsPGuLznJ6WTKvZBx73f/gLOgS1b+WZEGygNzz4ure X-Received: by 2002:a02:a10b:: with SMTP id f11mr4098218jag.16.1631272807305; Fri, 10 Sep 2021 04:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631272807; cv=none; d=google.com; s=arc-20160816; b=ZT41J/RR7/+DmIvknMQyZWTBwBzFqgGNkR2QXnW9pj0GWZ5aYJN9tMYTXN5jRi3ien wttCprcdmk2FKhoqcG2VgsVRZOgC2PnhrjUaEAmIp2wxeMCtkxrxgMb1MjLlyxwT2AKC nBfe59dSn17inc2eDjtmk9RZ/npEed7BY+QsXULJAoXnrr9NZdvbk4wt0BHjqTqExnBm qj5ew/PxEqUL0hsUktHNusqmpUQF8WwE0bZXFzWsRLtyALsnnDnOKOrPD5EDNoz1NWQX OMn+UVt8Pu8hWar/+3jsWlJbBGA0W4grJYjbfXRl6Wc2lXHttAV6CeJyDTIBrrqYydiE 9eUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=mc0xPslGZj9sy1U7IiLU0vE11/d4ChU3H+1S8KTMkf8=; b=My/lFLWxvlpTg1oiiKrX8Owde891/JpGhiRnQiHZT47Kz21Hwc8M+qZXlGdmPsrice APxEyQSQ2lYqmykVSpis20aJpqw1aLr2+/wS1RQkKiis/JJ5cFrbvLiyDuOzkA+S/SXR 7ESv6apzLQ1WDL8ctUtfvwq+bbbeERxiqJVLK94k6gqMn8j+YreFJnqYEouB31QmTttO fIcTWxuoXY2+EygeIr3tVfculHIyra3Zd9DrnNAFAUW0yjvsn1OnPgkVM0VKWf0wkBbd kd/evqALsvTqSMymouPLxCWPR7uU003zz7TfDVkHqJKIu3VjHBhceFRUxXlaccq2YhLf d6tQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w67si235769jaa.124.2021.09.10.04.19.55; Fri, 10 Sep 2021 04:20:07 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232755AbhIJLTn (ORCPT + 99 others); Fri, 10 Sep 2021 07:19:43 -0400 Received: from mail-oi1-f170.google.com ([209.85.167.170]:45679 "EHLO mail-oi1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbhIJLTm (ORCPT ); Fri, 10 Sep 2021 07:19:42 -0400 Received: by mail-oi1-f170.google.com with SMTP id q39so2401606oiw.12; Fri, 10 Sep 2021 04:18:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mc0xPslGZj9sy1U7IiLU0vE11/d4ChU3H+1S8KTMkf8=; b=t/exzw+EAAB1Lb6ptNFV4VsanYDttNI6btyE9NlQJHTkiIF8kgONdBe1jx0UeFJYG+ zBhB+fwW3NqRdNSsbsOW+3XFTEhiVYIDTv+tX9YyKFFMkOp4mCWUeeKe1G5PusyG+U02 s9YmMlykR6dQgH9xvq/YiTyY9cMtA1pBcrfWGKIh4rHSCw2rCZ8o1Xbfuh41zFuGjiVN NPuGJ6y98C6ZBX9G95IpOYNtl4N+k6SFH2pntqaykB8DfPA/KSgwUfig6QIpi0ayMJTu kI5cRNVjknKX4/8DWellORgk5zPe+sXBzw2xdAwJYhAsHNNTZS8jrUlYJRWh/0n2dmNi pKcQ== X-Gm-Message-State: AOAM532wxUP/vYRm1me0oBJxWF2+clxAHffNR7Mopd5KU2bCQ1AUSLE7 3/s5yMyPFJh/RBFgLnoeIzzYlK4N2ZPVttoCvhQ= X-Received: by 2002:a05:6808:10c1:: with SMTP id s1mr3523425ois.69.1631272711378; Fri, 10 Sep 2021 04:18:31 -0700 (PDT) MIME-Version: 1.0 References: <20210909034802.1708-1-dsmythies@telus.net> <223a72d91cfda9b13230e4f8cd6a29f853535277.camel@linux.intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 10 Sep 2021 13:18:19 +0200 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Override parameters if HWP forced by BIOS To: Doug Smythies Cc: "Rafael J. Wysocki" , Srinivas Pandruvada , Len Brown , Linux Kernel Mailing List , Linux PM Content-Type: multipart/mixed; boundary="0000000000007e802005cba246a4" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000007e802005cba246a4 Content-Type: text/plain; charset="UTF-8" On Fri, Sep 10, 2021 at 5:14 AM Doug Smythies wrote: > > On Thu, Sep 9, 2021 at 10:22 AM Rafael J. Wysocki wrote: > > On Thu, Sep 9, 2021 at 6:12 PM Rafael J. Wysocki wrote: > > > On Thu, Sep 9, 2021 at 3:20 PM Doug Smythies wrote: > > > > On Thu, Sep 9, 2021 at 4:18 AM Rafael J. Wysocki wrote: > > > > > On Thu, Sep 9, 2021 at 8:52 AM Srinivas Pandruvada > > > > > wrote: > > > > > > > > > > > > On Wed, 2021-09-08 at 20:48 -0700, Doug Smythies wrote: > > > > > > > If HWP has been already been enabled by BIOS, it may be > > > > > > > necessary to override some kernel command line parameters. > > > > > > > Once it has been enabled it requires a reset to be disabled. > > > > > > > > > > > > > > Signed-off-by: Doug Smythies > > > > > > > --- > > > > > > > drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------ > > > > > > > 1 file changed, 16 insertions(+), 6 deletions(-) > > > > > > > > > > > > > > diff --git a/drivers/cpufreq/intel_pstate.c > > > > > > > b/drivers/cpufreq/intel_pstate.c > > > > > > > index bb4549959b11..073bae5d4498 100644 > > > > > > > --- a/drivers/cpufreq/intel_pstate.c > > > > > > > +++ b/drivers/cpufreq/intel_pstate.c > > > > > > > @@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void) > > > > > > > */ > > > > > > > if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || > > > > > > > intel_pstate_hwp_is_enabled()) { > > > > > > > - hwp_active++; > > > > > > > + hwp_active = 1; > > > > > > Why this change? > > > > > > > > > > I think hwp_active can be changed to bool and then it would make sense > > > > > to update this line. > > > > > > > > > > > > hwp_mode_bdw = id->driver_data; > > > > > > > intel_pstate.attr = hwp_cpufreq_attrs; > > > > > > > intel_cpufreq.attr = hwp_cpufreq_attrs; > > > > > > > @@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init); > > > > > > > > > > > > > > static int __init intel_pstate_setup(char *str) > > > > > > > { > > > > > > > + /* > > > > > > > + * If BIOS is forcing HWP, then parameter > > > > > > > + * overrides might be needed. Only print > > > > > > > + * the message once, and regardless of > > > > > > > + * any overrides. > > > > > > > + */ > > > > > > > + if(!hwp_active > > > > > > This part of code is from early_param, Is it possible that > > > > > > hwp_active is not 0? > > > > > > > > > > Well, it wouldn't matter even if it were nonzero. This check is just > > > > > pointless anyway. > > > > > > > > > > > > && boot_cpu_has(X86_FEATURE_HWP)) > > > > > > > + if(intel_pstate_hwp_is_enabled()){ > > > > > > > > > > This should be > > > > > > > > > > if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) { > > > > > > > > Disagree. > > > > This routine gets executed once per intel_pstate related grub command > > > > line entry. The purpose of the "if(!hwp_active" part is to prevent the > > > > printing of the message to the logs multiple times. > > > > > > Ah OK. Fair enough. > > > > > > You can do all of the checks in one conditional, though. They will be > > > processed left-to-right anyway. > > > > > > But then it would be good to avoid calling > > > intel_pstate_hwp_is_enabled() multiple times if it returns false. > > > > > > And having said all that I'm not sure why you are trying to make > > > no_hwp depend on !hwp_active? I will not be taken into account anyway > > > if intel_pstate_hwp_is_enabled() returns 'true'? > > > > > > So if no_hwp is covered regardless, you may move the > > > intel_pstate_hwp_is_enabled() inside the no_load conditional. > > > > > > Alternatively, and I would do that, intel_pstate_hwp_is_enabled() > > > could be evaluated earlier in intel_pstate_init() and if it returned > > > 'true', both no_load and no_hwp would be disregarded. > > > > Something like the attached, for the record. > > O.K. and Thanks. > I was trying to avoid this line getting into the log: > > [ 0.000000] intel_pstate: HWP disabled > > only to overridden later by, now, these lines: > > [ 0.373742] intel_pstate: HWP enabled by BIOS > [ 0.374177] intel_pstate: Intel P-state driver initializing > [ 0.375097] intel_pstate: HWP enabled > > Let me see if I can go with your suggestion and get to > what I had hoped to get in the logs. It would be sufficient to put the "disabled" printk() after the "no_hwp" if () statement in intel_pstate_init(). See attached. BTW, I've changed the message to "HWP not enabled", because that's what really happens to be precise. --0000000000007e802005cba246a4 Content-Type: text/x-patch; charset="US-ASCII"; name="intel_pstate-arguments.patch" Content-Disposition: attachment; filename="intel_pstate-arguments.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kte9jpzq0 LS0tCiBkcml2ZXJzL2NwdWZyZXEvaW50ZWxfcHN0YXRlLmMgfCAgIDIyICsrKysrKysrKysrKysr LS0tLS0tLS0KIDEgZmlsZSBjaGFuZ2VkLCAxNCBpbnNlcnRpb25zKCspLCA4IGRlbGV0aW9ucygt KQoKSW5kZXg6IGxpbnV4LXBtL2RyaXZlcnMvY3B1ZnJlcS9pbnRlbF9wc3RhdG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