Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp430014pxb; Thu, 9 Sep 2021 04:24:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwllxHy4mS2YOeLkbghXzYg4jM7jtFpyjcaLgNXvJVnEHbZH072Tr7eemBUBBLLG6h6XtbQ X-Received: by 2002:a17:906:d92f:: with SMTP id rn15mr2866398ejb.151.1631186660433; Thu, 09 Sep 2021 04:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631186660; cv=none; d=google.com; s=arc-20160816; b=Ui+WGOJYudWdu/aDWBdU5PZx8H3h/UML9nBCb447zXlrQEx1Hh6dmdn0A/nxMfizKz craEBbV3oTMI91RNQ1RmuYea3pzGhRQ1bILs+eODkU7uISBlOjtt0GUVKpu08CZjKbzm aRsf3PeB5SA89FS3Tzj0SBPuPsxE8rAfttA46pUoI4WqOj2kEeQ8YM+wlp/ZT3MIABwI HL0hiLu9LVIUvHZtYuebedbTXx5OZeM5fA5+/FhJe+hcwzTduBA9GiLkoqHIPUf3s0Mu c6uEaIaQNrLVRbEeb3bmo6IF7xGnwjIaYqtzFEoslnk09RfjGBP+uLIHqtee1e4MSh3o f7Tw== 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=KB4OAq1FA2ibjg5GPYhy0r8vL3pcy4KSo6N7CuRv9t0=; b=OiJETDAfO0gNGsBTfkvvaqpE0lG+3/4TygXUBpxwBc+wYJuGLwR8CwkU/yeahfmeca b2z6H3ptXXPTdVSM12S8RHlsyYD4UA/FYVqy5eLgh00QL1dQ8GlX+BvrzAmNwUpMzDZ1 qXufxRKCXBi7mj/nBk8jJJ9vl35X5z6d+yHFQpGIFMRJEppxgHgxWAWlXxDIfwsiRwFG 6bqe7x7VNrWADK1Zo/7d9SricK/qU9x9ke6aobT7DVaYcVUiB+sMgdaP3yxq4Zeq54AU zh8Y7roYmwgEZ4S1768B3tbkPqO4xzh0Oj9f5ixuBmAr/iBB6TGgJyLlqPEWJF6bi/4D qtqw== 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 f17si1438964edv.462.2021.09.09.04.23.56; Thu, 09 Sep 2021 04:24:20 -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 S236759AbhIILUw (ORCPT + 99 others); Thu, 9 Sep 2021 07:20:52 -0400 Received: from mail-ot1-f44.google.com ([209.85.210.44]:43671 "EHLO mail-ot1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234993AbhIILT4 (ORCPT ); Thu, 9 Sep 2021 07:19:56 -0400 Received: by mail-ot1-f44.google.com with SMTP id x10-20020a056830408a00b004f26cead745so1982469ott.10; Thu, 09 Sep 2021 04:18:47 -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=KB4OAq1FA2ibjg5GPYhy0r8vL3pcy4KSo6N7CuRv9t0=; b=rPT8Ht9djkYZO7tpf/XG4G6u4N0u3x69s3X31gq8kSp0Jezqv0AmxopmRUbJW3dg2T ZQgQNnonZ7XRVeMWkDwUMGAOlmJv/NFG9O69NNOl3ytyku0xpfwM6Zfws65a/N8a4sCG hQa2j5f7vG0eqLZilBBq4Z3zOxU58YflXG8zZf0hhgE83E3y/936SOyZKzX2zC0UySYX KSWtZ03TvtiPd+9ZYkuzWVeviGUK4mk1IVUQTNkGqonm9NIcRTTpffIIigxFEy3//zEs Ijzi1kwdGmIkhvoJKgqt4JJ2Jw0F2mikE5RiJ8IpmqPzDi2tyNnp9WcvWFGW0xknbRto KDPw== X-Gm-Message-State: AOAM530T6vh6//zPqJK2fXjlc8muUdstfF/1zXwuKetnrm0it+hPLWMc zeCfZALhfM3BifPOnPtPR1+KM9fm1XjfL+IjYtM= X-Received: by 2002:a05:6830:34b:: with SMTP id h11mr2006848ote.319.1631186326826; Thu, 09 Sep 2021 04:18:46 -0700 (PDT) MIME-Version: 1.0 References: <20210909034802.1708-1-dsmythies@telus.net> <223a72d91cfda9b13230e4f8cd6a29f853535277.camel@linux.intel.com> In-Reply-To: <223a72d91cfda9b13230e4f8cd6a29f853535277.camel@linux.intel.com> From: "Rafael J. Wysocki" Date: Thu, 9 Sep 2021 13:18:35 +0200 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Override parameters if HWP forced by BIOS To: Srinivas Pandruvada , Doug Smythies Cc: "Rafael J. Wysocki" , Len Brown , Doug Smythies , Linux Kernel Mailing List , Linux PM 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 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()) { > > + 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" ? > > > - > > - if (!strcmp(str, "no_hwp")) { > > + if (!strcmp(str, "no_hwp") && !hwp_active) { > > pr_info("HWP disabled\n"); > > no_hwp = 1; > > } >