History log of /linux-master/tools/power/x86/intel-speed-select/isst-config.c
Revision Date Author Comments
# a590ed62 13-Oct-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.18 release

This version addresses issues with:
- When CPU 0 hotplug is not possible, try cgroup v2 isolation
without any user input
- Fix turbo mode enable/disable swapped
- Sanitize command line integer and hex arguments
- Add more error messages
- Increase CPU count in one request

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 3bc0f20a 03-Oct-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Use cgroup isolate for CPU 0

From kernel version 6.5, CPU 0 hotplug capability is deprecated.
If some SST profile doesn't have CPU 0, then it is no longer possible to
offline CPU 0. This means that user space threads will still run on
CPU 0.

To workaround this issue, use cgroup v2 isolation feature. Whenever there
/sys/devices/system/cpu/cpu0/online file is absent or open fails, isolate
CPU 0 via CPU cgroup v2 isolation. Also add a command line option to
force even if the /sys/devices/system/cpu/cpu0/online is present.

The previous commit "01bcb56f059e ("tools/power/x86/intel-speed-select:
Prevent CPU 0 offline") was just warning about this issue based on the
kernel version 6.5 and above. With this new approach, instead of warning
take action to mitigate the issue.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# bc5370cc 13-Oct-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Increase max CPUs in one request

With the increase in the CPU count, this count needs to be updated.
Increase max CPU count to 512.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# da4c1b9e 07-Sep-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Display error for core-power support

When core-power is getting enabled, if the feaure is not supported,
display error.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 2fe8d2d7 07-Sep-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: No TRL for non compute domains

Don't call to set or get TRL for domains in which there are no CPUs.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 7b00d101 07-Sep-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: turbo-mode enable disable swapped

The command for turbo-mode enable and disable is swapped. Fix that.
Previously turbo-mode enable was actually disabling and disable was
enabling.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 3076db34 07-Sep-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update help for TRL

TRL (turbo ratio limit) argument is passed in hex string. Clarify that
in the help.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 61f3d868 07-Sep-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Sanitize integer arguments

If the command takes some integer arguments, make sure the command
contains only digits. Same for Hex arguments. Otherwise return error.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 2fff509a 08-Aug-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.17 release

This version addresses issues with:
- CPU count display for power domain != 0
- Support more than 8 sockets
- Error on max CPU count exceeds in one request
- Prevent trying CPU 0 hotplug for kernel version 6.5 or later
- Change mem-frequency display to max-mem-frequency

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 01bcb56f 08-Aug-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Prevent CPU 0 offline

Kernel 6.5 version deprecated CPU 0 hotplug. This will cause all
requests to fail to offline CPU 0. Check version number of kernel
and ignore CPU 0 hotplug request with debug aid to use cgroup
isolation feature for CPU 0.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e67b6ed2 08-Aug-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Error on CPU count exceed in request

There is a limit on number of CPUs in one request. This is set to 256.
Currently tool silently ignores request for count over 256. Give an
error message to indicate this.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 7a4ab2f4 15-Jun-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix CPU count display

Fix CPU count display for power domain != 0. In the function
punit_id is always 0, so it never incremented cpu count for power
domain id != 0.

Update punit_id after call to update_punit_cpu_info() to what is
actually received from the kernel.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 7244720a 12-Jun-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.16 release

This version addresses issues with core power configuration for
non CPU dies. Also address issue with JSON formatting of output.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# fcf12783 22-May-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix json formatting issue

Fix two issues related to JSON formatting:
1.
intel-speed-select -f json -o cp.out -c 1 core-power assoc -c 1
Intel(R) Speed Select Technology
Executing on CPU model:143[0x8f]
[root@spr-bkc bin]# cat cp.out | jq .
"package-0:die-0:cpu-1"

2.
intel-speed-select -f json -o tf.out turbo-freq enable -a
Intel(R) Speed Select Technology
Executing on CPU model:143[0x8f]
[root@spr-bkc bin]# cat tf.out | jq .
{
"package-0:die-0:cpu-0": {
"turbo-freq": {
"enable": "success"
}
},
"package-1:die-0:cpu-48": {
"turbo-freq": {
"enable": "success"
}
}
}
"turbo-freq --auto"
parse error: Expected string key before ':' at line 17, column 24

Both of these issues needed proper closing "}" for JSON.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 4ebde55b 18-May-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Adjust scope of core-power config

When core-power configuration or enabled is modified, this is only done
for compute dies. But the config must also be set to cores with no CPUs.
Without this the configuration is not affective.

On displaying config information, allow display for non compute dies
also.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 19799d3a 17-Oct-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Update version

Update tool and supported API version. This is the first version which
supports newer Xeon platforms with TPMI support.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: subject and changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 1d54b139 22-Feb-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Identify Emerald Rapids

There are some differences compared to Sapphire Rapids. So, add a separate
API.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 997074df 22-Feb-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Use cgroup v2 isolation

On supported systems, it is possiible to isolate CPUs instead of
CPU online/offline. This is optional and can be specified using
-g option when running as daemon or in combination with -o option
for SST-PP level change.

CPU isolation doesn't isolate IRQs. So IRQs needs to be moved away
from isoolated CPUs. This can be done via IRQ sysfs or irqbalance daemon.

The IRQ balance daemon is also capable to parse thermal HFI messages to
move IRQs away from CPUS, which are supposed be isolated. But this
requires version released after July 2022.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 57797f19 22-Feb-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add missing free cpuset

