Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp39947imb; Thu, 28 Feb 2019 15:18:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ5u/pnbjFkmipdPP80TeLwevLwZkMfPWcmcKKQ+15LweopBGvh1Z0Q+2WcrKgLVTTiTQF1 X-Received: by 2002:aa7:9099:: with SMTP id i25mr2276156pfa.102.1551395904824; Thu, 28 Feb 2019 15:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551395904; cv=none; d=google.com; s=arc-20160816; b=v2rcgY290xOfZs+vhv90EvfD+CbaH+Sc8/Eh+3dpsOhMmlTDdt38zXyIDA9yMzJI9W upXOSk0QZEL6z2nas5bZNqF9kmQg3THg3fd1cylBkdef7kH77pdMxc3/0L98s/FFsY4A vJiQZt93MtYF52cNU/CLLy0alvyYxxunifgcisu6nmcI9omMVzNrtdsEe6qy7gVu/Vc1 OdUR8CotcMaSgNybmKB0cTKqWrFESuGK9pZeQEQKBe6/u6u1UJtzVz23rIlPyRySgWMu VPV04pvH5dqvlNsyWAlJ1dlhI1S5se4B6bc5SFuxh0wtX6XjpOmyvNwfyVExbSGMdqLT /veA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=cRJsSnyF/XTs3NecXPZWkb0YNUZklytRPh8uab7VC1g=; b=QIYM+IXG+EyYYW02pchKIqkgfSOOdClo6dYw+x72WSKek7apLWuURkwEYSKMysCHCO MsF3Y2jJlrT4BJiGtZUG7jsTIFO2uVZcfA+NGGxrbEhoiRmAz4K1a0tiGSH7Ax4R3kvc KJWQ8k5nNWhxaFs7rN46Vh5OOgEnWk1lUav3Ik5cy58gpMoTuDsBj0Wda0mFl8/YCOMM ON0lhyDdzuh/7f711i4pMdRph8bhZoo4Srf0MnE3+RoLubTGvYsvOn1c1muZgub+8h4r ZhFQ7mPoIFoO/4Vi1BnZfpYyM0GMXXuX5RGNb0DVkzvm1z2mLVVltbui9bou86idWro2 71Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si19326159pla.155.2019.02.28.15.18.01; Thu, 28 Feb 2019 15:18:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732469AbfB1W5B (ORCPT + 99 others); Thu, 28 Feb 2019 17:57:01 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46914 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727717AbfB1W5B (ORCPT ); Thu, 28 Feb 2019 17:57:01 -0500 Received: by mail-ot1-f67.google.com with SMTP id c18so19239635otl.13; Thu, 28 Feb 2019 14:57:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cRJsSnyF/XTs3NecXPZWkb0YNUZklytRPh8uab7VC1g=; b=FfbrW2pFMY9mSC7fnOQPrrV2l3kyBAPHgQ+E0sfjnp5lhGk96hlazg4YSTnt0Ivb7R /gOh8aHqJSoLg9en5xjhNH3cOxq0l6eSxBkaJJULoOffnrlpxDcs71Hln/h1fG4RL53Z YfdbXYRPSwdgRF5KORNl3GPqhjbz0bRjf4LV+wMGT2G8h8AatopvOobCzUOoAlm3aO5Z j2y9JEXnOGPzpvxweliCde6IvGpNLTbwuEiGiiXmLupfoMH1KqHPVmQ8w0PHq3ZeInYr O9q+6KwW7I0me5PrLGvKQvjukFa1LmLsr3aUJnohVVKaGN7qc0l8UdGBz2MP5RY7O763 E+Ow== X-Gm-Message-State: APjAAAX4P+qLXNkERweHFO6kiUf2JHkikKMhqCFOZIHwoEhxwCerf+KY X7cUl4WXN5WQHjHRsIxzBdjBmcMHQEdMdmpYSHY= X-Received: by 2002:a9d:7cd3:: with SMTP id r19mr1443384otn.139.1551394619852; Thu, 28 Feb 2019 14:56:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 28 Feb 2019 23:56:48 +0100 Message-ID: Subject: Re: [PATCH 2/2][RFC v2] ACPI: Update cpuinfo.max after bootup if necessary To: Chen Yu Cc: "Rafael J. Wysocki" , Viresh Kumar , Srinivas Pandruvada , Len Brown , Linux PM , Linux Kernel Mailing List , Yu Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 28, 2019 at 6:59 PM Chen Yu wrote: > > On Dell Inc. XPS13 9333, the BIOS changes the value of > MSR_IA32_MISC_ENABLE_TURBO_DISABLE at runtime (e.g., when > the power source changes), the maximum frequency of the > CPU is not updated accordingly. This is due to the policy's > cpuinfo.max is not updated when _PPC notifier fires. > > Fix this problem by updating the policy's cpuinfo.max when > necessary. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=200759 > Reported-and-tested-by: Gabriele Mazzotta > Originally-by: Srinivas Pandruvada > Signed-off-by: Chen Yu > --- > drivers/cpufreq/cpufreq.c | 2 ++ > drivers/cpufreq/intel_pstate.c | 15 +++++++++++++-- > 2 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index e35a886e00bc..95e08816b512 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2237,6 +2237,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, > > policy->min = new_policy->min; > policy->max = new_policy->max; > + policy->cpuinfo.max_freq = new_policy->cpuinfo.max_freq; > + policy->cpuinfo.min_freq = new_policy->cpuinfo.min_freq; > trace_cpu_frequency_limits(policy); > > policy->cached_target_freq = UINT_MAX; > diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c > index dd66decf2087..841c74f69f66 100644 > --- a/drivers/cpufreq/intel_pstate.c > +++ b/drivers/cpufreq/intel_pstate.c > @@ -2081,11 +2081,17 @@ static void intel_pstate_adjust_policy_max(struct cpufreq_policy *policy, > > static int intel_pstate_verify_policy(struct cpufreq_policy *policy) > { > + int max_freq; > struct cpudata *cpu = all_cpu_data[policy->cpu]; > > update_turbo_state(); > + max_freq = intel_pstate_get_max_freq(cpu); > + > + if (acpi_ppc && max_freq != policy->cpuinfo.max_freq) > + policy->cpuinfo.max_freq = policy->max = max_freq; Updating cpuinfo.max_freq here only causes the current limit to be reported via sysfs, because intel_pstate doesn't actually use cpuinfo.max_freq for anything and the core doesn't enforce it as a limit. All of the computations in the active mode in the driver actually use the current limit anyway AFAICS. > + > cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, > - intel_pstate_get_max_freq(cpu)); > + max_freq); > > if (policy->policy != CPUFREQ_POLICY_POWERSAVE && > policy->policy != CPUFREQ_POLICY_PERFORMANCE) > @@ -2192,11 +2198,16 @@ static struct cpufreq_driver intel_pstate = { > > static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) > { > + int max_freq; > struct cpudata *cpu = all_cpu_data[policy->cpu]; > > update_turbo_state(); > + max_freq = intel_pstate_get_max_freq(cpu); > + > + if (acpi_ppc && max_freq != policy->cpuinfo.max_freq) > + policy->cpuinfo.max_freq = policy->max = max_freq; In this case (passive mode) updating cpuinfo.max_freq will actually cause governors to use the new value in computations, so the P-state selection will work somewhat differently, but that isn't really consistent with what acpi-cpufreq does and with setting no_turbo in the intel_pstate sysfs to 1 without this patch. With acpi-cpufreq cpuinfo.max_freq is always the max frequency in the _PSS table regardless of what the _PSS limit is. Also setting no_turbo to 1 in intel_pstate without this patch doesn't cause cpuinfo.max_freq to change and I don't really think that it should. I would be tempted to always initialize cpuinfo.max_freq to the max turbo frequency, but there is a concern about systems in which MSR_IA32_MISC_ENABLE_TURBO_DISABLE is never set on the fly (just in the BIOS setup as it should be) and where it doesn't make sense to consider turbo frequencies at all. > cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, > - intel_pstate_get_max_freq(cpu)); > + max_freq); > > intel_pstate_adjust_policy_max(policy, cpu); > > -- It looks like I need to think about this a bit more.