mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

Highlights: - alienware-wmi-wmax: - Add HWMON support - Add ABI and admin-guide documentation - Expose GPIO debug methods through debug FS - Support manual fan control and "custom" thermal profile - amd/hsmp: - Add sysfs files to show HSMP telemetry - Report power readings and limits via hwmon - amd/isp4: Add AMD ISP platform config for OV05C10 - asus-wmi: - Refactor Ally suspend/resume to work better with older FW - hid-asus: check ROG Ally MCU version and warn about old FW versions - dasharo-acpi: Add driver for Dasharo devices supporting fans and temperatures monitoring - dell-ddv: - Expose the battery health and manufacture date to userspace using power supply extensions - Implement the battery matching algorithm - dell-pc: - Improve error propagation - Use faux device - int3472: - Add delays to avoid GPIO regulator spikes - Add handshake pin support - Make regulator supply name configurable and allow registering more than 1 GPIO regulator - Map mt9m114 powerdown pin to powerenable - intel/pmc: Add separate SSRAM Telemetry driver - intel-uncore-freq: Add attributes to show agent types and die ID - ISST: - Support SST-TF revision 2 (allows more cores per bucket) - Support SST-PP revision 2 (fabric 1 frequencies) - Remove unnecessary SST MSRs restore (the package retains MSRs despite CPU offlining) - mellanox: Add support for SN2201, SN4280, SN5610, and SN5640 - mellanox: mlxbf-pmc: Support additional PMC blocks - oxpec: - Add OneXFly variants - Add support for charge limit, charge thresholds, and turbo LED - Distinguish current X1 variants to avoid unwanted matching to new variants - Follow hwmon conventions - Move from hwmon/oxp-sensors to platform/x86 to match the enlarged scope - power: supply: - Add inhibit-charge-awake (needed by oxpec) - Add additional battery health status values ("blown fuse" and "cell imbalance") (needed by dell-ddv) - powerwell-ec: Add driver for Portwell EC supporting GPIO and watchdog - thinkpad-acpi: Support camera shutter switch hotkey - tuxedo: Add virtual LampArray for TUXEDO NB04 devices - tools/power/x86/intel-speed-select: - Support displaying SST-PP revision 2 fields - Skip uncore frequency update on newer generations of CPUs - Miscellaneous cleanups / refactoring / improvements The following is an automated shortlog grouped by driver: ABI: testing: sysfs-class-oxp: - add missing documentation - add tt_led attribute documentation Add AMD ISP platform config for OV05C10: - Add AMD ISP platform config for OV05C10 alienware-wmi-wmax: - Add a DebugFS interface - Add HWMON support - Add support for manual fan control - Add support for the "custom" thermal profile - Expose GPIO debug methods - Fix awcc_hwmon_fans_init() label logic - Fix uninitialized bitmap in awcc_hwmon_fans_init() - Improve ID processing - Improve internal AWCC API - Improve platform profile probe - Modify supported_thermal_profiles[] - Rename thermal related symbols amd/hsmp: acpi: - Add sysfs files to display HSMP telemetry amd/hsmp: - fix building with CONFIG_HWMON=m - Report power via hwmon sensors - Use a single DRIVER_VERSION for all hsmp modules arm64: huawei-gaokun-ec: - Remove unneeded semicolon asus-wmi: - fix build without CONFIG_SUSPEND - Refactor Ally suspend/resume Avoid -Wflex-array-member-not-at-end warning: - Avoid -Wflex-array-member-not-at-end warning barco-p50: - use new GPIO line value setter callbacks dell-ddv: - Expose the battery health to userspace - Expose the battery manufacture date to userspace - Implement the battery matching algorithm dell-pc: - Propagate errors when detecting feature support - Transition to faux device - Use non-atomic bitmap operations docs: ABI: - Fix "aassociated" to "associated" Documentation/ABI: - Add new attribute for mlxreg-io sysfs interfaces Documentation: ABI: - Add sysfs platform and debugfs ABI documentation for alienware-wmi Documentation: admin-guide: laptops: - Add documentation for alienware-wmi Documentation: admin-guide: pm: - Add documentation for agent_types - Add documentation for die_id Documentation: wmi: alienware-wmi: - Add GPIO control documentation Documentation: wmi: - Improve and update alienware-wmi documentation Do not enable by default during compile testing: - Do not enable by default during compile testing hid-asus: - check ROG Ally MCU version and warn hwmon: - (oxp-sensors) Add all OneXFly variants - (oxp-sensors) Distinguish the X1 variants int0002: - use new GPIO line value setter callbacks int3472: - Add handshake pin support - Add skl_int3472_register_clock() helper - Avoid GPIO regulator spikes - Debug log when remapping pins - Drop unused gpio field from struct int3472_gpio_regulator - Export int3472_discrete_parse_crs() - For mt9m114 sensors map powerdown to powerenable - Make regulator supply name configurable - Move common.h to public includes, symbols to INTEL_INT3472 - Prepare for registering more than 1 GPIO regulator - Remove unused sensor_config struct member - Rework AVDD second sensor quirk handling - Stop setting a supply-name for GPIO regulators - Stop using devm_gpiod_get() intel/pmc: - Convert index variables to be unsigned - Create Intel PMC SSRAM Telemetry driver - Improve pmc_core_get_lpm_req() - Move error handling to init function - Move PMC Core related functions - Move PMC devid to core.h - Remove unneeded header file inclusion - Remove unneeded io operations - Rename core_ssram to ssram_telemetry - Use devm for mutex_init intel: power-domains: - Add interface to get Linux die ID intel-uncore-freq: - Add attributes to show agent types - Add attributes to show die_id intel/vsec: - Change return type of intel_vsec_register Introduce dasharo-acpi platform driver: - Introduce dasharo-acpi platform driver ISST: - Do Not Restore SST MSRs on CPU Online Operation - Support SST-PP revision 2 - Support SST-TF revision 2 - Update minor version mellanox: - Cosmetic changes to improve code style - Introduce support of Nvidia smart switch - Rename field to improve code readability mlxbf-pmc: - Support additional PMC blocks mlx-platform: - Add support for new Nvidia system mlxreg-dpu: - Add initial support for Nvidia DPU - Fix smatch warnings nvsw-sn2200: - Add support for new system flavour - Fix .items in nvsw_sn2201_busbar_hotplug oxpec: - Add a lower bounds check in oxp_psy_ext_set_prop() - Add charge threshold and behaviour to OneXPlayer - Add support for the OneXPlayer G1 - Add turbo led support to X1 devices - Adhere to sysfs-class-hwmon and enable pwm on 2 - Convert defines to using tabs - Follow reverse xmas convention for tt_toggle - Make turbo val apply a bitmask - Move fan speed read to separate function - Move hwmon/oxp-sensors to platform/x86 - Move pwm_enable read to its own function - Move pwm value read/write to separate functions - Rename ec group to tt_toggle - Rename rval to ret in tt_toggle portwell-ec: - Add GPIO and WDT driver for Portwell EC power: supply: - add inhibit-charge-awake to charge_behaviour power: supply: core: - Add additional health status values silicom: - use new GPIO line value setter callbacks sony-laptop: - Remove unused sony laptop camera code thermal/drivers/acerhdf: - Constify struct thermal_zone_device_ops thinkpad-acpi: - Add support for new hotkey for camera shutter switch tools/power/x86/intel-speed-select: - Skip uncore frequency update - Support SST PP revision 2 fields - v1.23 release tuxedo: - Add virtual LampArray for TUXEDO NB04 devices - Prevent invalid Kconfig state Use strscpy()/scnprintf() with acpi_device_name/class(): - Use strscpy()/scnprintf() with acpi_device_name/class() Merges: - Merge branch 'fixes' into for-next - Merge branch 'intel-sst' of https://github.com/spandruvada/linux-kernel into for-next -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSCSUwRdwTNL2MhaBlZrE9hU+XOMQUCaDWJ7wAKCRBZrE9hU+XO MT8JAQDWW6qBoXuqpd6Yx1oOyROc6gJMQAsS9sNc7I60mGooEAEAnTLhOHDGkKb5 av1fz/SmXGl7joeRYkZV9FRzJ/26AAk= =ytxa -----END PGP SIGNATURE----- Merge tag 'platform-drivers-x86-v6.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 Pull x86 platform drivers updates from Ilpo Järvinen: "The changes are mostly business as usual. Besides pdx86 changes, there are a few power supply changes needed for related pdx86 features, move of oxpec driver from hwmon (oxp-sensors) to pdx86, and one FW version warning to hid-asus. Highlights: - alienware-wmi-wmax: - Add HWMON support - Add ABI and admin-guide documentation - Expose GPIO debug methods through debug FS - Support manual fan control and "custom" thermal profile - amd/hsmp: - Add sysfs files to show HSMP telemetry - Report power readings and limits via hwmon - amd/isp4: Add AMD ISP platform config for OV05C10 - asus-wmi: - Refactor Ally suspend/resume to work better with older FW - hid-asus: check ROG Ally MCU version and warn about old FW versions - dasharo-acpi: - Add driver for Dasharo devices supporting fans and temperatures monitoring - dell-ddv: - Expose the battery health and manufacture date to userspace using power supply extensions - Implement the battery matching algorithm - dell-pc: - Improve error propagation - Use faux device - int3472: - Add delays to avoid GPIO regulator spikes - Add handshake pin support - Make regulator supply name configurable and allow registering more than 1 GPIO regulator - Map mt9m114 powerdown pin to powerenable - intel/pmc: Add separate SSRAM Telemetry driver - intel-uncore-freq: Add attributes to show agent types and die ID - ISST: - Support SST-TF revision 2 (allows more cores per bucket) - Support SST-PP revision 2 (fabric 1 frequencies) - Remove unnecessary SST MSRs restore (the package retains MSRs despite CPU offlining) - mellanox: Add support for SN2201, SN4280, SN5610, and SN5640 - mellanox: mlxbf-pmc: Support additional PMC blocks - oxpec: - Add OneXFly variants - Add support for charge limit, charge thresholds, and turbo LED - Distinguish current X1 variants to avoid unwanted matching to new variants - Follow hwmon conventions - Move from hwmon/oxp-sensors to platform/x86 to match the enlarged scope - power supply: - Add inhibit-charge-awake (needed by oxpec) - Add additional battery health status values ("blown fuse" and "cell imbalance") (needed by dell-ddv) - powerwell-ec: Add driver for Portwell EC supporting GPIO and watchdog - thinkpad-acpi: Support camera shutter switch hotkey - tuxedo: Add virtual LampArray for TUXEDO NB04 devices - tools/power/x86/intel-speed-select: - Support displaying SST-PP revision 2 fields - Skip uncore frequency update on newer generations of CPUs - Miscellaneous cleanups / refactoring / improvements" * tag 'platform-drivers-x86-v6.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (112 commits) thermal/drivers/acerhdf: Constify struct thermal_zone_device_ops platform/x86/amd/hsmp: fix building with CONFIG_HWMON=m platform/x86: asus-wmi: fix build without CONFIG_SUSPEND docs: ABI: Fix "aassociated" to "associated" platform/x86: Add AMD ISP platform config for OV05C10 Documentation: admin-guide: pm: Add documentation for die_id platform/x86/intel-uncore-freq: Add attributes to show die_id platform/x86/intel: power-domains: Add interface to get Linux die ID Documentation: admin-guide: pm: Add documentation for agent_types platform/x86/intel-uncore-freq: Add attributes to show agent types platform/x86/tuxedo: Prevent invalid Kconfig state platform/x86: dell-ddv: Expose the battery health to userspace platform/x86: dell-ddv: Expose the battery manufacture date to userspace platform/x86: dell-ddv: Implement the battery matching algorithm power: supply: core: Add additional health status values platform/x86/amd/hsmp: acpi: Add sysfs files to display HSMP telemetry platform/x86/amd/hsmp: Report power via hwmon sensors platform/x86/amd/hsmp: Use a single DRIVER_VERSION for all hsmp modules platform/mellanox: mlxreg-dpu: Fix smatch warnings platform: mellanox: nvsw-sn2200: Fix .items in nvsw_sn2201_busbar_hotplug ...
264 lines
6.3 KiB
C
264 lines
6.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Mapping of TPMI power domains CPU mapping
|
|
*
|
|
* Copyright (c) 2024, Intel Corporation.
|
|
*/
|
|
|
|
#include <linux/bitfield.h>
|
|
#include <linux/cleanup.h>
|
|
#include <linux/cpuhotplug.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/export.h>
|
|
#include <linux/hashtable.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/overflow.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/topology.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/cpu_device_id.h>
|
|
#include <asm/intel-family.h>
|
|
#include <asm/msr.h>
|
|
|
|
#include "tpmi_power_domains.h"
|
|
|
|
#define MSR_PM_LOGICAL_ID 0x54
|
|
|
|
/*
|
|
* Struct of MSR 0x54
|
|
* [15:11] PM_DOMAIN_ID
|
|
* [10:3] MODULE_ID (aka IDI_AGENT_ID)
|
|
* [2:0] LP_ID
|
|
* For Atom:
|
|
* [2] Always 0
|
|
* [1:0] core ID within module
|
|
* For Core
|
|
* [2:1] Always 0
|
|
* [0] thread ID
|
|
*/
|
|
|
|
#define LP_ID_MASK GENMASK_ULL(2, 0)
|
|
#define MODULE_ID_MASK GENMASK_ULL(10, 3)
|
|
#define PM_DOMAIN_ID_MASK GENMASK_ULL(15, 11)
|
|
|
|
/**
|
|
* struct tpmi_cpu_info - Mapping information for a CPU
|
|
* @hnode: Used to add mapping information to hash list
|
|
* @linux_cpu: Linux CPU number
|
|
* @pkg_id: Package ID of this CPU
|
|
* @punit_thread_id: Punit thread id of this CPU
|
|
* @punit_core_id: Punit core id
|
|
* @punit_domain_id: Power domain id from Punit
|
|
*
|
|
* Structure to store mapping information for a Linux CPU
|
|
* to a Punit core, thread and power domain.
|
|
*/
|
|
struct tpmi_cpu_info {
|
|
struct hlist_node hnode;
|
|
int linux_cpu;
|
|
u8 pkg_id;
|
|
u8 punit_thread_id;
|
|
u8 punit_core_id;
|
|
u8 punit_domain_id;
|
|
};
|
|
|
|
static DEFINE_PER_CPU(struct tpmi_cpu_info, tpmi_cpu_info);
|
|
|
|
/* The dynamically assigned cpu hotplug state to free later */
|
|
static enum cpuhp_state tpmi_hp_state __read_mostly;
|
|
|
|
#define MAX_POWER_DOMAINS 8
|
|
|
|
static cpumask_t *tpmi_power_domain_mask;
|
|
|
|
static u16 *domain_die_map;
|
|
|
|
/* Lock to protect tpmi_power_domain_mask and tpmi_cpu_hash */
|
|
static DEFINE_MUTEX(tpmi_lock);
|
|
|
|
static const struct x86_cpu_id tpmi_cpu_ids[] = {
|
|
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, NULL),
|
|
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, NULL),
|
|
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT, NULL),
|
|
X86_MATCH_VFM(INTEL_ATOM_DARKMONT_X, NULL),
|
|
X86_MATCH_VFM(INTEL_GRANITERAPIDS_D, NULL),
|
|
X86_MATCH_VFM(INTEL_PANTHERCOVE_X, NULL),
|
|
{}
|
|
};
|
|
MODULE_DEVICE_TABLE(x86cpu, tpmi_cpu_ids);
|
|
|
|
static DECLARE_HASHTABLE(tpmi_cpu_hash, 8);
|
|
|
|
static bool tpmi_domain_is_valid(struct tpmi_cpu_info *info)
|
|
{
|
|
return info->pkg_id < topology_max_packages() &&
|
|
info->punit_domain_id < MAX_POWER_DOMAINS;
|
|
}
|
|
|
|
int tpmi_get_linux_cpu_number(int package_id, int domain_id, int punit_core_id)
|
|
{
|
|
struct tpmi_cpu_info *info;
|
|
int ret = -EINVAL;
|
|
|
|
guard(mutex)(&tpmi_lock);
|
|
hash_for_each_possible(tpmi_cpu_hash, info, hnode, punit_core_id) {
|
|
if (info->punit_domain_id == domain_id && info->pkg_id == package_id) {
|
|
ret = info->linux_cpu;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(tpmi_get_linux_cpu_number, "INTEL_TPMI_POWER_DOMAIN");
|
|
|
|
int tpmi_get_punit_core_number(int cpu_no)
|
|
{
|
|
if (cpu_no >= num_possible_cpus())
|
|
return -EINVAL;
|
|
|
|
return per_cpu(tpmi_cpu_info, cpu_no).punit_core_id;
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(tpmi_get_punit_core_number, "INTEL_TPMI_POWER_DOMAIN");
|
|
|
|
int tpmi_get_power_domain_id(int cpu_no)
|
|
{
|
|
if (cpu_no >= num_possible_cpus())
|
|
return -EINVAL;
|
|
|
|
return per_cpu(tpmi_cpu_info, cpu_no).punit_domain_id;
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(tpmi_get_power_domain_id, "INTEL_TPMI_POWER_DOMAIN");
|
|
|
|
cpumask_t *tpmi_get_power_domain_mask(int cpu_no)
|
|
{
|
|
struct tpmi_cpu_info *info;
|
|
cpumask_t *mask;
|
|
int index;
|
|
|
|
if (cpu_no >= num_possible_cpus())
|
|
return NULL;
|
|
|
|
info = &per_cpu(tpmi_cpu_info, cpu_no);
|
|
if (!tpmi_domain_is_valid(info))
|
|
return NULL;
|
|
|
|
index = info->pkg_id * MAX_POWER_DOMAINS + info->punit_domain_id;
|
|
guard(mutex)(&tpmi_lock);
|
|
mask = &tpmi_power_domain_mask[index];
|
|
|
|
return mask;
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(tpmi_get_power_domain_mask, "INTEL_TPMI_POWER_DOMAIN");
|
|
|
|
int tpmi_get_linux_die_id(int pkg_id, int domain_id)
|
|
{
|
|
if (pkg_id >= topology_max_packages() || domain_id >= MAX_POWER_DOMAINS)
|
|
return -EINVAL;
|
|
|
|
return domain_die_map[pkg_id * MAX_POWER_DOMAINS + domain_id];
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(tpmi_get_linux_die_id, "INTEL_TPMI_POWER_DOMAIN");
|
|
|
|
static int tpmi_get_logical_id(unsigned int cpu, struct tpmi_cpu_info *info)
|
|
{
|
|
u64 data;
|
|
int ret;
|
|
|
|
ret = rdmsrq_safe(MSR_PM_LOGICAL_ID, &data);
|
|
if (ret)
|
|
return ret;
|
|
|
|
info->punit_domain_id = FIELD_GET(PM_DOMAIN_ID_MASK, data);
|
|
if (info->punit_domain_id >= MAX_POWER_DOMAINS)
|
|
return -EINVAL;
|
|
|
|
info->punit_thread_id = FIELD_GET(LP_ID_MASK, data);
|
|
info->punit_core_id = FIELD_GET(MODULE_ID_MASK, data);
|
|
info->pkg_id = topology_physical_package_id(cpu);
|
|
info->linux_cpu = cpu;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tpmi_cpu_online(unsigned int cpu)
|
|
{
|
|
struct tpmi_cpu_info *info = &per_cpu(tpmi_cpu_info, cpu);
|
|
int ret, index;
|
|
|
|
/* Don't fail CPU online for some bad mapping of CPUs */
|
|
ret = tpmi_get_logical_id(cpu, info);
|
|
if (ret)
|
|
return 0;
|
|
|
|
index = info->pkg_id * MAX_POWER_DOMAINS + info->punit_domain_id;
|
|
|
|
guard(mutex)(&tpmi_lock);
|
|
cpumask_set_cpu(cpu, &tpmi_power_domain_mask[index]);
|
|
hash_add(tpmi_cpu_hash, &info->hnode, info->punit_core_id);
|
|
|
|
domain_die_map[info->pkg_id * MAX_POWER_DOMAINS + info->punit_domain_id] =
|
|
topology_die_id(cpu);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __init tpmi_init(void)
|
|
{
|
|
const struct x86_cpu_id *id;
|
|
u64 data;
|
|
int ret;
|
|
|
|
id = x86_match_cpu(tpmi_cpu_ids);
|
|
if (!id)
|
|
return -ENODEV;
|
|
|
|
/* Check for MSR 0x54 presence */
|
|
ret = rdmsrq_safe(MSR_PM_LOGICAL_ID, &data);
|
|
if (ret)
|
|
return ret;
|
|
|
|
tpmi_power_domain_mask = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
|
|
sizeof(*tpmi_power_domain_mask), GFP_KERNEL);
|
|
if (!tpmi_power_domain_mask)
|
|
return -ENOMEM;
|
|
|
|
domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
|
|
sizeof(*domain_die_map), GFP_KERNEL);
|
|
if (!domain_die_map)
|
|
goto free_domain_mask;
|
|
|
|
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
|
|
"platform/x86/tpmi_power_domains:online",
|
|
tpmi_cpu_online, NULL);
|
|
if (ret < 0)
|
|
goto free_domain_map;
|
|
|
|
tpmi_hp_state = ret;
|
|
|
|
return 0;
|
|
|
|
free_domain_map:
|
|
kfree(domain_die_map);
|
|
|
|
free_domain_mask:
|
|
kfree(tpmi_power_domain_mask);
|
|
|
|
return ret;
|
|
}
|
|
module_init(tpmi_init)
|
|
|
|
static void __exit tpmi_exit(void)
|
|
{
|
|
cpuhp_remove_state(tpmi_hp_state);
|
|
kfree(tpmi_power_domain_mask);
|
|
kfree(domain_die_map);
|
|
}
|
|
module_exit(tpmi_exit)
|
|
|
|
MODULE_DESCRIPTION("TPMI Power Domains Mapping");
|
|
MODULE_LICENSE("GPL");
|