During perf level change cpuset is allocated but not freed.
Add free_cpu_set() in success and failure path.

Although this is not an issue, as the program will exit after
processing of online/offline, but for completeness add the
free_cpu_set().

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# d0e12c46 13-Sep-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Add cpu id check

Some operations applies to cpu-power-domain only. Add check for cpu id
for these functions.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 14f0cf6c 02-Feb-2023 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Avoid setting duplicate tdp level

If the new TDP level requetsted is same as the current TDP level, don't
call into driver to change level.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 443bf104 17-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Prevent cpu clos config for non-cpu power domain

Non-cpu power domain does not support cpu clos config.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# a0ca5a09 06-Mar-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Get punit core mapping information

Get punit core mapping information using format of MSR 0x54. Based
on the API version, decode is done using new format. The new format
also include a power domain ID. TPMI SST information is for each
power domain.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 887e5be9 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce api_version helper

In some cases, the output format may be different with different
api_version because of different capabilities or for backward
capabilities reason.

Introduce api_version() to get the api_version of the platform running.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 9798768c 08-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce is_debug_enabled()

Platform specific code also needs to give debug output.
Introduce is_debug_enabled() for this purpose.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 05aab5b8 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Allow api_version based platform callbacks

Different api_version suggests different kernel driver used and
different interface is used to communication with the hardware.

Allow setting platform specific callbacks based on api_version.

Currently, all platforms with api_version 1 uses Mbox/MMIO interfaces.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 73452ccc 02-Feb-2023 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Abstract adjust_uncore_freq

Allow platform specific implementation to adjust the uncore frequency.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 05ece691 08-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Remove isst_get_pbf_info_complete

isst_get_pbf_info_complete does nothing but just free the core_mask.
Remove the function and do free core_mask directly and free core mask in
the caller.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# d0d1a603 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce isst-core-mbox.c

isst-core.c should contain generic core APIs only.
Platform specific implementations/configurations should be removed from
this file.

Introduce isst-core-mbox.c and move all mbox/mmio specific functions to
this file.

Introduce struct isst_platform_ops which contains a series of callbacks
that used by the core APIs but need platform specific implementation.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e9f79348 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Always invoke isst_fill_platform_info

isst_fill_platform_info fills platform specific information.
And it is the proper place to set platform specific callbacks, as done in
next patch.

As the platform specific callbacks are needed in all cases, including
isst_print_platform_information.

The best way to achieve both is to invoke isst_fill_platform_info
unconditionally, and make isst_print_platform_information leverage the
data already filled.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 13b868f8 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce isst_get_disp_freq_multiplier

Remove hardcoded DISP_FREQ_MULTIPLIER in the code and use
isst_get_disp_freq_multiplier() instead.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 2042c0ab 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Move mbox functions to isst-core.c

isst-config.c should only contain generic code.
Move mbox functions which are platform specific code to isst-core.c.

As there are some platform specific parameters set via generic
application options, introduce isst_update_platform_param to pass these
parameters to platform specific code.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# ad7e17fc 17-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Improve isst_print_extended_platform_info

The main thing done in isst_print_extended_platform_info is to get the
isst feature status by checking one of the power domains of the
platform.

This can be done using the for_each_online_power_domain_in_set()
function, which makes the code clean and easier to read.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# c77a8d4a 17-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Rename for_each_online_package_in_set

for_each_online_package_in_set is actually used to invoke callback for
each power domain.
This is not a problem when there is a single power domain within a
package/die, but it does not reflect the truth in multi-punit case.

Rename for_each_online_package_in_set to
for_each_online_power_domain_in_set.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# b4edf385 17-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce support for multi-punit

New platforms may have more than 1 punit in a Package/Die, thus it can
have multiple power domains in a Package/Die. Package id and die id is not
sufficient to refer to a specific Power domain.

Introduce support for multi-punit per package/die.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e157c847 17-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce punit to isst_id

Punit id can also be retrieved from ISST_IF_GET_PHY_ID.

punit id is unique within a Package/Die, and together with Package id and
Die id, they can be used to refer to a specific SST power domain.

For current platforms, Punit id is always Zero. So no functional changes
are expected for the current platforms.

While here, prevent issuing IOCTL if the file /dev/isst_interface can't be
opened.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# d1fcb749 17-Jan-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.14 release

This release adds following change:
- Minor fixes for coverity static analysis
- Don't read cpufreq on offline CPUs
- SST turbo-freq enable on auto mode when user disables SMT from
kernel command line
- Fix uncore frequency display
- Set uncore frequency max/min limits on perf level change

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 2612ae59 17-Jan-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Adjust uncore max/min frequency

When perf level is changed, uncore limits can change. Set the uncore
limits via Linux uncore sysfs, when user changes perf level with
-o option.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 61f9fdcd 24-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Add Emerald Rapid quirk

Need memory frequency quirk as Sapphire Rapids in Emerald Rapids.
So add Emerald Rapids CPU model check in is_spr_platform().

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: Subject, changelog and code edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 6ed9e363 06-Jan-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: turbo-freq auto mode with SMT off

When SMT is disabled from kernel command line, sibling CPUs still
appears in the sysfs as offline CPUs. This is a problem when turbo-freq
is enabled in auto mode. They are still assigned to CLOS value
of 3 as they are still in the present CPU list. But they are not in the
sibling list of a CPU. When the CPU is a high priority CPU, because of
sibling it will be still set to CLOS to 3 as CLOS is assigned at core
level not at CPU level.

