hwmon: (sch56xx) Automatically load on supported hardware
Subsystems (2)
cover hwmon: (sch56xx) Automatically load on supported hardware
The hardware monitoring solutions supported by the sch5627 and sch5636 drivers are Fujitsu-specific.
After some online searching, i found out that the solution used with the SCH5627 is called "Antiope" by Fujitsu, just like the "Theseus" solution inside the SCH5636.
I also found out that "Antiope" and "Theseus" are listed as DMI onboard devices on supported Fujitsu devices, so the sch56xx_common module can be loaded automatically an check for the DMI devices. However some devices like the Esprimo C700 have both devices, so after verifying that at least one onboard device is present, sch56xx_common still has to detect which chip is present.
This is safe however if at least one device is present.
Tested on a Fujitsu Esprimo P720.
Armin Wolf (4):
hwmon: (sch56xx) Autoload modules on platform device creation
hwmon: (sch56xx-common) Add automatic module loading on supported
devices
hwmon: (sch56xx-common) Replace msleep() with usleep_range()
hwmon: (sch56xx-common) Replace WDOG_ACTIVE with WDOG_HW_RUNNING
drivers/hwmon/sch5627.c | 9 +++++++ drivers/hwmon/sch5636.c | 9 +++++++ drivers/hwmon/sch56xx-common.c | 44 ++++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 4 deletions(-)
--
2.30.2
PATCH RESEND 1/4 hwmon: (sch56xx) Autoload modules on platform device creation
Right now, when sch56xx-common has detected a SCH5627/SCH5636 superio chip, the corresponding module is not automatically loaded.
Fix that by adding the necessary device tables to both modules.
Tested on a Fujitsu Esprimo P720.
--- drivers/hwmon/sch5627.c | 9 +++++++++ drivers/hwmon/sch5636.c | 9 +++++++++ 2 files changed, 18 insertions(+)
drivers/hwmon/sch5627.c +9 -0
@@ -7,6 +7,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/jiffies.h>
@@ -456,6 +457,14 @@ static int sch5627_probe(struct platform_device *pdev)return 0 ; } +static const struct platform_device_id sch5627_device_ids[]__initconst = { + { + .name ="sch5627" , + }, + { } +}; +MODULE_DEVICE_TABLE (platform, sch5627_device_ids); +static struct platform_driver sch5627_driver = { .driver = { .name =DRVNAME ,
drivers/hwmon/sch5636.c +9 -0
@@ -7,6 +7,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/jiffies.h>
@@ -501,6 +502,14 @@ static int sch5636_probe(struct platform_device *pdev)return err; } +static const struct platform_device_id sch5636_device_ids[]__initconst = { + { + .name ="sch5636" , + }, + { } +}; +MODULE_DEVICE_TABLE (platform, sch5636_device_ids); +static struct platform_driver sch5636_driver = { .driver = { .name =DRVNAME ,
--
2.30.2
kernel test robot
build botRe: [PATCH RESEND 1/4] hwmon: (sch56xx) Autoload modules on platform device creation
Thank you for the patch! Perhaps something to improve:
Hi Armin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on v5.17-rc2 next-20220131]
[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/Armin-Wolf/hwmon-sch56xx-Automatically-load-on-supported-hardware/20220131-173922 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-a013-20220131 (https://download.01.org/0day-ci/archive/20220131/202201312148.QC1Yn8ze-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2cdbaca3943a4d6259119f185656328bd3805b68)
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/fca8c6c3e08b173fb6ac72499933662f18332d95
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Armin-Wolf/hwmon-sch56xx-Automatically-load-on-supported-hardware/20220131-173922 git checkout fca8c6c3e08b173fb6ac72499933662f18332d95
# save the config file 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/hwmon/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/hwmon/sch5627.c:460:40: warning: unused variable 'sch5627_device_ids' [-Wunused-const-variable]
static const struct platform_device_id sch5627_device_ids[] __initconst = {
^1 warning generated.
vim +/sch5627_device_ids +460 drivers/hwmon/sch5627.c
459
> 460 static const struct platform_device_id sch5627_device_ids[] __initconst = { 461 {
462 .name = "sch5627",
463 },
464 { }
465 };
466 MODULE_DEVICE_TABLE(platform, sch5627_device_ids);
467
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH RESEND 1/4] hwmon: (sch56xx) Autoload modules on platform device creation
In reply to Armin WolfThank you for the patch! Perhaps something to improve:
Hi Armin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on v5.17-rc2 next-20220131]
[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/Armin-Wolf/hwmon-sch56xx-Automatically-load-on-supported-hardware/20220131-173922 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-a016-20220131 (https://download.01.org/0day-ci/archive/20220131/202201312123.4IfI3lGh-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2cdbaca3943a4d6259119f185656328bd3805b68)
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/fca8c6c3e08b173fb6ac72499933662f18332d95
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Armin-Wolf/hwmon-sch56xx-Automatically-load-on-supported-hardware/20220131-173922 git checkout fca8c6c3e08b173fb6ac72499933662f18332d95
# save the config file 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/hwmon/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/hwmon/sch5636.c:505:40: warning: unused variable 'sch5636_device_ids' [-Wunused-const-variable]
static const struct platform_device_id sch5636_device_ids[] __initconst = {
^1 warning generated.
vim +/sch5636_device_ids +505 drivers/hwmon/sch5636.c
504
> 505 static const struct platform_device_id sch5636_device_ids[] __initconst = { 506 {
507 .name = "sch5636",
508 },
509 { }
510 };
511 MODULE_DEVICE_TABLE(platform, sch5636_device_ids);
512
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH RESEND 2/4 hwmon: (sch56xx-common) Add automatic module loading on supported devices
In reply to Armin WolfThis patch enables the sch56xx-common module to get automatically loaded on supported machines.
If a machine supports Fujitsu's SCH56XX-based hardware monitoring solutions, it contains a "Antiope"/" Antiope" dmi onboard device in case of the sch5627 or a "Theseus"/" Theseus" dmi onboard device in case of the sch5636.
Since some machines like the Esprimo C700 have a seemingly faulty DMI table containing both onboard devices, the driver still needs to probe for the individual superio chip, which in presence of at least one DMI onboard device however can be considered safe. Also add a module parameter allowing for bypassing the DMI check.
Tested on a Fujitsu Esprimo P720.
--- drivers/hwmon/sch56xx-common.c | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/hwmon/sch56xx-common.c +38 -2
@@ -7,8 +7,10 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/platform_device.h> +#include <linux/dmi.h> #include <linux/err.h> #include <linux/io.h> #include <linux/acpi.h>
@@ -19,7 +21,10 @@#include <linux/slab.h> #include "sch56xx-common.h" -/* Insmod parameters */ +static bool ignore_dmi; +module_param (ignore_dmi, bool,0 ); +MODULE_PARM_DESC (ignore_dmi,"Omit DMI check for supported devices (default=0)" ); +static bool nowayout =WATCHDOG_NOWAYOUT ;module_param (nowayout, bool,0 ); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
@@ -518,11 +523,42 @@ static int __init sch56xx_device_add(int address, const char *name)return PTR_ERR_OR_ZERO (sch56xx_pdev); } +/* For autoloading only */ +static const struct dmi_system_id sch56xx_dmi_table[]__initconst = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU" ), + }, + }, + { } +}; +MODULE_DEVICE_TABLE (dmi, sch56xx_dmi_table); +static int __init sch56xx_init (void ) { -int address;const char *name =NULL ; +int address; +if (!ignore_dmi) { +if (!dmi_check_system (sch56xx_dmi_table)) +return -ENODEV ; + +/* +* Some machines like the Esprimo P720 and Esprimo C700 have +* onboard devices named " Antiope"/" Theseus" instead of +* "Antiope"/"Theseus", so we need to check for both. +*/ +if (!dmi_find_device (DMI_DEV_TYPE_OTHER ,"Antiope" ,NULL ) && + !dmi_find_device (DMI_DEV_TYPE_OTHER ," Antiope" ,NULL ) && + !dmi_find_device (DMI_DEV_TYPE_OTHER ,"Theseus" ,NULL ) && + !dmi_find_device (DMI_DEV_TYPE_OTHER ," Theseus" ,NULL )) +return -ENODEV ; + } + +/* +* Some devices like the Esprimo C700 have both onboard devices, +* so we still have to check manually +*/ address =sch56xx_find (0x4e , &name);if (address <0 ) address =sch56xx_find (0x2e , &name);
--
2.30.2
PATCH RESEND 3/4 hwmon: (sch56xx-common) Replace msleep() with usleep_range()
In reply to Armin Wolfmsleep(1) will often sleep more than 20ms, slowing down sensor and watchdog reads/writes. Use usleep_range() as recommended in timers-howto.rst to fix that.
Tested on a Fujitsu Esprimo P720.
--- drivers/hwmon/sch56xx-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/sch56xx-common.c +1 -1
@@ -139,7 +139,7 @@ static int sch56xx_send_cmd(u16 addr, u8 cmd, u16 reg, u8 v)/* EM Interface Polling "Algorithm" */ for (i =0 ; i < max_busy_polls + max_lazy_polls; i++) {if (i >= max_busy_polls) -msleep (1 ); +usleep_range (1 ,2 );/* Read Interrupt source Register */ val =inb (addr +8 );/* Write Clear the interrupt source bits */
--
2.30.2
PATCH RESEND 4/4 hwmon: (sch56xx-common) Replace WDOG_ACTIVE with WDOG_HW_RUNNING
In reply to Armin WolfIf the watchdog was already enabled by the BIOS after booting, the watchdog infrastructure needs to regularly send keepalives to prevent a unexpected reset.WDOG_ACTIVE only serves as an status indicator for userspace, we want to use WDOG_HW_RUNNING instead.
Since my Fujitsu Esprimo P720 does not support the watchdog, this change is compile-tested only.
--- drivers/hwmon/sch56xx-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/sch56xx-common.c +1 -1
@@ -427,7 +427,7 @@ void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, data->wddev.max_timeout =255 *60 ;watchdog_set_nowayout (&data->wddev, nowayout);if (output_enable &SCH56XX_WDOG_OUTPUT_ENABLE ) -set_bit (WDOG_ACTIVE , &data->wddev.status); +set_bit (WDOG_HW_RUNNING , &data->wddev.status);/* Since the watchdog uses a downcounter there is no register to read the BIOS set timeout from (if any was set at all) ->
--
2.30.2
Hi Armin,
Quoted 14 lines · Armin Wolf
The hardware monitoring solutions supported by the sch5627 and sch5636 drivers are Fujitsu-specific.
After some online searching, i found out that the solution used with the SCH5627 is called "Antiope" by Fujitsu, just like the "Theseus" solution inside the SCH5636.
I also found out that "Antiope" and "Theseus" are listed as DMI onboard devices on supported Fujitsu devices, so thesch56xx_commonmodule can be loaded automatically an check for the DMI devices. However some devices like the Esprimo C700 have both devices, so after verifying that at least one onboard device is present,sch56xx_commonstill has to detect which chip is present.
This is safe however if at least one device is present.
Quoted 8 lines
Tested on a Fujitsu Esprimo P720.
Armin Wolf (4):
hwmon: (sch56xx) Autoload modules on platform device creation
hwmon: (sch56xx-common) Add automatic module loading on supported
devices
hwmon: (sch56xx-common) Replacemsleep()withusleep_range()
hwmon: (sch56xx-common) ReplaceWDOG_ACTIVEwithWDOG_HW_RUNNING
Not sure why you did a resend? I received the original just fine ?
With that said the entire series looks good to me:
for the series.
Regards,
Hans
Quoted 9 lines
drivers/hwmon/sch5627.c | 9 +++++++ drivers/hwmon/sch5636.c | 9 +++++++ drivers/hwmon/sch56xx-common.c | 44 ++++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 4 deletions(-)--
2.30.2