From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50A0BC433FE for ; Thu, 9 Sep 2021 14:29:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F3F3610FF for ; Thu, 9 Sep 2021 14:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344848AbhIIObA (ORCPT ); Thu, 9 Sep 2021 10:31:00 -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-Google-Smtp-Source: ABdhPJzFMwW0LknShTWoOxG0dXjECyZ6gv0trd1ZifraCHGqs4Km5GClKkXYMJAM/YVYM2IowgbxvebsqinCnJploVU= 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; > > > } > >