So, avoid setting CLOS 3 to offline CPU.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# cf3b8e8f 06-Jan-2023 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: cpufreq reads on offline CPUs

Due to some recent kernel changes, reading cpufreq attributes like
scaling_max_freq on offline CPUs returns error. So avoid reading
cpufreq attributes on offline CPUs.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 689dfc9e 11-Jan-2023 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Use null-terminated string

strlen() and strtok() takes null-termimated strings as input.
Make sure these strings are null-terminated before using them.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 507fa17a 11-Jan-2023 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Remove wrong check in set_isst_id()

struct isst_id *id is a pointer, comparing it with less than zero is wrong.

The check is there to make sure the id->pkg and id->die is set to -1, when
it is illegal or unavailable. Here comparing with MAX_PACKAGE_COUNT and
MAX_DIE_PER_PACKAGE is sufficient.

Hence remove the wrong check.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: Subject and changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 97ec890d 15-Sep-2022 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Release v1.13

Update version number.

This version includes fixes for:
- fix build failure when using gcc options -Wl,--as-needed
- Fix warning for perf_cap.cpu may be uninitialized
- Fix off by one check for MAX_DIE_PER_PACKAGE
- Fix issue with use of get_physical_die_id instead of
get_physical_die_id

Optimizations:
- Removed unused interfaces and functions
- Better handle package, die, cpu combination by
defining a struct and set at one place instead
at each user level.

New functional change:
- Warn if turbo is disabled and SST turbo-freq feature is requested

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 921604b4 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Optimize CPU initialization

Optimize CPU initialization.
Do cpu related initialization in one function, including setting the cpu
present_cpumask, target_cpumask, and cpu_map and core_count arrays.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# ca56725d 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Utilize cpu_map to get physical id

cpu_map already has the cpu package id, die id information.
Thus there is no need to re-evaluating sysfs attributes or stored data
file to get the package id and die id of a given CPU each time.

In order to unitlize this, cpu_map needs to be created unconditionally.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# a05b925a 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Remove unused struct clos_config fields

pkg_id/die_id can be retrieved from struct isst_id, remove the redundant
clos_config->pkg_id/die_id fields.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 3ba6a275 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Enforce isst_id value

Enforce the pkg/die value in struct isst_id are either -1 or a valid
value.

This helps avoid inconsistent or redundant checks.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e616059e 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Do not export get_physical_id

Now, all the get_physical_pkg/die/core_id() users are inside
isst-config.c, so no need to export these APIs.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 00bb07db 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce is_cpu_in_power_domain helper

struct isst_id contains cpu, package and die info, and it can represent
a specific SST power domain.

Introduce is_cpu_in_power_domain() helper to identify if a cpu is in a
specified power_domain.

And cleanup the code to use the new helper.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 56d64692 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Cleanup get_physical_id usage

struct isst_id already contains package and die id information, thus
there is no need to get the package and die id information, when struct
isst_id is already available.

Remove unneeded get_physical_package_id/get_physical_die_id usage.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 30e0600e 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Convert more function to use isst_id

With pkg and die info added into struct isst_id, more functions can
be converted to use struct isst_id as parameter.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 32d6ab45 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Add pkg and die in isst_id

Code uses pkg_id and die_id to refer to a specific power domain.

The pkg/die information is already settled at start time. Adding package
id and die id information into struct isst_id so that code does not need
to retrieve them at runtime.

More code cleanups can be done with the package/die info available.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 850337ec 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Introduce struct isst_id

SST control is power-domain based rather than cpu based, on all the
systems including Sapphire Rapids and ealier.

SST core APIs uses cpu id as parameter, and use the underlying pkg_id and
die_id information to find a power domain, this is not straight forward
and introduces obscure logics in the code.

Introduce struct isst_id to represent a SST Power Domain.

All core APIs are converted to use struct isst_id as parameter instead of
using cpu id.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e2783369 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Remove unused core_mask array

Remove unused core_mask array.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 190ba965 20-Aug-2022 Zhang Rui <rui.zhang@intel.com>

tools/power/x86/intel-speed-select: Remove dead code

Remove dead code.

Not functional change in this patch

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 2da6391d 09-May-2022 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Display error on turbo mode disabled

For Intel SST turbo-freq feature to be enabled, the turbo mode on the
platform must be enabled also. If turbo mode is disabled, display error
while enabling turbo-freq feature.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20220510023421.3930540-1-srinivas.pandruvada@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# f3874e96 18-Jan-2022 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.12 release

This version allows out of band SST support, where some remote agent
changes SST profiles via some Board Management Controller.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 7fd786df 18-Jan-2022 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: OOB daemon mode

It is possible that some out of band agent changed config level. In this
case CPUs need to be online/offline to support this config change. Add
a command line option --oob, so that this tool can run as daemon and poll
for config level change and take action. The poll interval is configurable
in seconds using config option --poll-interval.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# da78fc79 15-Dec-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.11 release

This release adds following change:
- Update max performance when BIOS disabled turbo

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 9734213e 15-Dec-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update max frequency

When BIOS disables turbo, the cpuinfo_max_freq will also be same as the
power up base frequency. When SST-PP causes increase in base frequency
the performance will be still limited to the old base frequency as the
cpuinfo_max_freq will not be updated.

