Message ID | 20211025210303.29083-1-mario.limonciello@amd.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [v2] ACPI: platform_profile: Add support for notification chains | expand |
Hi Mario, Thank you for the patch! Yet something to improve: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on linus/master v5.15-rc7 next-20211025] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Mario-Limonciello/ACPI-platform_profile-Add-support-for-notification-chains/20211026-050443 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: i386-debian-10.3 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/753ef2d5047b65eb707df546173703ca66305f95 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mario-Limonciello/ACPI-platform_profile-Add-support-for-notification-chains/20211026-050443 git checkout 753ef2d5047b65eb707df546173703ca66305f95 # save the attached .config to linux build tree mkdir build_dir make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/ fs/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/platform/x86/asus-wmi.c:2172:12: error: conflicting types for 'platform_profile_get' 2172 | static int platform_profile_get(struct platform_profile_handler *pprof, | ^~~~~~~~~~~~~~~~~~~~ In file included from drivers/platform/x86/asus-wmi.c:29: include/linux/platform_profile.h:42:5: note: previous declaration of 'platform_profile_get' was here 42 | int platform_profile_get(enum platform_profile_option *profile); | ^~~~~~~~~~~~~~~~~~~~ -- >> drivers/platform/x86/hp-wmi.c:892:12: error: conflicting types for 'platform_profile_get' 892 | static int platform_profile_get(struct platform_profile_handler *pprof, | ^~~~~~~~~~~~~~~~~~~~ In file included from drivers/platform/x86/hp-wmi.c:24: include/linux/platform_profile.h:42:5: note: previous declaration of 'platform_profile_get' was here 42 | int platform_profile_get(enum platform_profile_option *profile); | ^~~~~~~~~~~~~~~~~~~~ vim +/platform_profile_get +2172 drivers/platform/x86/asus-wmi.c 2daa86e78c494d Leonid Maksymchuk 2019-12-15 2170 c63d44ae602419 Luke D. Jones 2021-08-19 2171 /* Platform profile ***********************************************************/ c63d44ae602419 Luke D. Jones 2021-08-19 @2172 static int platform_profile_get(struct platform_profile_handler *pprof, c63d44ae602419 Luke D. Jones 2021-08-19 2173 enum platform_profile_option *profile) c63d44ae602419 Luke D. Jones 2021-08-19 2174 { c63d44ae602419 Luke D. Jones 2021-08-19 2175 struct asus_wmi *asus; c63d44ae602419 Luke D. Jones 2021-08-19 2176 int tp; c63d44ae602419 Luke D. Jones 2021-08-19 2177 c63d44ae602419 Luke D. Jones 2021-08-19 2178 asus = container_of(pprof, struct asus_wmi, platform_profile_handler); c63d44ae602419 Luke D. Jones 2021-08-19 2179 c63d44ae602419 Luke D. Jones 2021-08-19 2180 tp = asus->throttle_thermal_policy_mode; c63d44ae602419 Luke D. Jones 2021-08-19 2181 c63d44ae602419 Luke D. Jones 2021-08-19 2182 switch (tp) { c63d44ae602419 Luke D. Jones 2021-08-19 2183 case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT: c63d44ae602419 Luke D. Jones 2021-08-19 2184 *profile = PLATFORM_PROFILE_BALANCED; c63d44ae602419 Luke D. Jones 2021-08-19 2185 break; c63d44ae602419 Luke D. Jones 2021-08-19 2186 case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST: c63d44ae602419 Luke D. Jones 2021-08-19 2187 *profile = PLATFORM_PROFILE_PERFORMANCE; c63d44ae602419 Luke D. Jones 2021-08-19 2188 break; c63d44ae602419 Luke D. Jones 2021-08-19 2189 case ASUS_THROTTLE_THERMAL_POLICY_SILENT: c63d44ae602419 Luke D. Jones 2021-08-19 2190 *profile = PLATFORM_PROFILE_QUIET; c63d44ae602419 Luke D. Jones 2021-08-19 2191 break; c63d44ae602419 Luke D. Jones 2021-08-19 2192 default: c63d44ae602419 Luke D. Jones 2021-08-19 2193 return -EINVAL; c63d44ae602419 Luke D. Jones 2021-08-19 2194 } c63d44ae602419 Luke D. Jones 2021-08-19 2195 c63d44ae602419 Luke D. Jones 2021-08-19 2196 return 0; c63d44ae602419 Luke D. Jones 2021-08-19 2197 } c63d44ae602419 Luke D. Jones 2021-08-19 2198 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Mario, Thank you for the patch! Yet something to improve: [auto build test ERROR on rafael-pm/linux-next] [also build test ERROR on linus/master v5.15-rc7 next-20211028] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Mario-Limonciello/ACPI-platform_profile-Add-support-for-notification-chains/20211026-050443 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: x86_64-randconfig-a013-20211028 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/753ef2d5047b65eb707df546173703ca66305f95 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mario-Limonciello/ACPI-platform_profile-Add-support-for-notification-chains/20211026-050443 git checkout 753ef2d5047b65eb707df546173703ca66305f95 # save the attached .config to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/platform/x86/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/platform/x86/asus-wmi.c:2172:12: error: static declaration of 'platform_profile_get' follows non-static declaration static int platform_profile_get(struct platform_profile_handler *pprof, ^ include/linux/platform_profile.h:42:5: note: previous declaration is here int platform_profile_get(enum platform_profile_option *profile); ^ >> drivers/platform/x86/asus-wmi.c:2239:45: error: incompatible function pointer types assigning to 'int (*)(struct platform_profile_handler *, enum platform_profile_option *)' from 'int (enum platform_profile_option *)' [-Werror,-Wincompatible-function-pointer-types] asus->platform_profile_handler.profile_get = platform_profile_get; ^ ~~~~~~~~~~~~~~~~~~~~ 2 errors generated. vim +/platform_profile_get +2172 drivers/platform/x86/asus-wmi.c 2daa86e78c494d Leonid Maksymchuk 2019-12-15 2170 c63d44ae602419 Luke D. Jones 2021-08-19 2171 /* Platform profile ***********************************************************/ c63d44ae602419 Luke D. Jones 2021-08-19 @2172 static int platform_profile_get(struct platform_profile_handler *pprof, c63d44ae602419 Luke D. Jones 2021-08-19 2173 enum platform_profile_option *profile) c63d44ae602419 Luke D. Jones 2021-08-19 2174 { c63d44ae602419 Luke D. Jones 2021-08-19 2175 struct asus_wmi *asus; c63d44ae602419 Luke D. Jones 2021-08-19 2176 int tp; c63d44ae602419 Luke D. Jones 2021-08-19 2177 c63d44ae602419 Luke D. Jones 2021-08-19 2178 asus = container_of(pprof, struct asus_wmi, platform_profile_handler); c63d44ae602419 Luke D. Jones 2021-08-19 2179 c63d44ae602419 Luke D. Jones 2021-08-19 2180 tp = asus->throttle_thermal_policy_mode; c63d44ae602419 Luke D. Jones 2021-08-19 2181 c63d44ae602419 Luke D. Jones 2021-08-19 2182 switch (tp) { c63d44ae602419 Luke D. Jones 2021-08-19 2183 case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT: c63d44ae602419 Luke D. Jones 2021-08-19 2184 *profile = PLATFORM_PROFILE_BALANCED; c63d44ae602419 Luke D. Jones 2021-08-19 2185 break; c63d44ae602419 Luke D. Jones 2021-08-19 2186 case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST: c63d44ae602419 Luke D. Jones 2021-08-19 2187 *profile = PLATFORM_PROFILE_PERFORMANCE; c63d44ae602419 Luke D. Jones 2021-08-19 2188 break; c63d44ae602419 Luke D. Jones 2021-08-19 2189 case ASUS_THROTTLE_THERMAL_POLICY_SILENT: c63d44ae602419 Luke D. Jones 2021-08-19 2190 *profile = PLATFORM_PROFILE_QUIET; c63d44ae602419 Luke D. Jones 2021-08-19 2191 break; c63d44ae602419 Luke D. Jones 2021-08-19 2192 default: c63d44ae602419 Luke D. Jones 2021-08-19 2193 return -EINVAL; c63d44ae602419 Luke D. Jones 2021-08-19 2194 } c63d44ae602419 Luke D. Jones 2021-08-19 2195 c63d44ae602419 Luke D. Jones 2021-08-19 2196 return 0; c63d44ae602419 Luke D. Jones 2021-08-19 2197 } c63d44ae602419 Luke D. Jones 2021-08-19 2198 c63d44ae602419 Luke D. Jones 2021-08-19 2199 static int platform_profile_set(struct platform_profile_handler *pprof, c63d44ae602419 Luke D. Jones 2021-08-19 2200 enum platform_profile_option profile) c63d44ae602419 Luke D. Jones 2021-08-19 2201 { c63d44ae602419 Luke D. Jones 2021-08-19 2202 struct asus_wmi *asus; c63d44ae602419 Luke D. Jones 2021-08-19 2203 int tp; c63d44ae602419 Luke D. Jones 2021-08-19 2204 c63d44ae602419 Luke D. Jones 2021-08-19 2205 asus = container_of(pprof, struct asus_wmi, platform_profile_handler); c63d44ae602419 Luke D. Jones 2021-08-19 2206 c63d44ae602419 Luke D. Jones 2021-08-19 2207 switch (profile) { c63d44ae602419 Luke D. Jones 2021-08-19 2208 case PLATFORM_PROFILE_PERFORMANCE: c63d44ae602419 Luke D. Jones 2021-08-19 2209 tp = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST; c63d44ae602419 Luke D. Jones 2021-08-19 2210 break; c63d44ae602419 Luke D. Jones 2021-08-19 2211 case PLATFORM_PROFILE_BALANCED: c63d44ae602419 Luke D. Jones 2021-08-19 2212 tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; c63d44ae602419 Luke D. Jones 2021-08-19 2213 break; c63d44ae602419 Luke D. Jones 2021-08-19 2214 case PLATFORM_PROFILE_QUIET: c63d44ae602419 Luke D. Jones 2021-08-19 2215 tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT; c63d44ae602419 Luke D. Jones 2021-08-19 2216 break; c63d44ae602419 Luke D. Jones 2021-08-19 2217 default: c63d44ae602419 Luke D. Jones 2021-08-19 2218 return -EOPNOTSUPP; c63d44ae602419 Luke D. Jones 2021-08-19 2219 } c63d44ae602419 Luke D. Jones 2021-08-19 2220 c63d44ae602419 Luke D. Jones 2021-08-19 2221 asus->throttle_thermal_policy_mode = tp; c63d44ae602419 Luke D. Jones 2021-08-19 2222 return throttle_thermal_policy_write(asus); c63d44ae602419 Luke D. Jones 2021-08-19 2223 } c63d44ae602419 Luke D. Jones 2021-08-19 2224 c63d44ae602419 Luke D. Jones 2021-08-19 2225 static int platform_profile_setup(struct asus_wmi *asus) c63d44ae602419 Luke D. Jones 2021-08-19 2226 { c63d44ae602419 Luke D. Jones 2021-08-19 2227 struct device *dev = &asus->platform_device->dev; c63d44ae602419 Luke D. Jones 2021-08-19 2228 int err; c63d44ae602419 Luke D. Jones 2021-08-19 2229 c63d44ae602419 Luke D. Jones 2021-08-19 2230 /* c63d44ae602419 Luke D. Jones 2021-08-19 2231 * Not an error if a component platform_profile relies on is unavailable c63d44ae602419 Luke D. Jones 2021-08-19 2232 * so early return, skipping the setup of platform_profile. c63d44ae602419 Luke D. Jones 2021-08-19 2233 */ c63d44ae602419 Luke D. Jones 2021-08-19 2234 if (!asus->throttle_thermal_policy_available) c63d44ae602419 Luke D. Jones 2021-08-19 2235 return 0; c63d44ae602419 Luke D. Jones 2021-08-19 2236 c63d44ae602419 Luke D. Jones 2021-08-19 2237 dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); c63d44ae602419 Luke D. Jones 2021-08-19 2238 c63d44ae602419 Luke D. Jones 2021-08-19 @2239 asus->platform_profile_handler.profile_get = platform_profile_get; c63d44ae602419 Luke D. Jones 2021-08-19 2240 asus->platform_profile_handler.profile_set = platform_profile_set; c63d44ae602419 Luke D. Jones 2021-08-19 2241 c63d44ae602419 Luke D. Jones 2021-08-19 2242 set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); c63d44ae602419 Luke D. Jones 2021-08-19 2243 set_bit(PLATFORM_PROFILE_BALANCED, c63d44ae602419 Luke D. Jones 2021-08-19 2244 asus->platform_profile_handler.choices); c63d44ae602419 Luke D. Jones 2021-08-19 2245 set_bit(PLATFORM_PROFILE_PERFORMANCE, c63d44ae602419 Luke D. Jones 2021-08-19 2246 asus->platform_profile_handler.choices); c63d44ae602419 Luke D. Jones 2021-08-19 2247 c63d44ae602419 Luke D. Jones 2021-08-19 2248 err = platform_profile_register(&asus->platform_profile_handler); c63d44ae602419 Luke D. Jones 2021-08-19 2249 if (err) c63d44ae602419 Luke D. Jones 2021-08-19 2250 return err; c63d44ae602419 Luke D. Jones 2021-08-19 2251 c63d44ae602419 Luke D. Jones 2021-08-19 2252 asus->platform_profile_support = true; c63d44ae602419 Luke D. Jones 2021-08-19 2253 return 0; c63d44ae602419 Luke D. Jones 2021-08-19 2254 } c63d44ae602419 Luke D. Jones 2021-08-19 2255 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index dd2fbf38e414..1badbc8d6012 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -21,6 +21,24 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_PERFORMANCE] = "performance", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static BLOCKING_NOTIFIER_HEAD(platform_profile_chain_head); + +int platform_profile_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&platform_profile_chain_head, nb); +} +EXPORT_SYMBOL_GPL(platform_profile_register_notifier); + +int platform_profile_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&platform_profile_chain_head, nb); +} +EXPORT_SYMBOL_GPL(platform_profile_unregister_notifier); + +static void platform_profile_call_notifier(unsigned long action, void *data) +{ + blocking_notifier_call_chain(&platform_profile_chain_head, action, data); +} static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, @@ -49,11 +67,8 @@ static ssize_t platform_profile_choices_show(struct device *dev, return len; } -static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) +int platform_profile_get(enum platform_profile_option *profile) { - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; err = mutex_lock_interruptible(&profile_lock); @@ -65,15 +80,28 @@ static ssize_t platform_profile_show(struct device *dev, return -ENODEV; } - err = cur_profile->profile_get(cur_profile, &profile); + err = cur_profile->profile_get(cur_profile, profile); mutex_unlock(&profile_lock); if (err) return err; /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) + if (WARN_ON((*profile < 0) || (*profile >= ARRAY_SIZE(profile_names)))) return -EIO; + return 0; +} +EXPORT_SYMBOL_GPL(platform_profile_get); + +static ssize_t platform_profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; + int ret = platform_profile_get(&profile); + + if (ret) + return ret; return sysfs_emit(buf, "%s\n", profile_names[profile]); } @@ -127,9 +155,17 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(void) { + enum platform_profile_option profile; + int ret; + if (!cur_profile) return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); + ret = platform_profile_get(&profile); + if (ret) + return; + platform_profile_call_notifier(PLATFORM_PROFILE_CHANGED, &profile); + } EXPORT_SYMBOL_GPL(platform_profile_notify); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index e5cbb6841f3a..05ba3403509a 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -11,6 +11,8 @@ #include <linux/bitops.h> +struct notifier_block; + /* * If more options are added please update profile_names array in * platform_profile.c and sysfs-platform_profile documentation. @@ -37,5 +39,13 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(void); void platform_profile_notify(void); +int platform_profile_get(enum platform_profile_option *profile); + +int platform_profile_register_notifier(struct notifier_block *nb); +int platform_profile_unregister_notifier(struct notifier_block *nb); + +enum platform_profile_notifier_actions { + PLATFORM_PROFILE_CHANGED, +}; #endif /*_PLATFORM_PROFILE_H_*/
Allow other drivers to initialize relative to current active profile and react to platform profile changes. Drivers wishing to utilize this should register for notification at module load and unregister when unloading. Notifications will come in the from a notifier call. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> --- V1: https://lore.kernel.org/linux-acpi/7d0c7f12-a412-582e-22f2-8285cf74066a@amd.com/T/#m834d32b2ebcf8bd3dab0c5aa48f6deaa48e34e62 Changes from v1->v2: * Add the new performance mode as part of the callback to simplify callers. * Drop the GPL symbol export for platform_profile_call_notifier drivers/acpi/platform_profile.c | 48 ++++++++++++++++++++++++++++---- include/linux/platform_profile.h | 10 +++++++ 2 files changed, 52 insertions(+), 6 deletions(-)