diag288 watchdog fixes and improvements
Subsystems (2)
cover diag288 watchdog fixes and improvements
Minor code refactoring to improve readability of the driver, reduce code duplication and remove dead code.
Alexander Egorenkov (5):
watchdog: diag288_wdt: get rid of register asm
watchdog: diag288_wdt: remove power management
watchdog: diag288_wdt: unify command buffer handling for diag288 zvm
watchdog: diag288_wdt: de-duplicate diag_stat_inc() calls
watchdog: diag288_wdt: unify lpar and zvm diag288 helpers
drivers/watchdog/diag288_wdt.c | 162 ++++++++------------------------- 1 file changed, 37 insertions(+), 125 deletions(-)
Signature · 1 line
2.37.2
PATCH 1/5 watchdog: diag288_wdt: get rid of register asm
Using register asm statements has been proven to be very error prone, especially when using code instrumentation where gcc may add function calls, which clobbers register contents in an unexpected way.
Therefore, get rid of register asm statements in watchdog code, and make sure this bug class cannot happen.
Moreover, remove the register r1 from the clobber list because this register is not changed by DIAG 288.
--- drivers/watchdog/diag288_wdt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/watchdog/diag288_wdt.c +7 -8
@@ -73,20 +73,19 @@ MODULE_ALIAS("vmwatchdog");static int __diag288 (unsigned int func,unsigned int timeout,unsigned long action,unsigned int len) { - register unsigned long __func asm("2") = func; - register unsigned long __timeout asm("3") = timeout; - register unsigned long __action asm("4") = action; - register unsigned long __len asm("5") = len; +union register_pair r1 = { .even = func, .odd = timeout, }; +union register_pair r3 = { .even = action, .odd = len, };int err; err = -EINVAL ; asmvolatile ( -" diag %1, %3, 0x288\n" -"0: la %0, 0\n" +" diag %[r1],%[r3],0x288\n" +"0: la %[err],0\n" "1:\n" EX_TABLE(0b, 1b) - : "+d" (err) : "d"(__func), "d"(__timeout), - "d"(__action), "d"(__len) : "1", "cc", "memory"); + : [err] "+d" (err) + : [r1] "d" (r1.pair), [r3] "d" (r3.pair) + : "cc", "memory"); return err; }
Signature · 1 line
2.37.2
Re: [PATCH 1/5] watchdog: diag288_wdt: get rid of register asm
Quoted 4 lines · Alexander Egorenkov
Using register asm statements has been proven to be very error prone, especially when using code instrumentation where gcc may add function calls, which clobbers register contents in an unexpected way.
Quoted 8 lines
Therefore, get rid of register asm statements in watchdog code, and make sure this bug class cannot happen.
Moreover, remove the register r1 from the clobber list because this register is not changed by DIAG 288.
Reviewed-by Heiko Carstens <[email protected]>Signed-off-by Alexander Egorenkov <[email protected]>
Quoted 36 lines
--- drivers/watchdog/diag288_wdt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)drivers/watchdog/diag288_wdt.c +7
-8@@ -73,20 +73,19 @@ MODULE_ALIAS("vmwatchdog");static int __diag288 (unsigned int func,unsigned int timeout,unsigned long action,unsigned int len) { - register unsigned long __func asm("2") = func; - register unsigned long __timeout asm("3") = timeout; - register unsigned long __action asm("4") = action; - register unsigned long __len asm("5") = len; +union register_pair r1 = { .even = func, .odd = timeout, }; +union register_pair r3 = { .even = action, .odd = len, };int err; err = -EINVAL ; asmvolatile ( -" diag %1, %3, 0x288\n" -"0: la %0, 0\n" +" diag %[r1],%[r3],0x288\n" +"0: la %[err],0\n" "1:\n" EX_TABLE(0b, 1b) - : "+d" (err) : "d"(__func), "d"(__timeout), - "d"(__action), "d"(__len) : "1", "cc", "memory"); + : [err] "+d" (err) + : [r1] "d" (r1.pair), [r3] "d" (r3.pair) + : "cc", "memory"); return err; }
PATCH 2/5 watchdog: diag288_wdt: remove power management
In reply to Alexander EgorenkovRemove power management because s390 no longer supports hibernation since commit 394216275c7d ("s390: remove broken hibernate / power management support").
--- drivers/watchdog/diag288_wdt.c | 65 ++-------------------------------- 1 file changed, 2 insertions(+), 63 deletions(-)
drivers/watchdog/diag288_wdt.c +2 -63
@@ -27,7 +27,6 @@#include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/watchdog.h> -#include <linux/suspend.h> #include <asm/ebcdic.h> #include <asm/diag.h> #include <linux/io.h>
@@ -103,10 +102,6 @@ static int __diag288_lpar(unsigned int func, unsigned int timeout,return __diag288 (func, timeout, action,0 ); } -static unsigned long wdt_status; - -#define DIAG_WDOG_BUSY 0 -static int wdt_start (struct watchdog_device *dev) {char *ebc_cmd;
@@ -114,15 +109,10 @@ static int wdt_start(struct watchdog_device *dev)int ret;unsigned int func; -if (test_and_set_bit (DIAG_WDOG_BUSY , &wdt_status)) -return -EBUSY ; -if (MACHINE_IS_VM ) { ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) { -clear_bit (DIAG_WDOG_BUSY , &wdt_status); +if (!ebc_cmd)return -ENOMEM ; - } len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN );ASCEBC (ebc_cmd,MAX_CMDLEN );EBC_TOUPPER (ebc_cmd,MAX_CMDLEN );
@@ -139,7 +129,6 @@ static int wdt_start(struct watchdog_device *dev)if (ret) {pr_err ("The watchdog cannot be activated\n" ); -clear_bit (DIAG_WDOG_BUSY , &wdt_status);return ret; }return 0 ;
@@ -152,8 +141,6 @@ static int wdt_stop(struct watchdog_device *dev)diag_stat_inc (DIAG_STAT_X288 ); ret =__diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); -clear_bit (DIAG_WDOG_BUSY , &wdt_status); -return ret; }
@@ -222,45 +209,6 @@ static struct watchdog_device wdt_dev = { .max_timeout = MAX_INTERVAL, }; -/* -* It makes no sense to go into suspend while the watchdog is running. -* Depending on the memory size, the watchdog might trigger, while we -* are still saving the memory. -*/ -static int wdt_suspend (void ) -{ -if (test_and_set_bit (DIAG_WDOG_BUSY , &wdt_status)) { -pr_err ("Linux cannot be suspended while the watchdog is in use\n" ); -return notifier_from_errno (-EBUSY ); - } -return NOTIFY_DONE ; -} - -static int wdt_resume (void ) -{ -clear_bit (DIAG_WDOG_BUSY , &wdt_status); -return NOTIFY_DONE ; -} - -static int wdt_power_event (struct notifier_block *this,unsigned long event, -void *ptr) -{ -switch (event) { -case PM_POST_HIBERNATION : -case PM_POST_SUSPEND : -return wdt_resume (); -case PM_HIBERNATION_PREPARE : -case PM_SUSPEND_PREPARE : -return wdt_suspend (); -default : -return NOTIFY_DONE ; - } -} - -static struct notifier_block wdt_power_notifier = { - .notifier_call = wdt_power_event, -}; -static int __init diag288_init (void ) {int ret;
@@ -297,21 +245,12 @@ static int __init diag288_init(void)return -EINVAL ; } - ret =register_pm_notifier (&wdt_power_notifier); -if (ret) -return ret; - - ret =watchdog_register_device (&wdt_dev); -if (ret) -unregister_pm_notifier (&wdt_power_notifier); - -return ret; +return watchdog_register_device (&wdt_dev); } static void __exit diag288_exit(void) {watchdog_unregister_device (&wdt_dev); -unregister_pm_notifier (&wdt_power_notifier); }module_init (diag288_init);
Signature · 1 line
2.37.2
Re: [PATCH 2/5] watchdog: diag288_wdt: remove power management
Quoted 6 lines · Alexander Egorenkov
Remove power management because s390 no longer supports hibernation since commit
394216275c7d("s390: remove broken hibernate / power management support").Reviewed-by Heiko Carstens <[email protected]>Signed-off-by Alexander Egorenkov <[email protected]>
Quoted 130 lines
--- drivers/watchdog/diag288_wdt.c | 65 ++-------------------------------- 1 file changed, 2 insertions(+), 63 deletions(-)drivers/watchdog/diag288_wdt.c +2
-63@@ -27,7 +27,6 @@#include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/watchdog.h> -#include <linux/suspend.h> #include <asm/ebcdic.h> #include <asm/diag.h> #include <linux/io.h> @@ -103,10 +102,6 @@ static int __diag288_lpar(unsigned int func, unsigned int timeout,return __diag288 (func, timeout, action,0 ); } -static unsigned long wdt_status; - -#define DIAG_WDOG_BUSY 0 -static int wdt_start (struct watchdog_device *dev) {char *ebc_cmd;@@ -114,15 +109,10 @@ static int wdt_start(struct watchdog_device *dev)int ret;unsigned int func; -if (test_and_set_bit (DIAG_WDOG_BUSY , &wdt_status)) -return -EBUSY ; -if (MACHINE_IS_VM ) { ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) { -clear_bit (DIAG_WDOG_BUSY , &wdt_status); +if (!ebc_cmd)return -ENOMEM ; - } len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN );ASCEBC (ebc_cmd,MAX_CMDLEN );EBC_TOUPPER (ebc_cmd,MAX_CMDLEN );@@ -139,7 +129,6 @@ static int wdt_start(struct watchdog_device *dev)if (ret) {pr_err ("The watchdog cannot be activated\n" ); -clear_bit (DIAG_WDOG_BUSY , &wdt_status);return ret; }return 0 ;@@ -152,8 +141,6 @@ static int wdt_stop(struct watchdog_device *dev)diag_stat_inc (DIAG_STAT_X288 ); ret =__diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); -clear_bit (DIAG_WDOG_BUSY , &wdt_status); -return ret; }@@ -222,45 +209,6 @@ static struct watchdog_device wdt_dev = { .max_timeout = MAX_INTERVAL, }; -/* -* It makes no sense to go into suspend while the watchdog is running. -* Depending on the memory size, the watchdog might trigger, while we -* are still saving the memory. -*/ -static int wdt_suspend (void ) -{ -if (test_and_set_bit (DIAG_WDOG_BUSY , &wdt_status)) { -pr_err ("Linux cannot be suspended while the watchdog is in use\n" ); -return notifier_from_errno (-EBUSY ); - } -return NOTIFY_DONE ; -} - -static int wdt_resume (void ) -{ -clear_bit (DIAG_WDOG_BUSY , &wdt_status); -return NOTIFY_DONE ; -} - -static int wdt_power_event (struct notifier_block *this,unsigned long event, -void *ptr) -{ -switch (event) { -case PM_POST_HIBERNATION : -case PM_POST_SUSPEND : -return wdt_resume (); -case PM_HIBERNATION_PREPARE : -case PM_SUSPEND_PREPARE : -return wdt_suspend (); -default : -return NOTIFY_DONE ; - } -} - -static struct notifier_block wdt_power_notifier = { - .notifier_call = wdt_power_event, -}; -static int __init diag288_init (void ) {int ret;@@ -297,21 +245,12 @@ static int __init diag288_init(void)return -EINVAL ; } - ret =register_pm_notifier (&wdt_power_notifier); -if (ret) -return ret; - - ret =watchdog_register_device (&wdt_dev); -if (ret) -unregister_pm_notifier (&wdt_power_notifier); - -return ret; +return watchdog_register_device (&wdt_dev); } static void __exit diag288_exit(void) {watchdog_unregister_device (&wdt_dev); -unregister_pm_notifier (&wdt_power_notifier); }module_init (diag288_init);
PATCH 3/5 watchdog: diag288_wdt: unify command buffer handling for diag288 zvm
In reply to Alexander EgorenkovSimplify and de-duplicate code by introducing a common single command buffer allocated once at initialization. Moreover, simplify the interface of __diag288_vm() by accepting ASCII strings as the command parameter and converting it to the EBCDIC format within the function itself.
--- drivers/watchdog/diag288_wdt.c | 55 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 35 deletions(-)
drivers/watchdog/diag288_wdt.c +20 -35
@@ -69,6 +69,8 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = CMODULE_ALIAS ("vmwatchdog" ); +static char *cmd_buf; +static int __diag288 (unsigned int func,unsigned int timeout,unsigned long action,unsigned int len) {
@@ -88,11 +90,18 @@ static int __diag288(unsigned int func, unsigned int timeout,return err; } -static int __diag288_vm (unsigned int func,unsigned int timeout, -char *cmd,size_t len) +static int __diag288_vm (unsigned int func,unsigned int timeout,char *cmd) { +ssize_t len; + + len =strscpy (cmd_buf, cmd,MAX_CMDLEN ); +if (len <0 ) +return len; +ASCEBC (cmd_buf,MAX_CMDLEN ); +EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); +diag_stat_inc (DIAG_STAT_X288 ); -return __diag288 (func, timeout,virt_to_phys (cmd), len); +return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); } static int __diag288_lpar(unsigned int func, unsigned int timeout,
@@ -104,24 +113,14 @@ static int __diag288_lpar(unsigned int func, unsigned int timeout,static int wdt_start (struct watchdog_device *dev) { -char *ebc_cmd; -size_t len;int ret;unsigned int func;if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) -return -ENOMEM ; - len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN ); -ASCEBC (ebc_cmd,MAX_CMDLEN ); -EBC_TOUPPER (ebc_cmd,MAX_CMDLEN ); - func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, ebc_cmd, len); + ret =__diag288_vm (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); -kfree (ebc_cmd); }else { ret =__diag288_lpar (WDT_FUNC_INIT , dev->timeout,LPARWDT_RESTART );
@@ -146,19 +145,10 @@ static int wdt_stop(struct watchdog_device *dev)static int wdt_ping (struct watchdog_device *dev) { -char *ebc_cmd; -size_t len;int ret;unsigned int func;if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) -return -ENOMEM ; - len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN ); -ASCEBC (ebc_cmd,MAX_CMDLEN ); -EBC_TOUPPER (ebc_cmd,MAX_CMDLEN ); -/* * It seems to be ok to z/VM to use the init function to * retrigger the watchdog. On LPAR WDT_FUNC_CHANGE must
@@ -167,9 +157,8 @@ static int wdt_ping(struct watchdog_device *dev) func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, ebc_cmd, len); + ret =__diag288_vm (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); -kfree (ebc_cmd); }else { ret =__diag288_lpar (WDT_FUNC_CHANGE , dev->timeout,0 ); }
@@ -212,25 +201,20 @@ static struct watchdog_device wdt_dev = {static int __init diag288_init (void ) {int ret; -char ebc_begin[] = { -194 ,197 ,199 ,201 ,213 - }; -char *ebc_cmd;watchdog_set_nowayout (&wdt_dev, nowayout_info);if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (sizeof (ebc_begin),GFP_KERNEL ); -if (!ebc_cmd) { + cmd_buf =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); +if (!cmd_buf) {pr_err ("The watchdog cannot be initialized\n" );return -ENOMEM ; } -memcpy (ebc_cmd, ebc_begin,sizeof (ebc_begin)); - ret =__diag288_vm (WDT_FUNC_INIT ,15 , - ebc_cmd,sizeof (ebc_begin)); -kfree (ebc_cmd); + + ret =__diag288_vm (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" );if (ret !=0 ) {pr_err ("The watchdog cannot be initialized\n" ); +kfree (cmd_buf);return -EINVAL ; } }else {
@@ -251,6 +235,7 @@ static int __init diag288_init(void) static void __exit diag288_exit(void) {watchdog_unregister_device (&wdt_dev); +kfree (cmd_buf); }module_init (diag288_init);
Signature · 1 line
2.37.2
Re: [PATCH 3/5] watchdog: diag288_wdt: unify command buffer handling for diag288 zvm
Quoted 16 lines · Alexander Egorenkov
Simplify and de-duplicate code by introducing a common single command buffer allocated once at initialization. Moreover, simplify the interface of
__diag288_vm()by accepting ASCII strings as the command parameter and converting it to the EBCDIC format within the function itself.Reviewed-by Heiko Carstens <[email protected]>Signed-off-by Alexander Egorenkov <[email protected]>--- drivers/watchdog/diag288_wdt.c | 55 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 35 deletions(-)drivers/watchdog/diag288_wdt.c +0
-0
drivers/watchdog/diag288_wdt.c MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = C · line 73
Quoted 5 lines
drivers/watchdog/diag288_wdt.c +2
-0@@ -69,6 +69,8 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = CMODULE_ALIAS ("vmwatchdog" ); +static char *cmd_buf; +
Personally I wound not even bother allocating this, but that is just my personal opinion. And I guess one more static variable doesn't make much of a difference either.
Quoted 121 lines
drivers/watchdog/diag288_wdt.c +18
-35static int __diag288 (unsigned int func,unsigned int timeout,unsigned long action,unsigned int len) {@@ -88,11 +90,18 @@ static int __diag288(unsigned int func, unsigned int timeout,return err; } -static int __diag288_vm (unsigned int func,unsigned int timeout, -char *cmd,size_t len) +static int __diag288_vm (unsigned int func,unsigned int timeout,char *cmd) { +ssize_t len; + + len =strscpy (cmd_buf, cmd,MAX_CMDLEN ); +if (len <0 ) +return len; +ASCEBC (cmd_buf,MAX_CMDLEN ); +EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); +diag_stat_inc (DIAG_STAT_X288 ); -return __diag288 (func, timeout,virt_to_phys (cmd), len); +return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); } static int __diag288_lpar(unsigned int func, unsigned int timeout,@@ -104,24 +113,14 @@ static int __diag288_lpar(unsigned int func, unsigned int timeout,static int wdt_start (struct watchdog_device *dev) { -char *ebc_cmd; -size_t len;int ret;unsigned int func;if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) -return -ENOMEM ; - len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN ); -ASCEBC (ebc_cmd,MAX_CMDLEN ); -EBC_TOUPPER (ebc_cmd,MAX_CMDLEN ); - func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, ebc_cmd, len); + ret =__diag288_vm (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); -kfree (ebc_cmd); }else { ret =__diag288_lpar (WDT_FUNC_INIT , dev->timeout,LPARWDT_RESTART );@@ -146,19 +145,10 @@ static int wdt_stop(struct watchdog_device *dev)static int wdt_ping (struct watchdog_device *dev) { -char *ebc_cmd; -size_t len;int ret;unsigned int func;if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); -if (!ebc_cmd) -return -ENOMEM ; - len =strlcpy (ebc_cmd, wdt_cmd,MAX_CMDLEN ); -ASCEBC (ebc_cmd,MAX_CMDLEN ); -EBC_TOUPPER (ebc_cmd,MAX_CMDLEN ); -/* * It seems to be ok to z/VM to use the init function to * retrigger the watchdog. On LPAR WDT_FUNC_CHANGE must @@ -167,9 +157,8 @@ static int wdt_ping(struct watchdog_device *dev) func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, ebc_cmd, len); + ret =__diag288_vm (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); -kfree (ebc_cmd); }else { ret =__diag288_lpar (WDT_FUNC_CHANGE , dev->timeout,0 ); }@@ -212,25 +201,20 @@ static struct watchdog_device wdt_dev = {static int __init diag288_init (void ) {int ret; -char ebc_begin[] = { -194 ,197 ,199 ,201 ,213 - }; -char *ebc_cmd;watchdog_set_nowayout (&wdt_dev, nowayout_info);if (MACHINE_IS_VM ) { - ebc_cmd =kmalloc (sizeof (ebc_begin),GFP_KERNEL ); -if (!ebc_cmd) { + cmd_buf =kmalloc (MAX_CMDLEN ,GFP_KERNEL ); +if (!cmd_buf) {pr_err ("The watchdog cannot be initialized\n" );return -ENOMEM ; } -memcpy (ebc_cmd, ebc_begin,sizeof (ebc_begin)); - ret =__diag288_vm (WDT_FUNC_INIT ,15 , - ebc_cmd,sizeof (ebc_begin)); -kfree (ebc_cmd); + + ret =__diag288_vm (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" );if (ret !=0 ) {pr_err ("The watchdog cannot be initialized\n" ); +kfree (cmd_buf);return -EINVAL ; } }else {@@ -251,6 +235,7 @@ static int __init diag288_init(void) static void __exit diag288_exit(void) {watchdog_unregister_device (&wdt_dev); +kfree (cmd_buf); }module_init (diag288_init);
PATCH 4/5 watchdog: diag288_wdt: de-duplicate diag_stat_inc() calls
In reply to Alexander EgorenkovCall diag_stat_inc() from __diag288() to reduce code duplication.
--- drivers/watchdog/diag288_wdt.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/watchdog/diag288_wdt.c +3 -8
@@ -78,6 +78,8 @@ static int __diag288(unsigned int func, unsigned int timeout,union register_pair r3 = { .even = action, .odd = len, };int err; +diag_stat_inc (DIAG_STAT_X288 ); + err = -EINVAL ; asmvolatile ( " diag %[r1],%[r3],0x288\n"
@@ -100,14 +102,12 @@ static int __diag288_vm(unsigned int func, unsigned int timeout, char *cmd)ASCEBC (cmd_buf,MAX_CMDLEN );EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); -diag_stat_inc (DIAG_STAT_X288 );return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); }static int __diag288_lpar (unsigned int func,unsigned int timeout,unsigned long action) { -diag_stat_inc (DIAG_STAT_X288 );return __diag288 (func, timeout, action,0 ); }
@@ -135,12 +135,7 @@ static int wdt_start(struct watchdog_device *dev)static int wdt_stop (struct watchdog_device *dev) { -int ret; - -diag_stat_inc (DIAG_STAT_X288 ); - ret =__diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); - -return ret; +return __diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); }static int wdt_ping (struct watchdog_device *dev)
Signature · 1 line
2.37.2
Re: [PATCH 4/5] watchdog: diag288_wdt: de-duplicate diag_stat_inc() calls
Quoted 4 lines · Alexander Egorenkov
Call
diag_stat_inc()from__diag288()to reduce code duplication.Reviewed-by Heiko Carstens <[email protected]>Signed-off-by Alexander Egorenkov <[email protected]>
Quoted 46 lines
--- drivers/watchdog/diag288_wdt.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/watchdog/diag288_wdt.c +3
-8@@ -78,6 +78,8 @@ static int __diag288(unsigned int func, unsigned int timeout,union register_pair r3 = { .even = action, .odd = len, };int err; +diag_stat_inc (DIAG_STAT_X288 ); + err = -EINVAL ; asmvolatile ( " diag %[r1],%[r3],0x288\n"@@ -100,14 +102,12 @@ static int __diag288_vm(unsigned int func, unsigned int timeout, char *cmd)ASCEBC (cmd_buf,MAX_CMDLEN );EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); -diag_stat_inc (DIAG_STAT_X288 );return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); }static int __diag288_lpar (unsigned int func,unsigned int timeout,unsigned long action) { -diag_stat_inc (DIAG_STAT_X288 );return __diag288 (func, timeout, action,0 ); }@@ -135,12 +135,7 @@ static int wdt_start(struct watchdog_device *dev)static int wdt_stop (struct watchdog_device *dev) { -int ret; - -diag_stat_inc (DIAG_STAT_X288 ); - ret =__diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); - -return ret; +return __diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); }static int wdt_ping (struct watchdog_device *dev)
PATCH 5/5 watchdog: diag288_wdt: unify lpar and zvm diag288 helpers
In reply to Alexander EgorenkovChange naming of the internal diag288 helper functions
to improve overall readability and reduce confusion:
* Rename __diag288() to diag288().
* Get rid of the misnamed helper __diag288_lpar() that was used not only on LPARs but also zVM and KVM systems.
* Rename __diag288_vm() to diag288_str().
--- drivers/watchdog/diag288_wdt.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-)
drivers/watchdog/diag288_wdt.c +13 -19
@@ -71,8 +71,8 @@ MODULE_ALIAS("vmwatchdog");static char *cmd_buf; -static int __diag288 (unsigned int func,unsigned int timeout, -unsigned long action,unsigned int len) +static int diag288 (unsigned int func,unsigned int timeout, +unsigned long action,unsigned int len) {union register_pair r1 = { .even = func, .odd = timeout, };union register_pair r3 = { .even = action, .odd = len, };
@@ -92,7 +92,7 @@ static int __diag288(unsigned int func, unsigned int timeout,return err; } -static int __diag288_vm (unsigned int func,unsigned int timeout,char *cmd) +static int diag288_str (unsigned int func,unsigned int timeout,char *cmd) {ssize_t len;
@@ -102,13 +102,7 @@ static int __diag288_vm(unsigned int func, unsigned int timeout, char *cmd)ASCEBC (cmd_buf,MAX_CMDLEN );EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); -return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); -} - -static int __diag288_lpar (unsigned int func,unsigned int timeout, -unsigned long action) -{ -return __diag288 (func, timeout, action,0 ); +return diag288 (func, timeout,virt_to_phys (cmd_buf), len); }static int wdt_start (struct watchdog_device *dev)
@@ -119,11 +113,10 @@ static int wdt_start(struct watchdog_device *dev)if (MACHINE_IS_VM ) { func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, wdt_cmd); + ret =diag288_str (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); }else { - ret =__diag288_lpar (WDT_FUNC_INIT , - dev->timeout,LPARWDT_RESTART ); + ret =diag288 (WDT_FUNC_INIT , dev->timeout,LPARWDT_RESTART ,0 ); }if (ret) {
@@ -135,7 +128,7 @@ static int wdt_start(struct watchdog_device *dev)static int wdt_stop (struct watchdog_device *dev) { -return __diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); +return diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); }static int wdt_ping (struct watchdog_device *dev)
@@ -152,10 +145,10 @@ static int wdt_ping(struct watchdog_device *dev) func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, wdt_cmd); + ret =diag288_str (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); }else { - ret =__diag288_lpar (WDT_FUNC_CHANGE , dev->timeout,0 ); + ret =diag288 (WDT_FUNC_CHANGE , dev->timeout,0 ,0 ); }if (ret)
@@ -206,20 +199,21 @@ static int __init diag288_init(void)return -ENOMEM ; } - ret =__diag288_vm (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" ); + ret =diag288_str (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" );if (ret !=0 ) {pr_err ("The watchdog cannot be initialized\n" );kfree (cmd_buf);return -EINVAL ; } }else { -if (__diag288_lpar (WDT_FUNC_INIT ,30 ,LPARWDT_RESTART )) { +if (diag288 (WDT_FUNC_INIT ,WDT_DEFAULT_TIMEOUT , +LPARWDT_RESTART ,0 )) {pr_err ("The watchdog cannot be initialized\n" );return -EINVAL ; } } -if (__diag288_lpar (WDT_FUNC_CANCEL ,0 ,0 )) { +if (diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 )) {pr_err ("The watchdog cannot be deactivated\n" );return -EINVAL ; }
Signature · 1 line
2.37.2
Re: [PATCH 5/5] watchdog: diag288_wdt: unify lpar and zvm diag288 helpers
Quoted 9 lines · Alexander Egorenkov
Change naming of the internal diag288 helper functions
to improve overall readability and reduce confusion:
* Rename__diag288()todiag288().
* Get rid of the misnamed helper__diag288_lpar()that was used not only on LPARs but also zVM and KVM systems.
* Rename__diag288_vm()todiag288_str().Reviewed-by Heiko Carstens <[email protected]>Signed-off-by Alexander Egorenkov <[email protected]>
Quoted 104 lines
--- drivers/watchdog/diag288_wdt.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-)drivers/watchdog/diag288_wdt.c +13
-19@@ -71,8 +71,8 @@ MODULE_ALIAS("vmwatchdog");static char *cmd_buf; -static int __diag288 (unsigned int func,unsigned int timeout, -unsigned long action,unsigned int len) +static int diag288 (unsigned int func,unsigned int timeout, +unsigned long action,unsigned int len) {union register_pair r1 = { .even = func, .odd = timeout, };union register_pair r3 = { .even = action, .odd = len, };@@ -92,7 +92,7 @@ static int __diag288(unsigned int func, unsigned int timeout,return err; } -static int __diag288_vm (unsigned int func,unsigned int timeout,char *cmd) +static int diag288_str (unsigned int func,unsigned int timeout,char *cmd) {ssize_t len;@@ -102,13 +102,7 @@ static int __diag288_vm(unsigned int func, unsigned int timeout, char *cmd)ASCEBC (cmd_buf,MAX_CMDLEN );EBC_TOUPPER (cmd_buf,MAX_CMDLEN ); -return __diag288 (func, timeout,virt_to_phys (cmd_buf), len); -} - -static int __diag288_lpar (unsigned int func,unsigned int timeout, -unsigned long action) -{ -return __diag288 (func, timeout, action,0 ); +return diag288 (func, timeout,virt_to_phys (cmd_buf), len); }static int wdt_start (struct watchdog_device *dev)@@ -119,11 +113,10 @@ static int wdt_start(struct watchdog_device *dev)if (MACHINE_IS_VM ) { func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, wdt_cmd); + ret =diag288_str (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); }else { - ret =__diag288_lpar (WDT_FUNC_INIT , - dev->timeout,LPARWDT_RESTART ); + ret =diag288 (WDT_FUNC_INIT , dev->timeout,LPARWDT_RESTART ,0 ); }if (ret) {@@ -135,7 +128,7 @@ static int wdt_start(struct watchdog_device *dev)static int wdt_stop (struct watchdog_device *dev) { -return __diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); +return diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 ); }static int wdt_ping (struct watchdog_device *dev)@@ -152,10 +145,10 @@ static int wdt_ping(struct watchdog_device *dev) func = conceal_on ? (WDT_FUNC_INIT |WDT_FUNC_CONCEAL ) :WDT_FUNC_INIT ; - ret =__diag288_vm (func, dev->timeout, wdt_cmd); + ret =diag288_str (func, dev->timeout, wdt_cmd);WARN_ON (ret !=0 ); }else { - ret =__diag288_lpar (WDT_FUNC_CHANGE , dev->timeout,0 ); + ret =diag288 (WDT_FUNC_CHANGE , dev->timeout,0 ,0 ); }if (ret)@@ -206,20 +199,21 @@ static int __init diag288_init(void)return -ENOMEM ; } - ret =__diag288_vm (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" ); + ret =diag288_str (WDT_FUNC_INIT ,MIN_INTERVAL ,"BEGIN" );if (ret !=0 ) {pr_err ("The watchdog cannot be initialized\n" );kfree (cmd_buf);return -EINVAL ; } }else { -if (__diag288_lpar (WDT_FUNC_INIT ,30 ,LPARWDT_RESTART )) { +if (diag288 (WDT_FUNC_INIT ,WDT_DEFAULT_TIMEOUT , +LPARWDT_RESTART ,0 )) {pr_err ("The watchdog cannot be initialized\n" );return -EINVAL ; } } -if (__diag288_lpar (WDT_FUNC_CANCEL ,0 ,0 )) { +if (diag288 (WDT_FUNC_CANCEL ,0 ,0 ,0 )) {pr_err ("The watchdog cannot be deactivated\n" );return -EINVAL ; }
Heiko Carstens
maintainerQuoted 10 lines · Alexander Egorenkov
Minor code refactoring to improve readability of the driver, reduce code duplication and remove dead code.
Alexander Egorenkov (5):
watchdog:diag288_wdt: get rid of register asm
watchdog:diag288_wdt: remove power management
watchdog:diag288_wdt: unify command buffer handling for diag288 zvm
watchdog:diag288_wdt: de-duplicatediag_stat_inc()calls
watchdog:diag288_wdt: unify lpar and zvm diag288 helpers
Quoted 2 lines
drivers/watchdog/diag288_wdt.c | 162 ++++++++------------------------- 1 file changed, 37 insertions(+), 125 deletions(-)
Guenter, Wim, how should this go upstream?
I can easily pick this up via the s390 tree for the next merge window. Please let me know.
Thanks,
Heiko
Guenter Roeck
maintainerQuoted 11 lines · Heiko Carstens
Quoted 10 lines · Alexander Egorenkov
Minor code refactoring to improve readability of the driver, reduce code duplication and remove dead code.
Alexander Egorenkov (5):
watchdog:diag288_wdt: get rid of register asm
watchdog:diag288_wdt: remove power management
watchdog:diag288_wdt: unify command buffer handling for diag288 zvm
watchdog:diag288_wdt: de-duplicatediag_stat_inc()calls
watchdog:diag288_wdt: unify lpar and zvm diag288 helpers
Quoted 8 lines
Quoted 2 lines
drivers/watchdog/diag288_wdt.c | 162 ++++++++------------------------- 1 file changed, 37 insertions(+), 125 deletions(-)Guenter, Wim, how should this go upstream?
I can easily pick this up via the s390 tree for the next merge window. Please let me know.
I have it currently in my watchdog-next tree, but that is not in linux-next. Fine with me to go through the s390 tree.
Guenter
Quoted 15 lines · Guenter Roeck
Quoted 14 lines · Heiko Carstens
Quoted 12 lines · Alexander Egorenkov
Minor code refactoring to improve readability of the driver, reduce code duplication and remove dead code.
Alexander Egorenkov (5):
watchdog:diag288_wdt: get rid of register asm
watchdog:diag288_wdt: remove power management
watchdog:diag288_wdt: unify command buffer handling for diag288 zvm
watchdog:diag288_wdt: de-duplicatediag_stat_inc()calls
watchdog:diag288_wdt: unify lpar and zvm diag288 helpersdrivers/watchdog/diag288_wdt.c | 162 ++++++++------------------------- 1 file changed, 37 insertions(+), 125 deletions(-)
Quoted 7 lines
Quoted 4 lines
Guenter, Wim, how should this go upstream?
I can easily pick this up via the s390 tree for the next merge window. Please let me know.
I have it currently in my watchdog-next tree, but that is not in linux-next. Fine with me to go through the s390 tree.
Applied to s390 tree - should be in next linux-next release.
Thank you!