In this case we need to update scaling_max frequency to the new
base_frequency. This will result in setting updated max performance
limit in the Pstate driver. So performance will not be limited to the
old base frequency.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 307722e8 10-Jun-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.10 release

This release adds following change:
- Fix reporting of memory frequency

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 159f130f 12-May-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix uncore memory frequency display

The uncore memory frequency value from the mailbox command
CONFIG_TDP_GET_MEM_FREQ needs to be scaled based on the platform for
display. There is no single constant multiplier.

This change introduces CPU model specific memory frequency multiplier.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 61ce18ff 04-Mar-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: v1.9 release

This release adds following changes:
- Support increased number of CPUs
- Return error when mailbox commmand fails to enable core-power
- Option to online all CPUs
- Removes build date and time print

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 17de9a56 12-Mar-2021 Antonio Terceiro <antonio.terceiro@linaro.org>

tools/power/x86/intel-speed-select: Drop __DATE__ and __TIME__ macros

These macros introduce nondeterminism in builds, and break reproducible
builds.

Signed-off-by: Antonio Terceiro <antonio.terceiro@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 0d3dfd75 29-Mar-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add options to force online

It is possible that users manually offlined CPUs via sysfs interface
and then started this utility. In this case we will not be able to get
package and die id of the those CPUs. So add an option to force online
if required for some commands.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# b84733a1 04-Mar-2021 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Process mailbox read error for core-power

Some older kernels don't support reading core-power status. In that case
mailbox command fails. So, display core-power status as "unknown" instead
of supported.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 2a76d235 22-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version to 1.8

Update version for changes released with v5.12 kernel release.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 2c7dc57e 22-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add new command to get/set TRL

Add a new command to get and set TRL (Turbo Ratio Limits). This will
help users to get/set TRL, when the direct MSR access is removed.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 006050a6 21-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add new command turbo-mode

Add a new command "turbo-mode", which allows to enable/disable
turbo mode globally. This uses base-frequency as the max frequency
when turbo-mode is disabled. This allows soft disable turbo mode
without depending on kernel or BIOS.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# bbaa2e95 21-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Set higher of cpuinfo_max_freq or base_frequency

In some case when BIOS disabled turbo, cpufreq cpuinfo_max_freq can be
lower than base_frequency at higher config level. So, in that case set
scaling_min_freq to base_frequency.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20201221071859.2783957-3-srinivas.pandruvada@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# f981dc17 21-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency

When BIOS disables turbo, The scaling_max_freq in cpufreq sysfs will be
limited to config level 0 base frequency. But when user selects a higher
config levels, this will result in higher base frequency. But since
scaling_max_freq is still old base frequency, the performance will still
be limited. So when the turbo is disabled and cpufreq base_frequency is
higher than scaling_max_freq, update the scaling_max_freq to the
base_frequency.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20201221071859.2783957-2-srinivas.pandruvada@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 5e27cb9b 03-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version for v5.11

Update version for changes released with v5.11 kernel release.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/platform-driver-x86/57d6648282491906e0e1f70fe3b9a44f72cec90d.camel@intel.com/
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 6c483225 03-Dec-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Account for missing sysfs for die_id

Some older kernels will not have support to get CPU die_id from the
sysfs. This requires several back ports. But the tool depends on getting
die_id to match to correct CPU.

Relax this restriction and use die_id as 0 when die_id is missing. This
is not a problem as we don't have any multi-die processors with Intel SST
support.

This helps in running this tool on older kernels with just Intel SST
drivers back ported.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/platform-driver-x86/57d6648282491906e0e1f70fe3b9a44f72cec90d.camel@intel.com/
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# e529412f 06-Oct-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version for v5.10

Update version for changes released with v5.10 kernel release.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 7566616f 30-Sep-2020 Jonathan Doman <jonathan.doman@intel.com>

tools/power/x86/intel-speed-select: Fix missing base-freq core IDs

The reported base-freq high-priority-cpu-list was potentially omitting
some cpus, due to incorrectly using a logical core count to constrain
the size of a physical punit core ID mask. We may need to read both high
and low PBF CORE_MASK values regardless of the logical core count.

Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# f65e1311 01-Jul-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version for v5.9

Update version for changes released with v5.9 kernel release.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 32279be7 01-Jul-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add retries for mail box commands

Retry mail box command on failure. The default retry count is 3. This can
be changed by "-r|--retry" options. This helps during early bring up of
platforms.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# a85a35fc 01-Jul-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add option to delay mbox commands

Add option "p|--pause" to introduce delay between two mail box commands
for test purpose. This delay can be specified in milliseconds. By default
there is no delay between two mailbox commands.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 6374de84 30-Jun-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Ignore -o option processing on error

When for some reason, CONFIG_TDP_GET_CORE_MASK mailbox command fails, then
don't continue online/offline operation for perf-profile set-config-level
with "-o" option.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# b1d12cef 30-Jun-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Change path for caching topology info

We want to cache the topology info to a file, which is not preserved
across boot cycle. The current storage in /tmp is getting preserved.
So change the path from /tmp/isst_cpu_topology.dat to
/var/run/isst_cpu_topology.dat.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 873e391f 19-May-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix invalid core mask

The core mask display is wrong in some cases. This is showing more
cpus than the mask has. This is because mask is 64 bit but it used
with BIT() macro to get the presence of CPU which doesn't support
unsigned long long. Added a new macro for BIT_ULL and use that
to get the presence of a CPU.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# e16ea663 15-May-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Increase CPU count

Increase CPU count so that more than 64 is supported in one request.

