Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1115079pxb; Thu, 9 Sep 2021 21:15:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU8RyLGOC1LTjMXl9TV8XJJ6/loNzQ9WKK9autmMXbQDHM1+duuW5sESq5g6gStYPaaTIE X-Received: by 2002:a17:906:3542:: with SMTP id s2mr7330745eja.379.1631247317554; Thu, 09 Sep 2021 21:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631247317; cv=none; d=google.com; s=arc-20160816; b=PyV0GFg6pr9HS7kPh4X2Ff5S1KhgcCa0OcdYvaqgdIODluJiO37I962hF4lAtn25lw 59EosXCkcek3Et6phJx37F00x3gWuF1F/wSGBtpg6DKNJWyJAZxZWcN480wA2iL9SmDf hL++6TpeWqTAiwKlLdYZ4yY1WvDcH8q78gmiUOw49r9q6KUqcG8NKp6qzEWxmDHhmGnC bJ3yhmIu/DkX2rssvjtqvVsryVPTqe9ADt8Bs96isLPFumyZA2BT+JPySQsc/CmlB99w xtTHQjcUHhsKnci55NGMl+3expbtZAqZ53UuiJAawiD77lbZFLTjTztP6kwRU4N50UfH U6vg== 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:dkim-signature; bh=DxuUJjYQzcMig7TJzqeQbDiwDXMeQY4AlFQzmAL8BFo=; b=hOREIvt2deFWFJh5sKxAIJA0t8ygQkMOTdVmtag1hn9G5BCu5cuXpBdNAmN+Zt9ZgE u0coiurwEYf+EU8qEChWucdkSc/3jYYtJCJE+P1n1DQ3qyZpyY+JR6kNjXe3Z7g6s07W 2qBWStsLVoxO1uBRQ8WKx5RwLg1CjR6mu8RKCy0EFJgHaSqlaJYkYtRQpWWkZ2RvOLFc mPCuAiPy589zjKXdpHnG1IMlciLLm8J7NwtWuYq9kdy7O/zD8gMMnnnVxrhvWk+8b+ZE W4UbAQvQkhroZ6dfpYcHSJkDvVNhFn6h1lwdCg9CrKBcOWO8lNBkcWn8hNhO4Z2mruRt Ed6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@telus.net header.s=google header.b=caV35vZB; 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=telus.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp36si4231987ejc.19.2021.09.09.21.14.53; Thu, 09 Sep 2021 21:15:17 -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=@telus.net header.s=google header.b=caV35vZB; 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=telus.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229507AbhIJENG (ORCPT + 99 others); Fri, 10 Sep 2021 00:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbhIJENG (ORCPT ); Fri, 10 Sep 2021 00:13:06 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE5CC061574 for ; Thu, 9 Sep 2021 21:11:55 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id k13so1375554lfv.2 for ; Thu, 09 Sep 2021 21:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DxuUJjYQzcMig7TJzqeQbDiwDXMeQY4AlFQzmAL8BFo=; b=caV35vZBF/+tv+N/twTyQQIepPYKrU77+eUwAhhJt3yzpY3fZR+jg6Vj0KzNx1wMlG khJyigYpp6RzraAOG24s+SRBLCuqBhIjY7ndBQ5GL05US8rXNihBIvuEIX2pK4RieWjG 6Oma/I6gIdr/zl/fcrcU85RJXRGJOekaW7423Xyfi+lyYoqWbNJSnZowbQOW0g/PO8dB Ip9MKNP9KqFk9e0puoqir2yz4xIKFi6wxSX5IOc1PAdQaFaBE1S6Ud9QaNAmx1MgV/pn OQeQiz/Ap2LiVmj6CAUlJuKzapQNJWxX0fvvO5nkN2r9//rFyQLpLHsbCSRiVgSPwI4L uCNQ== 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=DxuUJjYQzcMig7TJzqeQbDiwDXMeQY4AlFQzmAL8BFo=; b=n3X/mQqa6hIfASKpEpH7mJ8Nm1E2tDTi8oQiwMDqcLYMIWQWHNLiD4Y3aT9UNVGfXd bWLWMmDMqJxmr2qw6IgecvNCvQR5cDSptPgflhp/ZP/B/XQAieTVCoSTcKHehS7QZ5vJ Z65X9BGqVdp/13nc+HPedaZy7Q5wYlZe0HDHSHCf4tRXBsyQUS4JLJYSyeHZCezaV52i 6RebaU1X/jgElyiYV2PohG9wRz3xXuFvE3rWB+cA+uLGLlwEW3VZYtXMAIqrWFZLCnly KB+FipC0NrFUlQAPrMTdtoWS+J2QxU1tCzYmnY6yw+RxSvx3gCn0t/WLY2Uh4+ZymXmS l28Q== X-Gm-Message-State: AOAM533qMhptexRCfpg91Y6qVqB+PWn346u5OpqYZg6Mo4zwFSv+2EwC Otoh4M8R2ugjxFPNUoYf8j+IzflbQT37idgceYfoAQ== X-Received: by 2002:a05:6512:695:: with SMTP id t21mr2316218lfe.157.1631247113923; Thu, 09 Sep 2021 21:11:53 -0700 (PDT) MIME-Version: 1.0 References: <20210909034802.1708-1-dsmythies@telus.net> <223a72d91cfda9b13230e4f8cd6a29f853535277.camel@linux.intel.com> <9586d66802138dc144836b310ef5b20394c59695.camel@linux.intel.com> In-Reply-To: <9586d66802138dc144836b310ef5b20394c59695.camel@linux.intel.com> From: Doug Smythies Date: Thu, 9 Sep 2021 21:11:46 -0700 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Override parameters if HWP forced by BIOS To: Srinivas Pandruvada Cc: "Rafael J. Wysocki" , Len Brown , Linux Kernel Mailing List , Linux PM list , dsmythies Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 9, 2021 at 7:53 AM Srinivas Pandruvada wrote: > On Thu, 2021-09-09 at 06:30 -0700, Doug Smythies wrote: > > On Wed, Sep 8, 2021 at 11:33 PM 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? > > > > It was just to keep it at 1, but I agree not absolutely needed. > > > > > > > > > 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? > > > > Not at this point, in any testing I did. > > But I do not know the authoritative answer > > to your question. > > > But as you explained you want to prevent repeated print of > "HWP enabled by BIOS". So you need this. > > > > > > > > && boot_cpu_has(X86_FEATURE_HWP)) > > > > + if(intel_pstate_hwp_is_enabled()){ > > > > + pr_info("HWP enabled by BIOS\n"); > > > > + hwp_active = 1; > > > > + } > > > > if (!str) > > > > return -EINVAL; > > > > > > > > - if (!strcmp(str, "disable")) > > > > + if (!strcmp(str, "disable") && !hwp_active) > > > > no_load = 1; > > > > - else if (!strcmp(str, "active")) > > > > + if (!strcmp(str, "active")) > > > > default_driver = &intel_pstate; > > > > - else if (!strcmp(str, "passive")) > > > > + if (!strcmp(str, "passive")) > > > > default_driver = &intel_cpufreq; > > > > > > Why "else if" changed to "if" ? > > > > Because it doesn't matter anyway and I would > > have had to figure out another qualifier. > > This way, and given that this executes once per > > intel_pstate command line parameter, the code > > executes the way it used to, overall. > If someone specified intel_pstate=active, it will also compare with > "passive" with this change. Disagree. As far as I can tell, and I tested, it works as expected. ... Doug > > > > - > > > > - if (!strcmp(str, "no_hwp")) { > > > > + if (!strcmp(str, "no_hwp") && !hwp_active) { > > > > pr_info("HWP disabled\n"); > > > > no_hwp = 1; > > > > } > > > > > > > >