On Fri, 27 Sep 2024, at 3:22 AM, Mario Limonciello wrote: > On 9/26/2024 04:29, Luke D. Jones wrote: > > Adds the ppt_* and nv_* tuning knobs that are available via WMI methods > > and adds proper min/max levels plus defaults. > > > > Signed-off-by: Luke D. Jones <luke@xxxxxxxxxx> > > --- > > drivers/platform/x86/asus-armoury.c | 130 ++++++++++++++++++++++++++++ > > drivers/platform/x86/asus-armoury.h | 65 ++++++++++++++ > > 2 files changed, 195 insertions(+) > > > > diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c > > index 15eab4d45b81..766f944d0233 100644 > > --- a/drivers/platform/x86/asus-armoury.c > > +++ b/drivers/platform/x86/asus-armoury.c > > @@ -52,12 +52,40 @@ > > #define NVIDIA_TEMP_MIN 75 > > #define NVIDIA_TEMP_MAX 87 > > > > +/* Tunables provided by ASUS for gaming laptops */ > > +struct rog_tunables { > > + u32 cpu_default; > > + u32 cpu_min; > > + u32 cpu_max; > > + > > + u32 platform_default; > > + u32 platform_min; > > + u32 platform_max; > > + > > + u32 ppt_pl1_spl; // cpu > > + u32 ppt_pl2_sppt; // cpu > > + u32 ppt_apu_sppt; // plat > > + u32 ppt_platform_sppt; // plat > > + u32 ppt_fppt; // cpu > > + > > + u32 nv_boost_default; > > + u32 nv_boost_min; > > + u32 nv_boost_max; > > + u32 nv_dynamic_boost; > > + > > + u32 nv_temp_default; > > + u32 nv_temp_min; > > + u32 nv_temp_max; > > + u32 nv_temp_target; > > +}; > > + > > static const struct class *fw_attr_class; > > > > struct asus_armoury_priv { > > struct device *fw_attr_dev; > > struct kset *fw_attr_kset; > > > > + struct rog_tunables *rog_tunables; > > u32 mini_led_dev_id; > > u32 gpu_mux_dev_id; > > > > @@ -421,6 +449,25 @@ WMI_SHOW_INT(egpu_enable_current_value, "%d\n", ASUS_WMI_DEVID_EGPU); > > ATTR_GROUP_BOOL_CUSTOM(egpu_enable, "egpu_enable", "Enable the eGPU (also disables dGPU)"); > > > > /* Simple attribute creation */ > > +ATTR_GROUP_ROG_TUNABLE(ppt_pl1_spl, "ppt_pl1_spl", ASUS_WMI_DEVID_PPT_PL1_SPL, cpu_default, > > + cpu_min, cpu_max, 1, "Set the CPU slow package limit"); > > +ATTR_GROUP_ROG_TUNABLE(ppt_pl2_sppt, "ppt_pl2_sppt", ASUS_WMI_DEVID_PPT_PL2_SPPT, cpu_default, > > + cpu_min, cpu_max, 1, "Set the CPU fast package limit"); > > +ATTR_GROUP_ROG_TUNABLE(ppt_apu_sppt, "ppt_apu_sppt", ASUS_WMI_DEVID_PPT_APU_SPPT, > > + platform_default, platform_min, platform_max, 1, > > + "Set the CPU slow package limit"); > > +ATTR_GROUP_ROG_TUNABLE(ppt_platform_sppt, "ppt_platform_sppt", ASUS_WMI_DEVID_PPT_PLAT_SPPT, > > + platform_default, platform_min, platform_max, 1, > > + "Set the CPU slow package limit"); > > +ATTR_GROUP_ROG_TUNABLE(ppt_fppt, "ppt_fppt", ASUS_WMI_DEVID_PPT_FPPT, cpu_default, cpu_min, > > + cpu_max, 1, "Set the CPU slow package limit"); > > +ATTR_GROUP_ROG_TUNABLE(nv_dynamic_boost, "nv_dynamic_boost", ASUS_WMI_DEVID_NV_DYN_BOOST, > > + nv_boost_default, nv_boost_min, nv_boost_max, 1, > > + "Set the Nvidia dynamic boost limit"); > > +ATTR_GROUP_ROG_TUNABLE(nv_temp_target, "nv_temp_target", ASUS_WMI_DEVID_NV_THERM_TARGET, > > + nv_temp_default, nv_boost_min, nv_temp_max, 1, > > + "Set the Nvidia max thermal limit"); > > + > > ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_MODE, "0;1;2", > > "Show the current mode of charging"); > > > > @@ -441,6 +488,14 @@ static const struct asus_attr_group armoury_attr_groups[] = { > > { &egpu_enable_attr_group, ASUS_WMI_DEVID_EGPU }, > > { &dgpu_disable_attr_group, ASUS_WMI_DEVID_DGPU }, > > > > + { &ppt_pl1_spl_attr_group, ASUS_WMI_DEVID_PPT_PL1_SPL }, > > + { &ppt_pl2_sppt_attr_group, ASUS_WMI_DEVID_PPT_PL2_SPPT }, > > + { &ppt_apu_sppt_attr_group, ASUS_WMI_DEVID_PPT_APU_SPPT }, > > + { &ppt_platform_sppt_attr_group, ASUS_WMI_DEVID_PPT_PLAT_SPPT }, > > + { &ppt_fppt_attr_group, ASUS_WMI_DEVID_PPT_FPPT }, > > + { &nv_dynamic_boost_attr_group, ASUS_WMI_DEVID_NV_DYN_BOOST }, > > + { &nv_temp_target_attr_group, ASUS_WMI_DEVID_NV_THERM_TARGET }, > > + > > { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, > > { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, > > { &mcu_powersave_attr_group, ASUS_WMI_DEVID_MCU_POWERSAVE }, > > @@ -532,12 +587,87 @@ static int asus_fw_attr_add(void) > > > > /* Init / exit ****************************************************************/ > > > > +/* Set up the min/max and defaults for ROG tunables */ > > +static void init_rog_tunables(struct rog_tunables *rog) > > +{ > > + const char *product; > > + u32 max_boost = NVIDIA_BOOST_MAX; > > + u32 cpu_default = PPT_CPU_LIMIT_DEFAULT; > > + u32 cpu_max = PPT_CPU_LIMIT_MAX; > > + u32 platform_default = PPT_PLATFORM_DEFAULT; > > + u32 platform_max = PPT_PLATFORM_MAX; > > Reverse xmas tree here. Facepalm. Thanks. > > + > > + /* > > + * ASUS product_name contains everything required, e.g, > > + * "ROG Flow X16 GV601VV_GV601VV_00185149B" > > + */ > > + product = dmi_get_system_info(DMI_PRODUCT_NAME); Regarding the below, I think the above will always return somthing. I've never seen a blank product name. Unless this somehow errors? > > It's really too bad there isn't somewhere to programatically get the > correct upper bounds in their API. > > I'm wondering if you want something "like" this: > > if (!product) > pr_notice("Unknown hardware found. Setting safe limits, please report > to get limits corrected\n");