For example:
sudo ./intel-speed-select -d --cpu 0-66 core-power assoc -clos 0
The above command stops at 63. With this change, it can support more
CPU numbers from 0-255.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# b14cd9d5 08-May-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version

Update version to include 5.8 series enhancements.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 7983ed6f 30-Apr-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Enable clos for turbo-freq enable

turbo-freq enable, requires clos enable. So this is a two step process,
when "-a" option is used. This is causing confusion to users. So enable
clos by default for turbo-freq enable.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 28c59ae6 02-Apr-2020 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Fix CLX-N package information output

On CLX-N the perf-profile output is missing the package, die, and cpu
output. On CLX-N the pkg_dev struct will never be evaluated by the core
code so pkg_dev.processed is always 0 and the package, die, and cpu
information is never output.

Set the pkg_dev.processed flag to 1 for CLX-N processors.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: andriy.shevchenko@linux.intel.com
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org


# 3d904f06 20-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Check support status before enable

When turbo-freq or base-freq feature is not supported, the enable will
fail. So first check support status and print error.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


# 9945a247 09-Mar-2020 Masanari Iida <standby24x7@gmail.com>

tools/power/x86/intel-speed-select: Fix a typo in error message

This patch fix a spelling typo in error message.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 1e46d1d5 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version

Fair number of changes including bug fixes done to change version.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 4a960353 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Print friendly warning for bad command line

When user specifies invalid option, display "Unknown Option: ignore",
instead of "no match". Also display error for garbage on the command
line.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# b86639e1 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix avx options for turbo-freq feature

Specifying "avx2" and "avx512" option for display filter doesn't work
with short option "-r", only works with --try-type. Also compare full
6 characters for "avx512" string.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 7fc9fefd 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve CLX commands

CLX doesn't have capability to change the feature in the hardware, but
this acts as "--auto | -a" option. So even if user didn't specify the
option, use this as --auto | -a to set cpufreq scaling frequency limits.

Also remove perror with debug_printf as they don't bring any value.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 070fdea1 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Show error for invalid CPUs in the options

When --cpu or -c is used to specify target CPUs and non of them are valid,
display error.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# fe6fb216 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve core-power result and error display

This change adds improved error display and handling for commands related
to core-power feature. The changes include:
- Replace perror with helpful error message
- Use ordered priority for SKX based platform by default as the
proportional priority is not supported
- Don't show weight and epp in help and also give error when user
tries to set them in SKX based platforms
- Range check for epp and weights and display error

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 95f8e569 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Kernel interface error handling

Treat a case when mailbox/mmio command can't be handled by the kernel
drivers when the module is removed or send a command which no driver can
handle. In this case ENOTTY result is returned, so print error.

Also when the isst_if_mmio module is removed, we can't send CLOS message
messages via Mailbox on non SKX based platforms. When this module is
removed, isst_platform_info.mmio_supported is set to 0. So it can't be
used as a condition to send via mailbox. Here replace check for Skylake
based platform to send via mailbox, other platforms can't use mailbox in
lieu of MMIO.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# a9fd6ae7 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve error display for turbo-freq feature

This change adds improved error display and handling for commands related
to turbo-freq feature. The changes include:
- Replace perror/fprintf with helpful error message
- Error for not specifying TDP level when required
- Show error for invalid bucket number
- Show message to enable core-power before enabling turbo-freq feature

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 39bae0fc 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve error display for base-freq feature

This change adds improved error display and handling for commands related
to base-freq feature. The changes include:
- Replace perror/fprintf with helpful error message
- Error for not specifying TDP level when required
- For CLX show help which shows limitation

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 3d1a8579 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve output of perf-profile commands

Improve output of perf-profile commands:
get-config-enabled
get-lock-status

Instead of showing 0/1, show meaningful strings. Also show error when
command is failed.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 68e2f109 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Enhance help for core-power assoc

Enhance help to specify CPU and clos by an example.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# ac9d05ea 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Improve error display for perf-profile feature

This change adds improved error display and handling for commands related
to perf-profile feature. The changes include:
- When invalid TDP level is passed. display error and exit
- Replace perror with helpful error message
- Show error when TDP level can't be set
- Print error when information can't be read for a level
- Validate user options for invalid level
- Display error for TDP lock status

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 87e115b3 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Add an API for error/information print

Add a common API which can be used to print all error and information
messages. In this way a common format can be used.

For json output an error index in suffixed to make unique error key.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 1ba148ae 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Enhance --info option

Add additional information, which will allow user to detect available
features. This will allow users to check presence of features before
continue to test.
A sample output:

$sudo ./intel-speed-select --info

Intel(R) Speed Select Technology
Executing on CPU model:85[0x55]
Platform: API version : 1
Platform: Driver version : 1
Platform: mbox supported : 1
Platform: mmio supported : 0
Intel(R) SST-PP (feature perf-profile) is not supported
Only performance level 0 (base level) is present
TDP level change control is locked
Intel(R) SST-TF (feature turbo-freq) is supported
Intel(R) SST-BF (feature base-freq) is supported
Intel(R) SST-CP (feature core-power) is supported

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# addd116d 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Enhance help

Enhance help message which adds some example. The changes include:
- Print help when options are not recognized.
- For CLX, display only options which are applicable.
- Sort options in alphatical order.
- Disply help() instead of error:
"Feature name and|or command not specified"
- Remove duplicate display of
Intel(R) Speed Select Technology

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# f362cdcc 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Helpful warning for missing kernel interface

