Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp91625lqh; Wed, 27 Mar 2024 16:07:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1Vay/viWtBhYdGIwaoUFYUvf6RMaNnQo5+NipxxLasaifmPhvus4jXx89Udd2ecvzS50nx6/YqO8aEyUFAoOfm9dqklaEcIRuV7BHmg== X-Google-Smtp-Source: AGHT+IHC8L7vnSTGJA1eFkQ+jI1NGbpBl4hrTqLG96WeazQoLfBgO86wy+Y/k6tjSJvLq6GycwiE X-Received: by 2002:a17:906:f1d0:b0:a4e:ca2:f597 with SMTP id gx16-20020a170906f1d000b00a4e0ca2f597mr508518ejb.30.1711580842575; Wed, 27 Mar 2024 16:07:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711580842; cv=pass; d=google.com; s=arc-20160816; b=A+bX0LqrC5iY8dABUaMPcQJHyPijbwg2BxdD188MNtsbH+kn/aRclcTz9yTtx2GUjk edW95AklSjydYx9kjquiA+Bk2TWRA1mXOjnBnOd+IoFssd3o2gcsyk4luLAgmBDJwFOJ U4A7e40OmRXcQ0Ll8hG1OxI+P4WHkeVY1WmIB+xsx1NO0MN7u/8eAoZX3HtigT13creg mGbJtVOWFXWll5gtXbi9m+cd+skJQbXrjcwL6C/FJwJbYgPWf15YKzOKsZQ/ADfaGd1B wAcPG7PSZk5xDFxYVmHTra8heRZ9hX5TQwvdEy9+JtbGW619Hhkn/X/x6cJOIkQwGzwe BnoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=r+MgBwOSBmx+FMDmtcmiqTwVcXn5T3HZLzrrHM5Byh8=; fh=M5m7vRyS2OJF9dOU4iZ6nCSzpwVPj0CaLaFqZwojpck=; b=xfe4p0aHGgPyIRsp+CtUVCS6EgUDA55xJLl6R2ntQhxhyOnVTTQ0kmuxnRjOVDPhaa tSFVczr/nYTSjcC0oAnrTY6uQWKPRgqxHzqK6yKmtgP/umjAtr87ZO6w72JrvJDNHJOE UNHDQTejs4RLJPu1GK/fHsMisFuTLwalrYHHblHjIqB44fEf3GHa5Ap/rmK2TFF5F7po VfdiNxaKXFfCeQkShmdhl2JR79aIwT2gUQKmWUBGOtfeFwaS3vpZIkisnYGec7hABbMh 0Y54EBH1NL2df+SMC1bLGU0o+pJ8Eh8C1Qv6v43iMxem1+QX9MKhN3QnlDjUf4csivyS 2AiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VrtmX0td; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kg3-20020a17090776e300b00a474ba1d1a3si47119ejc.541.2024.03.27.16.07.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 16:07:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VrtmX0td; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121785-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5E1121F34BEA for ; Wed, 27 Mar 2024 18:08:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3798914D71E; Wed, 27 Mar 2024 18:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VrtmX0td" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E946F14E2D0; Wed, 27 Mar 2024 18:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711562927; cv=none; b=BQjis2renq1XbEZ7jwSBZ0Y6p4FAg+4VrKj7OKwrR/b8Bb+K5TgevkbLyDZLN94ZFiTjK0grJc7adgUtkegUMIMFAKeeDsHwsu/ToNYL2zwITQjYvf0RRy8Du871oVHQO1AiEnncg2QSYqmrro5H2WV0mKM9hhv+NAwoUZZjQds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711562927; c=relaxed/simple; bh=r+MgBwOSBmx+FMDmtcmiqTwVcXn5T3HZLzrrHM5Byh8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=sirxFysSWdMF8N8/g2AhDKq5+p82Gl0QxsdPNZFXqIp1ZLXFB4kBRTXTQVctfzIXFBtiV1PO23u/gFafTGPB7V6tYS80g6UW9OZQhOi00eSY+mPhLyiMWxlMhQdF7/JslOr+LIk8tNRmgTMUgfR3H9ClCMS1cH2FLbHECgSIaiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VrtmX0td; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711562924; x=1743098924; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=r+MgBwOSBmx+FMDmtcmiqTwVcXn5T3HZLzrrHM5Byh8=; b=VrtmX0tdxuliyhozkjD3BihbHkhEDhTBzxm/HWH/WqnnzOfx604Ycy6w 1gjTwKKu5NzVSLUTyhG7ka/7XIQt8oIWC0XzEmwfmxpGMNnzL8h1p9PYo m9P0LuzBIX/P+ExBOB2uKfhITyOJSOiFIjsHFeP8aP82Sqjk9fvLRRvHZ oYMHYgwodPNmJXoPTizHlG7k0OKnaFPw1kLBFIIkE243Qp83+Z6ukS9JF 2CWhuVPBqhozjgbskhpqbYH5LWebd1Kq3Owu9hPZeXr5ZL1GNUv98xw2p ANOvPqSeERZrr5Y7rCp8nRGrLNIU8+KbyWGOJ5b4Rxse0iW9ADdzKDQrY A==; X-CSE-ConnectionGUID: Zv0dCqpXSe+JBKIaQqj8Lg== X-CSE-MsgGUID: Bry9A9oIT0O0+nPX/LdMMg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="24138214" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="24138214" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 11:08:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16312915" Received: from spandruv-desk1.amr.corp.intel.com ([10.209.18.107]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 11:08:43 -0700 Message-ID: Subject: Re: [PATCH v1 6/6] cpufreq: intel_pstate: Update the maximum CPU frequency consistently From: srinivas pandruvada To: "Rafael J. Wysocki" , Linux PM Cc: LKML Date: Wed, 27 Mar 2024 11:08:42 -0700 In-Reply-To: <9269494.CDJkKcVGEf@kreacher> References: <13494237.uLZWGnKmhe@kreacher> <9269494.CDJkKcVGEf@kreacher> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2024-03-25 at 18:06 +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki >=20 > There are 3 places at which the maximum CPU frequency may change, > store_no_turbo(), intel_pstate_update_limits() (when called by the > cpufreq core) and intel_pstate_notify_work() (when handling a HWP > change notification).=C2=A0 Currently, cpuinfo.max_freq is only updated b= y > store_no_turbo(), although it principle it may be necessary to update > it at the other 2 places too. It also works for intel_pstate_notify_work() path as is without this change. To start with: $ sudo rdmsr 0x771 6080c14 $ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_* 2000000 800000 0 Now trigger a max frequency change via SST. intel_pstate_notify_work() called because guaranteed also changed. We didn't subscribe for max change only (although we should). Max changed from 2GHz to 1.9 GHz. $ sudo rdmsr 0x771 6080e13 [labuser@gnr-bkc ~]$ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_* 1900000 800000 0 Now trigger SST to change to max frequency to 2GHz. sudo rdmsr 0x771 6080c14 cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_* 2000000 800000 0 May be you mean something else. Thanks, Srinivas >=20 > Make all of them mutually consistent. >=20 > Signed-off-by: Rafael J. Wysocki > --- > =C2=A0drivers/cpufreq/intel_pstate.c |=C2=A0=C2=A0 23 ++++++++++++++++++-= ---- > =C2=A01 file changed, 18 insertions(+), 5 deletions(-) >=20 > Index: linux-pm/drivers/cpufreq/intel_pstate.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c > +++ linux-pm/drivers/cpufreq/intel_pstate.c > @@ -1153,18 +1153,32 @@ static void intel_pstate_update_policies > =C2=A0static void __intel_pstate_update_max_freq(struct cpudata *cpudata, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct cpufreq_policy > *policy) > =C2=A0{ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0intel_pstate_get_hwp_cap(cpuda= ta); > + > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0policy->cpuinfo.max_freq = =3D READ_ONCE(global.no_turbo) ? > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cpu= data->pstate.max_freq : cpudata- > >pstate.turbo_freq; > + > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0refresh_frequency_limits(= policy); > =C2=A0} > =C2=A0 > =C2=A0static void intel_pstate_update_limits(unsigned int cpu) > =C2=A0{ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mutex_lock(&intel_pstate_drive= r_lock); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct cpufreq_policy *policy = =3D cpufreq_cpu_acquire(cpu); > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cpufreq_update_policy(cpu); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!policy) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0return; > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mutex_unlock(&intel_pstate_dri= ver_lock); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0__intel_pstate_update_max_freq= (all_cpu_data[cpu], policy); > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cpufreq_cpu_release(policy); > +} > + > +static void intel_pstate_update_limits_for_all(void) > +{ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int cpu; > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0for_each_possible_cpu(cpu) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0intel_pstate_update_limits(cpu); > =C2=A0} > =C2=A0 > =C2=A0/************************** sysfs begin ************************/ > @@ -1311,7 +1325,7 @@ static ssize_t store_no_turbo(struct kob > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mutex_unlock(&intel_pstat= e_limits_lock); > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0intel_pstate_update_policies()= ; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0intel_pstate_update_limits_for= _all(); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0arch_set_max_freq_ratio(n= o_turbo); > =C2=A0 > =C2=A0unlock_driver: > @@ -1595,7 +1609,6 @@ static void intel_pstate_notify_work(str > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct cpufreq_policy *po= licy =3D cpufreq_cpu_acquire(cpudata- > >cpu); > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (policy) { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0intel_pstate_get_hwp_cap(cpudata); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0__intel_pstate_update_max_freq(cpudata, policy); > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0cpufreq_cpu_release(policy); >=20 >=20 >=20