Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp579608pxb; Thu, 9 Sep 2021 07:31:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb9PRvtz0l2YQadzEqj6+R5e4wLJgCdpcjTDZTEQxSgteDjHDx67CV8ZiQuzxVd9ugyAOu X-Received: by 2002:a05:6512:224b:: with SMTP id i11mr70031lfu.605.1631197911143; Thu, 09 Sep 2021 07:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631197911; cv=none; d=google.com; s=arc-20160816; b=fVlFtH5LEqrvVm3DZEp0/HZABJzzwSdiCcyviAsd+NTmnBBiXO41rApnNaA5z1QlaR aHHGo4fPecFCuo5F2HQelUwKgcRHyvtSIRtvhX8D3F7CqaMwIMX5ITL6obXusM+1S/hi GfFfdwiMgOiMbedmfOHIFYCqXB3pN45AVojQgqXfuaoovb0U8tx1y9bywLR00Ze+RVyT S7KN+noQSoLXVSqzsxi5YduDtS/Cg41jrHUyspcch5l+IKBq1TFizrUj6Bxs2UPTdnBA Mwos6AG6mLzsvCAVGDTsoHvjgIprhGawOoSK/q0EjfQuXzdS74yAfL4HLFsSN2wfjYc3 Xc6A== 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=LhLDAgLz2Ns2LxKgq91jjelAjLVn8rnv2rxAxrObxNY=; b=QG70w4CC4Cx+vHr4K1kck1V+nQ8sgirC6SD9sRKIYwoNoKdm1Tlec8vxt+0vUYGLpO UNihx2m0rYMooOTXDAwTFT3/T3AiKA1FCA/f/laLLwpiPo75FEC8vjUHkzTF7BFbQX+A Nn9MZCso3iH/rGtlXvmDrvgczZpapkvBmqjqdckGrR2KBwA3p9P6632kevh/jGMskov9 ADg/SZTnQ3+TL/v8dqNBBgkmmmG8ZcSswlf+09qMUtSJFBHxk2amNXhsmYcFUGdFl6Uk kQzjQF9iURPamx48j8gFx+2e7UcUg/0vGnYbSwSKQqGKMq4hdbFOmG2po7m7t9dcvuGL ZczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@telus.net header.s=google header.b=EZbNiLk6; 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 b2si2081624edw.361.2021.09.09.07.31.22; Thu, 09 Sep 2021 07:31:51 -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=EZbNiLk6; 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 S239952AbhIIOa7 (ORCPT + 99 others); Thu, 9 Sep 2021 10:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239664AbhIIOaz (ORCPT ); Thu, 9 Sep 2021 10:30:55 -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 7C975C141149 for ; Thu, 9 Sep 2021 06:20:57 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id f18so3654741lfk.12 for ; Thu, 09 Sep 2021 06:20:57 -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=LhLDAgLz2Ns2LxKgq91jjelAjLVn8rnv2rxAxrObxNY=; b=EZbNiLk6QT/lInWHMhAJpHF8jEuu6FDWlWjLNo6BfRNMmpqmEXsxuIN1DP2BhdlKmv EGiIRpPenm/DvgX81YBa2XN++Eg4ivMCQROUQyjjZOCtcBv2VeLzqLvhmuafdih1TC5y oT3TUc0wDuguRPVzrNnFpe7IxWU2Xgo+nGfEW9n1Z1+Gi0FuhQM9PA1g72qFzMSOaqKV LT5Ro2nuSiQoNS1HUdj6HS34s/MVbunJuETqYH7gyiD9hEd4L1FHyNgECc4qQPPDe0N2 3dV1GRVB1n+4wDSgKvX3bdsmU3Wpeh2P8RiGZg88ZBvT8E/sigHgOpoNd1VFQvs4gtzr tSuA== 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=LhLDAgLz2Ns2LxKgq91jjelAjLVn8rnv2rxAxrObxNY=; b=CGdwoY1eHqS2xGLI4eWC2XugZSnNC6CNjxYzpVxf6IYzN0Hc7FKI/vFpTXKAyYrGgC U2p06VMs35xosVeZCcIrKGVhTHw0I62f6hs0GhahpePAKA9iKTvM40yvJPL7P/bHQk8j aZZ+KeejKF9n83Q4Et00lEQjFgymnOvgZ2SIn1W6E45+2EBj6GP9Jr/g04stq3UNHhJI g02UEoqOPG+FXBbluyr4dZnTRbhJIHrDRLt8IShiPbRI0Yhtq2xrTtkQuvIZro/e36Tv HK11GYAQpKzxV4w9SzK9j5vXSRaH6iQehq5mq1wezfQTlMoSce+YMwPpGpa/leN8C8hs 9+BA== X-Gm-Message-State: AOAM5308PPDfTYR4bXLrG8VvaacbQ3ZKJ3PjvoE3SIrktU5BtT2qwfrL wNArybomOKAPBoDf6IbrO3PsTCzM7d5crNsYjXhTng== X-Received: by 2002:a05:6512:3a86:: with SMTP id q6mr2334594lfu.4.1631193655837; Thu, 09 Sep 2021 06:20:55 -0700 (PDT) MIME-Version: 1.0 References: <20210909034802.1708-1-dsmythies@telus.net> <223a72d91cfda9b13230e4f8cd6a29f853535277.camel@linux.intel.com> In-Reply-To: From: Doug Smythies Date: Thu, 9 Sep 2021 06:20:45 -0700 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Override parameters if HWP forced by BIOS To: "Rafael J. Wysocki" Cc: Srinivas Pandruvada , Len Brown , Linux Kernel Mailing List , Linux PM , 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 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. > > > > + 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; > > > } > >