When the device file "/dev/isst_interface" is not present, instead of
failing on access, check at the start and print a helpful warning.

Here CLX platform is an exception, which doesn't depend on the device
file. So continue for CLX platform.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# fb186158 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Store topology information

Once the CPU is offline, the topology information (core-id, package-id,
die-id) is not accessible via sysfs. So when user selects a config level
more than base config 0 and offlined CPUs to match the config level,
to return to base config he has to manually online CPUs before. Without
this CPUs information mapping from Punit CPU numbering will lot work
as it needs atlest package id for each CPU.

To avoid this additional steps store the topology information in a file
, which is created on the very first run after boot. Since system boots
in base config and all CPUs are online, we can get information about
every CPU.

Once any of the APIs like get_physical_package_id(),
get_physical_core_id() or get_physical_die_id() fails to read from
sysfs, read from the stored mapping file.

This mapping file is stored in /tmp file system. so on every boot
it is recreated to make sure that any new CPUs are added to the
system before boot are taken into account.

But don't use the stored physical device id when trying to get
information for CPU to send message in for_each_online_package_in_set().
Here use the real value from syfs and in case fails try the next CPU.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 864dc09e 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Max CPU count calculation when CPU0 is offline

Currently /sys/devices/system/cpu/cpu0/topology/thread_siblings is used to
get the max CPU count. But when CPU0 is offline, then this file will be
absent.

So add processing so that we can get count from any first CPU in the
system. which is online.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 69669198 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Special handling for CPU 0 online/offline

When "-o" option for force online/offline is used with command:
perf-profile set-config-level

If the config level calls for CPU 0 online/offline, then call fails
as there is special kernel setup required for CPU 0 online/offline
and the currently not setup for that.

But when call is for online CPU 0, then don't fail. Just warn that
this system is not setup for CPU 0 online/offline.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 143ad322 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Enhance core-power info command

In addition to CLOS enable status, also show the core-power feature
status. This will help why clos enable status didn't give desired
results as the core-power feature may be disabled or unsupported.

The new display looks as follows:

$intel-speed-select core-power info
Intel(R) Speed Select Technology
..
package-0
die-0
cpu-0
core-power
support-status:supported
enable-status:enabled
clos-enable-status:1
priority-type:0

In the above display "support-status" and "enable-status", shows the
status of the core-power feature and "clos-enable-status", shows the
status of the clos.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# f5205f49 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Make target CPU optional for core-power info

Currently "-c" is a mandatory option for "core-power info" command. Make
this optional as this is a per package/die property. When not specified,
it will print info for every package/die.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# f0e0b4d1 05-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Warn for invalid package id

When CPU is offline, we can't get package id. So print error for this
and don't use output.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# ced2f530 03-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix last cpu number

Here topology_max_cpus is used for total CPU count, not the last CPU
number. So remove "-1".

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 8ddbda76 03-Mar-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix mailbox usage for CLOS_PM_QOS_CONFIG

Even for the products using MMIO, this message needs to be sent via
mail box. The previous fix done for this didn't properly address this.
That fix simply removed sending command via MMIO, but still didn't
trigger sending via mailbox.

Add additional condition to check for CLOS_PM_QOS_CONFIG, when MMIO
is supported on a platform.

Fixes: cd0e63706549 (tools/power/x86/intel-speed-select: Use mailbox for CLOS_PM_QOS_CONFIG)
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 14a8aa49 30-Jan-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix display for turbo-freq auto mode

When mailbox command for the turbo-freq enable fails, then don't display
result for auto-mode. When turbo-freq enable fails, there is no point
to set CPU priorities.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 19be0b2a 14-Jan-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Update version

As we added new set of mailbox commands, increment version.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 097a5222 14-Jan-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Change the order for clos disable

In turbo-freq or base-freq auto mode, for disable, first disable the feature and
then disable clos.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 78e77b7d 14-Jan-2020 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode

The turbo-freq enable with auto mode, prints result for the last possible
CPU, which is not correct when either CPU is not present or user wants
command to be limited to a single die/package. For example, in the
below command user wants to limit to die/package 0, but the
"turbo-freq --auto" result is displayed using the other package.

$ sudo intel-speed-select -c 0 turbo-freq enable -a
Intel(R) Speed Select Technology
package-0
die-0
cpu-0
turbo-freq
enable:success
package--1
die-0
cpu-31
turbo-freq --auto
enable:success

Since we do have to traverse all CPUs, don't display CPU info for
"turbo-freq --auto", as we already displayed the result for
turbo-freq enable with the CPU information.

With the fix, the same command results in:

$ sudo intel-speed-select -c 0 turbo-freq enable -a
Intel(R) Speed Select Technology
package-0
die-0
cpu-0
turbo-freq
enable:success
turbo-freq --auto
enable:success

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 5c14aba7 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Increment version

Since the tool now adds support for another Intel SST implementation,
increment version number.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# de7f9d3d 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Use core count for base-freq mask

Some firmware implementation gives error when a command is sent get mask
for core count 32-61. So use core count to decide.

But there is no function to get core count. So introduce one function to
get core count.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 7af5a95b 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Support platform with limited Intel(R) Speed Select

There are some platforms, where there limited support of Intel(R) SST
features. Here perf-profile has only one base configuration and limited
support of commands. But still has support for discovery of base-freq and
turbo-freq features. So it is important to show minimum features to use
base-freq and turbo-freq features.

Here the change are:
- When there is no support of CONFIG_TDP_GET_LEVELS_INFO, then instead
of treating this as fatal error, treat this with number of config levels
= 0, that means only base level 0 is present.
- There is no support of mail box commands to get base frequencies or
turbo frequencies. Here present base frequency by reading cpufreq
base freq and turbo frequency by reading MSR 0x1AD.
- Don't display any field, which has value == 0.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 21c3390d 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Use Frequency weight for CLOS

Use different frequency weights for CLOS 0 and and CLOS1-3, to define
relative priority for power budgeting. This will be used for --auto
mode to enable base-freq and turbo-freq feature.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 40dee9dd 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Make CLOS frequency in MHz

To be consistant with the other frequency units, change the CLOS
unit to MHz instead of ratios.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# cd0e6370 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Use mailbox for CLOS_PM_QOS_CONFIG

Use mailbox to read/write CLOS_PM_QOS_CONFIG instead of read/write to
MMIO offset.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# a9b2f8e2 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Auto mode for CLX

There is an expectation in the CLX platform for SST base-freq feature that
Scaling min frequency be different for high and low priority cores.
This is the way the firmware will understand the priority.

So this change will look at high priority and low priority cores, and set
scaling_min_freq to P1High for high priority cores and P1Low to low
priority cores.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 91d92814 04-Nov-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Correct CLX-N frequency units

In CLX_N base_frequency is read from cpufreq sysfs, where units are in
KHz. The internal units in the code matches the real ratios which are
in 100MHz scale. So when storing units for CLX-N frequencies, convert
to 100MHz scale.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 1aa7177c 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Implement base-freq commands on CascadeLake-N

Add functionality for base-freq info|enable|disable info on CascadeLake-N.

Sample output:
Intel(R) Speed Select Technology
Executing on CPU model:85[0x55]
package-0
die-0
cpu-0
speed-select-base-freq
high-priority-base-frequency(MHz):2700000
high-priority-cpu-mask:00000000,0000e8c0
high-priority-cpu-list:6,7,11,13,14,15
low-priority-base-frequency(MHz):2100000
package-1
die-0
cpu-20
speed-select-base-freq
high-priority-base-frequency(MHz):2700000
high-priority-cpu-mask:0000000e,8c000000
high-priority-cpu-list:26,27,31,33,34,35
low-priority-base-frequency(MHz):2100000

The enable command always returns success, and the disable command always
returns failed because SST-BF cannot be enabled or disabled from the OS on
CascadeLake-N.

Enable command also have support for --auto|-a option, which sets cpufreq
scaling_min to max, so that the high priority base frequency can be the
required minimum for high priority cores. Disable command with -a/--auto
option reset the setting back to the min frequency.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 062e4aac 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Implement 'perf-profile info' on CascadeLake-N

Add functionality for "perf-profile info" on CascadeLake-N.

Sample output:
intel-speed-select perf-profile info
Intel(R) Speed Select Technology
Executing on CPU model:85[0x55]
package-0
die-0
cpu-0
perf-profile-level-0
cpu-count:20
enable-cpu-mask:00000000,000fffff
enable-cpu-list:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
thermal-design-power-ratio:23
base-frequency(MHz):2300
speed-select-turbo-freq:unsupported
speed-select-base-freq:enabled
speed-select-base-freq
high-priority-base-frequency(MHz):2700000
high-priority-cpu-mask:00000000,0000e8c0
high-priority-cpu-list:6,7,11,13,14,15
low-priority-base-frequency(MHz):2100000
package-1
die-0
cpu-20
perf-profile-level-0
cpu-count:20
enable-cpu-mask:000000ff,fff00000
enable-cpu-list:20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
thermal-design-power-ratio:23
base-frequency(MHz):2300
speed-select-turbo-freq:unsupported
speed-select-base-freq:enabled
speed-select-base-freq
high-priority-base-frequency(MHz):2700000
high-priority-cpu-mask:0000000e,8c000000
high-priority-cpu-list:26,27,31,33,34,35
low-priority-base-frequency(MHz):2100000

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# c829f0ef 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Implement CascadeLake-N help and command functions structures

CascadeLake-N only supports SST-BF and needs some of the perf-profile
commands, and the base-freq commands.

Add help functions, and create an empty command structures (the functions
will be implemented later in this patchset). Call these functions
when running on CascadeLake-N.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 1c1d935c 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Add check for CascadeLake-N models

Three CascadeLake-N models (6252N, 6230N, and 5218N) have SST-PBF support.

Return an error if the CascadeLake processor is not one of these specific
models.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 210369dc 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Make process_command generic

Make the process_command take any help command and command list. This
will make it easier to help commands and a command list for CascadeLake-N.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# ce1326a2 10-Oct-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Add int argument to command functions

The current code structure has similar but separate command functions for
the enable and disable operations. This can be improved by adding an int
argument to the command function structure, and interpreting 1 as enable
and 0 as disable. This change results in the removal of the disable
command functions.

Add int argument to the command function structure.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# a6a82f9b 10-Oct-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Turbo-freq feature auto mode

Introduce --auto|-a option to turbo-freq enable feature, so that it
does in one step for users who are OK by setting all passed target cores
as high priority and set in CLOS 0 and remaining in CLOS 3. In this way,
users don't have to take multiple steps to enable turbo-freq feature. For
users who want more fine grain control, they can always use core-power
feature to set custom CLOS configuration and assignment.

While here also print the error to output when clos configuration fails.

For example
intel-speed-select -c 0-4 turbo-freq enable --auto

The above command will enable turbo-freq and core-power feature. Also
mark CPU 0 to CPU 4 as high priority.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 354bd06f 10-Oct-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Base-freq feature auto mode

Introduce --auto|-a option to base-freq enable feature, so that it
does in one step for users who are OK by setting all cores with higher
base frequency to be set in CLOS 0 and remaining in CLOS 3. This option
also sets corresponding clos.min to CLOS 0 and CLOS3. In this way, users
don't have to take multiple steps to enable base-freq feature. For users
who want more fine grain control, they can always use core-power feature
to set custom CLOS configuration and assignment.

Also adjust cpufreq/scaling_min_freq for higher and lower priority cores.

For example user can use:
intel-speed-select base-freq enable --auto

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# abd120e3 10-Oct-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Remove warning for unused result

Fix warning for:
isst-config.c: In function ‘set_cpu_online_offline’:
isst-config.c:221:3: warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result [-Wunused-result]
write(fd, "1\n", 2);

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# b3abfd77 17-Sep-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix perf-profile command output

commit "c016ae8f9fa04d361efc8629de49ad3af12b5262
"tools/power/x86/intel-speed-select: Output success/failed for command
output" introduced a regression in perf-profile outputs. With this
the result field is changed to string interpreting every non zero
value as errors. But these commands display on zero (>0) result.
For example before this commit the display was:

package-1
die-0
cpu-14
get-config-levels:4

Here the get-config-levels is interpreted as error and displayed
as error with the above commit:

package-1
die-0
cpu-14
get-config-levels:failed(error 4)

Fix this issue by not using isst_display_result() to display such results,
but define a new function which formats this data and prints.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 188afed9 14-Sep-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Extend core-power command set

Add additional command to get the clos enable and priority type. The
current info option is actually dumping per clos QOS config, so name
the command appropriately to get-config.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# d2d1f304 14-Sep-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Fix some debug prints

Fix wrong debug print for cpu, which is displayed as CLOS. Also
avoid printing clos id, when user is specify clos as parameter.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# e118fbe3 14-Sep-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Format get-assoc information

Format the get-assoc command output consistant with other commands.
For example:

Intel(R) Speed Select Technology
Executing on CPU model:142[0x8e]
package-0
die-0
cpu-0
get-assoc
clos:0

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 3c64c81a 14-Sep-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86/intel-speed-select: Allow online/offline based on tdp

Using enable core mask, do online offline CPUs. There is a new option
--online|-o for set-config-level.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 44460efe 14-Sep-2019 Youquan Song <youquan.song@intel.com>

tools/power/x86/intel-speed-select: Fix high priority core mask over count

If the CPU package has the less logical CPU than topo_max_cpus, but un-present
CPU's punit_cpu_core will be initiated to 0 and they will be count to core 0

Like below, there are only 10 high priority cores (20 logical CPUs) in the CPU
package, but it count to 27 logic CPUs.

./intel-speed-select base-freq info -l 0 | grep mask
high-priority-cpu-mask:7f000179,f000179f

With the fix patch:
./intel-speed-select base-freq info -l 0
high-priority-cpu-mask:00000179,f000179f

Signed-off-by: Youquan Song <youquan.song@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 3bc3d30c 05-Sep-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Fix memory leak

cpumasks are allocated by calling the alloc_cpu_mask() function and are
never free'd. They should be free'd after the commands have run.

Fix the memory leaks by calling free_cpu_set().

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 522586a9 05-Sep-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Output success/failed for command output

Command output has confusing data, returning "0" on success. For example

|# ./intel-speed-select -c 14 turbo-freq enable
Intel(R) Speed Select Technology
Executing on CPU model:106[0x6a]
package-1
die-0
cpu-14
turbo-freq
enable:0

To avoid confusion change the command output to 'success' or 'failed'.

v2: Remove help output line.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 3ec2aef1 05-Sep-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Fix cpu-count output

I have a system with 28 threads/socket but intel-speed-select reports
a cpu-count of 29.

Fix an off-by-one error in the cpu_count() function.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 43774c0d 05-Sep-2019 Prarit Bhargava <prarit@redhat.com>

tools/power/x86/intel-speed-select: Fix help option typo

Help is -h, not --h.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 3fb4f7cd 30-Jun-2019 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

tools/power/x86: A tool to validate Intel Speed Select commands

The Intel(R) Speed select technologies contains four features.

Performance profile:An non architectural mechanism that allows multiple
optimized performance profiles per system via static and/or dynamic
adjustment of core count, workload, Tjmax, and TDP, etc. aka ISS
in the documentation.

Base Frequency: Enables users to increase guaranteed base frequency on
certain cores (high priority cores) in exchange for lower base frequency
on remaining cores (low priority cores). aka PBF in the documenation.

Turbo frequency: Enables the ability to set different turbo ratio limits
to cores based on priority. aka FACT in the documentation.

Core power: An Interface that allows user to define per core/tile
priority.

There is a multi level help for commands and options. This can be used
to check required arguments for each feature and commands for the
feature.

To start navigating the features start with

$sudo intel-speed-select --help

For help on a specific feature for example
$sudo intel-speed-select perf-profile --help

To get help for a command for a feature for example
$sudo intel-speed-select perf-profile get-lock-status --help

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Len Brown <len.brown@intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>